How to use the bpython.repl.Repl 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 ivanov / bipython / bipython / __init__.py View on Github external
def __init__(self, event_loop, palette, interpreter, config):
        repl.Repl.__init__(self, interpreter, config)

        self._redraw_handle = None
        self._redraw_pending = False
        self._redraw_time = 0

        self.listbox = BPythonListBox(urwid.SimpleListWalker([]))

        self.tooltip = urwid.ListBox(urwid.SimpleListWalker([]))
        self.tooltip.grid = None
        self.overlay = Tooltip(self.listbox, self.tooltip)
        self.stdout_hist = ''

        self.frame = urwid.Frame(self.overlay)

        if urwid.get_encoding_mode() == 'narrow':
            input_filter = decoding_input_filter
github bpython / bpython / bpython / repl.py View on Github external
self.matches_iter.clear()
            return bool(self.funcprops)

        self.matches_iter.update(
            self.cursor_offset, self.current_line, matches, completer
        )

        if len(matches) == 1:
            if tab:
                # if this complete is being run for a tab key press, substitute
                # common sequence
                (
                    self._cursor_offset,
                    self._current_line,
                ) = self.matches_iter.substitute_cseq()
                return Repl.complete(self)  # again for
            elif self.matches_iter.current_word == matches[0]:
                self.matches_iter.clear()
                return False
            return completer.shown_before_tab

        else:
            return tab or completer.shown_before_tab
github bpython / bpython / bpython / urwid.py View on Github external
def __init__(self, event_loop, palette, interpreter, config):
        repl.Repl.__init__(self, interpreter, config)

        self._redraw_handle = None
        self._redraw_pending = False
        self._redraw_time = 0

        self.listbox = BPythonListBox(urwid.SimpleListWalker([]))

        self.tooltip = urwid.ListBox(urwid.SimpleListWalker([]))
        self.tooltip.grid = None
        self.overlay = Tooltip(self.listbox, self.tooltip)
        self.stdout_hist = ""  # native str (bytes in Py2, unicode in Py3)

        self.frame = urwid.Frame(self.overlay)

        if urwid.get_encoding_mode() == "narrow":
            input_filter = decoding_input_filter
github ivanov / bipython / bipython / __init__.py View on Github external
def push(self, s, insert_into_history=True):
        # Restore the original SIGINT handler. This is needed to be able
        # to break out of infinite loops. If the interpreter itself
        # sees this it prints 'KeyboardInterrupt' and returns (good).
        orig_handler = signal.getsignal(signal.SIGINT)
        signal.signal(signal.SIGINT, signal.default_int_handler)
        # Pretty blindly adapted from bpython.cli
        try:
            msg_id = self.send_ipython(s)
            #self.rl_history.enter(s)
            if hasattr(repl.Repl, 'insert_into_history'):
                # this is only in unreleased version of bpython
                self.insert_into_history(s)
                # on the IPython side, at least for the Python kernel, history
                # is managed for us by the history manager, so there's no need
                # to do anything here.
            if self.edit is not None:
                self.edit.make_readonly()
            self.buffer = []
            self.edit = None
            ret_msg = self.ipython_get_child_msg(msg_id)
            if 'execution_count' in ret_msg['content']:
                self.ipy_execution_count = ret_msg['content']['execution_count']
            #self.echod('\n shell: ' + str(ret_msg['content']))
            #self.send_ipython("###retmsg " + str(ret_msg))
            #self.send_ipython("###retmsg " + str(returned))
            #self.prompt(
github bpython / bpython / bpython / curtsiesfrontend / repl.py View on Github external
def prompt_for_undo():
            n = BpythonRepl.prompt_undo(self)
            if n > 0:
                self.request_undo(n=n)