Python prompt_toolkit.key_binding.vi_state.InputMode.NAVIGATION Examples
The following are 11
code examples of prompt_toolkit.key_binding.vi_state.InputMode.NAVIGATION().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
prompt_toolkit.key_binding.vi_state.InputMode
, or try the search function
.
Example #1
Source File: python_input.py From ptpython with BSD 3-Clause "New" or "Revised" License | 6 votes |
def enter_history(self) -> None: """ Display the history. """ app = get_app() app.vi_state.input_mode = InputMode.NAVIGATION history = PythonHistory(self, self.default_buffer.document) from prompt_toolkit.application import in_terminal import asyncio async def do_in_terminal() -> None: async with in_terminal(): result = await history.app.run_async() if result is not None: self.default_buffer.text = result app.vi_state.input_mode = InputMode.INSERT asyncio.ensure_future(do_in_terminal())
Example #2
Source File: app.py From python-prompt-toolkit with BSD 3-Clause "New" or "Revised" License | 6 votes |
def vi_navigation_mode() -> bool: """ Active when the set for Vi navigation key bindings are active. """ from prompt_toolkit.key_binding.vi_state import InputMode app = get_app() if ( app.editing_mode != EditingMode.VI or app.vi_state.operator_func or app.vi_state.waiting_for_digraph or app.current_buffer.selection_state ): return False return ( app.vi_state.input_mode == InputMode.NAVIGATION or app.vi_state.temporary_navigation_mode or app.current_buffer.read_only() )
Example #3
Source File: pgtoolbar.py From pgcli with BSD 3-Clause "New" or "Revised" License | 5 votes |
def _get_vi_mode(): return { InputMode.INSERT: "I", InputMode.NAVIGATION: "N", InputMode.REPLACE: "R", InputMode.INSERT_MULTIPLE: "M", }[get_app().vi_state.input_mode]
Example #4
Source File: clitoolbar.py From litecli with BSD 3-Clause "New" or "Revised" License | 5 votes |
def _get_vi_mode(): """Get the current vi mode for display.""" return { InputMode.INSERT: "I", InputMode.NAVIGATION: "N", InputMode.REPLACE: "R", InputMode.INSERT_MULTIPLE: "M", }[get_app().vi_state.input_mode]
Example #5
Source File: clitoolbar.py From athenacli with BSD 3-Clause "New" or "Revised" License | 5 votes |
def _get_vi_mode(): """Get the current vi mode for display.""" return { InputMode.INSERT: 'I', InputMode.NAVIGATION: 'N', InputMode.REPLACE: 'R', InputMode.INSERT_MULTIPLE: 'M', }[get_app().vi_state.input_mode]
Example #6
Source File: mssqltoolbar.py From mssql-cli with BSD 3-Clause "New" or "Revised" License | 5 votes |
def _get_vi_mode(): return { InputMode.INSERT: 'I', InputMode.NAVIGATION: 'N', InputMode.REPLACE: 'R', InputMode.INSERT_MULTIPLE: 'M', }[get_app().vi_state.input_mode]
Example #7
Source File: editor.py From pyvim with BSD 3-Clause "New" or "Revised" License | 5 votes |
def run(self): """ Run the event loop for the interface. This starts the interaction. """ # Make sure everything is in sync, before starting. self.sync_with_prompt_toolkit() def pre_run(): # Start in navigation mode. self.application.vi_state.input_mode = InputMode.NAVIGATION # Run eventloop of prompt_toolkit. self.application.run(pre_run=pre_run)
Example #8
Source File: editor.py From pyvim with BSD 3-Clause "New" or "Revised" License | 5 votes |
def leave_command_mode(self, append_to_history=False): """ Leave command mode. Focus document window again. """ self.previewer.restore() self.application.layout.focus_last() self.application.vi_state.input_mode = InputMode.NAVIGATION self.command_buffer.reset(append_to_history=append_to_history)
Example #9
Source File: vi.py From android_universal with MIT License | 5 votes |
def load_vi_system_bindings(): registry = ConditionalRegistry(Registry(), ViMode()) handle = registry.add_binding has_focus = filters.HasFocus(SYSTEM_BUFFER) navigation_mode = ViNavigationMode() @handle('!', filter=~has_focus & navigation_mode) def _(event): """ '!' opens the system prompt. """ event.cli.push_focus(SYSTEM_BUFFER) event.cli.vi_state.input_mode = InputMode.INSERT @handle(Keys.Escape, filter=has_focus) @handle(Keys.ControlC, filter=has_focus) def _(event): """ Cancel system prompt. """ event.cli.vi_state.input_mode = InputMode.NAVIGATION event.cli.buffers[SYSTEM_BUFFER].reset() event.cli.pop_focus() @handle(Keys.ControlJ, filter=has_focus) def _(event): """ Run system command. """ event.cli.vi_state.input_mode = InputMode.NAVIGATION system_buffer = event.cli.buffers[SYSTEM_BUFFER] event.cli.run_system_command(system_buffer.text) system_buffer.reset(append_to_history=True) # Focus previous buffer again. event.cli.pop_focus() return registry
Example #10
Source File: cli.py From android_universal with MIT License | 5 votes |
def __call__(self, cli): if (cli.editing_mode != EditingMode.VI or cli.vi_state.operator_func or cli.vi_state.waiting_for_digraph or cli.current_buffer.selection_state): return False return (cli.vi_state.input_mode == ViInputMode.NAVIGATION or cli.current_buffer.read_only())
Example #11
Source File: layout.py From ptpython with BSD 3-Clause "New" or "Revised" License | 4 votes |
def get_inputmode_fragments(python_input: "PythonInput") -> StyleAndTextTuples: """ Return current input mode as a list of (token, text) tuples for use in a toolbar. """ app = get_app() @if_mousedown def toggle_vi_mode(mouse_event: MouseEvent) -> None: python_input.vi_mode = not python_input.vi_mode token = "class:status-toolbar" input_mode_t = "class:status-toolbar.input-mode" mode = app.vi_state.input_mode result: StyleAndTextTuples = [] append = result.append if python_input.title: result.extend(to_formatted_text(python_input.title)) append((input_mode_t, "[F4] ", toggle_vi_mode)) # InputMode if python_input.vi_mode: recording_register = app.vi_state.recording_register if recording_register: append((token, " ")) append((token + " class:record", "RECORD({})".format(recording_register))) append((token, " - ")) if app.current_buffer.selection_state is not None: if app.current_buffer.selection_state.type == SelectionType.LINES: append((input_mode_t, "Vi (VISUAL LINE)", toggle_vi_mode)) elif app.current_buffer.selection_state.type == SelectionType.CHARACTERS: append((input_mode_t, "Vi (VISUAL)", toggle_vi_mode)) append((token, " ")) elif app.current_buffer.selection_state.type == SelectionType.BLOCK: append((input_mode_t, "Vi (VISUAL BLOCK)", toggle_vi_mode)) append((token, " ")) elif mode in (InputMode.INSERT, "vi-insert-multiple"): append((input_mode_t, "Vi (INSERT)", toggle_vi_mode)) append((token, " ")) elif mode == InputMode.NAVIGATION: append((input_mode_t, "Vi (NAV)", toggle_vi_mode)) append((token, " ")) elif mode == InputMode.REPLACE: append((input_mode_t, "Vi (REPLACE)", toggle_vi_mode)) append((token, " ")) else: if app.emacs_state.is_recording: append((token, " ")) append((token + " class:record", "RECORD")) append((token, " - ")) append((input_mode_t, "Emacs", toggle_vi_mode)) append((token, " ")) return result