@@ -163,7 +163,7 @@ def statusline_print(self):
163163 move = ""
164164 # earease line
165165 move += terminal .ANSIControl .cursor .previous_line (1 )
166- move += terminal .ANSIControl .erase_line (0 )
166+ move += terminal .ANSIControl .erase_line (2 )
167167
168168 # reprint echo
169169 line = self ._get_statusline ()
@@ -196,7 +196,7 @@ def echo_print(self):
196196 # # eareas
197197 # move += terminal.ANSIControl.cursor.previous_line(line_count)
198198 # move += terminal.ANSIControl.cursor.previous_line(0)
199- move += terminal .ANSIControl .erase_line (0 )
199+ move += terminal .ANSIControl .erase_line (2 )
200200
201201 # reprint line
202202 line = self ._get_echo_line ()
@@ -219,7 +219,7 @@ def echo_print(self):
219219 moveback = moveback ,
220220 )
221221 )
222- print ("\n \n \n \n \n \n {} \n \n \n \n \n \n " .format (repr (text )))
222+ print ("\n \n \n {} \n \n \n " .format (repr (text )))
223223 # execute all the things ;-)
224224 print (text , end = "" )
225225
@@ -242,21 +242,29 @@ def print(self, *args):
242242 if self .statusline :
243243 # earease statusline
244244 move += terminal .ANSIControl .cursor .previous_line (1 )
245- move += terminal .ANSIControl .erase_line (0 )
245+ move += terminal .ANSIControl .erase_line (2 )
246246 if self .echo :
247247 # earease echoline
248- move += terminal .ANSIControl .cursor .previous_line (1 )
249- move += terminal .ANSIControl .erase_line (0 )
248+ # move += terminal.ANSIControl.cursor.previous_line(1)
249+ move += terminal .ANSIControl .erase_line (2 )
250+ # print("\n\n\n{}\n\n\n".format(repr(move)))
251+ # print(repr(terminal.ANSIControl.cursor.previous_line(1)))
252+ # print(repr(terminal.ANSIControl.erase_line(2)))
250253 print (move , end = "" )
254+ time .sleep (1 )
251255 # *normally print output
252256 print (* args )
253257 # print(*args, end=end)
254258 # print statement is finished.
255259 # now we have to reprint echo & statusline
256260 if self .echo :
257- print (self ._get_echo_line ())
261+ print (self ._get_echo_line (), end = "" )
262+ # print(self._get_echo_line())
258263 if self .statusline :
259- print (self ._get_statusline ())
264+ print (self ._get_statusline (), end = "" )
265+ # if not self.echo and not self.statusline:
266+ # # add new end
267+ # print()
260268 else :
261269 # print(*args, end)
262270 print (* args )
@@ -308,6 +316,16 @@ def _buffer_handle_backspace(self):
308316 self .input_buffer [: pos - 1 ] + self .input_buffer [pos + 1 :]
309317 )
310318
319+ def _buffer_handle_cursor_position (self ):
320+ # # TODO: implement Cursor position managment
321+ # if "\x08" in self.input_buffer:
322+ # while (pos := self.input_buffer.find("\x08")) > -1:
323+ # # strip character before backspace and backspace itself.
324+ # self.input_buffer = (
325+ # self.input_buffer[: pos - 1] + self.input_buffer[pos + 1 :]
326+ # )
327+ pass
328+
311329 def input (self ):
312330 """
313331 Input.
@@ -334,7 +352,9 @@ def update(self):
334352 available = self .serial .in_waiting
335353 while available :
336354 raw = self .serial .read (available )
337- self .input_buffer += raw .decode (self .encoding )
355+ text = raw .decode (self .encoding )
356+ # self._buffer_handle_cursor_position()
357+ self .input_buffer += text
338358 self ._buffer_handle_backspace ()
339359 if self .echo :
340360 # self.serial.write(raw)
0 commit comments