def vertical_line(): " Draw a vertical line between windows. (In case of a vsplit) " char = '│' content.append(HSplit([ Window( width=D.exact(1), height=D.exact(1), content=FillControl(char, token=Token.TitleBar.Line)), Window(width=D.exact(1), content=FillControl(char, token=Token.Line)) ]))
def vertical_line(): " Draw a vertical line between windows. (In case of a vsplit) " char = '│' content.append( HSplit([ ConditionalContainer( content=Window(width=D.exact(1), height=D.exact(1), content=FillControl( char, token=Token.TitleBar.Line)), filter=Condition(lambda cli: pymux.enable_pane_status), ), Window(width=D.exact(1), content=FillControl(char, token=Token.Line)) ]))
def horizontal_line(): char = '─' content.append( ConditionalContainer( content=Window(height=D.exact(1), content=FillControl(char, token=Token.Line)), filter=Condition(lambda cli: not pymux.enable_pane_status)), )
def __init__(self, message="openstack> ", menu_height=12, multiwindow=False): toolbar = Toolbar() main_layout = create_prompt_layout( message=message, lexer=OSLexer, get_bottom_toolbar_tokens=toolbar.handler, reserve_space_for_menu=menu_height) if multiwindow: self.mlayout = VSplit([ main_layout, Window(width=D.exact(1), content=FillControl('|', token=Token.Line)), Window(width=D.exact(70), wrap_lines=True, content=BufferControl(buffer_name='HELP')), ]) if multiwindow: self.layout = self.mlayout else: self.layout = main_layout
def get_anyhline(config): """ if there is a line between descriptions and example """ if config.BOOLEAN_STATES[config.config.get('Layout', 'command_description')] or\ config.BOOLEAN_STATES[config.config.get('Layout', 'param_description')]: return Window(width=LayoutDimension.exact(1), height=LayoutDimension.exact(1), content=FillControl('-', token=Token.Line)) return get_empty()
def create_popup_window(title, body): """ Return the layout for a pop-up window. It consists of a title bar showing the `title` text, and a body layout. The window is surrounded by borders. """ assert isinstance(title, six.text_type) assert isinstance(body, Container) return HSplit([ VSplit([ Window(width=D.exact(1), height=D.exact(1), content=FillControl(BORDER.TOP_LEFT, token=Token.Window.Border)), TokenListToolbar( get_tokens=lambda cli: [(Token.Window.Title, ' %s ' % title)], align_center=True, default_char=Char(BORDER.HORIZONTAL, Token.Window.Border)), Window(width=D.exact(1), height=D.exact(1), content=FillControl(BORDER.TOP_RIGHT, token=Token.Window.Border)), ]), VSplit([ Window(width=D.exact(1), content=FillControl(BORDER.VERTICAL, token=Token.Window.Border)), body, Window(width=D.exact(1), content=FillControl(BORDER.VERTICAL, token=Token.Window.Border)), ]), VSplit([ Window(width=D.exact(1), height=D.exact(1), content=FillControl(BORDER.BOTTOM_LEFT, token=Token.Window.Border)), Window(height=D.exact(1), content=FillControl(BORDER.HORIZONTAL, token=Token.Window.Border)), Window(width=D.exact(1), height=D.exact(1), content=FillControl(BORDER.BOTTOM_RIGHT, token=Token.Window.Border)), ]), ])
def setup_layout(self): """docstring for setup_layout""" if bool(egc.TEXT_EDITOR_ENABLE_LEFT_MARGIN) is True: self._left_margin = NumberredMargin(display_tildes=True) if bool(egc.TEXT_EDITOR_ENABLE_RIGHT_MARGIN) is True: self._right_margin = ScrollbarMargin(display_arrows=True) self._buffer_control = BufferControl(buffer_name=self._editor_buffer_name) self._editor_aiml_code_window = Window(content=self._buffer_control, left_margins=[self._left_margin,]) self._vertical_line = FillControl('|', token=Token.Line) self._window_separater = Window(width=D.exact(1), content=self._vertical_line) self._aiml_list = TokenListControl(get_tokens=self.get_aiml_list) self._editor_aiml_list_window = Window(content=self._aiml_list, right_margins=[self._right_margin,]) self._layout = VSplit([ self._editor_aiml_code_window, self._window_separater, self._editor_aiml_list_window, ])
def __init__(self, opt_ns, srv_c, inst_xml): manager = KeyBindingManager() # Start with the `KeyBindingManager`. self.srv_text = ServiceOutput(opt_ns, srv_c, inst_xml) layout = HSplit( [ # One window that holds the BufferControl with the default buffer on the # left. Window( height=D.exact(1), content=TokenListControl( self.get_title_line, default_char=Char(" ", token=Token.String.ICSW.Header) ) ), Window( height=D.exact(1), content=FillControl('-', token=Token.Line) ), # Display the text 'Hello world' on the right. Window( content=TokenListControl( self.get_icsw_output, ) ), ] ) self._updating = False @manager.registry.add_binding(Keys.ControlC, eager=True) @manager.registry.add_binding("q", eager=True) def _handler_data(event): event.cli.set_return_value(0) our_style = style_from_dict(logging_tools.get_icsw_prompt_styles()) application = Application( layout=layout, use_alternate_screen=True, style=our_style, on_input_timeout=self.input_timeout, key_bindings_registry=manager.registry, ) event_loop = create_eventloop() self.application = application self.event_loop = event_loop
def create_layout_from_node(node): if isinstance(node, window_arrangement.Window): # Create frame for Window, or reuse it, if we had one already. key = (node, node.editor_buffer) frame = existing_frames.get(key) if frame is None: frame = self._create_window_frame(node.editor_buffer) self._frames[key] = frame return frame elif isinstance(node, window_arrangement.VSplit): children = [] for n in node: children.append(create_layout_from_node(n)) children.append(Window(width=LayoutDimension.exact(1), content=FillControl('\u2502', token=Token.FrameBorder))) children.pop() return VSplit(children) if isinstance(node, window_arrangement.HSplit): return HSplit([create_layout_from_node(n) for n in node])
def create_layout(python_input, history_mapping): """ Create and return a `Container` instance for the history application. """ processors = [ HighlightSearchProcessor(preview_search=True), HighlightSelectionProcessor() ] help_window = create_popup_window( title='History Help', body=Window(content=BufferControl(buffer_name=HELP_BUFFER, default_char=Char(token=Token), lexer=PygmentsLexer(RstLexer), input_processors=processors), right_margins=[ScrollbarMargin()], scroll_offsets=ScrollOffsets(top=2, bottom=2))) return HSplit([ # Top title bar. TokenListToolbar(get_tokens=_get_top_toolbar_tokens, align_center=True, default_char=Char(' ', Token.Toolbar.Status)), FloatContainer( content=VSplit([ # Left side: history. Window(content=BufferControl(buffer_name=HISTORY_BUFFER, lexer=PygmentsLexer(PythonLexer), input_processors=processors), wrap_lines=False, left_margins=[HistoryMargin(history_mapping)], scroll_offsets=ScrollOffsets(top=2, bottom=2)), # Separator. Window(width=D.exact(1), content=FillControl(BORDER.LIGHT_VERTICAL, token=Token.Separator)), # Right side: result. Window( content=BufferControl(buffer_name=DEFAULT_BUFFER, input_processors=processors + [GrayExistingText(history_mapping)], lexer=PygmentsLexer(PythonLexer)), wrap_lines=False, left_margins=[ResultMargin(history_mapping)], scroll_offsets=ScrollOffsets(top=2, bottom=2)), ]), floats=[ # Help text as a float. Float( width=60, top=3, bottom=2, content=ConditionalContainer( # (We use InFocusStack, because it's possible to search # through the help text as well, and at that point the search # buffer has the focus.) content=help_window, filter=InFocusStack(HELP_BUFFER))), ]), # Bottom toolbars. ArgToolbar(), SearchToolbar(), TokenListToolbar(get_tokens=partial(_get_bottom_toolbar_tokens, python_input=python_input), default_char=Char(' ', Token.Toolbar.Status)), ])
def create_layout(buffers, settings, key_bindings_manager, python_prompt_control=None, lexer=PythonLexer, extra_sidebars=None, extra_buffer_processors=None): D = LayoutDimension show_all_buffers = Condition(lambda cli: settings.show_all_buffers) extra_sidebars = extra_sidebars or [] extra_buffer_processors = extra_buffer_processors or [] def create_buffer_window(buffer_name): def menu_position(cli): """ When there is no autocompletion menu to be shown, and we have a signature, set the pop-up position at `bracket_start`. """ b = cli.buffers[buffer_name] if b.complete_state is None and b.signatures: row, col = b.signatures[0].bracket_start index = b.document.translate_row_col_to_index(row - 1, col) return index return Window( BufferControl( buffer_name=buffer_name, lexer=lexer, show_line_numbers=ShowLineNumbersFilter(settings, buffer_name), input_processors=[BracketsMismatchProcessor()] + extra_buffer_processors, menu_position=menu_position, ), # As long as we're editing, prefer a minimal height of 8. get_height=(lambda cli: (None if cli.is_done else D(min=6))), # When done, show only if this was focussed. filter=(~IsDone() & show_all_buffers) | PythonBufferFocussed(buffer_name, settings)) def create_buffer_window_separator(buffer_name): return Window(width=D.exact(1), content=FillControl('\u2502', token=Token.Separator), filter=~IsDone() & show_all_buffers) buffer_windows = [] for b in sorted(buffers): if b.startswith('python-'): buffer_windows.append(create_buffer_window_separator(b)) buffer_windows.append(create_buffer_window(b)) return HSplit([ VSplit([ HSplit([ TabsToolbar(settings), FloatContainer(content=HSplit([ VSplit([ Window( python_prompt_control, dont_extend_width=True, ), VSplit(buffer_windows), ]), ]), floats=[ Float(xcursor=True, ycursor=True, content=CompletionsMenu( max_height=12, extra_filter=ShowCompletionsMenu( settings))), Float(xcursor=True, ycursor=True, content=SignatureToolbar(settings)) ]), ArgToolbar(), SearchToolbar(), SystemToolbar(), ValidationToolbar(), CompletionsToolbar( extra_filter=ShowCompletionsToolbar(settings)), # Docstring region. Window(height=D.exact(1), content=FillControl('\u2500', token=Token.Separator), filter=HasSignature(settings) & ShowDocstring(settings) & ~IsDone()), Window( BufferControl( buffer_name='docstring', default_token=Token.Docstring, #lexer=PythonLexer, ), filter=HasSignature(settings) & ShowDocstring(settings) & ~IsDone(), height=D(max=12), ), ]), ] + extra_sidebars + [ PythonSidebar(settings, key_bindings_manager), ]), VSplit([ PythonToolbar(key_bindings_manager, settings), ShowSidebarButtonInfo(), ]) ])
def create_buffer_window_separator(buffer_name): return Window(width=D.exact(1), content=FillControl('\u2502', token=Token.Separator), filter=~IsDone() & show_all_buffers)
# So, for this example, we create a layout that shows the content of the # default buffer on the left, shows a line in the middle and another buffer # (called 'RESULT') on the right. layout = VSplit([ # One window that holds the BufferControl with the default buffer on the # left. Window(content=BufferControl(buffer_name=DEFAULT_BUFFER)), # A vertical line in the middle. We explicitely specify the width, to make # sure that the layout engine will not try to divide the whole width by # three for all these windows. The `FillControl` will simply fill the whole # window by repeating this character. Window(width=D.exact(1), content=FillControl('|', token=Token.Line)), # Display the Result buffer on the right. Window(content=BufferControl(buffer_name='RESULT')), ]) # As a demonstration. Let's add a title bar to the top, displaying "Hello world". # somewhere, because usually the default key bindings include searching. (Press # Ctrl-R.) It would be really annoying if the search key bindings are handled, # but the user doesn't see any feedback. We will add the search toolbar to the # bottom by using an HSplit. def get_titlebar_tokens(cli): return [ (Token.Title, ' Hello world '),
def help(event): if application.layout == layout: application.layout = Window(FillControl(char=Char('x'))) else: application.layout = layout
def get_vline(): """ gets a vertical line """ return Window( width=D.exact(1), height=D.exact(1), content=FillControl('*', token=Token.Line))
def main(): manager = KeyBindingManager(enable_system_bindings=Always()) D = LayoutDimension layout = HSplit([ VSplit([ Window(width=D(min=15, max=30, preferred=30), content=FillControl('a', token=Token.A)), Window(width=D.exact(1), content=FillControl('|', token=Token.Line)), Window(content=TokenListControl.static([(Token.HelloWorld, lipsum)])), Window(width=D.exact(1), content=FillControl('|', token=Token.Line)), Window(content=BufferControl( lexer=PygmentsLexer(PythonLexer), margin=NumberredMargin(), input_processors=[ DefaultPrompt.from_message('python> '), AfterInput.static(' <python', token=Token.AfterInput), ]), ), Window(width=D.exact(1), content=FillControl('|', token=Token.Line)), HSplit([ Window(width=D(max=40), height=D.exact(4), content=FillControl('b', token=Token.B)), Window(width=D(max=40), content=FillControl('f', token=Token.F)), Window(width=D.exact(30), height=D.exact(2), content=FillControl('c', token=Token.C)), ]), #CompletionsMenu(), ]), Window(height=D.exact(1), content=FillControl('-', token=Token.Line)), Window(height=D.exact(3), content=FillControl('d', token=Token.D)), SystemToolbar(), ArgToolbar(), CompletionsToolbar(), SearchToolbar(), ]) layout = FloatContainer(content=layout, floats=[ Float(xcursor=True, ycursor=True, content=VSplit([ Window(width=D.exact(5), content=FillControl( 'f', token=Token.F)), CompletionsMenu(), ])), ]) eventloop = create_eventloop() application = Application(layout=layout, style=TestStyle, key_bindings_registry=manager.registry, buffer=Buffer(is_multiline=Always(), completer=TestCompleter())) cli = CommandLineInterface(application=application, eventloop=eventloop) cli.run() eventloop.close()
def get_empty(): """ returns an empty window because of syntaxical issues """ return Window( content=FillControl(' ') )
def get_hline(): """ gets a horiztonal line """ return Window( width=D.exact(1), height=D.exact(1), content=FillControl('-', token=Token.Line))
def create_layout(settings, key_bindings_manager, python_prompt_control=None, lexer=PythonLexer, extra_sidebars=None, extra_buffer_processors=None): D = LayoutDimension extra_sidebars = extra_sidebars or [] extra_buffer_processors = extra_buffer_processors or [] def create_python_input_window(): def menu_position(cli): """ When there is no autocompletion menu to be shown, and we have a signature, set the pop-up position at `bracket_start`. """ b = cli.buffers['default'] if b.complete_state is None and settings.signatures: row, col = settings.signatures[0].bracket_start index = b.document.translate_row_col_to_index(row - 1, col) return index return Window( BufferControl( buffer_name=DEFAULT_BUFFER, lexer=lexer, show_line_numbers=ShowLineNumbersFilter(settings, 'default'), input_processors=[ # Show matching parentheses, but only while editing. ConditionalProcessor( processor=HighlightMatchingBracketProcessor(chars='[](){}'), filter=HasFocus(DEFAULT_BUFFER) & ~IsDone()), HighlightSearchProcessor(preview_search=Always()), HighlightSelectionProcessor()] + extra_buffer_processors, menu_position=menu_position, # Make sure that we always see the result of an reverse-i-search: preview_search=Always(), ), # As long as we're editing, prefer a minimal height of 6. get_height=(lambda cli: (None if cli.is_done else D(min=6))), ) return HSplit([ VSplit([ HSplit([ FloatContainer( content=HSplit([ VSplit([ Window( python_prompt_control, dont_extend_width=True, ), create_python_input_window(), ]), ]), floats=[ Float(xcursor=True, ycursor=True, content=CompletionsMenu( max_height=12, extra_filter=ShowCompletionsMenu(settings))), Float(xcursor=True, ycursor=True, content=SignatureToolbar(settings)) ]), ArgToolbar(), SearchToolbar(), SystemToolbar(), ValidationToolbar(), CompletionsToolbar(extra_filter=ShowCompletionsToolbar(settings)), # Docstring region. Window(height=D.exact(1), content=FillControl('\u2500', token=Token.Separator), filter=HasSignature(settings) & ShowDocstring(settings) & ~IsDone()), Window( BufferControl( buffer_name='docstring', default_token=Token.Docstring, #lexer=PythonLexer, ), filter=HasSignature(settings) & ShowDocstring(settings) & ~IsDone(), height=D(max=12), ), ]), ] + extra_sidebars + [ PythonSidebar(settings, key_bindings_manager), ]), VSplit([ PythonToolbar(key_bindings_manager, settings), ShowSidebarButtonInfo(), ]) ])
from .pygments import FranzLexer def get_titlebar_tokens(cli): return [ (Token.Title, ' Franz 0.0 '), (Token.Title, ' (Press [Meta-Enter] to evaluate buffer. Press [Ctrl-Q] to quit.) '), ] layout = HSplit([ Window(content=BufferControl(buffer_name=DEFAULT_BUFFER, lexer=PygmentsLexer(FranzLexer))), Window(height=D.exact(1), content=FillControl(u"\u2015", token=Token.Line)), Window(content=BufferControl(buffer_name='RESULT')), ]) layout = HSplit([ Window(height=D.exact(1), content=TokenListControl(get_titlebar_tokens, align_center=True)), Window(height=D.exact(1), content=FillControl(u"\u2015", token=Token.Line)), layout, ]) def repl(parser, interpreter, style_name='default'): registry = load_key_bindings()
def vpad(width, ch=' ', token=Token.Padding): return Window(width=D.exact(width), content=FillControl(ch, token=token))
def create_layout(python_input, key_bindings_manager, lexer=PythonLexer, extra_body=None, extra_toolbars=None, extra_buffer_processors=None, input_buffer_height=None): D = LayoutDimension extra_body = [extra_body] if extra_body else [] extra_toolbars = extra_toolbars or [] extra_buffer_processors = extra_buffer_processors or [] input_buffer_height = input_buffer_height or D(min=6) def create_python_input_window(): def menu_position(cli): """ When there is no autocompletion menu to be shown, and we have a signature, set the pop-up position at `bracket_start`. """ b = cli.buffers[DEFAULT_BUFFER] if b.complete_state is None and python_input.signatures: row, col = python_input.signatures[0].bracket_start index = b.document.translate_row_col_to_index(row - 1, col) return index return Window( BufferControl( buffer_name=DEFAULT_BUFFER, lexer=lexer, input_processors=[ ConditionalProcessor( processor=HighlightSearchProcessor( preview_search=True), filter=HasFocus(SEARCH_BUFFER), ), HighlightSelectionProcessor(), DisplayMultipleCursors(DEFAULT_BUFFER), # Show matching parentheses, but only while editing. ConditionalProcessor( processor=HighlightMatchingBracketProcessor( chars='[](){}'), filter=HasFocus(DEFAULT_BUFFER) & ~IsDone() & Condition(lambda cli: python_input. highlight_matching_parenthesis)), ConditionalProcessor(processor=AppendAutoSuggestion(), filter=~IsDone()) ] + 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. get_height=(lambda cli: (None if cli.is_done or python_input. show_exit_confirmation else input_buffer_height)), wrap_lines=Condition(lambda cli: python_input.wrap_lines), ) return HSplit([ VSplit([ HSplit([ FloatContainer( content=HSplit([create_python_input_window()] + extra_body), floats=[ Float(xcursor=True, ycursor=True, content=CompletionsMenu( scroll_offset=Integer.from_callable( lambda: python_input. completion_menu_scroll_offset), max_height=12, extra_filter=show_completions_menu( python_input))), Float( xcursor=True, ycursor=True, content=MultiColumnCompletionsMenu( extra_filter=show_multi_column_completions_menu( python_input))), Float(xcursor=True, ycursor=True, content=signature_toolbar(python_input)), Float(left=2, bottom=1, content=exit_confirmation(python_input)), Float(bottom=0, right=0, height=1, content=meta_enter_message(python_input), hide_when_covering_content=True), Float(bottom=1, left=1, right=0, content=python_sidebar_help(python_input)), ]), ArgToolbar(), SearchToolbar(), SystemToolbar(), ValidationToolbar(), CompletionsToolbar( extra_filter=show_completions_toolbar(python_input)), # Docstring region. ConditionalContainer(content=Window( height=D.exact(1), content=FillControl('\u2500', token=Token.Separator)), filter=HasSignature(python_input) & ShowDocstring(python_input) & ~IsDone()), ConditionalContainer( content=Window( BufferControl( buffer_name='docstring', lexer=SimpleLexer(default_token=Token.Docstring), #lexer=PythonLexer, ), height=D(max=12)), filter=HasSignature(python_input) & ShowDocstring(python_input) & ~IsDone(), ), ]), HSplit([ python_sidebar(python_input), python_sidebar_navigation(python_input), ]) ]), ] + extra_toolbars + [ VSplit([ status_bar(key_bindings_manager, python_input), show_sidebar_button_info(python_input), ]) ])
def __init__(self): self.command_parser = BrewPiCommandParser(self) self.buffers = { DEFAULT_BUFFER: Buffer(completer=command_completer, enable_history_search=True, history=InMemoryHistory(), accept_action=AcceptAction(self.command_parser.parse)), 'MESSAGES': Buffer(), 'RESULT': Buffer(), 'STATE': Buffer(), } self.registry = load_key_bindings() self.registry.add_binding(Keys.ControlC, eager=True)(self._on_request_shutdown) self.registry.add_binding(Keys.ControlQ, eager=True)(self._on_request_shutdown) self.layout = HSplit([ # One window that holds the BufferControl with the default buffer on the # left. VSplit([ HSplit([ Window(content=TokenListControl(get_tokens=lambda cli: [( Token.Title, 'Command Result')]), height=D.exact(1)), Window(content=BufferControl(buffer_name='RESULT'), wrap_lines=True, left_margins=[ScrollbarMargin()]), ]), Window(width=D.exact(1), content=FillControl('|', token=Token.Line)), HSplit([ Window(content=TokenListControl(get_tokens=lambda cli: [( Token.Title, 'Raw Protocol Messages')]), height=D.exact(1)), Window( content=BufferControl(buffer_name='MESSAGES', lexer=PygmentsLexer(JsonLexer)), wrap_lines=True, left_margins=[NumberredMargin()], right_margins=[ScrollbarMargin()]) ]) ]), VSplit([ Window(content=TokenListControl( get_tokens=self.get_prompt_tokens), height=D.exact(1), dont_extend_width=True), Window(content=BufferControl(buffer_name=DEFAULT_BUFFER), height=D.exact(1), dont_extend_height=True), ]), Window(content=BufferControl(buffer_name='STATE'), height=D.exact(1), dont_extend_height=True) ]) super().__init__( layout=self.layout, buffers=self.buffers, key_bindings_registry=self.registry, mouse_support=True, style=style_from_pygments( get_style_by_name('emacs'), style_dict={ Token.Toolbar: '#ffffff bg:#333333', Token.Title: '#ffffff bg:#000088', # User input. Token: '#ff0066', # Prompt. Token.Name: '#884444 italic', Token.At: '#00aa00', Token.Colon: '#00aa00', Token.Pound: '#00aa00', Token.Host: '#000088 bg:#aaaaff', Token.Path: '#884444 underline', # Make a selection reverse/underlined. # (Use Control-Space to select.) Token.SelectedText: 'reverse underline', }), use_alternate_screen=True) # BrewPi Stuff self.controller_manager = BrewPiControllerManager() self.msg_decoder = RawMessageDecoder() self.controller = None
def separator(): return ConditionalContainer(content=Window( height=LayoutDimension.exact(1), content=FillControl(u'\u2500', token=Token.Separator)), filter=HasDocumentation(app) & ~IsDone())
def __init__(self): pdb.Pdb.__init__(self) # Cache for the grammar. self._grammar_cache = None # (current_pdb_commands, grammar) tuple. self.completer = None self.validator = None self.lexer = None self._source_code_window = Window(BufferControl( buffer_name='source_code', lexer=PygmentsLexer(PythonLexer), input_processors=[ HighlightSearchProcessor(preview_search=True), HighlightSelectionProcessor(), ], ), left_margins=[ SourceCodeMargin(self), NumberredMargin(), ], right_margins=[ScrollbarMargin()], scroll_offsets=ScrollOffsets( top=2, bottom=2), height=LayoutDimension(preferred=10)) # Callstack window. callstack = CallStack(weakref.ref(self)) self.callstack_focussed = False # When True, show cursor there, and allow navigation through it. self.callstack_selected_frame = 0 # Top frame. show_pdb_content_filter = ~IsDone() & Condition( lambda cli: not self.python_input.show_exit_confirmation) self.python_input = PythonInput( get_locals=lambda: self.curframe.f_locals, get_globals=lambda: self.curframe.f_globals, _completer=DynamicCompleter(lambda: self.completer), _validator=DynamicValidator(lambda: self.validator), _accept_action=self._create_accept_action(), _extra_buffers={'source_code': Buffer(read_only=True)}, _input_buffer_height=LayoutDimension(min=2, max=4), _lexer=PdbLexer(), _extra_buffer_processors=[ ConditionalProcessor(processor=CompletionHint(), filter=~IsDone()) ], _extra_layout_body=ConditionalContainer( HSplit([ VSplit([ HSplit([ SourceTitlebar(weakref.ref(self)), FloatContainer( content=self._source_code_window, floats=[ Float(right=0, bottom=0, content=BreakPointInfoToolbar( weakref.ref(self))) ]), ]), HSplit([ Window(width=LayoutDimension.exact(1), height=LayoutDimension.exact(1), content=FillControl( '\u252c', token=Token.Toolbar.Title)), Window(width=LayoutDimension.exact(1), content=FillControl('\u2502', token=Token.Separator)), ]), HSplit([ StackTitlebar(weakref.ref(self)), Window(callstack, scroll_offsets=ScrollOffsets(top=2, bottom=2), right_margins=[ScrollbarMargin()], height=LayoutDimension(preferred=10)), ]), ]), ]), filter=show_pdb_content_filter), _extra_toolbars=[ ConditionalContainer(PdbShortcutsToolbar(weakref.ref(self)), show_pdb_content_filter) ], history_filename=os.path.expanduser('~/.ptpdb_history'), ) # Override prompt style. self.python_input.all_prompt_styles['pdb'] = PdbPromptStyle( self._get_current_pdb_commands()) self.python_input.prompt_style = 'pdb' # Override exit message. self.python_input.exit_message = 'Do you want to quit BDB? This raises BdbQuit.' # Set UI styles. self.python_input.ui_styles = { 'ptpdb': get_ui_style(), } self.python_input.use_ui_colorscheme('ptpdb') # Set autocompletion style. (Multi-column works nicer.) self.python_input.completion_visualisation = CompletionVisualisation.MULTI_COLUMN # Load additional key bindings. load_custom_pdb_key_bindings(self, self.python_input.key_bindings_registry) self.cli = CommandLineInterface( eventloop=create_eventloop(), application=self.python_input.create_application())
# larger than what was available to the window. # So, for this example, we create a layout that shows the content of the # default buffer on the left, shows a line in the middle and another buffer # (called 'RESULT') on the right. layout = VSplit([ # One window that holds the BufferControl with the default buffer on the # left. Window(content=BufferControl(buffer_name=DEFAULT_BUFFER)), # A vertical line in the middle. We explicitely specify the width, to make # sure that the layout engine will not try to divide the whole width by # three for all these windows. The `FillControl` will simply fill the whole # window by repeating this character. Window(width=D.exact(1), content=FillControl('|', token=Token.Line)), # Display the Result buffer on the right. Window(content=BufferControl(buffer_name='RESULT')), ]) # As a demonstration. Let's add a title bar to the top, displaying "Hello world". # somewhere, because usually the default key bindings include searching. (Press # Ctrl-R.) It would be really annoying if the search key bindings are handled, # but the user doesn't see any feedback. We will add the search toolbar to the # bottom by using an HSplit. def get_titlebar_tokens(cli): return [
def hpad(height, ch=' ', token=Token.Padding): return Window(height=D.exact(height), content=FillControl(ch, token=token))