@@ -240,7 +240,7 @@ def refresh(self, screen, c_xy):
240240 self .__hide_cursor ()
241241 self .__move (0 , len (self .screen ) - 1 )
242242 self .__write ("\n " )
243- self .__posxy = 0 , len (self .screen )
243+ self .posxy = 0 , len (self .screen )
244244 self .screen .append ("" )
245245 else :
246246 while len (self .screen ) < len (screen ):
@@ -250,7 +250,7 @@ def refresh(self, screen, c_xy):
250250 self .__gone_tall = 1
251251 self .__move = self .__move_tall
252252
253- px , py = self .__posxy
253+ px , py = self .posxy
254254 old_offset = offset = self .__offset
255255 height = self .height
256256
@@ -271,15 +271,15 @@ def refresh(self, screen, c_xy):
271271 if old_offset > offset and self ._ri :
272272 self .__hide_cursor ()
273273 self .__write_code (self ._cup , 0 , 0 )
274- self .__posxy = 0 , old_offset
274+ self .posxy = 0 , old_offset
275275 for i in range (old_offset - offset ):
276276 self .__write_code (self ._ri )
277277 oldscr .pop (- 1 )
278278 oldscr .insert (0 , "" )
279279 elif old_offset < offset and self ._ind :
280280 self .__hide_cursor ()
281281 self .__write_code (self ._cup , self .height - 1 , 0 )
282- self .__posxy = 0 , old_offset + self .height - 1
282+ self .posxy = 0 , old_offset + self .height - 1
283283 for i in range (offset - old_offset ):
284284 self .__write_code (self ._ind )
285285 oldscr .pop (0 )
@@ -299,7 +299,7 @@ def refresh(self, screen, c_xy):
299299 while y < len (oldscr ):
300300 self .__hide_cursor ()
301301 self .__move (0 , y )
302- self .__posxy = 0 , y
302+ self .posxy = 0 , y
303303 self .__write_code (self ._el )
304304 y += 1
305305
@@ -321,7 +321,7 @@ def move_cursor(self, x, y):
321321 self .event_queue .insert (Event ("scroll" , None ))
322322 else :
323323 self .__move (x , y )
324- self .__posxy = x , y
324+ self .posxy = x , y
325325 self .flushoutput ()
326326
327327 def prepare (self ):
@@ -350,7 +350,7 @@ def prepare(self):
350350
351351 self .__buffer = []
352352
353- self .__posxy = 0 , 0
353+ self .posxy = 0 , 0
354354 self .__gone_tall = 0
355355 self .__move = self .__move_short
356356 self .__offset = 0
@@ -559,7 +559,7 @@ def clear(self):
559559 self .__write_code (self ._clear )
560560 self .__gone_tall = 1
561561 self .__move = self .__move_tall
562- self .__posxy = 0 , 0
562+ self .posxy = 0 , 0
563563 self .screen = []
564564
565565 @property
@@ -644,8 +644,8 @@ def __write_changed_line(self, y, oldline, newline, px_coord):
644644 # if we need to insert a single character right after the first detected change
645645 if oldline [x_pos :] == newline [x_pos + 1 :] and self .ich1 :
646646 if (
647- y == self .__posxy [1 ]
648- and x_coord > self .__posxy [0 ]
647+ y == self .posxy [1 ]
648+ and x_coord > self .posxy [0 ]
649649 and oldline [px_pos :x_pos ] == newline [px_pos + 1 : x_pos + 1 ]
650650 ):
651651 x_pos = px_pos
@@ -654,7 +654,7 @@ def __write_changed_line(self, y, oldline, newline, px_coord):
654654 self .__move (x_coord , y )
655655 self .__write_code (self .ich1 )
656656 self .__write (newline [x_pos ])
657- self .__posxy = x_coord + character_width , y
657+ self .posxy = x_coord + character_width , y
658658
659659 # if it's a single character change in the middle of the line
660660 elif (
@@ -665,7 +665,7 @@ def __write_changed_line(self, y, oldline, newline, px_coord):
665665 character_width = wlen (newline [x_pos ])
666666 self .__move (x_coord , y )
667667 self .__write (newline [x_pos ])
668- self .__posxy = x_coord + character_width , y
668+ self .posxy = x_coord + character_width , y
669669
670670 # if this is the last character to fit in the line and we edit in the middle of the line
671671 elif (
@@ -677,22 +677,22 @@ def __write_changed_line(self, y, oldline, newline, px_coord):
677677 ):
678678 self .__hide_cursor ()
679679 self .__move (self .width - 2 , y )
680- self .__posxy = self .width - 2 , y
680+ self .posxy = self .width - 2 , y
681681 self .__write_code (self .dch1 )
682682
683683 character_width = wlen (newline [x_pos ])
684684 self .__move (x_coord , y )
685685 self .__write_code (self .ich1 )
686686 self .__write (newline [x_pos ])
687- self .__posxy = character_width + 1 , y
687+ self .posxy = character_width + 1 , y
688688
689689 else :
690690 self .__hide_cursor ()
691691 self .__move (x_coord , y )
692692 if wlen (oldline ) > wlen (newline ):
693693 self .__write_code (self ._el )
694694 self .__write (newline [x_pos :])
695- self .__posxy = wlen (newline ), y
695+ self .posxy = wlen (newline ), y
696696
697697 if "\x1b " in newline :
698698 # ANSI escape characters are present, so we can't assume
@@ -711,32 +711,36 @@ def __maybe_write_code(self, fmt, *args):
711711 self .__write_code (fmt , * args )
712712
713713 def __move_y_cuu1_cud1 (self , y ):
714- dy = y - self .__posxy [1 ]
714+ assert self ._cud1 is not None
715+ assert self ._cuu1 is not None
716+ dy = y - self .posxy [1 ]
715717 if dy > 0 :
716718 self .__write_code (dy * self ._cud1 )
717719 elif dy < 0 :
718720 self .__write_code ((- dy ) * self ._cuu1 )
719721
720722 def __move_y_cuu_cud (self , y ):
721- dy = y - self .__posxy [1 ]
723+ dy = y - self .posxy [1 ]
722724 if dy > 0 :
723725 self .__write_code (self ._cud , dy )
724726 elif dy < 0 :
725727 self .__write_code (self ._cuu , - dy )
726728
727729 def __move_x_hpa (self , x : int ) -> None :
728- if x != self .__posxy [0 ]:
730+ if x != self .posxy [0 ]:
729731 self .__write_code (self ._hpa , x )
730732
731733 def __move_x_cub1_cuf1 (self , x : int ) -> None :
732- dx = x - self .__posxy [0 ]
734+ assert self ._cuf1 is not None
735+ assert self ._cub1 is not None
736+ dx = x - self .posxy [0 ]
733737 if dx > 0 :
734738 self .__write_code (self ._cuf1 * dx )
735739 elif dx < 0 :
736740 self .__write_code (self ._cub1 * (- dx ))
737741
738742 def __move_x_cub_cuf (self , x : int ) -> None :
739- dx = x - self .__posxy [0 ]
743+ dx = x - self .posxy [0 ]
740744 if dx > 0 :
741745 self .__write_code (self ._cuf , dx )
742746 elif dx < 0 :
@@ -766,12 +770,12 @@ def __show_cursor(self):
766770
767771 def repaint (self ):
768772 if not self .__gone_tall :
769- self .__posxy = 0 , self .__posxy [1 ]
773+ self .posxy = 0 , self .posxy [1 ]
770774 self .__write ("\r " )
771775 ns = len (self .screen ) * ["\000 " * self .width ]
772776 self .screen = ns
773777 else :
774- self .__posxy = 0 , self .__offset
778+ self .posxy = 0 , self .__offset
775779 self .__move (0 , self .__offset )
776780 ns = self .height * ["\000 " * self .width ]
777781 self .screen = ns
0 commit comments