@@ -118,12 +118,13 @@ def __init__(self):
118118
119119 def register (self , fd , flag ):
120120 self .fd = fd
121+
121122 # note: The 'timeout' argument is received as *milliseconds*
122123 def poll (self , timeout : float | None = None ) -> list [int ]:
123124 if timeout is None :
124125 r , w , e = select .select ([self .fd ], [], [])
125126 else :
126- r , w , e = select .select ([self .fd ], [], [], timeout / 1000 )
127+ r , w , e = select .select ([self .fd ], [], [], timeout / 1000 )
127128 return r
128129
129130 poll = MinimalPoll # type: ignore[assignment]
@@ -201,8 +202,7 @@ def _my_getstr(cap: str, optional: bool = False) -> bytes | None:
201202
202203 def more_in_buffer (self ) -> bool :
203204 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 )
206206 )
207207
208208 def __read (self , n : int ) -> bytes :
@@ -216,7 +216,6 @@ def __read(self, n: int) -> bytes:
216216 self .input_buffer_pos = 0
217217 return ret
218218
219-
220219 def change_encoding (self , encoding : str ) -> None :
221220 """
222221 Change the encoding used for I/O operations.
@@ -342,8 +341,11 @@ def prepare(self):
342341 tcsetattr (self .input_fd , termios .TCSADRAIN , raw )
343342
344343 # 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")
347349
348350 self .screen = []
349351 self .height , self .width = self .getheightwidth ()
@@ -373,8 +375,11 @@ def restore(self):
373375 self .flushoutput ()
374376 tcsetattr (self .input_fd , termios .TCSADRAIN , self .__svtermstate )
375377
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")
378383
379384 if hasattr (self , "old_sigwinch" ):
380385 signal .signal (signal .SIGWINCH , self .old_sigwinch )
@@ -448,14 +453,14 @@ def getheightwidth(self):
448453 - tuple: Height and width of the console.
449454 """
450455 try :
451- return int (os .environ ["LINES" ]), int (os .environ ["COLUMNS" ])
456+ return int (os .environ ["LINES" ]), int (os .environ ["COLUMNS" ]) - 1
452457 except KeyError :
453458 height , width = struct .unpack (
454459 "hhhh" , ioctl (self .input_fd , TIOCGWINSZ , b"\000 " * 8 )
455460 )[0 :2 ]
456461 if not height :
457462 return 25 , 80
458- return height , width
463+ return height , width - 1
459464
460465 else :
461466
0 commit comments