Skip to content

Commit 5c0f7ba

Browse files
committed
Refactor check if we can use blessed
1 parent 0f1ce53 commit 5c0f7ba

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

curtsies/window.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -265,13 +265,15 @@ def __init__(
265265
if in_stream is None:
266266
in_stream = sys.__stdin__
267267
self.in_stream = in_stream
268+
# whether we can use blessed to handle some operations
269+
self._use_blessed = (
270+
self.out_stream == sys.__stdout__ and self.in_stream == sys.__stdin__
271+
)
268272
self._last_cursor_column: Optional[int] = None
269273
self._last_cursor_row: Optional[int] = None
270274
self.keep_last_line = keep_last_line
271275
self.cbreak = (
272-
Cbreak(self.in_stream)
273-
if in_stream != sys.__stdin__ and out_stream != sys.__stdout__
274-
else self.t.cbreak()
276+
Cbreak(self.in_stream) if not self._use_blessed else self.t.cbreak()
275277
)
276278
self.extra_bytes_callback = extra_bytes_callback
277279

0 commit comments

Comments
 (0)