How to use the ptpython.layout.PythonPromptMargin function in ptpython

To help you get started, we’ve selected a few ptpython 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 prompt-toolkit / ptpython / ptpython / layout.py View on Github external
self.python_input = python_input

        def get_prompt_style():
            return python_input.all_prompt_styles[python_input.prompt_style]

        def get_prompt():
            return to_formatted_text(get_prompt_style().in_prompt())

        def get_continuation(width, line_number, is_soft_wrap):
            if python_input.show_line_numbers and not is_soft_wrap:
                text = ('%i ' % (line_number + 1)).rjust(width)
                return [('class:line-number', text)]
            else:
                return get_prompt_style().in2_prompt(width)

        super(PythonPromptMargin, self).__init__(get_prompt, get_continuation)
github prompt-toolkit / ptpython / ptpython / layout.py View on Github external
DisplayMultipleCursors(),
                        # Show matching parentheses, but only while editing.
                        ConditionalProcessor(
                            processor=HighlightMatchingBracketProcessor(chars='[](){}'),
                            filter=has_focus(DEFAULT_BUFFER) & ~is_done &
                                Condition(lambda: python_input.highlight_matching_parenthesis)),
                        ConditionalProcessor(
                            processor=AppendAutoSuggestion(),
                            filter=~is_done)
                    ] + extra_buffer_processors,
                    menu_position=menu_position,

                    # Make sure that we always see the result of an reverse-i-search:
                    preview_search=True,
                ),
                left_margins=[PythonPromptMargin(python_input)],
                # Scroll offsets. The 1 at the bottom is important to make sure
                # the cursor is never below the "Press [Meta+Enter]" message
                # which is a float.
                scroll_offsets=ScrollOffsets(bottom=1, left=4, right=4),
                # As long as we're editing, prefer a minimal height of 6.
                height=(lambda: (
                    None if get_app().is_done or python_input.show_exit_confirmation
                            else input_buffer_height)),
                wrap_lines=Condition(lambda: python_input.wrap_lines),
            )