How to use the bpython.curtsiesfrontend.replpainter.display_linize function in bpython

To help you get started, we’ve selected a few bpython examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github bpython / bpython / bpython / curtsiesfrontend / repl.py View on Github external
tracebacks already formatted."""
        if not output:
            return
        lines = output.split("\n")
        logger.debug("display_lines: %r", self.display_lines)
        self.current_stdouterr_line += lines[0]
        if len(lines) > 1:
            self.display_lines.extend(
                paint.display_linize(
                    self.current_stdouterr_line, self.width, blank_line=True
                )
            )
            self.display_lines.extend(
                sum(
                    (
                        paint.display_linize(line, self.width, blank_line=True)
                        for line in lines[1:-1]
                    ),
                    [],
                )
            )
            self.current_stdouterr_line = lines[-1]
        logger.debug("display_lines: %r", self.display_lines)
github bpython / bpython / bpython / curtsiesfrontend / repl.py View on Github external
def send_to_stdouterr(self, output):
        """Send unicode strings or FmtStr to Repl stdout or stderr

        Must be able to handle FmtStrs because interpreter pass in
        tracebacks already formatted."""
        if not output:
            return
        lines = output.split("\n")
        logger.debug("display_lines: %r", self.display_lines)
        self.current_stdouterr_line += lines[0]
        if len(lines) > 1:
            self.display_lines.extend(
                paint.display_linize(
                    self.current_stdouterr_line, self.width, blank_line=True
                )
            )
            self.display_lines.extend(
                sum(
                    (
                        paint.display_linize(line, self.width, blank_line=True)
                        for line in lines[1:-1]
                    ),
                    [],
                )
            )
            self.current_stdouterr_line = lines[-1]
        logger.debug("display_lines: %r", self.display_lines)
github bpython / bpython / bpython / curtsiesfrontend / repl.py View on Github external
else:
            history = paint.paint_history(current_line_start_row, width, self.lines_for_display)
            arr[:history.height,:history.width] = history

        current_line = paint.paint_current_line(min_height, width, self.current_cursor_line)
        if user_quit: # quit() or exit() in interp
            current_line_start_row = current_line_start_row - current_line.height
        logging.debug("---current line row slice %r, %r", current_line_start_row, current_line_start_row + current_line.height)
        logging.debug("---current line col slice %r, %r", 0, current_line.width)
        arr[current_line_start_row:current_line_start_row + current_line.height,
            0:current_line.width] = current_line

        if current_line.height > min_height:
            return arr, (0, 0) # short circuit, no room for infobox

        lines = paint.display_linize(self.current_cursor_line+'X', width)
                                       # extra character for space for the cursor
        cursor_row = current_line_start_row + len(lines) - 1
        if self.stdin.has_focus:
            cursor_column = (len(self.current_stdouterr_line) + self.stdin.cursor_offset_in_line) % width
            assert cursor_column >= 0, cursor_column
        elif self.coderunner.running:
            cursor_column = (len(self.current_cursor_line) + self.cursor_offset_in_line) % width
            assert cursor_column >= 0, (cursor_column, len(self.current_cursor_line), len(self._current_line), self.cursor_offset_in_line)
        else:
            cursor_column = (len(self.current_cursor_line) - len(self._current_line) + self.cursor_offset_in_line) % width
            assert cursor_column >= 0, (cursor_column, len(self.current_cursor_line), len(self._current_line), self.cursor_offset_in_line)

        if self.list_win_visible:
            logging.debug('infobox display code running')
            visible_space_above = history.height
            visible_space_below = min_height - cursor_row - 1
github bpython / bpython / bpython / curtsiesfrontend / repl.py View on Github external
def send_to_stdout(self, output):
        lines = output.split('\n')
        logging.debug('display_lines: %r', self.display_lines)
        if len(lines) and lines[0]:
            self.current_stdouterr_line += lines[0]
        if len(lines) > 1:
            self.display_lines.extend(paint.display_linize(self.current_stdouterr_line, self.width))
            self.display_lines.extend(sum([paint.display_linize(line, self.width) for line in lines[1:-1]], []))
            self.current_stdouterr_line = lines[-1]
        logging.debug('display_lines: %r', self.display_lines)
github bpython / bpython / bpython / curtsiesfrontend / repl.py View on Github external
def keyboard_interrupt(self):
        # TODO factor out the common cleanup from running a line
        self.cursor_offset = -1
        self.unhighlight_paren()
        self.display_lines.extend(self.display_buffer_lines)
        self.display_lines.extend(
            paint.display_linize(self.current_cursor_line, self.width)
        )
        self.display_lines.extend(
            paint.display_linize("KeyboardInterrupt", self.width)
        )
        self.clear_current_block(remove_from_history=False)
github bpython / bpython / bpython / curtsiesfrontend / repl.py View on Github external
def keyboard_interrupt(self):
        # TODO factor out the common cleanup from running a line
        self.cursor_offset = -1
        self.unhighlight_paren()
        self.display_lines.extend(self.display_buffer_lines)
        self.display_lines.extend(
            paint.display_linize(self.current_cursor_line, self.width)
        )
        self.display_lines.extend(
            paint.display_linize("KeyboardInterrupt", self.width)
        )
        self.clear_current_block(remove_from_history=False)
github bpython / bpython / bpython / curtsiesfrontend / repl.py View on Github external
def display_buffer_lines(self):
        """The display lines (wrapped, colored, +prompts) of current buffer"""
        lines = []
        for display_line in self.display_buffer:
            prompt = func_for_letter(self.config.color_scheme["prompt"])
            more = func_for_letter(self.config.color_scheme["prompt_more"])
            display_line = (
                more(self.ps2) if lines else prompt(self.ps1)
            ) + display_line
            for line in paint.display_linize(display_line, self.width):
                lines.append(line)
        return lines
github bpython / bpython / bpython / curtsiesfrontend / repl.py View on Github external
r = self.coderunner.run_code(for_code=for_code)
        if r:
            logging.debug("----- Running finish command stuff -----")
            logging.debug("saved_indent: %r", self.saved_indent)
            unfinished = r == 'unfinished'
            err = self.saved_predicted_parse_error
            self.saved_predicted_parse_error = False

            indent = self.saved_indent
            if err:
                indent = 0

            #TODO This should be printed ABOVE the error that just happened instead
            # or maybe just thrown away and not shown
            if self.current_stdouterr_line:
                self.display_lines.extend(paint.display_linize(self.current_stdouterr_line, self.width))
                self.current_stdouterr_line = ''

            self._current_line = ' '*indent
            self.cursor_offset_in_line = len(self._current_line)
            self.done = not unfinished