Skip to main content

Editor

Struct Editor 

Source
pub struct Editor {
    pub position_history: PositionHistory,
    /* private fields */
}
Expand description

The main editor struct - manages multiple buffers, clipboard, and rendering

Fields§

§position_history: PositionHistory

Position history for back/forward navigation

Implementations§

Source§

impl Editor

Source

pub fn open_file(&mut self, path: &Path) -> Result<BufferId>

Open a file and return its buffer ID

If the file doesn’t exist, creates an unsaved buffer with that filename. Saving the buffer will create the file.

Source

pub fn open_file_no_focus(&mut self, path: &Path) -> Result<BufferId>

Open a file without switching focus to it

Creates a new buffer for the file (or returns existing buffer ID if already open) but does not change the active buffer. Useful for opening files in background tabs.

If the file doesn’t exist, creates an unsaved buffer with that filename.

Source

pub fn open_local_file(&mut self, path: &Path) -> Result<BufferId>

Open a local file (always uses local filesystem, not remote)

This is used for opening local files like log files when in remote mode. Unlike open_file, this always uses the local filesystem even when the editor is connected to a remote server.

Source

pub fn open_file_with_encoding( &mut self, path: &Path, encoding: Encoding, ) -> Result<BufferId>

Open a file with a specific encoding (no auto-detection).

Used when the user disables auto-detection in the file browser and selects a specific encoding to use.

Source

pub fn reload_with_encoding(&mut self, encoding: Encoding) -> Result<()>

Reload the current file with a specific encoding.

Requires the buffer to have no unsaved modifications.

Source

pub fn open_file_large_encoding_confirmed( &mut self, path: &Path, ) -> Result<BufferId>

Open a large file with confirmed full loading for non-resynchronizable encoding.

Called after user confirms they want to load a large file with an encoding like GB18030, GBK, Shift-JIS, or EUC-KR that requires loading the entire file into memory.

Source

pub fn goto_line_col(&mut self, line: usize, column: Option<usize>)

Navigate to a specific line and column in the active buffer.

Line and column are 1-indexed (matching typical editor conventions). If the line is out of bounds, navigates to the last line. If the column is out of bounds, navigates to the end of the line.

Source

pub fn select_range( &mut self, start_line: usize, start_col: Option<usize>, end_line: usize, end_col: Option<usize>, )

Select a range in the active buffer. Lines/columns are 1-indexed. The cursor moves to the end of the range and the anchor is set to the start, producing a visual selection.

Source

pub fn goto_byte_offset(&mut self, offset: usize)

Go to an exact byte offset in the buffer (used in byte-offset mode for large files)

Source

pub fn new_buffer(&mut self) -> BufferId

Create a new empty buffer

Source

pub fn open_stdin_buffer( &mut self, temp_path: &Path, thread_handle: Option<JoinHandle<Result<()>>>, ) -> AnyhowResult<BufferId>

Create a new buffer from stdin content stored in a temp file

Uses lazy chunk loading for efficient handling of large stdin inputs. The buffer is unnamed (no file path for save) - saving will prompt for a filename. The temp file path is preserved internally for lazy loading to work.

§Arguments
  • temp_path - Path to temp file where stdin content is being written
  • thread_handle - Optional handle to background thread streaming stdin to temp file
Source

pub fn poll_stdin_streaming(&mut self) -> bool

Poll stdin streaming state and extend buffer if file grew. Returns true if the status changed (needs render).

Source

pub fn complete_stdin_streaming(&mut self)

Mark stdin streaming as complete. Called when the background thread finishes.

Source

pub fn is_stdin_streaming(&self) -> bool

Check if stdin streaming is active (not complete).

Source

pub fn create_virtual_buffer( &mut self, name: String, mode: String, read_only: bool, ) -> BufferId

Create a new virtual buffer (not backed by a file)

§Arguments
  • name - Display name (e.g., “Diagnostics”)
  • mode - Buffer mode for keybindings (e.g., “diagnostics-list”)
  • read_only - Whether the buffer should be read-only
§Returns

The BufferId of the created virtual buffer

Source

pub fn set_virtual_buffer_content( &mut self, buffer_id: BufferId, entries: Vec<TextPropertyEntry>, ) -> Result<(), String>

Set the content of a virtual buffer with text properties

§Arguments
  • buffer_id - The virtual buffer to update
  • entries - Text entries with embedded properties
Source

pub fn open_help_manual(&mut self)

Open the built-in help manual in a read-only buffer

If a help manual buffer already exists, switch to it instead of creating a new one.

Source

pub fn open_keyboard_shortcuts(&mut self)

Open the keyboard shortcuts viewer in a read-only buffer

If a keyboard shortcuts buffer already exists, switch to it instead of creating a new one. The shortcuts are dynamically generated from the current keybindings configuration.

Source

pub fn show_warnings_popup(&mut self)

Show warnings by opening the warning log file directly

If there are no warnings, shows a brief status message. Otherwise, opens the warning log file for the user to view.

Source

pub fn show_lsp_status_popup(&mut self)

Show LSP status - opens the warning log file if there are LSP warnings, otherwise shows a brief status message.

Source

pub fn show_file_message_popup(&mut self, message: &str)

Show a transient hover popup with the given message text, positioned below the cursor. Used for file-open messages (e.g. file.txt:10@"Look at this").

Source

pub fn get_text_properties_at_cursor(&self) -> Option<Vec<&TextProperty>>

Get text properties at the cursor position in the active buffer

Source

pub fn close_buffer(&mut self, id: BufferId) -> Result<()>

Close the given buffer

Source

pub fn force_close_buffer(&mut self, id: BufferId) -> Result<()>

Force close the given buffer without checking for unsaved changes Use this when the user has already confirmed they want to discard changes

Source

pub fn switch_buffer(&mut self, id: BufferId)

Switch to the given buffer

Source

pub fn close_tab(&mut self)

Close the current tab in the current split view. If the tab is the last viewport of the underlying buffer, do the same as close_buffer (including triggering the save/discard prompt for modified buffers).

Source

pub fn close_tab_in_split( &mut self, buffer_id: BufferId, split_id: LeafId, ) -> bool

Close a specific tab (buffer) in a specific split. Used by mouse click handler on tab close button. Returns true if the tab was closed without needing a prompt.

Source

pub fn close_other_tabs_in_split( &mut self, keep_buffer_id: BufferId, split_id: LeafId, )

Close all other tabs in a split, keeping only the specified buffer

Source

pub fn close_tabs_to_right_in_split( &mut self, buffer_id: BufferId, split_id: LeafId, )

Close tabs to the right of the specified buffer in a split

Source

pub fn close_tabs_to_left_in_split( &mut self, buffer_id: BufferId, split_id: LeafId, )

Close tabs to the left of the specified buffer in a split

Source

pub fn close_all_tabs_in_split(&mut self, split_id: LeafId)

Close all tabs in a split

Source

pub fn next_buffer(&mut self)

Switch to next buffer in current split’s tabs

Source

pub fn prev_buffer(&mut self)

Switch to previous buffer in current split’s tabs

Source

pub fn navigate_back(&mut self)

Navigate back in position history

Source

pub fn navigate_forward(&mut self)

Navigate forward in position history

Source

pub fn get_mouse_hover_state(&self) -> Option<(usize, u16, u16)>

Get the current mouse hover state for testing Returns Some((byte_position, screen_x, screen_y)) if hovering over text

Source

pub fn has_transient_popup(&self) -> bool

Check if a transient popup (hover/signature help) is currently visible

Source

pub fn force_check_mouse_hover(&mut self) -> bool

Force check the mouse hover timer (for testing) This bypasses the normal 500ms delay

Source

pub fn schedule_hot_exit_recovery(&mut self)

Queue a file to be opened after the TUI starts.

This is used for CLI file arguments to ensure they go through the same code path as interactive file opens, providing consistent error handling (e.g., encoding confirmation prompts are shown in the UI instead of crashing). Schedule hot exit recovery to run after the next batch of pending file opens.

Source

pub fn queue_file_open( &mut self, path: PathBuf, line: Option<usize>, column: Option<usize>, end_line: Option<usize>, end_column: Option<usize>, message: Option<String>, wait_id: Option<u64>, )

Source

pub fn process_pending_file_opens(&mut self) -> bool

Process pending file opens (called from the event loop).

Opens files that were queued during startup, using the same error handling as interactive file opens. Returns true if any files were processed.

Source

pub fn take_completed_waits(&mut self) -> Vec<u64>

Take and return completed wait IDs (for –wait support).

Source

pub fn remove_wait_tracking(&mut self, wait_id: u64)

Remove wait tracking for a given wait_id (e.g., when waiting client disconnects).

Source

pub fn start_incremental_line_scan(&mut self, open_goto_line: bool)

Start an incremental line-feed scan for the active buffer.

Shared by the Action::ScanLineIndex command and the Go to Line scan confirmation prompt. Sets up LineScanState so that process_line_scan will advance the scan one batch per frame.

When open_goto_line is true (Go to Line flow), the Go to Line prompt opens automatically when the scan completes.

Source

pub fn process_line_scan(&mut self) -> bool

Process chunks for the incremental line-feed scan. Returns true if the UI should re-render (progress updated or scan finished).

Source

pub fn process_search_scan(&mut self) -> bool

Process chunks for the incremental search scan. Returns true if the UI should re-render (progress updated or scan finished).

Source§

impl Editor

Source

pub fn open_calibration_wizard(&mut self)

Open the calibration wizard

Source

pub fn save_calibration(&mut self, wizard: CalibrationWizard)

Save calibration and close wizard

Source

pub fn handle_calibration_input(&mut self, event: &KeyEvent) -> InputResult

Handle input when calibration wizard is active

Source

pub fn is_calibration_active(&self) -> bool

Check if calibration wizard is active

Source§

impl Editor

Source

pub fn copy_selection(&mut self)

Copy the current selection to clipboard

If no selection exists, copies the entire current line (like VSCode/Rider/Zed). For block selections, copies only the rectangular region.

Source

pub fn copy_selection_with_theme(&mut self, theme_name: &str)

Copy selection with a specific theme’s formatting

If theme_name is empty, opens a prompt to select a theme. Otherwise, copies the selected text as HTML with inline CSS styles.

Source

pub fn cut_selection(&mut self)

Cut the current selection to clipboard

If no selection exists, cuts the entire current line (like VSCode/Rider/Zed).

Source

pub fn paste(&mut self)

Paste the clipboard content at all cursor positions

Handles:

  • Single cursor paste
  • Multi-cursor paste (pastes at each cursor)
  • Selection replacement (deletes selection before inserting)
  • Atomic undo (single undo step for entire operation)
Source

pub fn paste_text(&mut self, paste_text: String)

Paste text directly into the editor

Handles:

  • Line ending normalization (CRLF/CR → buffer’s format)
  • Single cursor paste
  • Multi-cursor paste (pastes at each cursor)
  • Selection replacement (deletes selection before inserting)
  • Atomic undo (single undo step for entire operation)
  • Routing to prompt if one is open
Source

pub fn add_cursor_at_next_match(&mut self)

Add a cursor at the next occurrence of the selected text If no selection, first selects the entire word at cursor position

Source

pub fn add_cursor_above(&mut self)

Add a cursor above the primary cursor at the same column

Source

pub fn add_cursor_below(&mut self)

Add a cursor below the primary cursor at the same column

Source

pub fn yank_word_forward(&mut self)

Yank (copy) from cursor to next word start

Source

pub fn yank_vi_word_end(&mut self)

Yank (copy) from cursor to vim word end (inclusive)

Source

pub fn yank_word_backward(&mut self)

Yank (copy) from previous word start to cursor

Source

pub fn yank_to_line_end(&mut self)

Yank (copy) from cursor to end of line

Source

pub fn yank_to_line_start(&mut self)

Yank (copy) from start of line to cursor

Source§

impl Editor

Source

pub fn is_composite_buffer(&self, buffer_id: BufferId) -> bool

Check if a buffer is a composite buffer

Source

pub fn get_composite(&self, buffer_id: BufferId) -> Option<&CompositeBuffer>

Get a composite buffer by ID

Source

pub fn get_composite_mut( &mut self, buffer_id: BufferId, ) -> Option<&mut CompositeBuffer>

Get a mutable composite buffer by ID

Source

pub fn get_composite_view_state( &mut self, split_id: LeafId, buffer_id: BufferId, ) -> Option<&mut CompositeViewState>

Get or create composite view state for a split

Source

pub fn create_composite_buffer( &mut self, name: String, mode: String, layout: CompositeLayout, sources: Vec<SourcePane>, ) -> BufferId

Create a new composite buffer

§Arguments
  • name - Display name for the composite buffer (shown in tab)
  • mode - Mode for keybindings (e.g., “diff-view”)
  • layout - How panes are arranged (side-by-side, stacked, unified)
  • sources - Source panes to display
§Returns

The ID of the newly created composite buffer

Source

pub fn set_composite_alignment( &mut self, buffer_id: BufferId, alignment: LineAlignment, )

Set the line alignment for a composite buffer

The alignment determines how lines from different source buffers are paired up for display (important for diff views).

Source

pub fn close_composite_buffer(&mut self, buffer_id: BufferId)

Close a composite buffer and clean up associated state

Source

pub fn composite_focus_next(&mut self, split_id: LeafId, buffer_id: BufferId)

Switch focus to the next pane in a composite buffer

Source

pub fn composite_focus_prev(&mut self, split_id: LeafId, buffer_id: BufferId)

Switch focus to the previous pane in a composite buffer

Source

pub fn composite_next_hunk( &mut self, split_id: LeafId, buffer_id: BufferId, ) -> bool

Navigate to the next hunk in a composite buffer’s diff view

Source

pub fn composite_prev_hunk( &mut self, split_id: LeafId, buffer_id: BufferId, ) -> bool

Navigate to the previous hunk in a composite buffer’s diff view

Source

pub fn composite_scroll( &mut self, split_id: LeafId, buffer_id: BufferId, delta: isize, )

Scroll a composite buffer view

Source

pub fn composite_scroll_to( &mut self, split_id: LeafId, buffer_id: BufferId, row: usize, )

Scroll composite buffer to a specific row

Source

pub fn handle_composite_action( &mut self, buffer_id: BufferId, action: &Action, ) -> Option<bool>

Handle an action for a composite buffer.

For navigation and selection actions, this forwards to the focused source buffer and syncs scroll between panes. Returns Some(true) if handled, None to fall through to normal buffer handling.

Source§

impl Editor

Source

pub fn open_event_debug(&mut self)

Open the event debug dialog

Source

pub fn handle_event_debug_input(&mut self, event: &KeyEvent) -> InputResult

Handle input when event debug dialog is active

Source

pub fn is_event_debug_active(&self) -> bool

Check if event debug dialog is active

Source§

impl Editor

Source

pub fn file_explorer_visible(&self) -> bool

Source

pub fn file_explorer(&self) -> Option<&FileTreeView>

Source

pub fn toggle_file_explorer(&mut self)

Source

pub fn show_file_explorer(&mut self)

Source

pub fn sync_file_explorer_to_active_file(&mut self)

Source

pub fn focus_file_explorer(&mut self)

Source

pub fn focus_editor(&mut self)

Source

pub fn file_explorer_navigate_up(&mut self)

Source

pub fn file_explorer_navigate_down(&mut self)

Source

pub fn file_explorer_page_up(&mut self)

Source

pub fn file_explorer_page_down(&mut self)

Source

pub fn file_explorer_collapse(&mut self)

Collapse behavior for left arrow:

  • If on expanded directory: collapse it
  • If on file or collapsed directory: select parent directory
Source

pub fn file_explorer_toggle_expand(&mut self)

Source

pub fn file_explorer_open_file(&mut self) -> AnyhowResult<()>

Source

pub fn file_explorer_refresh(&mut self)

Source

pub fn file_explorer_new_file(&mut self)

Source

pub fn file_explorer_new_directory(&mut self)

Source

pub fn file_explorer_delete(&mut self)

Source

pub fn perform_file_explorer_delete(&mut self, path: PathBuf, _is_dir: bool)

Perform the actual file explorer delete operation (called after prompt confirmation) For local files: moves to system trash/recycle bin For remote files: moves to ~/.local/share/fresh/trash/ on remote

Source

pub fn file_explorer_rename(&mut self)

Source

pub fn perform_file_explorer_rename( &mut self, original_path: PathBuf, original_name: String, new_name: String, is_new_file: bool, )

Perform the actual file explorer rename operation (called after prompt confirmation)

Source

pub fn file_explorer_toggle_hidden(&mut self)

Source

pub fn file_explorer_toggle_gitignored(&mut self)

Source

pub fn file_explorer_search_clear(&mut self)

Clear the file explorer search

Source

pub fn file_explorer_search_push_char(&mut self, c: char)

Add a character to the file explorer search

Source

pub fn file_explorer_search_pop_char(&mut self)

Remove a character from the file explorer search (backspace)

Source

pub fn handle_set_file_explorer_decorations( &mut self, namespace: String, decorations: Vec<FileExplorerDecoration>, )

Source

pub fn handle_clear_file_explorer_decorations(&mut self, namespace: &str)

Source§

impl Editor

Source

pub fn is_file_open_active(&self) -> bool

Check if the file open dialog is active (for OpenFile, SwitchProject, or SaveFileAs)

Source

pub fn handle_file_open_action(&mut self, action: &Action) -> bool

Handle action for file open dialog Returns true if the action was handled, false if it should be passed to normal prompt handling

Source

pub fn start_large_file_encoding_confirmation( &mut self, confirmation: &LargeFileEncodingConfirmation, )

Start the large file encoding confirmation prompt.

This is called when opening a file that has a non-resynchronizable encoding (like GBK, GB18030, Shift-JIS) and the file is large enough to require user confirmation before loading the entire file into memory.

Source

pub fn start_open_file_with_encoding_prompt(&mut self, path: PathBuf)

Start the encoding selection prompt for opening a file

Source

pub fn update_file_open_filter(&mut self)

Update filter when prompt text changes

Source

pub fn file_open_toggle_sort(&mut self, mode: SortMode)

Handle sorting toggle (called from keybinding)

Source

pub fn file_open_toggle_hidden(&mut self)

Handle hidden files toggle

Source

pub fn file_open_toggle_detect_encoding(&mut self)

Handle encoding detection toggle

Source

pub fn handle_file_open_scroll(&mut self, delta: i32) -> bool

Handle mouse wheel scroll in file browser Returns true if the scroll was handled

Source

pub fn handle_file_open_click(&mut self, x: u16, y: u16) -> bool

Handle mouse click in file browser

Source

pub fn handle_file_open_double_click(&mut self, x: u16, y: u16) -> bool

Handle double-click in file browser

Source

pub fn compute_file_browser_hover(&self, x: u16, y: u16) -> Option<HoverTarget>

Compute hover target for file browser

Source§

impl Editor

Source

pub fn save(&mut self) -> Result<()>

Save the active buffer

Source

pub fn auto_save_persistent_buffers(&mut self) -> Result<usize>

Auto-save all modified buffers to their original files on disk Returns the number of buffers saved

Source

pub fn save_all_on_exit(&mut self) -> Result<usize>

Save all modified file-backed buffers to disk (called on exit when auto_save is enabled). Unlike auto_save_persistent_buffers, this skips the interval check and only saves named file-backed buffers (not unnamed buffers).

Source

pub fn revert_file(&mut self) -> Result<bool>

Revert the active buffer to the last saved version on disk Returns Ok(true) if reverted, Ok(false) if no file path, Err on failure

Source

pub fn toggle_auto_revert(&mut self)

Toggle auto-revert mode

Source

pub fn poll_file_changes(&mut self) -> bool

Poll for file changes (called from main loop)

Checks modification times of open files to detect external changes. Returns true if any file was changed (requires re-render).

Source

pub fn poll_file_tree_changes(&mut self) -> bool

Poll for file tree changes (called from main loop)

Checks modification times of expanded directories to detect new/deleted files. Returns true if any directory was refreshed (requires re-render).

Source

pub fn handle_file_changed(&mut self, changed_path: &str)

Handle a file change notification (from file watcher)

Source

pub fn check_save_conflict(&self) -> Option<SystemTime>

Check if saving would overwrite changes made by another process Returns Some(current_mtime) if there’s a conflict, None otherwise

Source§

impl Editor

Source

pub fn get_key_context(&self) -> KeyContext

Determine the current keybinding context based on UI state

Source

pub fn handle_key( &mut self, code: KeyCode, modifiers: KeyModifiers, ) -> AnyhowResult<()>

Handle a key event and return whether it was handled This is the central key handling logic used by both main.rs and tests

Source§

impl Editor

Source

pub fn dispatch_terminal_input( &mut self, event: &KeyEvent, ) -> Option<InputResult>

Dispatch input when in terminal mode.

Returns Some(InputResult) if terminal mode handled the input, None if not in terminal mode or if a modal is active.

Source

pub fn dispatch_modal_input(&mut self, event: &KeyEvent) -> Option<InputResult>

Dispatch input to the appropriate modal handler.

Returns Some(InputResult) if a modal handled the input, None if no modal is active and input should be handled normally.

Source

pub fn process_deferred_actions(&mut self, ctx: InputContext)

Process deferred actions collected during input handling.

Source§

impl Editor

Source

pub fn open_keybinding_editor(&mut self)

Open the keybinding editor modal

Source

pub fn handle_keybinding_editor_input( &mut self, event: &KeyEvent, ) -> InputResult

Handle input when keybinding editor is active

Source

pub fn is_keybinding_editor_active(&self) -> bool

Check if keybinding editor is active

Source

pub fn handle_keybinding_editor_mouse( &mut self, mouse_event: MouseEvent, ) -> Result<bool>

Handle mouse events when keybinding editor is active Returns Ok(true) if a re-render is needed

Source§

impl Editor

Source

pub fn handle_lsp_restart(&mut self)

Handle the LspRestart action.

For a single-server config, restarts immediately (no prompt). For multiple servers, shows a prompt to select which server(s) to restart.

Source

pub fn handle_lsp_stop(&mut self)

Handle the LspStop action.

Shows a prompt to select which LSP server to stop, with suggestions for all currently running servers.

Source

pub fn handle_lsp_toggle_for_buffer(&mut self)

Handle the LspToggleForBuffer action.

Toggles LSP on/off for the current buffer only. Requires an LSP server to be configured for the current buffer’s language.

Source

pub fn toggle_fold_at_cursor(&mut self)

Toggle folding at the current cursor position.

Source

pub fn toggle_fold_at_line(&mut self, buffer_id: BufferId, line: usize)

Toggle folding for the given line in the specified buffer.

Kept for callers that only have a line number (e.g. gutter clicks that already resolved the line). Converts to a byte position and delegates to Self::toggle_fold_at_byte.

Source

pub fn toggle_fold_at_byte(&mut self, buffer_id: BufferId, byte_pos: usize)

Toggle folding at the given byte position in the specified buffer.

Source§

impl Editor

Source

pub fn has_pending_lsp_requests(&self) -> bool

Check if there are any pending LSP requests

Source

pub fn handle_rename_response( &mut self, _request_id: u64, result: Result<WorkspaceEdit, String>, ) -> AnyhowResult<()>

Handle rename response from LSP

Source§

impl Editor

Source

pub fn handle_menu_activate(&mut self)

Handle MenuActivate action - opens the first menu. If the menu bar is hidden, it will be temporarily shown.

Source

pub fn close_menu_with_auto_hide(&mut self)

Close the menu and auto-hide the menu bar if it was temporarily shown. Use this method instead of menu_state.close_menu() to ensure auto-hide works.

Source

pub fn handle_menu_close(&mut self)

Handle MenuClose action - closes the active menu. If the menu bar was auto-shown, it will be hidden again.

Source

pub fn handle_menu_left(&mut self)

Handle MenuLeft action - close submenu or go to previous menu.

Source

pub fn handle_menu_right(&mut self)

Handle MenuRight action - open submenu or go to next menu.

Source

pub fn handle_menu_up(&mut self)

Handle MenuUp action - select previous item in menu.

Source

pub fn handle_menu_down(&mut self)

Handle MenuDown action - select next item in menu.

Source

pub fn handle_menu_execute(&mut self) -> Option<Action>

Handle MenuExecute action - execute highlighted item or open submenu.

Returns Some(action) if an action should be executed after this call.

Source

pub fn handle_menu_open(&mut self, menu_name: &str)

Handle MenuOpen action - open a specific menu by name. If the menu bar is hidden, it will be temporarily shown.

Source§

impl Editor

Source

pub fn menu_context(&self) -> MenuContext

Return a clone of the current menu context (boolean state flags).

This is used by the GUI layer to sync native menu item states (enabled/disabled, checkmarks) without knowing about the editor’s internal state.

Source

pub fn expanded_menu_definitions(&self) -> Vec<Menu>

Return the fully-expanded menu definitions (with DynamicSubmenu items resolved to Submenu). Used by the GUI layer to build platform-native menus.

Source

pub fn update_menu_context(&mut self)

Update all menu context values based on current editor state. This should be called before rendering the menu bar.

Source§

impl Editor

Source

pub fn handle_mouse(&mut self, mouse_event: MouseEvent) -> AnyhowResult<bool>

Handle a mouse event. Returns true if a re-render is needed.

Source§

impl Editor

Source

pub fn run_on_save_actions(&mut self) -> Result<bool, String>

Run on-save actions for the active buffer after a successful save. This includes format-on-save (if enabled) and any on_save actions. Returns Ok(true) if actions ran successfully, Ok(false) if no actions, or Err with an error message.

Source

pub fn format_buffer(&mut self) -> Result<(), String>

Format the current buffer using the configured formatter. Returns Ok(()) if formatting succeeded, or Err with an error message.

Source

pub fn trim_trailing_whitespace(&mut self) -> Result<bool, String>

Trim trailing whitespace from all lines in the active buffer. Returns Ok(true) if any changes were made, Ok(false) if buffer unchanged.

Source

pub fn ensure_final_newline(&mut self) -> Result<bool, String>

Ensure the buffer ends with a newline. Returns Ok(true) if a newline was added, Ok(false) if already ends with newline.

Source§

impl Editor

Source

pub fn handle_popup_confirm(&mut self) -> PopupConfirmResult

Handle PopupConfirm action.

Returns PopupConfirmResult indicating what the caller should do next.

Source

pub fn handle_popup_cancel(&mut self)

Handle PopupCancel action.

Source

pub fn handle_popup_type_char(&mut self, c: char)

Handle typing a character while completion popup is open. Inserts the character into the buffer and re-filters the completion list.

Source

pub fn handle_popup_backspace(&mut self)

Handle backspace while completion popup is open. Deletes a character and re-filters the completion list.

Source§

impl Editor

Source

pub fn handle_prompt_confirm_input( &mut self, input: String, prompt_type: PromptType, selected_index: Option<usize>, ) -> PromptResult

Handle prompt confirmation based on the prompt type.

Returns a PromptResult indicating what the caller should do next.

Source

pub fn handle_stop_lsp_server(&mut self, input: &str)

Handle StopLspServer prompt confirmation.

Input format: "language" (stops all servers) or "language/server_name" (stops a specific server).

Source

pub fn handle_restart_lsp_server(&mut self, input: &str)

Handle RestartLspServer prompt confirmation.

Input format: "language" (restarts all enabled servers) or "language/server_name" (restarts a specific server).

Source§

impl Editor

Source

pub fn start_recovery_session(&mut self) -> AnyhowResult<()>

Start the recovery session (call on editor startup after recovery check)

Source

pub fn end_recovery_session(&mut self) -> AnyhowResult<()>

End the recovery session cleanly (call on normal shutdown)

Source

pub fn has_recovery_files(&self) -> AnyhowResult<bool>

Check if there are files to recover from a crash

Source

pub fn list_recoverable_files(&self) -> AnyhowResult<Vec<RecoveryEntry>>

Get list of recoverable files

Source

pub fn recover_all_buffers(&mut self) -> AnyhowResult<usize>

Recover all buffers from recovery files Returns the number of buffers recovered

Source

pub fn discard_all_recovery(&mut self) -> AnyhowResult<usize>

Discard all recovery files (user decided not to recover) Returns the number of recovery files deleted

Source

pub fn auto_recovery_save_dirty_buffers(&mut self) -> AnyhowResult<usize>

Perform auto-recovery-save for all modified buffers if needed. Called frequently (every frame); rate-limited by auto_recovery_save_interval_secs.

Source

pub fn is_active_buffer_recovery_dirty(&self) -> bool

Check if the active buffer is marked dirty for auto-recovery-save Used for testing to verify that edits properly trigger recovery tracking

Source

pub fn delete_buffer_recovery( &mut self, buffer_id: BufferId, ) -> AnyhowResult<()>

Delete recovery for a buffer (call after saving or closing)

Source§

impl Editor

Source

pub fn render(&mut self, frame: &mut Frame<'_>)

Render the editor to the terminal

Source

pub fn add_overlay( &mut self, namespace: Option<OverlayNamespace>, range: Range<usize>, face: OverlayFace, priority: i32, message: Option<String>, ) -> OverlayHandle

Add an overlay for decorations (underlines, highlights, etc.)

Source

pub fn remove_overlay(&mut self, handle: OverlayHandle)

Remove an overlay by handle

Source

pub fn remove_overlays_in_range(&mut self, range: Range<usize>)

Remove all overlays in a range

Source

pub fn clear_overlays(&mut self)

Clear all overlays

Source

pub fn show_popup(&mut self, popup: PopupData)

Show a popup window

Source

pub fn hide_popup(&mut self)

Hide the topmost popup

Source

pub fn clear_popups(&mut self)

Clear all popups

Source

pub fn show_lsp_confirmation_popup(&mut self, language: &str)

Show the LSP confirmation popup for a language server

This displays a centered popup asking the user to confirm whether they want to start the LSP server for the given language.

Source

pub fn handle_lsp_confirmation_response(&mut self, action: &str) -> bool

Handle the LSP confirmation popup response

This is called when the user confirms their selection in the LSP confirmation popup. It processes the response and starts the LSP server if approved.

Returns true if a response was handled, false if there was no pending confirmation.

Source

pub fn has_pending_lsp_confirmation(&self) -> bool

Check if there’s a pending LSP confirmation

Source

pub fn popup_select_next(&mut self)

Navigate popup selection (next item)

Source

pub fn popup_select_prev(&mut self)

Navigate popup selection (previous item)

Source

pub fn popup_page_down(&mut self)

Navigate popup (page down)

Source

pub fn popup_page_up(&mut self)

Navigate popup (page up)

Source

pub fn action_to_events(&mut self, action: Action) -> Option<Vec<Event>>

Convert an action into a list of events to apply to the active buffer Returns None for actions that don’t generate events (like Quit)

Source

pub fn recompute_layout(&mut self, width: u16, height: u16)

Recompute the view_line_mappings layout without drawing. Used during macro replay so that visual-line movements (MoveLineEnd, MoveUp, MoveDown on wrapped lines) see correct, up-to-date layout information between each replayed action.

Source

pub fn clear_search_history(&mut self)

Clear the search history Used primarily for testing to ensure test isolation

Source

pub fn save_histories(&self)

Save all prompt histories to disk Called on shutdown to persist history across sessions

Source§

impl Editor

Source

pub fn open_settings(&mut self)

Open the settings modal

Source

pub fn close_settings(&mut self, save: bool)

Close the settings modal

If save is true and there are changes, they will be applied first.

Source

pub fn save_settings(&mut self)

Save the settings from the modal to config

Source

pub fn open_config_file(&mut self, layer: ConfigLayer) -> AnyhowResult<()>

Open the config file for the specified layer in the editor. Creates the file with default template if it doesn’t exist. If there are pending changes in the Settings UI, warns the user and doesn’t proceed.

Source

pub fn settings_navigate_up(&mut self)

Navigate settings up

Source

pub fn settings_navigate_down(&mut self)

Navigate settings down

Source

pub fn settings_activate_current(&mut self)

Activate/toggle the currently selected setting

Source

pub fn settings_increment_current(&mut self)

Increment the current setting value (for Number and Dropdown controls)

Source

pub fn settings_decrement_current(&mut self)

Decrement the current setting value (for Number and Dropdown controls)

Source§

impl Editor

Source

pub fn start_shell_command_prompt(&mut self, replace: bool)

Start a shell command prompt. If replace is true, the output will replace the buffer/selection. If replace is false, the output goes to a new buffer.

Source

pub fn execute_shell_command(&mut self, command: &str) -> Result<String, String>

Execute a shell command with the current buffer/selection as stdin. Returns Ok(output) on success, Err(error_message) on failure.

Source

pub fn handle_shell_command(&mut self, command: &str, replace: bool)

Handle shell command execution after prompt confirmation. If replace is true, replaces the selection/buffer with output. If replace is false, creates a new buffer with the output.

Source§

impl Editor

Source

pub fn split_pane_horizontal(&mut self)

Split the current pane horizontally

Source

pub fn split_pane_vertical(&mut self)

Split the current pane vertically

Source

pub fn close_active_split(&mut self)

Close the active split

Source

pub fn next_split(&mut self)

Switch to next split

Source

pub fn prev_split(&mut self)

Switch to previous split

Source

pub fn adjust_split_size(&mut self, delta: f32)

Adjust the size of the active split

Source

pub fn toggle_maximize_split(&mut self)

Toggle maximize state for the active split

Source

pub fn get_separator_areas( &self, ) -> &[(ContainerId, SplitDirection, u16, u16, u16)]

Get cached separator areas for testing Returns (split_id, direction, x, y, length) tuples

Source

pub fn get_tab_layouts(&self) -> &HashMap<LeafId, TabLayout>

Get cached tab layouts for testing

Source

pub fn get_split_areas(&self) -> &[(LeafId, BufferId, Rect, Rect, usize, usize)]

Get cached split content areas for testing Returns (split_id, buffer_id, content_rect, scrollbar_rect, thumb_start, thumb_end) tuples

Source

pub fn get_split_ratio(&self, split_id: SplitId) -> Option<f32>

Get the ratio of a specific split (for testing)

Source

pub fn get_active_split(&self) -> LeafId

Get the active split ID (for testing)

Source

pub fn get_split_buffer(&self, split_id: SplitId) -> Option<BufferId>

Get the buffer ID for a split (for testing)

Source

pub fn get_split_tabs(&self, split_id: LeafId) -> Vec<BufferId>

Get the open buffers (tabs) in a split (for testing)

Source

pub fn get_split_count(&self) -> usize

Get the number of splits (for testing)

Source

pub fn compute_drop_zone( &self, col: u16, row: u16, source_split_id: LeafId, ) -> Option<TabDropZone>

Compute the drop zone for a tab drag at a given position (for testing)

Source§

impl Editor

Source

pub fn open_terminal(&mut self)

Open a new terminal in the current split

Source

pub fn close_terminal(&mut self)

Close the current terminal (if viewing a terminal buffer)

Source

pub fn is_terminal_buffer(&self, buffer_id: BufferId) -> bool

Check if a buffer is a terminal buffer

Source

pub fn get_terminal_id(&self, buffer_id: BufferId) -> Option<TerminalId>

Get the terminal ID for a buffer (if it’s a terminal buffer)

Source

pub fn get_active_terminal_state(&self) -> Option<MutexGuard<'_, TerminalState>>

Get the terminal state for the active buffer (if it’s a terminal buffer)

Source

pub fn send_terminal_input(&mut self, data: &[u8])

Send input to the active terminal

Source

pub fn send_terminal_key(&mut self, code: KeyCode, modifiers: KeyModifiers)

Send a key event to the active terminal

Source

pub fn send_terminal_mouse( &mut self, col: u16, row: u16, kind: TerminalMouseEventKind, modifiers: KeyModifiers, )

Send a mouse event to the active terminal

Source

pub fn is_terminal_in_alternate_screen(&self, buffer_id: BufferId) -> bool

Check if the active terminal buffer is in alternate screen mode. Programs like vim, less, htop use alternate screen mode.

Source

pub fn resize_terminal(&mut self, buffer_id: BufferId, cols: u16, rows: u16)

Resize terminal to match split dimensions

Source

pub fn resize_visible_terminals(&mut self)

Resize all visible terminal PTYs to match their current split dimensions. Call this after operations that change split layout (maximize, resize, etc.)

Source

pub fn handle_terminal_key( &mut self, code: KeyCode, modifiers: KeyModifiers, ) -> bool

Handle terminal input when in terminal mode

Source

pub fn sync_terminal_to_buffer(&mut self, buffer_id: BufferId)

Sync terminal content to the text buffer for read-only viewing/selection

This uses the incremental streaming architecture:

  1. Scrollback has already been streamed to the backing file during PTY reads
  2. We just append the visible screen (~50 lines) to the backing file
  3. Reload the buffer from the backing file (lazy load for large files)

Performance: O(screen_size) instead of O(total_history)

Source

pub fn enter_terminal_mode(&mut self)

Re-enter terminal mode from read-only buffer view

This truncates the backing file to remove the visible screen tail that was appended when we exited terminal mode, leaving only the incrementally-streamed scrollback history.

Source

pub fn get_terminal_content( &self, buffer_id: BufferId, ) -> Option<Vec<Vec<TerminalCell>>>

Get terminal content for rendering

Source§

impl Editor

Source

pub fn is_terminal_mode(&self) -> bool

Check if terminal mode is active (for testing)

Source

pub fn is_in_terminal_mode_resume(&self, buffer_id: BufferId) -> bool

Check if a buffer is in terminal_mode_resume set (for testing/debugging)

Source

pub fn is_keyboard_capture(&self) -> bool

Check if keyboard capture is enabled in terminal mode (for testing)

Source

pub fn set_terminal_jump_to_end_on_output(&mut self, value: bool)

Set terminal jump_to_end_on_output config option (for testing)

Source

pub fn terminal_manager(&self) -> &TerminalManager

Get read-only access to the terminal manager (for testing)

Source

pub fn terminal_backing_files(&self) -> &HashMap<TerminalId, PathBuf>

Get read-only access to terminal backing files map (for testing)

Source

pub fn active_buffer_id(&self) -> BufferId

Get the currently active buffer ID

Source

pub fn get_buffer_content(&self, buffer_id: BufferId) -> Option<String>

Get buffer content as a string (for testing)

Source

pub fn get_cursor_position(&self, buffer_id: BufferId) -> Option<usize>

Get cursor position for a buffer (for testing)

Source

pub fn render_terminal_splits( &self, frame: &mut Frame<'_>, split_areas: &[(LeafId, BufferId, Rect, Rect, usize, usize)], )

Render terminal content for all terminal buffers in split areas

Renders all visible terminal buffers from their live terminal state. This ensures terminals continue updating even when not focused, as long as they remain visible in a split.

Source§

impl Editor

Source

pub fn toggle_scroll_sync(&mut self)

Toggle line numbers in the gutter for the active split.

Line number visibility is stored per-split in BufferViewState so that different splits of the same buffer can independently show/hide line numbers (e.g., source mode shows them, compose mode hides them). Toggle scroll sync for same-buffer splits.

Source

pub fn toggle_line_numbers(&mut self)

Source

pub fn toggle_debug_highlights(&mut self)

Toggle debug highlight mode for the active buffer When enabled, shows byte positions and highlight span info for debugging

Source

pub fn toggle_menu_bar(&mut self)

Toggle menu bar visibility

Source

pub fn toggle_tab_bar(&mut self)

Toggle tab bar visibility

Source

pub fn tab_bar_visible(&self) -> bool

Get tab bar visibility

Source

pub fn toggle_status_bar(&mut self)

Toggle status bar visibility

Source

pub fn status_bar_visible(&self) -> bool

Get status bar visibility

Source

pub fn toggle_prompt_line(&mut self)

Toggle prompt line visibility

Source

pub fn prompt_line_visible(&self) -> bool

Get prompt line visibility

Source

pub fn toggle_vertical_scrollbar(&mut self)

Toggle vertical scrollbar visibility

Source

pub fn toggle_horizontal_scrollbar(&mut self)

Toggle horizontal scrollbar visibility

Source

pub fn reset_buffer_settings(&mut self)

Reset buffer settings (tab_size, use_tabs, auto_close, whitespace visibility) to config defaults

Source

pub fn toggle_mouse_capture(&mut self)

Toggle mouse capture on/off

Source

pub fn is_mouse_enabled(&self) -> bool

Check if mouse capture is enabled

Source

pub fn toggle_mouse_hover(&mut self)

Toggle mouse hover for LSP on/off

On Windows, this also switches the mouse tracking mode: mode 1003 (all motion) when enabled, mode 1002 (cell motion) when disabled.

Source

pub fn is_mouse_hover_enabled(&self) -> bool

Check if mouse hover is enabled

Source

pub fn set_gpm_active(&mut self, active: bool)

Set GPM active flag (enables software mouse cursor rendering)

When GPM is used for mouse input on Linux consoles, we need to draw our own mouse cursor because GPM can’t draw on the alternate screen buffer used by TUI applications.

Source

pub fn toggle_inlay_hints(&mut self)

Toggle inlay hints visibility

Source

pub fn dump_config(&mut self)

Dump the current configuration to the user’s config file

Source

pub fn save_config(&self) -> Result<(), String>

Save the current configuration to file (without opening it)

Returns Ok(()) on success, or an error message on failure

Source

pub fn reload_config(&mut self)

Reload configuration from the config file

This reloads the config from disk, applies runtime changes (theme, keybindings), and emits a config_changed event so plugins can update their state accordingly. Uses the layered config system to properly merge with defaults.

Source

pub fn reload_themes(&mut self)

Reload the theme registry from disk.

Call this after installing new theme packages or saving new themes. This rescans all theme directories and updates the available themes list.

Source§

impl Editor

Source

pub fn handle_undo(&mut self)

Handle Undo action - revert the last edit operation.

Source

pub fn handle_redo(&mut self)

Handle Redo action - reapply an undone edit operation.

Source§

impl Editor

Source

pub fn handle_toggle_page_view(&mut self)

Toggle between Compose and Source view modes.

Source§

impl Editor

Source

pub fn capture_workspace(&self) -> Workspace

Capture current editor state into a Workspace

Source

pub fn save_workspace(&mut self) -> Result<(), WorkspaceError>

Save the current workspace to disk

Ensures all active terminals have their visible screen synced to backing files before capturing the workspace. Also saves global file states (scroll/cursor positions per file).

Source

pub fn try_restore_workspace(&mut self) -> Result<bool, WorkspaceError>

Try to load and apply a workspace for the current working directory

Returns true if a workspace was successfully loaded and applied.

Source

pub fn apply_hot_exit_recovery(&mut self) -> Result<usize>

Apply hot exit recovery to all currently open file-backed buffers.

This restores unsaved changes from recovery files for buffers that were opened via CLI (without workspace restore). Returns the number of buffers recovered.

Source

pub fn apply_workspace( &mut self, workspace: &Workspace, ) -> Result<(), WorkspaceError>

Apply a loaded workspace to the editor

Source§

impl Editor

Source

pub fn new( config: Config, width: u16, height: u16, dir_context: DirectoryContext, color_capability: ColorCapability, filesystem: Arc<dyn FileSystem + Send + Sync>, ) -> AnyhowResult<Self>

Create a new editor with the given configuration and terminal dimensions Uses system directories for state (recovery, sessions, etc.)

Source

pub fn with_working_dir( config: Config, width: u16, height: u16, working_dir: Option<PathBuf>, dir_context: DirectoryContext, plugins_enabled: bool, color_capability: ColorCapability, filesystem: Arc<dyn FileSystem + Send + Sync>, ) -> AnyhowResult<Self>

Create a new editor with an explicit working directory This is useful for testing with isolated temporary directories

Source

pub fn for_test( config: Config, width: u16, height: u16, working_dir: Option<PathBuf>, dir_context: DirectoryContext, color_capability: ColorCapability, filesystem: Arc<dyn FileSystem + Send + Sync>, time_source: Option<SharedTimeSource>, grammar_registry: Option<Arc<GrammarRegistry>>, ) -> AnyhowResult<Self>

Create a new editor for testing with custom backends

By default uses empty grammar registry for fast initialization. Pass Some(registry) for tests that need syntax highlighting or shebang detection.

Source

pub fn event_broadcaster(&self) -> &EventBroadcaster

Get a reference to the event broadcaster

Source

pub fn async_bridge(&self) -> Option<&AsyncBridge>

Get a reference to the async bridge (if available)

Source

pub fn config(&self) -> &Config

Get a reference to the config

Source

pub fn key_translator(&self) -> &KeyTranslator

Get a reference to the key translator (for input calibration)

Source

pub fn time_source(&self) -> &SharedTimeSource

Get a reference to the time source

Source

pub fn emit_event(&self, name: impl Into<String>, data: Value)

Emit a control event

Source

pub fn get_all_keybindings(&self) -> Vec<(String, String)>

Get all keybindings as (key, action) pairs

Source

pub fn get_keybinding_for_action(&self, action_name: &str) -> Option<String>

Get the formatted keybinding for a specific action (for display in messages) Returns None if no keybinding is found for the action

Source

pub fn mode_registry_mut(&mut self) -> &mut ModeRegistry

Get mutable access to the mode registry

Source

pub fn mode_registry(&self) -> &ModeRegistry

Get immutable access to the mode registry

Source

pub fn active_buffer(&self) -> BufferId

Get the currently active buffer ID.

This is derived from the split manager (single source of truth). The editor always has at least one buffer, so this never fails.

Source

pub fn active_buffer_mode(&self) -> Option<&str>

Get the mode name for the active buffer (if it’s a virtual buffer)

Source

pub fn is_active_buffer_read_only(&self) -> bool

Check if the active buffer is read-only

Source

pub fn is_editing_disabled(&self) -> bool

Check if editing should be disabled for the active buffer This returns true when editing_disabled is true (e.g., for read-only virtual buffers)

Source

pub fn mark_buffer_read_only(&mut self, buffer_id: BufferId, read_only: bool)

Mark a buffer as read-only, setting both metadata and editor state consistently. This is the single entry point for making a buffer read-only.

Source

pub fn effective_mode(&self) -> Option<&str>

Get the effective mode for the active buffer.

Buffer-local mode (virtual buffers) takes precedence over the global editor mode, so that e.g. a search-replace panel isn’t hijacked by a markdown-source or vi-mode global mode.

Source

pub fn has_active_lsp_progress(&self) -> bool

Check if LSP has any active progress tasks (e.g., indexing)

Source

pub fn get_lsp_progress(&self) -> Vec<(String, String, Option<String>)>

Get the current LSP progress info (if any)

Source

pub fn is_lsp_server_ready(&self, language: &str) -> bool

Check if any LSP server for a given language is running (ready)

Source

pub fn get_lsp_status(&self) -> &str

Get the LSP status string (displayed in status bar)

Source

pub fn get_stored_diagnostics(&self) -> &HashMap<String, Vec<Diagnostic>>

Get stored LSP diagnostics (for testing and external access) Returns a reference to the diagnostics map keyed by file URI

Source

pub fn is_update_available(&self) -> bool

Check if an update is available

Source

pub fn latest_version(&self) -> Option<&str>

Get the latest version string if an update is available

Source

pub fn get_update_result(&self) -> Option<&ReleaseCheckResult>

Get the cached release check result (for shutdown notification)

Source

pub fn set_lsp_config(&mut self, language: String, config: Vec<LspServerConfig>)

Configure LSP server for a specific language

Source

pub fn running_lsp_servers(&self) -> Vec<String>

Get a list of currently running LSP server languages

Source

pub fn pending_completion_requests_count(&self) -> usize

Return the number of pending completion requests.

Source

pub fn completion_items_count(&self) -> usize

Return the number of stored completion items.

Source

pub fn initialized_lsp_server_count(&self, language: &str) -> usize

Return the number of initialized LSP servers for a given language.

Source

pub fn shutdown_lsp_server(&mut self, language: &str) -> bool

Shutdown an LSP server by language (marks it as disabled until manual restart)

Returns true if the server was found and shutdown, false otherwise

Source

pub fn enable_event_streaming<P: AsRef<Path>>( &mut self, path: P, ) -> AnyhowResult<()>

Enable event log streaming to a file

Source

pub fn log_keystroke(&mut self, key_code: &str, modifiers: &str)

Log keystroke for debugging

Source

pub fn set_warning_log(&mut self, receiver: Receiver<()>, path: PathBuf)

Set up warning log monitoring

When warnings/errors are logged, they will be written to the specified path and the editor will be notified via the receiver.

Source

pub fn set_status_log_path(&mut self, path: PathBuf)

Set the status message log path

Source

pub fn set_process_spawner(&mut self, spawner: Arc<dyn ProcessSpawner>)

Set the process spawner for plugin command execution Use RemoteProcessSpawner for remote editing, LocalProcessSpawner for local

Source

pub fn remote_connection_info(&self) -> Option<&str>

Get remote connection info if editing remote files

Returns Some("user@host") for remote editing, None for local.

Source

pub fn get_status_log_path(&self) -> Option<&PathBuf>

Get the status log path

Source

pub fn open_status_log(&mut self)

Open the status log file (user clicked on status message)

Source

pub fn check_warning_log(&mut self) -> bool

Check for and handle any new warnings in the warning log

Updates the general warning domain for the status bar. Returns true if new warnings were found.

Source

pub fn get_warning_domains(&self) -> &WarningDomainRegistry

Get the warning domain registry

Source

pub fn get_warning_log_path(&self) -> Option<&PathBuf>

Get the warning log path (for opening when user clicks indicator)

Source

pub fn open_warning_log(&mut self)

Open the warning log file (user-initiated action)

Source

pub fn clear_warning_indicator(&mut self)

Clear the general warning indicator (user dismissed)

Source

pub fn clear_warnings(&mut self)

Clear all warning indicators (user dismissed via command)

Source

pub fn has_lsp_error(&self) -> bool

Check if any LSP server is in error state

Source

pub fn get_effective_warning_level(&self) -> WarningLevel

Get the effective warning level for the status bar (LSP indicator) Returns Error if LSP has errors, Warning if there are warnings, None otherwise

Source

pub fn get_general_warning_level(&self) -> WarningLevel

Get the general warning level (for the general warning badge)

Source

pub fn get_general_warning_count(&self) -> usize

Get the general warning count

Source

pub fn update_lsp_warning_domain(&mut self)

Update LSP warning domain from server statuses

Source

pub fn check_mouse_hover_timer(&mut self) -> bool

Check if mouse hover timer has expired and trigger LSP hover request

This implements debounced hover - we wait for the configured delay before sending the request to avoid spamming the LSP server on every mouse move. Returns true if a hover request was triggered.

Source

pub fn check_semantic_highlight_timer(&self) -> bool

Check if semantic highlight debounce timer has expired

Returns true if a redraw is needed because the debounce period has elapsed and semantic highlights need to be recomputed.

Source

pub fn check_diagnostic_pull_timer(&mut self) -> bool

Check if diagnostic pull timer has expired and trigger re-pull if so.

Debounced diagnostic re-pull after document changes — waits 500ms after the last edit before requesting fresh diagnostics from the LSP server.

Source

pub fn check_completion_trigger_timer(&mut self) -> bool

Check if completion trigger timer has expired and trigger completion if so

This implements debounced completion - we wait for quick_suggestions_delay_ms before sending the completion request to avoid spamming the LSP server. Returns true if a completion request was triggered.

Source

pub fn active_state(&self) -> &EditorState

Get the currently active buffer state

Source

pub fn active_state_mut(&mut self) -> &mut EditorState

Get the currently active buffer state (mutable)

Source

pub fn active_cursors(&self) -> &Cursors

Get the cursors for the active buffer in the active split

Source

pub fn active_cursors_mut(&mut self) -> &mut Cursors

Get the cursors for the active buffer in the active split (mutable)

Source

pub fn set_completion_items(&mut self, items: Vec<CompletionItem>)

Set completion items for type-to-filter (for testing)

Source

pub fn active_viewport(&self) -> &Viewport

Get the viewport for the active split

Source

pub fn active_viewport_mut(&mut self) -> &mut Viewport

Get the viewport for the active split (mutable)

Source

pub fn get_buffer_display_name(&self, buffer_id: BufferId) -> String

Get the display name for a buffer (filename or virtual buffer name)

Source

pub fn log_and_apply_event(&mut self, event: &Event)

Apply an event to the active buffer with all cross-cutting concerns. This is the centralized method that automatically handles:

  • Event application to buffer
  • Plugin hooks (after-insert, after-delete, etc.)
  • LSP notifications
  • Any other cross-cutting concerns

All event applications MUST go through this method to ensure consistency. Log an event and apply it to the active buffer. For Delete events, captures displaced marker positions before applying so undo can restore them to their exact original positions.

Source

pub fn apply_event_to_active_buffer(&mut self, event: &Event)

Source

pub fn apply_events_as_bulk_edit( &mut self, events: Vec<Event>, description: String, ) -> Option<Event>

Apply multiple Insert/Delete events efficiently using bulk edit optimization.

This avoids O(n²) complexity by:

  1. Converting events to (position, delete_len, insert_text) tuples
  2. Applying all edits in a single tree pass via apply_bulk_edits
  3. Creating a BulkEdit event for undo (stores tree snapshot via Arc clone = O(1))
§Arguments
  • events - Vec of Insert/Delete events (sorted by position descending for correct application)
  • description - Description for the undo log
§Returns

The BulkEdit event that was applied, for tracking purposes

Source

pub fn active_event_log(&self) -> &EventLog

Get the event log for the active buffer

Source

pub fn active_event_log_mut(&mut self) -> &mut EventLog

Get the event log for the active buffer (mutable)

Source

pub fn should_quit(&self) -> bool

Check if the editor should quit

Source

pub fn should_detach(&self) -> bool

Check if the client should detach (keep server running)

Source

pub fn clear_detach(&mut self)

Clear the detach flag (after processing)

Source

pub fn set_session_mode(&mut self, session_mode: bool)

Set session mode (use hardware cursor only, no REVERSED style for software cursor)

Source

pub fn is_session_mode(&self) -> bool

Check if running in session mode

Source

pub fn set_software_cursor_only(&mut self, enabled: bool)

Mark that the backend does not render a hardware cursor. When set, the renderer always draws a software cursor indicator.

Source

pub fn set_session_name(&mut self, name: Option<String>)

Set the session name for display in status bar.

When a session name is set, the recovery service is reinitialized to use a session-scoped recovery directory so each named session’s recovery data is isolated.

Source

pub fn session_name(&self) -> Option<&str>

Get the session name (for status bar display)

Source

pub fn queue_escape_sequences(&mut self, sequences: &[u8])

Queue escape sequences to be sent to the client (session mode only)

Source

pub fn take_pending_escape_sequences(&mut self) -> Vec<u8>

Take pending escape sequences, clearing the queue

Source

pub fn take_pending_clipboard(&mut self) -> Option<PendingClipboard>

Take pending clipboard data queued in session mode, clearing the request

Source

pub fn should_restart(&self) -> bool

Check if the editor should restart with a new working directory

Source

pub fn take_restart_dir(&mut self) -> Option<PathBuf>

Take the restart directory, clearing the restart request Returns the new working directory if a restart was requested

Source

pub fn request_full_redraw(&mut self)

Request the editor to restart with a new working directory This triggers a clean shutdown and restart with the new project root Request a full hardware terminal clear and redraw on the next frame. Used after external commands have messed up the terminal state.

Source

pub fn take_full_redraw_request(&mut self) -> bool

Check if a full redraw was requested, and clear the flag.

Source

pub fn request_restart(&mut self, new_working_dir: PathBuf)

Source

pub fn theme(&self) -> &Theme

Get the active theme

Source

pub fn is_settings_open(&self) -> bool

Check if the settings dialog is open and visible

Source

pub fn quit(&mut self)

Request the editor to quit

Source

pub fn focus_gained(&mut self)

Handle terminal focus gained event

Source

pub fn resize(&mut self, width: u16, height: u16)

Resize all buffers to match new terminal size

Source

pub fn start_prompt(&mut self, message: String, prompt_type: PromptType)

Start a new prompt (enter minibuffer mode)

Source

pub fn start_prompt_with_suggestions( &mut self, message: String, prompt_type: PromptType, suggestions: Vec<Suggestion>, )

Start a new prompt with autocomplete suggestions

Source

pub fn start_prompt_with_initial_text( &mut self, message: String, prompt_type: PromptType, initial_text: String, )

Start a new prompt with initial text

Source

pub fn start_quick_open(&mut self)

Start Quick Open prompt with command palette as default

Source

pub fn change_working_dir(&mut self, new_path: PathBuf)

Change the working directory to a new path

This requests a full editor restart with the new working directory. The main loop will drop the current editor instance and create a fresh one pointing to the new directory. This ensures:

  • All buffers are cleanly closed
  • LSP servers are properly shut down and restarted with new root
  • Plugins are cleanly restarted
  • No state leaks between projects
Source

pub fn cancel_prompt(&mut self)

Cancel the current prompt and return to normal mode

Source

pub fn handle_prompt_scroll(&mut self, delta: i32) -> bool

Handle mouse wheel scroll in prompt with suggestions. Returns true if scroll was handled, false if no prompt is active or has no suggestions.

Source

pub fn confirm_prompt(&mut self) -> Option<(String, PromptType, Option<usize>)>

Get the confirmed input and prompt type, consuming the prompt For command palette, returns the selected suggestion if available, otherwise the raw input Returns (input, prompt_type, selected_index) Returns None if trying to confirm a disabled command

Source

pub fn is_prompting(&self) -> bool

Check if currently in prompt mode

Source

pub fn editor_mode(&self) -> Option<String>

Get the current global editor mode (e.g., “vi-normal”, “vi-insert”) Returns None if no special mode is active

Source

pub fn command_registry(&self) -> &Arc<RwLock<CommandRegistry>>

Get access to the command registry

Source

pub fn plugin_manager(&self) -> &PluginManager

Get access to the plugin manager

Source

pub fn plugin_manager_mut(&mut self) -> &mut PluginManager

Get mutable access to the plugin manager

Source

pub fn file_explorer_is_focused(&self) -> bool

Check if file explorer has focus

Source

pub fn prompt_input(&self) -> Option<&str>

Get current prompt input (for display)

Source

pub fn has_active_selection(&self) -> bool

Check if the active cursor currently has a selection

Source

pub fn prompt_mut(&mut self) -> Option<&mut Prompt>

Get mutable reference to prompt (for input handling)

Source

pub fn set_status_message(&mut self, message: String)

Set a status message to display in the status bar

Source

pub fn get_status_message(&self) -> Option<&String>

Get the current status message

Source

pub fn get_plugin_errors(&self) -> &[String]

Get accumulated plugin errors (for test assertions) Returns all error messages that were detected in plugin status messages

Source

pub fn clear_plugin_errors(&mut self)

Clear accumulated plugin errors

Source

pub fn update_prompt_suggestions(&mut self)

Update prompt suggestions based on current input

Source

pub fn process_async_messages(&mut self) -> bool

Process pending async messages from the async bridge

This should be called each frame in the main loop to handle:

  • LSP diagnostics
  • LSP initialization/errors
  • File system changes (future)
  • Git status updates
Source

pub fn handle_plugin_command( &mut self, command: PluginCommand, ) -> AnyhowResult<()>

Handle a plugin command - dispatches to specialized handlers in plugin_commands module

Auto Trait Implementations§

§

impl !Freeze for Editor

§

impl !RefUnwindSafe for Editor

§

impl !Send for Editor

§

impl !Sync for Editor

§

impl Unpin for Editor

§

impl UnsafeUnpin for Editor

§

impl !UnwindSafe for Editor

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
Source§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
Source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<'a, T> FromIn<'a, T> for T

Source§

fn from_in(t: T, _: &'a Allocator) -> T

Converts to this type from the input type within the given allocator.
Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<'a, T, U> IntoIn<'a, U> for T
where U: FromIn<'a, T>,

Source§

fn into_in(self, allocator: &'a Allocator) -> U

Converts this type into the (usually inferred) input type within the given allocator.
Source§

impl<D> OwoColorize for D

Source§

fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>
where C: Color,

Set the foreground color generically Read more
Source§

fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>
where C: Color,

Set the background color generically. Read more
Source§

fn black(&self) -> FgColorDisplay<'_, Black, Self>

Change the foreground color to black
Source§

fn on_black(&self) -> BgColorDisplay<'_, Black, Self>

Change the background color to black
Source§

fn red(&self) -> FgColorDisplay<'_, Red, Self>

Change the foreground color to red
Source§

fn on_red(&self) -> BgColorDisplay<'_, Red, Self>

Change the background color to red
Source§

fn green(&self) -> FgColorDisplay<'_, Green, Self>

Change the foreground color to green
Source§

fn on_green(&self) -> BgColorDisplay<'_, Green, Self>

Change the background color to green
Source§

fn yellow(&self) -> FgColorDisplay<'_, Yellow, Self>

Change the foreground color to yellow
Source§

fn on_yellow(&self) -> BgColorDisplay<'_, Yellow, Self>

Change the background color to yellow
Source§

fn blue(&self) -> FgColorDisplay<'_, Blue, Self>

Change the foreground color to blue
Source§

fn on_blue(&self) -> BgColorDisplay<'_, Blue, Self>

Change the background color to blue
Source§

fn magenta(&self) -> FgColorDisplay<'_, Magenta, Self>

Change the foreground color to magenta
Source§

fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>

Change the background color to magenta
Source§

fn purple(&self) -> FgColorDisplay<'_, Magenta, Self>

Change the foreground color to purple
Source§

fn on_purple(&self) -> BgColorDisplay<'_, Magenta, Self>

Change the background color to purple
Source§

fn cyan(&self) -> FgColorDisplay<'_, Cyan, Self>

Change the foreground color to cyan
Source§

fn on_cyan(&self) -> BgColorDisplay<'_, Cyan, Self>

Change the background color to cyan
Source§

fn white(&self) -> FgColorDisplay<'_, White, Self>

Change the foreground color to white
Source§

fn on_white(&self) -> BgColorDisplay<'_, White, Self>

Change the background color to white
Source§

fn default_color(&self) -> FgColorDisplay<'_, Default, Self>

Change the foreground color to the terminal default
Source§

fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>

Change the background color to the terminal default
Source§

fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>

Change the foreground color to bright black
Source§

fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>

Change the background color to bright black
Source§

fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>

Change the foreground color to bright red
Source§

fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>

Change the background color to bright red
Source§

fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>

Change the foreground color to bright green
Source§

fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>

Change the background color to bright green
Source§

fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>

Change the foreground color to bright yellow
Source§

fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>

Change the background color to bright yellow
Source§

fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>

Change the foreground color to bright blue
Source§

fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>

Change the background color to bright blue
Source§

fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>

Change the foreground color to bright magenta
Source§

fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>

Change the background color to bright magenta
Source§

fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>

Change the foreground color to bright purple
Source§

fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>

Change the background color to bright purple
Source§

fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>

Change the foreground color to bright cyan
Source§

fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>

Change the background color to bright cyan
Source§

fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>

Change the foreground color to bright white
Source§

fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>

Change the background color to bright white
Source§

fn bold(&self) -> BoldDisplay<'_, Self>

Make the text bold
Source§

fn dimmed(&self) -> DimDisplay<'_, Self>

Make the text dim
Source§

fn italic(&self) -> ItalicDisplay<'_, Self>

Make the text italicized
Source§

fn underline(&self) -> UnderlineDisplay<'_, Self>

Make the text underlined
Make the text blink
Make the text blink (but fast!)
Source§

fn reversed(&self) -> ReversedDisplay<'_, Self>

Swap the foreground and background colors
Source§

fn hidden(&self) -> HiddenDisplay<'_, Self>

Hide the text
Source§

fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>

Cross out the text
Source§

fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>
where Color: DynColor,

Set the foreground color at runtime. Only use if you do not know which color will be used at compile-time. If the color is constant, use either OwoColorize::fg or a color-specific method, such as OwoColorize::green, Read more
Source§

fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>
where Color: DynColor,

Set the background color at runtime. Only use if you do not know what color to use at compile-time. If the color is constant, use either OwoColorize::bg or a color-specific method, such as OwoColorize::on_yellow, Read more
Source§

fn fg_rgb<const R: u8, const G: u8, const B: u8>( &self, ) -> FgColorDisplay<'_, CustomColor<R, G, B>, Self>

Set the foreground color to a specific RGB value.
Source§

fn bg_rgb<const R: u8, const G: u8, const B: u8>( &self, ) -> BgColorDisplay<'_, CustomColor<R, G, B>, Self>

Set the background color to a specific RGB value.
Source§

fn truecolor(&self, r: u8, g: u8, b: u8) -> FgDynColorDisplay<'_, Rgb, Self>

Sets the foreground color to an RGB value.
Source§

fn on_truecolor(&self, r: u8, g: u8, b: u8) -> BgDynColorDisplay<'_, Rgb, Self>

Sets the background color to an RGB value.
Source§

fn style(&self, style: Style) -> Styled<&Self>

Apply a runtime-determined style
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ParallelSend for T