From 7cdc597947e2d371dd2183bc2167e9f13eae7875 Mon Sep 17 00:00:00 2001 From: Sebastian Ramacher Date: Wed, 5 Oct 2022 23:40:25 +0200 Subject: [PATCH] Move init of cbreak to __enter__ (fixes #174) Required by blessed. --- curtsies/window.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/curtsies/window.py b/curtsies/window.py index e6830a8..3f6e970 100644 --- a/curtsies/window.py +++ b/curtsies/window.py @@ -272,9 +272,6 @@ def __init__( self._last_cursor_column: Optional[int] = None self._last_cursor_row: Optional[int] = None self.keep_last_line = keep_last_line - self.cbreak = ( - Cbreak(self.in_stream) if not self._use_blessed else self.t.cbreak() - ) self.extra_bytes_callback = extra_bytes_callback # whether another SIGWINCH is queued up @@ -284,6 +281,9 @@ def __init__( self.in_get_cursor_diff = False def __enter__(self) -> "CursorAwareWindow": + self.cbreak = ( + Cbreak(self.in_stream) if not self._use_blessed else self.t.cbreak() + ) self.cbreak.__enter__() self.top_usable_row, _ = self.get_cursor_position() self._orig_top_usable_row = self.top_usable_row