@@ -144,7 +144,7 @@ def _statusline_update_check_intervall(self):
144144 """Update the Statusline if intervall is over."""
145145 if self .statusline_next_update <= time .monotonic ():
146146 self .statusline_next_update = time .monotonic () + self .statusline_intervall
147- self .statusline_print ( )
147+ self .print ( content = None )
148148
149149 def _get_statusline (self ):
150150 return self .statusline_fn ()
@@ -159,70 +159,14 @@ def _get_echo_line(self):
159159 def statusline_print (self ):
160160 """Update the Statusline."""
161161 if self .statusline :
162- move = ""
163- # earease line
164- move += terminal .ANSIControl .cursor .previous_line (1 )
165- move += terminal .ANSIControl .erase_line (2 )
166-
167- # reprint echo
168- line = self ._get_statusline ()
169-
170- # move back to bottom of screen
171- moveback = terminal .ANSIControl .cursor .next_line (1 )
172-
173- # execute all the things ;-)
174- print (
175- "{move}"
176- "{line}"
177- "{moveback}"
178- "" .format (
179- move = move ,
180- line = line ,
181- moveback = moveback ,
182- ),
183- end = "" ,
184- )
162+ self .print (content = None )
185163
186164 def echo_print (self ):
187165 """Update the echho line."""
188166 if self .echo :
167+ self .print (content = None )
189168
190- move = ""
191- # line_count = 1
192- # if self.statusline:
193- # # jump over statusline
194- # line_count += 1
195- # # eareas
196- # move += terminal.ANSIControl.cursor.previous_line(line_count)
197- # move += terminal.ANSIControl.cursor.previous_line(0)
198- move += terminal .ANSIControl .erase_line (2 )
199- move += terminal .ANSIControl .cursor .horizontal_absolute (1 )
200-
201- # reprint line
202- line = self ._get_echo_line ()
203-
204- # move back to bottom of screen
205- moveback = ""
206- # line_count = 1
207- # if self.statusline:
208- # # jump over statusline
209- # line_count += 1
210- # moveback = terminal.ANSIControl.cursor.next_line(line_count)
211-
212- text = (
213- "{move}"
214- "{line}"
215- "{moveback}"
216- "" .format (
217- move = move ,
218- line = line ,
219- moveback = moveback ,
220- )
221- )
222- # execute all the things ;-)
223- print (text , end = "" )
224-
225- def print (self , * args ):
169+ def print (self , * args , content = True ):
226170 # def print(self, *args, end="\n"):
227171 """
228172 Print information & variables to the connected serial.
@@ -238,29 +182,34 @@ def print(self, *args):
238182 # :param bool end: line end character to print. Default: "\n"
239183 if self .echo or self .statusline :
240184 move = ""
241- # if self.statusline:
242- # # earease statusline
243- # move += terminal.ANSIControl.cursor.previous_line(1)
244- # move += terminal.ANSIControl.erase_line(2)
245185 if self .echo :
246186 # earease echoline
247- # move += terminal.ANSIControl.cursor.previous_line(1)
248187 move += terminal .ANSIControl .erase_line (2 )
188+ if self .statusline :
189+ if self .echo :
190+ move += terminal .ANSIControl .cursor .previous_line (1 )
191+ # earease statusline
192+ move += terminal .ANSIControl .erase_line (2 )
193+ if self .echo :
194+ move += terminal .ANSIControl .cursor .next_line (1 )
195+ # move += terminal.ANSIControl.cursor.position("1, 1")
249196 move += terminal .ANSIControl .cursor .horizontal_absolute (1 )
250197 # 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)))
253198 print (move , end = "" )
254- # *normally print output
255- print (* args )
199+ if content :
200+ # *normally print output
201+ print (* args )
202+ # time.sleep(0.)
203+ # print("*", end="")
256204 # print(*args, end=end)
257205 # print statement is finished.
258206 # now we have to reprint echo & statusline
207+ if self .statusline :
208+ print (self ._get_statusline (), end = "" )
209+ # print(terminal.ANSIControl.cursor.next_line(1), end="")
259210 if self .echo :
260211 print (self ._get_echo_line (), end = "" )
261212 # print(self._get_echo_line())
262- # if self.statusline:
263- # print(self._get_statusline(), end="")
264213 # if not self.echo and not self.statusline:
265214 # # add new end
266215 # print()
@@ -356,7 +305,7 @@ def update(self):
356305 self .input_buffer += text
357306 self ._buffer_handle_backspace ()
358307 if self .echo :
359- self .echo_print ( )
308+ self .print ( content = None )
360309 # decode: keyword argeuments and errors not supported by CircuitPython
361310 # encoding=self.encoding,
362311 # errors="strict",
0 commit comments