@@ -118,12 +118,13 @@ def __init__(self):
118
118
119
119
def register (self , fd , flag ):
120
120
self .fd = fd
121
+
121
122
# note: The 'timeout' argument is received as *milliseconds*
122
123
def poll (self , timeout : float | None = None ) -> list [int ]:
123
124
if timeout is None :
124
125
r , w , e = select .select ([self .fd ], [], [])
125
126
else :
126
- r , w , e = select .select ([self .fd ], [], [], timeout / 1000 )
127
+ r , w , e = select .select ([self .fd ], [], [], timeout / 1000 )
127
128
return r
128
129
129
130
poll = MinimalPoll # type: ignore[assignment]
@@ -201,8 +202,7 @@ def _my_getstr(cap: str, optional: bool = False) -> bytes | None:
201
202
202
203
def more_in_buffer (self ) -> bool :
203
204
return bool (
204
- self .input_buffer
205
- and self .input_buffer_pos < len (self .input_buffer )
205
+ self .input_buffer and self .input_buffer_pos < len (self .input_buffer )
206
206
)
207
207
208
208
def __read (self , n : int ) -> bytes :
@@ -216,7 +216,6 @@ def __read(self, n: int) -> bytes:
216
216
self .input_buffer_pos = 0
217
217
return ret
218
218
219
-
220
219
def change_encoding (self , encoding : str ) -> None :
221
220
"""
222
221
Change the encoding used for I/O operations.
@@ -342,8 +341,11 @@ def prepare(self):
342
341
tcsetattr (self .input_fd , termios .TCSADRAIN , raw )
343
342
344
343
# In macOS terminal we need to deactivate line wrap via ANSI escape code
345
- if platform .system () == "Darwin" and os .getenv ("TERM_PROGRAM" ) == "Apple_Terminal" :
346
- os .write (self .output_fd , b"\033 [?7l" )
344
+ # if (
345
+ # platform.system() == "Darwin"
346
+ # and os.getenv("TERM_PROGRAM") == "Apple_Terminal"
347
+ # ):
348
+ # os.write(self.output_fd, b"\033[?7l")
347
349
348
350
self .screen = []
349
351
self .height , self .width = self .getheightwidth ()
@@ -373,8 +375,11 @@ def restore(self):
373
375
self .flushoutput ()
374
376
tcsetattr (self .input_fd , termios .TCSADRAIN , self .__svtermstate )
375
377
376
- if platform .system () == "Darwin" and os .getenv ("TERM_PROGRAM" ) == "Apple_Terminal" :
377
- os .write (self .output_fd , b"\033 [?7h" )
378
+ # if (
379
+ # platform.system() == "Darwin"
380
+ # and os.getenv("TERM_PROGRAM") == "Apple_Terminal"
381
+ # ):
382
+ # os.write(self.output_fd, b"\033[?7h")
378
383
379
384
if hasattr (self , "old_sigwinch" ):
380
385
signal .signal (signal .SIGWINCH , self .old_sigwinch )
@@ -448,14 +453,14 @@ def getheightwidth(self):
448
453
- tuple: Height and width of the console.
449
454
"""
450
455
try :
451
- return int (os .environ ["LINES" ]), int (os .environ ["COLUMNS" ])
456
+ return int (os .environ ["LINES" ]), int (os .environ ["COLUMNS" ]) - 1
452
457
except KeyError :
453
458
height , width = struct .unpack (
454
459
"hhhh" , ioctl (self .input_fd , TIOCGWINSZ , b"\000 " * 8 )
455
460
)[0 :2 ]
456
461
if not height :
457
462
return 25 , 80
458
- return height , width
463
+ return height , width - 1
459
464
460
465
else :
461
466
0 commit comments