def updateScreen(self): """ Update the UI after a change """ # generate the tab bar self.tabbar = [] for veh in self.tabs: if veh.active: self.tabbar.append( ('class:tabbar.tab.active', ' {0} '.format(veh.name))) else: self.tabbar.append( ('class:tabbar.tab', ' {0} '.format(veh.name))) self.tabbar.append(('class:tabbar', ' ')) self.hscreen[0].content = FormattedTextControl(self.tabbar, style='class:tabbar') for veh in self.tabs: if veh.active: self.hscreen[2].content = BufferControl(buffer=veh.output, focusable=False) self.hscreen[4].content = BufferControl( buffer=veh.input, focusable=True, input_processors=[veh.prompt]) return
def create(self): from freud.key_bindings import response_kb, header_kb right_margins = [ScrollbarMargin(display_arrows=True)] left_margins = [NumberedMargin()] self.buffer_control = BufferControl( lexer=PygmentsLexer(JsonLexer), search_buffer_control=search_toolbar.control, buffer=response_buffer) header_window = Window( wrap_lines=True, right_margins=right_margins, left_margins=left_margins, height=HEADER_HEIGHT, content=BufferControl(key_bindings=header_kb, search_buffer_control=search_toolbar.control, lexer=PygmentsLexer(HeaderLexer), buffer=header_buffer)) body_window = Window(left_margins=left_margins, right_margins=right_margins, wrap_lines=True, content=self.buffer_control) return HSplit([ header_window, Window(height=1, char='─', style='class:line'), body_window, ], key_bindings=response_kb)
def create_tutorial_layout(lex): """ layout for example tutorial """ lexer, _, _ = get_lexers(lex, None, None) layout_full = HSplit([ FloatContainer( Window(BufferControl(input_processors=input_processors, lexer=lexer, preview_search=Always()), get_height=get_height), [ Float(xcursor=True, ycursor=True, content=CompletionsMenu( max_height=MAX_COMPLETION, scroll_offset=1, extra_filter=(HasFocus(DEFAULT_BUFFER)))) ]), ConditionalContainer(HSplit([ get_hline(), get_param(lexer), get_hline(), Window(content=BufferControl(buffer_name='example_line', lexer=lexer), ), Window(TokenListControl(get_tutorial_tokens, default_char=Char(' ', Token.Toolbar)), height=D.exact(1)), ]), filter=~IsDone() & RendererHeightIsKnown()) ]) return layout_full
def make_exchange_container( e_key ): exchange = {} exchange['empty_buffer'] = Buffer_() exchange['name'] = allowed_exchanges[e_key]['name'] exchange['title'] = FormattedTextControl() exchange['title'].text = HTML('awaiting connection') exchange['book_buffer'] = FormattedTextControl() exchange['trades_buffer'] = Buffer_() exchange['summary'] = FormattedTextControl() exchange['summary'].text = get_summary_text() exchange['container'] = HSplit( [ Window(BufferControl(exchange['empty_buffer']), height=0), Window( height=1, content=exchange['title'], align=WindowAlign.LEFT, left_margins=[ScrollbarMargin()], ), Window(height=1, char="-", style="class:line.light"), Window( height=1, content=exchange['book_buffer'], align=WindowAlign.LEFT ), Window(height=1, char="-", style="class:line.light"), Window(height=5, width=45, content=exchange['summary'], align=WindowAlign.LEFT, left_margins=[ScrollbarMargin()], ), # VSplit([ # Window(height=5, width=45, content=exchange['summary'], align=WindowAlign.LEFT, left_margins=[ScrollbarMargin()], ), # # Window(width=1, char=".", style="class:mbline"), # ]), Window(height=1, char="-", style="class:line"), Window( BufferControl(exchange['trades_buffer'], input_processors=[FormatText()], include_default_input_processors=True), # right_margins=[ScrollbarMargin(), ScrollbarMargin()], ), ] ) return exchange
def set_input_editable(self): if self.json["cell_type"] == "code": self.input_window.content = BufferControl(buffer=self.input_buffer, lexer=lexer) else: self.input_window.content = BufferControl(buffer=self.input_buffer) self.input_window.height = self.input_buffer.text.count("\n") + 1
def create(self): window = Window(content=BufferControl(buffer=buffer), height=6) self.border_window = Window(char='─', height=1) self.time_window = window self.clock_window = Window(content=BufferControl(buffer=clock_buffer), height=10) return HSplit( [self.time_window, self.border_window, self.clock_window])
def _content(self, main_control: "BufferControl", ti: TransformationInput) -> "UIContent": from prompt_toolkit.layout.controls import BufferControl # Emulate the BufferControl through which we are searching. # For this we filter out some of the input processors. excluded_processors = tuple(self._excluded_input_processors) def filter_processor(item: Processor) -> Optional[Processor]: """Filter processors from the main control that we want to disable here. This returns either an accepted processor or None.""" # For a `_MergedProcessor`, check each individual processor, recursively. if isinstance(item, _MergedProcessor): accepted_processors = [ filter_processor(p) for p in item.processors ] return merge_processors( [p for p in accepted_processors if p is not None]) # For a `ConditionalProcessor`, check the body. elif isinstance(item, ConditionalProcessor): p = filter_processor(item.processor) if p: return ConditionalProcessor(p, item.filter) # Otherwise, check the processor itself. else: if not isinstance(item, excluded_processors): return item return None filtered_processor = filter_processor( merge_processors(main_control.input_processors or [])) highlight_processor = HighlightIncrementalSearchProcessor() if filtered_processor: new_processors = [filtered_processor, highlight_processor] else: new_processors = [highlight_processor] from .controls import SearchBufferControl assert isinstance(ti.buffer_control, SearchBufferControl) buffer_control = BufferControl( buffer=main_control.buffer, input_processors=new_processors, include_default_input_processors=False, lexer=main_control.lexer, preview_search=True, search_buffer_control=cast(SearchBufferControl, ti.buffer_control), ) return buffer_control.create_content(ti.width, ti.height, preview_search=True)
def __init__(self, loop, txClbk, vehListClk, vehObjClk, cmdProcessClk, prntr, settingsDir, isGUI, wxAppPersistMgr): BaseModule.__init__(self, loop, txClbk, vehListClk, vehObjClk, cmdProcessClk, prntr, settingsDir, isGUI, wxAppPersistMgr) self.tabs = [] # all the vehicles, one in each tab # commands self.shortName = "terminal" self.tabbar = [] self.style_extensions = { # Tabs 'tabbar': 'noinherit', 'tabbar.tab': '', 'tabbar.tab.active': 'bold noinherit reverse', } self.current_style = Style.from_dict(self.style_extensions) # make the screen self.hscreen = [] self.hscreen.append( Window(height=1, content=FormattedTextControl(self.tabbar, style='class:tabbar'), align=WindowAlign.LEFT)) self.hscreen.append(Window(height=1, char='-', style='class:line')) self.hscreen.append(Window(content=None, wrap_lines=True)) self.hscreen.append(Window(height=1, char='-', style='class:line')) self.hscreen.append(Window(height=1, content=None)) self.root_container = HSplit(self.hscreen) self.layout = Layout(self.root_container) self.application = Application(layout=self.layout, key_bindings=KB, full_screen=True, style=self.current_style) # event linkages self.application.nextTab = self.nextTab # initial layout self.tabbar.append(('class:tabbar.tab', ' {0} '.format("tmp"))) self.tabbar.append(('class:tabbar', ' ')) self.hscreen[0].content = FormattedTextControl(self.tabbar, style='class:tabbar') self.hscreen[2].content = BufferControl(focusable=False) self.hscreen[4].content = BufferControl(focusable=True) asyncio.ensure_future(self.runUI())
def _gen_layout(self): stat_windows = [] for stat_group in statinfo.groups: for stat in stat_group: stat_windows.append(make_stat_window(stat)) stat_windows.append(vpad(1)) stat_windows.append( Window(content=BufferControl(buffer_name='REROLLS_STAT_BUFFER'), **stat_args)) stat_windows.append(vpad(1)) @Condition def scroll_cond(cli): if self.info_window.render_info is None: return True try: l = self.buffers['INFO_BUFFER'].document.line_count return self.info_window.render_info.window_height < l except: return True self.info_window = Window( content=BufferControl(buffer_name='INFO_BUFFER'), dont_extend_width=True, wrap_lines=True, always_hide_cursor=True, right_margins=[ ConditionalMargin(ScrollbarMargin(display_arrows=True), scroll_cond) ]) return HSplit([ hpad(1), VSplit([ vpad(1), HSplit(stat_windows), vpad(2), # idk why there's an extra space on the stats self.info_window, vpad(1) ]), hpad(1), Window(content=BufferControl(buffer_name='MSG_BUFFER'), height=D.exact(3), wrap_lines=True), Window(content=BufferControl(buffer_name=DEFAULT_BUFFER), height=D.exact(1), always_hide_cursor=True) ])
def create_layout(self, exam_lex, toolbar_lex): """ creates the layout """ lexer, exam_lex, toolbar_lex = get_lexers(self.shell_ctx.lexer, exam_lex, toolbar_lex) if not any( isinstance(processor, DefaultPrompt) for processor in self.input_processors): self.input_processors.append(DefaultPrompt(self.get_prompt_tokens)) layout_lower = ConditionalContainer(HSplit([ get_anyhline(self.shell_ctx.config), get_descriptions(self.shell_ctx.config, exam_lex, lexer), get_examplehline(self.shell_ctx.config), get_example(self.shell_ctx.config, exam_lex), ConditionalContainer(get_hline(), filter=self.show_default | self.show_symbol), ConditionalContainer(Window(content=BufferControl( buffer_name='default_values', lexer=lexer)), filter=self.show_default), ConditionalContainer(get_hline(), filter=self.show_default & self.show_symbol), ConditionalContainer(Window( content=BufferControl(buffer_name='symbols', lexer=exam_lex)), filter=self.show_symbol), ConditionalContainer(Window( content=BufferControl(buffer_name='progress', lexer=lexer)), filter=self.show_progress), Window(content=BufferControl(buffer_name='bottom_toolbar', lexer=toolbar_lex), ), ]), filter=~IsDone() & RendererHeightIsKnown()) layout_full = HSplit([ FloatContainer( Window( BufferControl(input_processors=self.input_processors, lexer=lexer, preview_search=Always()), get_height=get_height, ), [ Float(xcursor=True, ycursor=True, content=CompletionsMenu( max_height=MAX_COMPLETION, scroll_offset=1, extra_filter=(HasFocus(DEFAULT_BUFFER)))) ]), layout_lower ]) return layout_full
def _content(self, main_control, ti): from prompt_toolkit.layout.controls import BufferControl # Emulate the BufferControl through which we are searching. # For this we filter out some of the input processors. excluded_processors = tuple(self._excluded_input_processors) def filter_processor(item): """ Filter processors from the main control that we want to disable here. This returns either an accepted processor or None. """ # For a `_MergedProcessor`, check each individual processor, recursively. if isinstance(item, _MergedProcessor): accepted_processors = [ filter_processor(p) for p in item.processors ] accepted_processors = [ p for p in accepted_processors if p is not None ] if len(accepted_processors) > 1: return _MergedProcessor(accepted_processors) elif accepted_processors == 1: return accepted_processors[0] # For a `ConditionalProcessor`, check the body. elif isinstance(item, ConditionalProcessor): p = filter_processor(item.processor) if p: return ConditionalProcessor(p, item.filter) # Otherwise, check the processor itself. else: if not isinstance(item, excluded_processors): return item filtered_processor = filter_processor(main_control.input_processor) highlight_processor = HighlightSearchProcessor(preview_search=True) if filtered_processor: new_processor = _MergedProcessor( [filtered_processor, highlight_processor]) else: new_processor = highlight_processor buffer_control = BufferControl(buffer=main_control.buffer, input_processor=new_processor, lexer=main_control.lexer, preview_search=True, search_buffer_control=ti.buffer_control) return buffer_control.create_content(ti.width, ti.height)
def __init__( self, state, ): self.state = state self.kb = KeyBindings() # layout components self.header_bar = FormattedTextControl(focusable=False, ) self.input_buffer = Buffer(multiline=False, ) self.input_buffer.on_text_changed += self.update_results self.results_control = SelectableList(text="") self.preview_bar = FormattedTextControl(focusable=False, ) self.preview_buffer = BufferControl( input_processors=[TabsProcessor(tabstop=4, char1="", char2="")], focusable=False, ) self.status_bar = FormattedTextControl() self.layout = Layout( HSplit([ Window(self.header_bar, height=1, style="reverse"), Window( BufferControl(self.input_buffer), height=1, ), Window(self.results_control, height=Dimension(**RESULTS_DIMENSION_DICT)), Window(self.preview_bar, height=1, style="reverse"), Window( self.preview_buffer, wrap_lines=True, height=Dimension(**PREVIEW_DIMENSION_DICT), ), Window(self.status_bar, height=1, style="reverse"), ]), ) self.reset_view() @self.kb.add("up") def _(event): self.results_control.index -= 1 self.update_preview() @self.kb.add("down") def _(event): self.results_control.index += 1 self.update_preview() @self.kb.add("enter") def _(event): self.select_collection() self.reset_view()
def _content(self, main_control: 'BufferControl', ti: TransformationInput) -> 'UIContent': from prompt_toolkit.layout.controls import BufferControl # Emulate the BufferControl through which we are searching. # For this we filter out some of the input processors. excluded_processors = tuple(self._excluded_input_processors) def filter_processor(item: Processor) -> Optional[Processor]: """ Filter processors from the main control that we want to disable here. This returns either an accepted processor or None. """ # For a `_MergedProcessor`, check each individual processor, recursively. if isinstance(item, _MergedProcessor): accepted_processors = [filter_processor(p) for p in item.processors] return merge_processors( [p for p in accepted_processors if p is not None]) # For a `ConditionalProcessor`, check the body. elif isinstance(item, ConditionalProcessor): p = filter_processor(item.processor) if p: return ConditionalProcessor(p, item.filter) # Otherwise, check the processor itself. else: if not isinstance(item, excluded_processors): return item return None filtered_processor = filter_processor( merge_processors(main_control.input_processors or [])) highlight_processor = HighlightIncrementalSearchProcessor() if filtered_processor: new_processors = [filtered_processor, highlight_processor] else: new_processors = [highlight_processor] from .controls import SearchBufferControl assert isinstance(ti.buffer_control, SearchBufferControl) buffer_control = BufferControl( buffer=main_control.buffer, input_processors=new_processors, include_default_input_processors=False, lexer=main_control.lexer, preview_search=True, search_buffer_control=cast(SearchBufferControl, ti.buffer_control)) return buffer_control.create_content(ti.width, ti.height, preview_search=True)
def __init__(self): super(CommandLine, self).__init__(BufferControl( buffer_name=COMMAND_BUFFER, input_processors=[BeforeInput.static(':')], lexer=create_command_lexer()), height=LayoutDimension.exact(1), filter=HasFocus(COMMAND_BUFFER))
def application(): root_container = VSplit([ # One window that holds the BufferControl with the default buffer on # the left. input_field, # A vertical line in the middle. We explicitly 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 window will simply fill its # content by repeating this character. Window(width=1, char='|'), # Display the text 'Hello world' on the right. Window(content=BufferControl(buffer=right_buffer)), ]) layout = Layout(root_container) # TODO : different layout if input/output not a terminal... application = Application( key_bindings=kb, layout=layout, full_screen=True, ) return application
def __init__( self, prompt: AnyFormattedText = "Shell command: ", enable_global_bindings: FilterOrBool = True, ) -> None: self.prompt = prompt self.enable_global_bindings = to_filter(enable_global_bindings) self.system_buffer = Buffer(name=SYSTEM_BUFFER) self._bindings = self._build_key_bindings() self.buffer_control = BufferControl( buffer=self.system_buffer, lexer=SimpleLexer(style="class:system-toolbar.text"), input_processors=[ BeforeInput(lambda: self.prompt, style="class:system-toolbar") ], key_bindings=self._bindings, ) self.window = Window( self.buffer_control, height=1, style="class:system-toolbar" ) self.container = ConditionalContainer( content=self.window, filter=has_focus(self.system_buffer) )
def __init__(self, text='', width=None, extend_width=True, read_only=False, on_accepted=None, on_changed=None, style=''): self._activity_indicator = utils.ActivityIndicator( callback=self.set_text) self.read_only = read_only self.on_accepted = on_accepted self.buffer = Buffer( multiline=False, accept_handler=self._accept_handler, on_text_changed=on_changed, read_only=Condition(lambda: self.read_only), ) self.container = Window( content=BufferControl(self.buffer), always_hide_cursor=Condition(lambda: self.read_only), width=width, dont_extend_height=True, dont_extend_width=not extend_width, style=style, ) if text: self.set_text(text, ignore_callback=True)
def get_example(config, exam_lex): """ example description window """ if config.BOOLEAN_STATES[config.config.get('Layout', 'examples')]: return Window( content=BufferControl(buffer_name="examples", lexer=exam_lex)) else: return get_empty()
def __init__(self, app=None, show=False, title='[ A Window ]', show_divider=lambda:True, get_lexer=lambda: None, height=Dimension(preferred=1), wrap_lines=False, scroll_offsets=ScrollOffsets()): self.app = app self.show = show self.buffer = Buffer(document=Document(), multiline=True) self.control = BufferControl(buffer=self.buffer, focusable=True, lexer=self.lexer, focus_on_click=True) self.window = PromptWindow(content=self.control, height=height, wrap_lines=wrap_lines, scroll_offsets=scroll_offsets) self.divider = Divider(self, show=show_divider) self.info = InfoLine(title, width=240) self.container = ConditionalContainer( content=VSplit([ self.divider.get_ui(), HSplit([self.info.get_ui(), self.window])]), filter=Condition(lambda: self.show))
def __init__(self, question, candidates, other=False, default=None, **kwargs): self._candidates = candidates self._other = other self._selected, other_value = self._get_default_selected(default) self._candidate_control = ChoiceCandidatesControl( candidates, self._selected) if self.has_other: buf = Buffer(accept_handler=self._buffer_handler, multiline=False, **kwargs) buf.document = Document(other_value) self._other_value_control = BufferControl(buf) self._other_label_control = ChoiceOtherLabelControl( self.other_selected, self._other if isinstance(self._other, str) else None, ) super().__init__(question)
def __init__(self, editor): super(CommandLine, self).__init__( Window(BufferControl(buffer=editor.command_buffer, input_processors=[BeforeInput(':')], lexer=create_command_lexer()), height=1), filter=has_focus(editor.command_buffer))
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 setup_logging_containers(repl): j = KosmosShellConfig.j panel_line_count = j.core.myenv.config.get("LOGGER_PANEL_NRLINES", 12) parent_container = get_ptpython_parent_container(repl) parent_container.children.extend( [ ConditionalContainer( content=Window(height=Dimension.exact(1), char="\u2500", style="class:separator"), filter=HasLogs(repl) & ~is_done, ), ConditionalContainer( content=Window( BufferControl( buffer=LogPane.Buffer, input_processors=[FormatANSIText(), HighlightIncrementalSearchProcessor()], focusable=False, preview_search=True, ), wrap_lines=True, height=Dimension.exact(panel_line_count), ), filter=HasLogs(repl) & ~is_done, ), ] )
def main(): eventloop = create_eventloop() done = [False] # Non local def on_read_start(cli): """ This function is called when we start reading at the input. (Actually the start of the read-input event loop.) """ # Following function should be run in the background. # We do it by using an executor thread from the `CommandLineInterface` # instance. def run(): # Send every second a redraw request. while not done[0]: time.sleep(1) cli.request_redraw() cli.eventloop.run_in_executor(run) def on_read_end(cli): done[0] = True app = Application(layout=Window( BufferControl(input_processors=[BeforeInput(_clock_tokens)])), on_start=Callback(on_read_start), on_stop=Callback(on_read_end)) cli = CommandLineInterface(application=app, eventloop=eventloop) code_obj = cli.run() print('You said: %s' % code_obj.text) eventloop.close()
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_layout(self): has_before_fragments, get_prompt_text_1, get_prompt_text_2 = \ _split_multiline_prompt(self._get_prompt) default_buffer = self.default_buffer default_buffer_control = BufferControl( buffer=default_buffer, search_buffer_control=None, input_processors=[], include_default_input_processors=False) prompt_window = Window(FormattedTextControl(get_prompt_text_1), dont_extend_height=True) default_buffer_window = Window( default_buffer_control, dont_extend_height=True, get_line_prefix=partial(self._get_line_prefix, get_prompt_text_2=get_prompt_text_2)) divider = Window(char='_', height=1, style='fg:gray bg:black') search_window = Window(content=SearchControl(), style='') bottom_toolbar = ConditionalContainer( Window(FormattedTextControl(lambda: self.bottom_toolbar), dont_extend_height=True, height=Dimension(min=1)), filter=~is_done & renderer_height_is_known & Condition(lambda: self.bottom_toolbar is not None)) layout = HSplit([ prompt_window, default_buffer_window, divider, search_window, bottom_toolbar ]) return Layout(layout, default_buffer_window)
def get_buffer_window(self): " Return the Container object according to which Buffer/Source is visible. " source = self.pager.source if source not in self._bodies: input_processors = [ ConditionalProcessor( processor=_EscapeProcessor(self.pager), filter=Condition( lambda cli: not bool(self.pager.source.lexer)), ), TabsProcessor(), HighlightSelectionProcessor(), ConditionalProcessor( processor=HighlightSearchProcessor(preview_search=True), filter=Condition(lambda cli: self.pager.highlight_search), ), HighlightMatchingBracketProcessor(), ] buffer_window = Window( always_hide_cursor=True, content=BufferControl( buffer_name=self.pager.source_info[source].buffer_name, lexer=source.lexer, input_processors=input_processors)) self._bodies[source] = buffer_window return self._bodies[source]
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))), )
def __init__(self, session): self.session = session self.tabs_toolbar = TabsToolbar(self.session) self.float_container = FloatContainer( # Dummy window content=VSplit([Window(BufferControl())]), floats=[]) super().__init__( children=[ # Tabs self.tabs_toolbar, # Seperation line. Window(height=1, char='-', style='class:line'), # Here goes current tab buffer self.float_container ], window_too_small=None, align=VerticalAlign.JUSTIFY, padding=0, padding_char=None, padding_style='', width=None, height=None, z_index=None, modal=False, key_bindings=None, style='')
def __init__(self, inpipe): self.inpipe = inpipe self.tempfile = tempfile.NamedTemporaryFile(mode="w", delete=True) self.initialize_nodes() root = VSplit( [ # Input buffer and status line HSplit( [ self.first_line, Window( content=BufferControl( buffer=self.input_buffer, # This lexer is disabled for now because # I don't want to mess with colourschemes # lexer=PygmentsLexer(PythonLexer), ) ), self.error_output, ], width=Dimension(), ), Window(width=1, char="|"), # Output display area Window(ignore_content_width=True, content=self.output, wrap_lines=True), ], width=Dimension(), ) layout = Layout(root) self.app = Application(layout=layout, key_bindings=kb, full_screen=True)
def editor_window(self): """configure the editor window and returns a application class""" self.buffer_1 = Buffer() # need the text in another method self.text = self.open_file() f_ext = pathlib.PurePath(self.file_abs_path).suffix # set container(s) self.buffer_1.text = self.text style_n = style_from_pygments_cls(get_style_by_name("friendly")) container = Window( BufferControl(buffer=self.buffer_1, lexer=syntax_highlight(f_ext))) # create layout layout_editor = Layout(container) # make an instance from keybinds method key_bind = self.key_binds("") # define application that will be started app = Application(layout=layout_editor, key_bindings=key_bind, full_screen=True, style=style_n) return app