def _render_sdl(self, sdl: str) -> None: desc_doc = pt_document.Document(sdl) lexer = pt_lexers.PygmentsLexer(eql_pygments.EdgeQLLexer) formatter = lexer.lex_document(desc_doc) for line in range(desc_doc.line_count): pt_shortcuts.print_formatted_text(pt_formatted_text.FormattedText( formatter(line)), style=self.style) print()
def build_propmpt(self) -> pt_shortcuts.PromptSession: history = pt_history.FileHistory( os.path.expanduser('~/.edgedbhistory')) bindings = pt_key_binding.KeyBindings() handle = bindings.add @handle('f3') # type: ignore def _mode_toggle(event: Any) -> None: self.context.toggle_query_mode() @handle('f4') # type: ignore def _implicit_toggle(event: Any) -> None: self.context.toggle_implicit() @handle('f5') # type: ignore def _introspect_toggle(event: Any) -> None: self.context.toggle_introspect_types() if self.context.introspect_types: self.ensure_connection() self.introspect_db(self.connection) else: self.context.typenames = None @handle('tab') # type: ignore def _tab(event: Any) -> None: b = prompt.app.current_buffer before_cursor = b.document.current_line_before_cursor if b.text and (not before_cursor or before_cursor.isspace()): b.insert_text(' ') prompt = pt_shortcuts.PromptSession( lexer=pt_lexers.PygmentsLexer(eql_pygments.EdgeQLLexer), include_default_pygments_style=False, completer=pt_complete.DummyCompleter(), reserve_space_for_menu=6, message=self.get_prompt_tokens, prompt_continuation=self.get_continuation_tokens, bottom_toolbar=self.get_toolbar_tokens, multiline=is_multiline, history=history, complete_while_typing=pt_filters.Always(), key_bindings=bindings, style=self.style, editing_mode=pt_enums.EditingMode.VI, search_ignore_case=True, ) return prompt