def __init__(self, env, ticks, silent, debug, compat_debug, debug_lines, autostep_debug, output_limit): """ :param dots.environement.Env env: The env of the interpreter :param int ticks: The max number of ticks for the program :param bool silent: True to turn off all outputs :param bool debug: True to show the execution of the program :param bool compat_debug: True to show the debug with only builtin functions :param int debug_lines: The number of lines to show the debug :param float autostep_debug: The timebetween automatic ticks. 0 disables the auto ticks. :param int output_limit: The max number of outputs for the program """ super().__init__(env) # if it is zero or false, we don't want to stop self.ticks_left = ticks or float('inf') self.outputs_left = output_limit or float('inf') self.silent = silent self.debug = debug self.compat_debug = compat_debug self.debug_lines = debug_lines self.debug_cols = terminalsize.get_terminal_size()[0] - 1 self.autostep_debug = autostep_debug self.compat_logging_buffer = '' self.compat_logging_buffer_lines = terminal_lines - debug_lines - 1 self.first_tick = True if self.debug and not self.compat_debug: self.logging_loc = 0 self.logging_x = 1 self.stdscr = curses.initscr() curses.start_color() curses.init_pair(1, curses.COLOR_RED, curses.COLOR_BLACK) curses.init_pair(2, curses.COLOR_GREEN, curses.COLOR_BLACK) curses.init_pair(3, curses.COLOR_YELLOW, curses.COLOR_BLACK) curses.init_pair(4, curses.COLOR_BLUE, curses.COLOR_BLACK) curses.noecho() # hides the cursor curses.curs_set(False) # defining the two main parts of the screen: the view of the program self.win_program = curses.newwin(self.debug_lines, curses.COLS, 0, 0) # and pad for the output of the prog self.logging_pad = curses.newpad(1000, curses.COLS - 1) def signal_handler(signal, frame): self.on_finish() sys.exit(0) signal.signal(signal.SIGINT, signal_handler)
os.environ['LANG'] = 'en_US.utf-8' from dots.interpreter import AsciiDotsInterpreter from dots.callbacks import IOCallbacksStorage from dots import terminalsize try: import curses except ImportError: print('failed to import curses; running in compatibility mode') compat_debug_default = True else: compat_debug_default = False terminal_lines = terminalsize.get_terminal_size()[1] default_debug_lines = int(terminal_lines * 2 / 3) interpreter = None debug_ = True autostep_debug_ = False class DefaultIOCallbacks(IOCallbacksStorage): """The default class to manage the input and output of a dots program.""" def __init__(self, env, ticks, silent, debug, compat_debug, debug_lines, autostep_debug, output_limit): """ :param dots.environment.Env env: The env of the interpreter