def on_output(self, value):
value = str(value)
self.outputs_left -= 1
# maximum output reached, we quit the prog
if self.outputs_left == 0:
raise DotsExit
# no printing mode
if self.silent:
return
if not self.debug:
print(value, end='', flush=True)
elif self.compat_debug:
# we add the ouput to the buffer
self.compat_logging_buffer += value
# and we keep the maximum number of line to compat_logging_buffer_lines
self.compat_logging_buffer = '\n'.join(
self.compat_logging_buffer.split('\n')[-self.compat_logging_buffer_lines:])
else:
# add the output string to the pad
self.logging_pad.addstr(self.logging_loc, self.logging_x, str(value))
self.logging_pad.refresh(self.logging_loc - min(self.logging_loc, curses.LINES -
self.debug_lines - 1),
0, self.debug_lines, 0, curses.LINES - 1, curses.COLS - 1)
# FIXME: This should count the number of newlines instead
if str(value).endswith('\n'):
self.logging_loc += 1
self.logging_x = 1
else:
self.logging_x += len(value)
评论列表
文章目录