pub struct Editor {
pub position_history: PositionHistory,
/* private fields */
}Expand description
The main editor struct - manages multiple buffers, clipboard, and rendering
Fields§
§position_history: PositionHistoryPosition history for back/forward navigation
Implementations§
Source§impl Editor
impl Editor
Sourcepub fn open_file(&mut self, path: &Path) -> Result<BufferId>
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.
Sourcepub fn open_file_no_focus(&mut self, path: &Path) -> Result<BufferId>
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.
Sourcepub fn open_local_file(&mut self, path: &Path) -> Result<BufferId>
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.
Sourcepub fn open_file_with_encoding(
&mut self,
path: &Path,
encoding: Encoding,
) -> Result<BufferId>
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.
Sourcepub fn reload_with_encoding(&mut self, encoding: Encoding) -> Result<()>
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.
Sourcepub fn open_file_large_encoding_confirmed(
&mut self,
path: &Path,
) -> Result<BufferId>
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.
Sourcepub fn goto_line_col(&mut self, line: usize, column: Option<usize>)
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.
Sourcepub fn select_range(
&mut self,
start_line: usize,
start_col: Option<usize>,
end_line: usize,
end_col: Option<usize>,
)
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.
Sourcepub fn goto_byte_offset(&mut self, offset: usize)
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)
Sourcepub fn new_buffer(&mut self) -> BufferId
pub fn new_buffer(&mut self) -> BufferId
Create a new empty buffer
Sourcepub fn open_stdin_buffer(
&mut self,
temp_path: &Path,
thread_handle: Option<JoinHandle<Result<()>>>,
) -> AnyhowResult<BufferId>
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 writtenthread_handle- Optional handle to background thread streaming stdin to temp file
Sourcepub fn poll_stdin_streaming(&mut self) -> bool
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).
Sourcepub fn complete_stdin_streaming(&mut self)
pub fn complete_stdin_streaming(&mut self)
Mark stdin streaming as complete. Called when the background thread finishes.
Sourcepub fn is_stdin_streaming(&self) -> bool
pub fn is_stdin_streaming(&self) -> bool
Check if stdin streaming is active (not complete).
Sourcepub fn create_virtual_buffer(
&mut self,
name: String,
mode: String,
read_only: bool,
) -> BufferId
pub fn create_virtual_buffer( &mut self, name: String, mode: String, read_only: bool, ) -> BufferId
Sourcepub fn set_virtual_buffer_content(
&mut self,
buffer_id: BufferId,
entries: Vec<TextPropertyEntry>,
) -> Result<(), String>
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 updateentries- Text entries with embedded properties
Sourcepub fn open_help_manual(&mut self)
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.
Sourcepub fn open_keyboard_shortcuts(&mut self)
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.
Sourcepub fn show_warnings_popup(&mut self)
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.
Sourcepub fn show_lsp_status_popup(&mut self)
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.
Sourcepub fn show_file_message_popup(&mut self, message: &str)
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").
Sourcepub fn get_text_properties_at_cursor(&self) -> Option<Vec<&TextProperty>>
pub fn get_text_properties_at_cursor(&self) -> Option<Vec<&TextProperty>>
Get text properties at the cursor position in the active buffer
Sourcepub fn close_buffer(&mut self, id: BufferId) -> Result<()>
pub fn close_buffer(&mut self, id: BufferId) -> Result<()>
Close the given buffer
Sourcepub fn force_close_buffer(&mut self, id: BufferId) -> Result<()>
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
Sourcepub fn switch_buffer(&mut self, id: BufferId)
pub fn switch_buffer(&mut self, id: BufferId)
Switch to the given buffer
Sourcepub fn close_tab(&mut self)
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).
Sourcepub fn close_tab_in_split(
&mut self,
buffer_id: BufferId,
split_id: LeafId,
) -> bool
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.
Sourcepub fn close_other_tabs_in_split(
&mut self,
keep_buffer_id: BufferId,
split_id: LeafId,
)
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
Sourcepub fn close_tabs_to_right_in_split(
&mut self,
buffer_id: BufferId,
split_id: LeafId,
)
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
Sourcepub fn close_tabs_to_left_in_split(
&mut self,
buffer_id: BufferId,
split_id: LeafId,
)
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
Sourcepub fn close_all_tabs_in_split(&mut self, split_id: LeafId)
pub fn close_all_tabs_in_split(&mut self, split_id: LeafId)
Close all tabs in a split
Sourcepub fn next_buffer(&mut self)
pub fn next_buffer(&mut self)
Switch to next buffer in current split’s tabs
Sourcepub fn prev_buffer(&mut self)
pub fn prev_buffer(&mut self)
Switch to previous buffer in current split’s tabs
Navigate back in position history
Navigate forward in position history
Sourcepub fn get_mouse_hover_state(&self) -> Option<(usize, u16, u16)>
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
Sourcepub fn has_transient_popup(&self) -> bool
pub fn has_transient_popup(&self) -> bool
Check if a transient popup (hover/signature help) is currently visible
Sourcepub fn force_check_mouse_hover(&mut self) -> bool
pub fn force_check_mouse_hover(&mut self) -> bool
Force check the mouse hover timer (for testing) This bypasses the normal 500ms delay
Sourcepub fn schedule_hot_exit_recovery(&mut self)
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.
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>, )
Sourcepub fn process_pending_file_opens(&mut self) -> bool
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.
Sourcepub fn take_completed_waits(&mut self) -> Vec<u64>
pub fn take_completed_waits(&mut self) -> Vec<u64>
Take and return completed wait IDs (for –wait support).
Sourcepub fn remove_wait_tracking(&mut self, wait_id: u64)
pub fn remove_wait_tracking(&mut self, wait_id: u64)
Remove wait tracking for a given wait_id (e.g., when waiting client disconnects).
Sourcepub fn start_incremental_line_scan(&mut self, open_goto_line: bool)
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.
Sourcepub fn process_line_scan(&mut self) -> bool
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).
Sourcepub fn process_search_scan(&mut self) -> bool
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
impl Editor
Sourcepub fn open_calibration_wizard(&mut self)
pub fn open_calibration_wizard(&mut self)
Open the calibration wizard
Sourcepub fn save_calibration(&mut self, wizard: CalibrationWizard)
pub fn save_calibration(&mut self, wizard: CalibrationWizard)
Save calibration and close wizard
Sourcepub fn handle_calibration_input(&mut self, event: &KeyEvent) -> InputResult
pub fn handle_calibration_input(&mut self, event: &KeyEvent) -> InputResult
Handle input when calibration wizard is active
Sourcepub fn is_calibration_active(&self) -> bool
pub fn is_calibration_active(&self) -> bool
Check if calibration wizard is active
Source§impl Editor
impl Editor
Sourcepub fn copy_selection(&mut self)
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.
Sourcepub fn copy_selection_with_theme(&mut self, theme_name: &str)
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.
Sourcepub fn cut_selection(&mut self)
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).
Sourcepub fn paste(&mut self)
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)
Sourcepub fn paste_text(&mut self, paste_text: String)
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
Sourcepub fn add_cursor_at_next_match(&mut self)
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
Sourcepub fn add_cursor_above(&mut self)
pub fn add_cursor_above(&mut self)
Add a cursor above the primary cursor at the same column
Sourcepub fn add_cursor_below(&mut self)
pub fn add_cursor_below(&mut self)
Add a cursor below the primary cursor at the same column
Sourcepub fn yank_word_forward(&mut self)
pub fn yank_word_forward(&mut self)
Yank (copy) from cursor to next word start
Sourcepub fn yank_vi_word_end(&mut self)
pub fn yank_vi_word_end(&mut self)
Yank (copy) from cursor to vim word end (inclusive)
Sourcepub fn yank_word_backward(&mut self)
pub fn yank_word_backward(&mut self)
Yank (copy) from previous word start to cursor
Sourcepub fn yank_to_line_end(&mut self)
pub fn yank_to_line_end(&mut self)
Yank (copy) from cursor to end of line
Sourcepub fn yank_to_line_start(&mut self)
pub fn yank_to_line_start(&mut self)
Yank (copy) from start of line to cursor
Source§impl Editor
impl Editor
Sourcepub fn is_composite_buffer(&self, buffer_id: BufferId) -> bool
pub fn is_composite_buffer(&self, buffer_id: BufferId) -> bool
Check if a buffer is a composite buffer
Sourcepub fn get_composite(&self, buffer_id: BufferId) -> Option<&CompositeBuffer>
pub fn get_composite(&self, buffer_id: BufferId) -> Option<&CompositeBuffer>
Get a composite buffer by ID
Sourcepub fn get_composite_mut(
&mut self,
buffer_id: BufferId,
) -> Option<&mut CompositeBuffer>
pub fn get_composite_mut( &mut self, buffer_id: BufferId, ) -> Option<&mut CompositeBuffer>
Get a mutable composite buffer by ID
Sourcepub fn get_composite_view_state(
&mut self,
split_id: LeafId,
buffer_id: BufferId,
) -> Option<&mut CompositeViewState>
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
Sourcepub fn create_composite_buffer(
&mut self,
name: String,
mode: String,
layout: CompositeLayout,
sources: Vec<SourcePane>,
) -> BufferId
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
Sourcepub fn set_composite_alignment(
&mut self,
buffer_id: BufferId,
alignment: LineAlignment,
)
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).
Sourcepub fn close_composite_buffer(&mut self, buffer_id: BufferId)
pub fn close_composite_buffer(&mut self, buffer_id: BufferId)
Close a composite buffer and clean up associated state
Sourcepub fn composite_focus_next(&mut self, split_id: LeafId, buffer_id: BufferId)
pub fn composite_focus_next(&mut self, split_id: LeafId, buffer_id: BufferId)
Switch focus to the next pane in a composite buffer
Sourcepub fn composite_focus_prev(&mut self, split_id: LeafId, buffer_id: BufferId)
pub fn composite_focus_prev(&mut self, split_id: LeafId, buffer_id: BufferId)
Switch focus to the previous pane in a composite buffer
Sourcepub fn composite_next_hunk(
&mut self,
split_id: LeafId,
buffer_id: BufferId,
) -> bool
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
Sourcepub fn composite_prev_hunk(
&mut self,
split_id: LeafId,
buffer_id: BufferId,
) -> bool
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
Sourcepub fn composite_scroll(
&mut self,
split_id: LeafId,
buffer_id: BufferId,
delta: isize,
)
pub fn composite_scroll( &mut self, split_id: LeafId, buffer_id: BufferId, delta: isize, )
Scroll a composite buffer view
Sourcepub fn composite_scroll_to(
&mut self,
split_id: LeafId,
buffer_id: BufferId,
row: usize,
)
pub fn composite_scroll_to( &mut self, split_id: LeafId, buffer_id: BufferId, row: usize, )
Scroll composite buffer to a specific row
Sourcepub fn handle_composite_action(
&mut self,
buffer_id: BufferId,
action: &Action,
) -> Option<bool>
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
impl Editor
Sourcepub fn open_event_debug(&mut self)
pub fn open_event_debug(&mut self)
Open the event debug dialog
Sourcepub fn handle_event_debug_input(&mut self, event: &KeyEvent) -> InputResult
pub fn handle_event_debug_input(&mut self, event: &KeyEvent) -> InputResult
Handle input when event debug dialog is active
Sourcepub fn is_event_debug_active(&self) -> bool
pub fn is_event_debug_active(&self) -> bool
Check if event debug dialog is active
Source§impl Editor
impl Editor
pub fn file_explorer_visible(&self) -> bool
pub fn file_explorer(&self) -> Option<&FileTreeView>
pub fn toggle_file_explorer(&mut self)
pub fn show_file_explorer(&mut self)
pub fn sync_file_explorer_to_active_file(&mut self)
pub fn focus_file_explorer(&mut self)
pub fn focus_editor(&mut self)
pub fn file_explorer_page_up(&mut self)
pub fn file_explorer_page_down(&mut self)
Sourcepub fn file_explorer_collapse(&mut self)
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
pub fn file_explorer_toggle_expand(&mut self)
pub fn file_explorer_open_file(&mut self) -> AnyhowResult<()>
pub fn file_explorer_refresh(&mut self)
pub fn file_explorer_new_file(&mut self)
pub fn file_explorer_new_directory(&mut self)
pub fn file_explorer_delete(&mut self)
Sourcepub fn perform_file_explorer_delete(&mut self, path: PathBuf, _is_dir: bool)
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
pub fn file_explorer_rename(&mut self)
Sourcepub fn perform_file_explorer_rename(
&mut self,
original_path: PathBuf,
original_name: String,
new_name: String,
is_new_file: bool,
)
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)
pub fn file_explorer_toggle_gitignored(&mut self)
Sourcepub fn file_explorer_search_clear(&mut self)
pub fn file_explorer_search_clear(&mut self)
Clear the file explorer search
Sourcepub fn file_explorer_search_push_char(&mut self, c: char)
pub fn file_explorer_search_push_char(&mut self, c: char)
Add a character to the file explorer search
Sourcepub fn file_explorer_search_pop_char(&mut self)
pub fn file_explorer_search_pop_char(&mut self)
Remove a character from the file explorer search (backspace)
pub fn handle_set_file_explorer_decorations( &mut self, namespace: String, decorations: Vec<FileExplorerDecoration>, )
pub fn handle_clear_file_explorer_decorations(&mut self, namespace: &str)
Source§impl Editor
impl Editor
Sourcepub fn is_file_open_active(&self) -> bool
pub fn is_file_open_active(&self) -> bool
Check if the file open dialog is active (for OpenFile, SwitchProject, or SaveFileAs)
Sourcepub fn handle_file_open_action(&mut self, action: &Action) -> bool
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
Sourcepub fn start_large_file_encoding_confirmation(
&mut self,
confirmation: &LargeFileEncodingConfirmation,
)
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.
Sourcepub fn start_open_file_with_encoding_prompt(&mut self, path: PathBuf)
pub fn start_open_file_with_encoding_prompt(&mut self, path: PathBuf)
Start the encoding selection prompt for opening a file
Sourcepub fn update_file_open_filter(&mut self)
pub fn update_file_open_filter(&mut self)
Update filter when prompt text changes
Sourcepub fn file_open_toggle_sort(&mut self, mode: SortMode)
pub fn file_open_toggle_sort(&mut self, mode: SortMode)
Handle sorting toggle (called from keybinding)
Handle hidden files toggle
Sourcepub fn file_open_toggle_detect_encoding(&mut self)
pub fn file_open_toggle_detect_encoding(&mut self)
Handle encoding detection toggle
Sourcepub fn handle_file_open_scroll(&mut self, delta: i32) -> bool
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
Sourcepub fn handle_file_open_click(&mut self, x: u16, y: u16) -> bool
pub fn handle_file_open_click(&mut self, x: u16, y: u16) -> bool
Handle mouse click in file browser
Sourcepub fn handle_file_open_double_click(&mut self, x: u16, y: u16) -> bool
pub fn handle_file_open_double_click(&mut self, x: u16, y: u16) -> bool
Handle double-click in file browser
Sourcepub fn compute_file_browser_hover(&self, x: u16, y: u16) -> Option<HoverTarget>
pub fn compute_file_browser_hover(&self, x: u16, y: u16) -> Option<HoverTarget>
Compute hover target for file browser
Source§impl Editor
impl Editor
Sourcepub fn auto_save_persistent_buffers(&mut self) -> Result<usize>
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
Sourcepub fn save_all_on_exit(&mut self) -> Result<usize>
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).
Sourcepub fn revert_file(&mut self) -> Result<bool>
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
Sourcepub fn toggle_auto_revert(&mut self)
pub fn toggle_auto_revert(&mut self)
Toggle auto-revert mode
Sourcepub fn poll_file_changes(&mut self) -> bool
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).
Sourcepub fn poll_file_tree_changes(&mut self) -> bool
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).
Sourcepub fn handle_file_changed(&mut self, changed_path: &str)
pub fn handle_file_changed(&mut self, changed_path: &str)
Handle a file change notification (from file watcher)
Sourcepub fn check_save_conflict(&self) -> Option<SystemTime>
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
impl Editor
Sourcepub fn get_key_context(&self) -> KeyContext
pub fn get_key_context(&self) -> KeyContext
Determine the current keybinding context based on UI state
Sourcepub fn handle_key(
&mut self,
code: KeyCode,
modifiers: KeyModifiers,
) -> AnyhowResult<()>
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
impl Editor
Sourcepub fn dispatch_terminal_input(
&mut self,
event: &KeyEvent,
) -> Option<InputResult>
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.
Sourcepub fn dispatch_modal_input(&mut self, event: &KeyEvent) -> Option<InputResult>
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.
Sourcepub fn process_deferred_actions(&mut self, ctx: InputContext)
pub fn process_deferred_actions(&mut self, ctx: InputContext)
Process deferred actions collected during input handling.
Source§impl Editor
impl Editor
Sourcepub fn open_keybinding_editor(&mut self)
pub fn open_keybinding_editor(&mut self)
Open the keybinding editor modal
Sourcepub fn handle_keybinding_editor_input(
&mut self,
event: &KeyEvent,
) -> InputResult
pub fn handle_keybinding_editor_input( &mut self, event: &KeyEvent, ) -> InputResult
Handle input when keybinding editor is active
Sourcepub fn is_keybinding_editor_active(&self) -> bool
pub fn is_keybinding_editor_active(&self) -> bool
Check if keybinding editor is active
Sourcepub fn handle_keybinding_editor_mouse(
&mut self,
mouse_event: MouseEvent,
) -> Result<bool>
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
impl Editor
Sourcepub fn handle_lsp_restart(&mut self)
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.
Sourcepub fn handle_lsp_stop(&mut self)
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.
Sourcepub fn handle_lsp_toggle_for_buffer(&mut self)
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.
Sourcepub fn toggle_fold_at_cursor(&mut self)
pub fn toggle_fold_at_cursor(&mut self)
Toggle folding at the current cursor position.
Sourcepub fn toggle_fold_at_line(&mut self, buffer_id: BufferId, line: usize)
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.
Sourcepub fn toggle_fold_at_byte(&mut self, buffer_id: BufferId, byte_pos: usize)
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
impl Editor
Sourcepub fn has_pending_lsp_requests(&self) -> bool
pub fn has_pending_lsp_requests(&self) -> bool
Check if there are any pending LSP requests
Sourcepub fn handle_rename_response(
&mut self,
_request_id: u64,
result: Result<WorkspaceEdit, String>,
) -> AnyhowResult<()>
pub fn handle_rename_response( &mut self, _request_id: u64, result: Result<WorkspaceEdit, String>, ) -> AnyhowResult<()>
Handle rename response from LSP
Source§impl Editor
impl Editor
Handle MenuActivate action - opens the first menu. If the menu bar is hidden, it will be temporarily shown.
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.
Handle MenuClose action - closes the active menu. If the menu bar was auto-shown, it will be hidden again.
Handle MenuLeft action - close submenu or go to previous menu.
Handle MenuRight action - open submenu or go to next menu.
Handle MenuUp action - select previous item in menu.
Handle MenuDown action - select next item in menu.
Handle MenuExecute action - execute highlighted item or open submenu.
Returns Some(action) if an action should be executed after this call.
Handle MenuOpen action - open a specific menu by name. If the menu bar is hidden, it will be temporarily shown.
Source§impl Editor
impl Editor
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.
Return the fully-expanded menu definitions (with DynamicSubmenu
items resolved to Submenu). Used by the GUI layer to build
platform-native menus.
Update all menu context values based on current editor state. This should be called before rendering the menu bar.
Source§impl Editor
impl Editor
Sourcepub fn handle_mouse(&mut self, mouse_event: MouseEvent) -> AnyhowResult<bool>
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
impl Editor
Sourcepub fn run_on_save_actions(&mut self) -> Result<bool, String>
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.
Sourcepub fn format_buffer(&mut self) -> Result<(), String>
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.
Sourcepub fn trim_trailing_whitespace(&mut self) -> Result<bool, String>
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.
Sourcepub fn ensure_final_newline(&mut self) -> Result<bool, String>
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
impl Editor
Sourcepub fn handle_popup_confirm(&mut self) -> PopupConfirmResult
pub fn handle_popup_confirm(&mut self) -> PopupConfirmResult
Handle PopupConfirm action.
Returns PopupConfirmResult indicating what the caller should do next.
Sourcepub fn handle_popup_cancel(&mut self)
pub fn handle_popup_cancel(&mut self)
Handle PopupCancel action.
Sourcepub fn handle_popup_type_char(&mut self, c: char)
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.
Sourcepub fn handle_popup_backspace(&mut self)
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
impl Editor
Sourcepub fn handle_prompt_confirm_input(
&mut self,
input: String,
prompt_type: PromptType,
selected_index: Option<usize>,
) -> PromptResult
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.
Sourcepub fn handle_stop_lsp_server(&mut self, input: &str)
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).
Sourcepub fn handle_restart_lsp_server(&mut self, input: &str)
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
impl Editor
Sourcepub fn start_recovery_session(&mut self) -> AnyhowResult<()>
pub fn start_recovery_session(&mut self) -> AnyhowResult<()>
Start the recovery session (call on editor startup after recovery check)
Sourcepub fn end_recovery_session(&mut self) -> AnyhowResult<()>
pub fn end_recovery_session(&mut self) -> AnyhowResult<()>
End the recovery session cleanly (call on normal shutdown)
Sourcepub fn has_recovery_files(&self) -> AnyhowResult<bool>
pub fn has_recovery_files(&self) -> AnyhowResult<bool>
Check if there are files to recover from a crash
Sourcepub fn list_recoverable_files(&self) -> AnyhowResult<Vec<RecoveryEntry>>
pub fn list_recoverable_files(&self) -> AnyhowResult<Vec<RecoveryEntry>>
Get list of recoverable files
Sourcepub fn recover_all_buffers(&mut self) -> AnyhowResult<usize>
pub fn recover_all_buffers(&mut self) -> AnyhowResult<usize>
Recover all buffers from recovery files Returns the number of buffers recovered
Sourcepub fn discard_all_recovery(&mut self) -> AnyhowResult<usize>
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
Sourcepub fn auto_recovery_save_dirty_buffers(&mut self) -> AnyhowResult<usize>
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.
Sourcepub fn is_active_buffer_recovery_dirty(&self) -> bool
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
Sourcepub fn delete_buffer_recovery(
&mut self,
buffer_id: BufferId,
) -> AnyhowResult<()>
pub fn delete_buffer_recovery( &mut self, buffer_id: BufferId, ) -> AnyhowResult<()>
Delete recovery for a buffer (call after saving or closing)
Source§impl Editor
impl Editor
Sourcepub fn add_overlay(
&mut self,
namespace: Option<OverlayNamespace>,
range: Range<usize>,
face: OverlayFace,
priority: i32,
message: Option<String>,
) -> OverlayHandle
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.)
Sourcepub fn remove_overlay(&mut self, handle: OverlayHandle)
pub fn remove_overlay(&mut self, handle: OverlayHandle)
Remove an overlay by handle
Sourcepub fn remove_overlays_in_range(&mut self, range: Range<usize>)
pub fn remove_overlays_in_range(&mut self, range: Range<usize>)
Remove all overlays in a range
Sourcepub fn clear_overlays(&mut self)
pub fn clear_overlays(&mut self)
Clear all overlays
Sourcepub fn show_popup(&mut self, popup: PopupData)
pub fn show_popup(&mut self, popup: PopupData)
Show a popup window
Sourcepub fn hide_popup(&mut self)
pub fn hide_popup(&mut self)
Hide the topmost popup
Sourcepub fn clear_popups(&mut self)
pub fn clear_popups(&mut self)
Clear all popups
Sourcepub fn show_lsp_confirmation_popup(&mut self, language: &str)
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.
Sourcepub fn handle_lsp_confirmation_response(&mut self, action: &str) -> bool
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.
Sourcepub fn has_pending_lsp_confirmation(&self) -> bool
pub fn has_pending_lsp_confirmation(&self) -> bool
Check if there’s a pending LSP confirmation
Sourcepub fn popup_select_next(&mut self)
pub fn popup_select_next(&mut self)
Navigate popup selection (next item)
Sourcepub fn popup_select_prev(&mut self)
pub fn popup_select_prev(&mut self)
Navigate popup selection (previous item)
Sourcepub fn popup_page_down(&mut self)
pub fn popup_page_down(&mut self)
Navigate popup (page down)
Sourcepub fn popup_page_up(&mut self)
pub fn popup_page_up(&mut self)
Navigate popup (page up)
Sourcepub fn action_to_events(&mut self, action: Action) -> Option<Vec<Event>>
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)
Sourcepub fn recompute_layout(&mut self, width: u16, height: u16)
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.
Sourcepub fn clear_search_history(&mut self)
pub fn clear_search_history(&mut self)
Clear the search history Used primarily for testing to ensure test isolation
Sourcepub fn save_histories(&self)
pub fn save_histories(&self)
Save all prompt histories to disk Called on shutdown to persist history across sessions
Source§impl Editor
impl Editor
Sourcepub fn open_settings(&mut self)
pub fn open_settings(&mut self)
Open the settings modal
Sourcepub fn close_settings(&mut self, save: bool)
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.
Sourcepub fn save_settings(&mut self)
pub fn save_settings(&mut self)
Save the settings from the modal to config
Sourcepub fn open_config_file(&mut self, layer: ConfigLayer) -> AnyhowResult<()>
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.
Navigate settings up
Navigate settings down
Sourcepub fn settings_activate_current(&mut self)
pub fn settings_activate_current(&mut self)
Activate/toggle the currently selected setting
Sourcepub fn settings_increment_current(&mut self)
pub fn settings_increment_current(&mut self)
Increment the current setting value (for Number and Dropdown controls)
Sourcepub fn settings_decrement_current(&mut self)
pub fn settings_decrement_current(&mut self)
Decrement the current setting value (for Number and Dropdown controls)
Source§impl Editor
impl Editor
Sourcepub fn start_shell_command_prompt(&mut self, replace: bool)
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.
Sourcepub fn execute_shell_command(&mut self, command: &str) -> Result<String, String>
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.
Sourcepub fn handle_shell_command(&mut self, command: &str, replace: bool)
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
impl Editor
Sourcepub fn split_pane_horizontal(&mut self)
pub fn split_pane_horizontal(&mut self)
Split the current pane horizontally
Sourcepub fn split_pane_vertical(&mut self)
pub fn split_pane_vertical(&mut self)
Split the current pane vertically
Sourcepub fn close_active_split(&mut self)
pub fn close_active_split(&mut self)
Close the active split
Sourcepub fn next_split(&mut self)
pub fn next_split(&mut self)
Switch to next split
Sourcepub fn prev_split(&mut self)
pub fn prev_split(&mut self)
Switch to previous split
Sourcepub fn adjust_split_size(&mut self, delta: f32)
pub fn adjust_split_size(&mut self, delta: f32)
Adjust the size of the active split
Sourcepub fn toggle_maximize_split(&mut self)
pub fn toggle_maximize_split(&mut self)
Toggle maximize state for the active split
Sourcepub fn get_separator_areas(
&self,
) -> &[(ContainerId, SplitDirection, u16, u16, u16)]
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
Sourcepub fn get_tab_layouts(&self) -> &HashMap<LeafId, TabLayout>
pub fn get_tab_layouts(&self) -> &HashMap<LeafId, TabLayout>
Get cached tab layouts for testing
Sourcepub fn get_split_areas(&self) -> &[(LeafId, BufferId, Rect, Rect, usize, usize)]
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
Sourcepub fn get_split_ratio(&self, split_id: SplitId) -> Option<f32>
pub fn get_split_ratio(&self, split_id: SplitId) -> Option<f32>
Get the ratio of a specific split (for testing)
Sourcepub fn get_active_split(&self) -> LeafId
pub fn get_active_split(&self) -> LeafId
Get the active split ID (for testing)
Sourcepub fn get_split_buffer(&self, split_id: SplitId) -> Option<BufferId>
pub fn get_split_buffer(&self, split_id: SplitId) -> Option<BufferId>
Get the buffer ID for a split (for testing)
Sourcepub fn get_split_tabs(&self, split_id: LeafId) -> Vec<BufferId>
pub fn get_split_tabs(&self, split_id: LeafId) -> Vec<BufferId>
Get the open buffers (tabs) in a split (for testing)
Sourcepub fn get_split_count(&self) -> usize
pub fn get_split_count(&self) -> usize
Get the number of splits (for testing)
Sourcepub fn compute_drop_zone(
&self,
col: u16,
row: u16,
source_split_id: LeafId,
) -> Option<TabDropZone>
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
impl Editor
Sourcepub fn open_terminal(&mut self)
pub fn open_terminal(&mut self)
Open a new terminal in the current split
Sourcepub fn close_terminal(&mut self)
pub fn close_terminal(&mut self)
Close the current terminal (if viewing a terminal buffer)
Sourcepub fn is_terminal_buffer(&self, buffer_id: BufferId) -> bool
pub fn is_terminal_buffer(&self, buffer_id: BufferId) -> bool
Check if a buffer is a terminal buffer
Sourcepub fn get_terminal_id(&self, buffer_id: BufferId) -> Option<TerminalId>
pub fn get_terminal_id(&self, buffer_id: BufferId) -> Option<TerminalId>
Get the terminal ID for a buffer (if it’s a terminal buffer)
Sourcepub fn get_active_terminal_state(&self) -> Option<MutexGuard<'_, TerminalState>>
pub fn get_active_terminal_state(&self) -> Option<MutexGuard<'_, TerminalState>>
Get the terminal state for the active buffer (if it’s a terminal buffer)
Sourcepub fn send_terminal_input(&mut self, data: &[u8])
pub fn send_terminal_input(&mut self, data: &[u8])
Send input to the active terminal
Sourcepub fn send_terminal_key(&mut self, code: KeyCode, modifiers: KeyModifiers)
pub fn send_terminal_key(&mut self, code: KeyCode, modifiers: KeyModifiers)
Send a key event to the active terminal
Sourcepub fn send_terminal_mouse(
&mut self,
col: u16,
row: u16,
kind: TerminalMouseEventKind,
modifiers: KeyModifiers,
)
pub fn send_terminal_mouse( &mut self, col: u16, row: u16, kind: TerminalMouseEventKind, modifiers: KeyModifiers, )
Send a mouse event to the active terminal
Sourcepub fn is_terminal_in_alternate_screen(&self, buffer_id: BufferId) -> bool
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.
Sourcepub fn resize_terminal(&mut self, buffer_id: BufferId, cols: u16, rows: u16)
pub fn resize_terminal(&mut self, buffer_id: BufferId, cols: u16, rows: u16)
Resize terminal to match split dimensions
Sourcepub fn resize_visible_terminals(&mut self)
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.)
Sourcepub fn handle_terminal_key(
&mut self,
code: KeyCode,
modifiers: KeyModifiers,
) -> bool
pub fn handle_terminal_key( &mut self, code: KeyCode, modifiers: KeyModifiers, ) -> bool
Handle terminal input when in terminal mode
Sourcepub fn sync_terminal_to_buffer(&mut self, buffer_id: BufferId)
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:
- Scrollback has already been streamed to the backing file during PTY reads
- We just append the visible screen (~50 lines) to the backing file
- Reload the buffer from the backing file (lazy load for large files)
Performance: O(screen_size) instead of O(total_history)
Sourcepub fn enter_terminal_mode(&mut self)
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.
Sourcepub fn get_terminal_content(
&self,
buffer_id: BufferId,
) -> Option<Vec<Vec<TerminalCell>>>
pub fn get_terminal_content( &self, buffer_id: BufferId, ) -> Option<Vec<Vec<TerminalCell>>>
Get terminal content for rendering
Source§impl Editor
impl Editor
Sourcepub fn is_terminal_mode(&self) -> bool
pub fn is_terminal_mode(&self) -> bool
Check if terminal mode is active (for testing)
Sourcepub fn is_in_terminal_mode_resume(&self, buffer_id: BufferId) -> bool
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)
Sourcepub fn is_keyboard_capture(&self) -> bool
pub fn is_keyboard_capture(&self) -> bool
Check if keyboard capture is enabled in terminal mode (for testing)
Sourcepub fn set_terminal_jump_to_end_on_output(&mut self, value: bool)
pub fn set_terminal_jump_to_end_on_output(&mut self, value: bool)
Set terminal jump_to_end_on_output config option (for testing)
Sourcepub fn terminal_manager(&self) -> &TerminalManager
pub fn terminal_manager(&self) -> &TerminalManager
Get read-only access to the terminal manager (for testing)
Sourcepub fn terminal_backing_files(&self) -> &HashMap<TerminalId, PathBuf>
pub fn terminal_backing_files(&self) -> &HashMap<TerminalId, PathBuf>
Get read-only access to terminal backing files map (for testing)
Sourcepub fn active_buffer_id(&self) -> BufferId
pub fn active_buffer_id(&self) -> BufferId
Get the currently active buffer ID
Sourcepub fn get_buffer_content(&self, buffer_id: BufferId) -> Option<String>
pub fn get_buffer_content(&self, buffer_id: BufferId) -> Option<String>
Get buffer content as a string (for testing)
Sourcepub fn get_cursor_position(&self, buffer_id: BufferId) -> Option<usize>
pub fn get_cursor_position(&self, buffer_id: BufferId) -> Option<usize>
Get cursor position for a buffer (for testing)
Sourcepub fn render_terminal_splits(
&self,
frame: &mut Frame<'_>,
split_areas: &[(LeafId, BufferId, Rect, Rect, usize, usize)],
)
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
impl Editor
Sourcepub fn toggle_scroll_sync(&mut self)
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.
pub fn toggle_line_numbers(&mut self)
Sourcepub fn toggle_debug_highlights(&mut self)
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
Toggle menu bar visibility
Sourcepub fn toggle_tab_bar(&mut self)
pub fn toggle_tab_bar(&mut self)
Toggle tab bar visibility
Sourcepub fn tab_bar_visible(&self) -> bool
pub fn tab_bar_visible(&self) -> bool
Get tab bar visibility
Sourcepub fn toggle_status_bar(&mut self)
pub fn toggle_status_bar(&mut self)
Toggle status bar visibility
Sourcepub fn status_bar_visible(&self) -> bool
pub fn status_bar_visible(&self) -> bool
Get status bar visibility
Sourcepub fn toggle_prompt_line(&mut self)
pub fn toggle_prompt_line(&mut self)
Toggle prompt line visibility
Sourcepub fn prompt_line_visible(&self) -> bool
pub fn prompt_line_visible(&self) -> bool
Get prompt line visibility
Sourcepub fn toggle_vertical_scrollbar(&mut self)
pub fn toggle_vertical_scrollbar(&mut self)
Toggle vertical scrollbar visibility
Sourcepub fn toggle_horizontal_scrollbar(&mut self)
pub fn toggle_horizontal_scrollbar(&mut self)
Toggle horizontal scrollbar visibility
Sourcepub fn reset_buffer_settings(&mut self)
pub fn reset_buffer_settings(&mut self)
Reset buffer settings (tab_size, use_tabs, auto_close, whitespace visibility) to config defaults
Sourcepub fn toggle_mouse_capture(&mut self)
pub fn toggle_mouse_capture(&mut self)
Toggle mouse capture on/off
Sourcepub fn is_mouse_enabled(&self) -> bool
pub fn is_mouse_enabled(&self) -> bool
Check if mouse capture is enabled
Sourcepub fn toggle_mouse_hover(&mut self)
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.
Sourcepub fn is_mouse_hover_enabled(&self) -> bool
pub fn is_mouse_hover_enabled(&self) -> bool
Check if mouse hover is enabled
Sourcepub fn set_gpm_active(&mut self, active: bool)
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.
Sourcepub fn toggle_inlay_hints(&mut self)
pub fn toggle_inlay_hints(&mut self)
Toggle inlay hints visibility
Sourcepub fn dump_config(&mut self)
pub fn dump_config(&mut self)
Dump the current configuration to the user’s config file
Sourcepub fn save_config(&self) -> Result<(), String>
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
Sourcepub fn reload_config(&mut self)
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.
Sourcepub fn reload_themes(&mut self)
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
impl Editor
Sourcepub fn handle_undo(&mut self)
pub fn handle_undo(&mut self)
Handle Undo action - revert the last edit operation.
Sourcepub fn handle_redo(&mut self)
pub fn handle_redo(&mut self)
Handle Redo action - reapply an undone edit operation.
Source§impl Editor
impl Editor
Sourcepub fn handle_toggle_page_view(&mut self)
pub fn handle_toggle_page_view(&mut self)
Toggle between Compose and Source view modes.
Source§impl Editor
impl Editor
Sourcepub fn capture_workspace(&self) -> Workspace
pub fn capture_workspace(&self) -> Workspace
Capture current editor state into a Workspace
Sourcepub fn save_workspace(&mut self) -> Result<(), WorkspaceError>
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).
Sourcepub fn try_restore_workspace(&mut self) -> Result<bool, WorkspaceError>
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.
Sourcepub fn apply_hot_exit_recovery(&mut self) -> Result<usize>
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.
Sourcepub fn apply_workspace(
&mut self,
workspace: &Workspace,
) -> Result<(), WorkspaceError>
pub fn apply_workspace( &mut self, workspace: &Workspace, ) -> Result<(), WorkspaceError>
Apply a loaded workspace to the editor
Source§impl Editor
impl Editor
Sourcepub fn new(
config: Config,
width: u16,
height: u16,
dir_context: DirectoryContext,
color_capability: ColorCapability,
filesystem: Arc<dyn FileSystem + Send + Sync>,
) -> AnyhowResult<Self>
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.)
Sourcepub 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>
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
Sourcepub 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>
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.
Sourcepub fn event_broadcaster(&self) -> &EventBroadcaster
pub fn event_broadcaster(&self) -> &EventBroadcaster
Get a reference to the event broadcaster
Sourcepub fn async_bridge(&self) -> Option<&AsyncBridge>
pub fn async_bridge(&self) -> Option<&AsyncBridge>
Get a reference to the async bridge (if available)
Sourcepub fn key_translator(&self) -> &KeyTranslator
pub fn key_translator(&self) -> &KeyTranslator
Get a reference to the key translator (for input calibration)
Sourcepub fn time_source(&self) -> &SharedTimeSource
pub fn time_source(&self) -> &SharedTimeSource
Get a reference to the time source
Sourcepub fn emit_event(&self, name: impl Into<String>, data: Value)
pub fn emit_event(&self, name: impl Into<String>, data: Value)
Emit a control event
Sourcepub fn get_all_keybindings(&self) -> Vec<(String, String)>
pub fn get_all_keybindings(&self) -> Vec<(String, String)>
Get all keybindings as (key, action) pairs
Sourcepub fn get_keybinding_for_action(&self, action_name: &str) -> Option<String>
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
Sourcepub fn mode_registry_mut(&mut self) -> &mut ModeRegistry
pub fn mode_registry_mut(&mut self) -> &mut ModeRegistry
Get mutable access to the mode registry
Sourcepub fn mode_registry(&self) -> &ModeRegistry
pub fn mode_registry(&self) -> &ModeRegistry
Get immutable access to the mode registry
Sourcepub fn active_buffer(&self) -> BufferId
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.
Sourcepub fn active_buffer_mode(&self) -> Option<&str>
pub fn active_buffer_mode(&self) -> Option<&str>
Get the mode name for the active buffer (if it’s a virtual buffer)
Sourcepub fn is_active_buffer_read_only(&self) -> bool
pub fn is_active_buffer_read_only(&self) -> bool
Check if the active buffer is read-only
Sourcepub fn is_editing_disabled(&self) -> bool
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)
Sourcepub fn mark_buffer_read_only(&mut self, buffer_id: BufferId, read_only: bool)
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.
Sourcepub fn effective_mode(&self) -> Option<&str>
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.
Sourcepub fn has_active_lsp_progress(&self) -> bool
pub fn has_active_lsp_progress(&self) -> bool
Check if LSP has any active progress tasks (e.g., indexing)
Sourcepub fn get_lsp_progress(&self) -> Vec<(String, String, Option<String>)>
pub fn get_lsp_progress(&self) -> Vec<(String, String, Option<String>)>
Get the current LSP progress info (if any)
Sourcepub fn is_lsp_server_ready(&self, language: &str) -> bool
pub fn is_lsp_server_ready(&self, language: &str) -> bool
Check if any LSP server for a given language is running (ready)
Sourcepub fn get_lsp_status(&self) -> &str
pub fn get_lsp_status(&self) -> &str
Get the LSP status string (displayed in status bar)
Sourcepub fn get_stored_diagnostics(&self) -> &HashMap<String, Vec<Diagnostic>>
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
Sourcepub fn is_update_available(&self) -> bool
pub fn is_update_available(&self) -> bool
Check if an update is available
Sourcepub fn latest_version(&self) -> Option<&str>
pub fn latest_version(&self) -> Option<&str>
Get the latest version string if an update is available
Sourcepub fn get_update_result(&self) -> Option<&ReleaseCheckResult>
pub fn get_update_result(&self) -> Option<&ReleaseCheckResult>
Get the cached release check result (for shutdown notification)
Sourcepub fn set_lsp_config(&mut self, language: String, config: Vec<LspServerConfig>)
pub fn set_lsp_config(&mut self, language: String, config: Vec<LspServerConfig>)
Configure LSP server for a specific language
Sourcepub fn running_lsp_servers(&self) -> Vec<String>
pub fn running_lsp_servers(&self) -> Vec<String>
Get a list of currently running LSP server languages
Sourcepub fn pending_completion_requests_count(&self) -> usize
pub fn pending_completion_requests_count(&self) -> usize
Return the number of pending completion requests.
Sourcepub fn completion_items_count(&self) -> usize
pub fn completion_items_count(&self) -> usize
Return the number of stored completion items.
Sourcepub fn initialized_lsp_server_count(&self, language: &str) -> usize
pub fn initialized_lsp_server_count(&self, language: &str) -> usize
Return the number of initialized LSP servers for a given language.
Sourcepub fn shutdown_lsp_server(&mut self, language: &str) -> bool
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
Sourcepub fn enable_event_streaming<P: AsRef<Path>>(
&mut self,
path: P,
) -> AnyhowResult<()>
pub fn enable_event_streaming<P: AsRef<Path>>( &mut self, path: P, ) -> AnyhowResult<()>
Enable event log streaming to a file
Sourcepub fn log_keystroke(&mut self, key_code: &str, modifiers: &str)
pub fn log_keystroke(&mut self, key_code: &str, modifiers: &str)
Log keystroke for debugging
Sourcepub fn set_warning_log(&mut self, receiver: Receiver<()>, path: PathBuf)
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.
Sourcepub fn set_status_log_path(&mut self, path: PathBuf)
pub fn set_status_log_path(&mut self, path: PathBuf)
Set the status message log path
Sourcepub fn set_process_spawner(&mut self, spawner: Arc<dyn ProcessSpawner>)
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
Sourcepub fn remote_connection_info(&self) -> Option<&str>
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.
Sourcepub fn get_status_log_path(&self) -> Option<&PathBuf>
pub fn get_status_log_path(&self) -> Option<&PathBuf>
Get the status log path
Sourcepub fn open_status_log(&mut self)
pub fn open_status_log(&mut self)
Open the status log file (user clicked on status message)
Sourcepub fn check_warning_log(&mut self) -> bool
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.
Sourcepub fn get_warning_domains(&self) -> &WarningDomainRegistry
pub fn get_warning_domains(&self) -> &WarningDomainRegistry
Get the warning domain registry
Sourcepub fn get_warning_log_path(&self) -> Option<&PathBuf>
pub fn get_warning_log_path(&self) -> Option<&PathBuf>
Get the warning log path (for opening when user clicks indicator)
Sourcepub fn open_warning_log(&mut self)
pub fn open_warning_log(&mut self)
Open the warning log file (user-initiated action)
Sourcepub fn clear_warning_indicator(&mut self)
pub fn clear_warning_indicator(&mut self)
Clear the general warning indicator (user dismissed)
Sourcepub fn clear_warnings(&mut self)
pub fn clear_warnings(&mut self)
Clear all warning indicators (user dismissed via command)
Sourcepub fn has_lsp_error(&self) -> bool
pub fn has_lsp_error(&self) -> bool
Check if any LSP server is in error state
Sourcepub fn get_effective_warning_level(&self) -> WarningLevel
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
Sourcepub fn get_general_warning_level(&self) -> WarningLevel
pub fn get_general_warning_level(&self) -> WarningLevel
Get the general warning level (for the general warning badge)
Sourcepub fn get_general_warning_count(&self) -> usize
pub fn get_general_warning_count(&self) -> usize
Get the general warning count
Sourcepub fn update_lsp_warning_domain(&mut self)
pub fn update_lsp_warning_domain(&mut self)
Update LSP warning domain from server statuses
Sourcepub fn check_mouse_hover_timer(&mut self) -> bool
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.
Sourcepub fn check_semantic_highlight_timer(&self) -> bool
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.
Sourcepub fn check_diagnostic_pull_timer(&mut self) -> bool
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.
Sourcepub fn check_completion_trigger_timer(&mut self) -> bool
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.
Sourcepub fn active_state(&self) -> &EditorState
pub fn active_state(&self) -> &EditorState
Get the currently active buffer state
Sourcepub fn active_state_mut(&mut self) -> &mut EditorState
pub fn active_state_mut(&mut self) -> &mut EditorState
Get the currently active buffer state (mutable)
Sourcepub fn active_cursors(&self) -> &Cursors
pub fn active_cursors(&self) -> &Cursors
Get the cursors for the active buffer in the active split
Sourcepub fn active_cursors_mut(&mut self) -> &mut Cursors
pub fn active_cursors_mut(&mut self) -> &mut Cursors
Get the cursors for the active buffer in the active split (mutable)
Sourcepub fn set_completion_items(&mut self, items: Vec<CompletionItem>)
pub fn set_completion_items(&mut self, items: Vec<CompletionItem>)
Set completion items for type-to-filter (for testing)
Sourcepub fn active_viewport(&self) -> &Viewport
pub fn active_viewport(&self) -> &Viewport
Get the viewport for the active split
Sourcepub fn active_viewport_mut(&mut self) -> &mut Viewport
pub fn active_viewport_mut(&mut self) -> &mut Viewport
Get the viewport for the active split (mutable)
Sourcepub fn get_buffer_display_name(&self, buffer_id: BufferId) -> String
pub fn get_buffer_display_name(&self, buffer_id: BufferId) -> String
Get the display name for a buffer (filename or virtual buffer name)
Sourcepub fn log_and_apply_event(&mut self, event: &Event)
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.
pub fn apply_event_to_active_buffer(&mut self, event: &Event)
Sourcepub fn apply_events_as_bulk_edit(
&mut self,
events: Vec<Event>,
description: String,
) -> Option<Event>
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:
- Converting events to (position, delete_len, insert_text) tuples
- Applying all edits in a single tree pass via apply_bulk_edits
- 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
Sourcepub fn active_event_log(&self) -> &EventLog
pub fn active_event_log(&self) -> &EventLog
Get the event log for the active buffer
Sourcepub fn active_event_log_mut(&mut self) -> &mut EventLog
pub fn active_event_log_mut(&mut self) -> &mut EventLog
Get the event log for the active buffer (mutable)
Sourcepub fn should_quit(&self) -> bool
pub fn should_quit(&self) -> bool
Check if the editor should quit
Sourcepub fn should_detach(&self) -> bool
pub fn should_detach(&self) -> bool
Check if the client should detach (keep server running)
Sourcepub fn clear_detach(&mut self)
pub fn clear_detach(&mut self)
Clear the detach flag (after processing)
Sourcepub fn set_session_mode(&mut self, session_mode: bool)
pub fn set_session_mode(&mut self, session_mode: bool)
Set session mode (use hardware cursor only, no REVERSED style for software cursor)
Sourcepub fn is_session_mode(&self) -> bool
pub fn is_session_mode(&self) -> bool
Check if running in session mode
Sourcepub fn set_software_cursor_only(&mut self, enabled: bool)
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.
Sourcepub fn set_session_name(&mut self, name: Option<String>)
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.
Sourcepub fn session_name(&self) -> Option<&str>
pub fn session_name(&self) -> Option<&str>
Get the session name (for status bar display)
Sourcepub fn queue_escape_sequences(&mut self, sequences: &[u8])
pub fn queue_escape_sequences(&mut self, sequences: &[u8])
Queue escape sequences to be sent to the client (session mode only)
Sourcepub fn take_pending_escape_sequences(&mut self) -> Vec<u8> ⓘ
pub fn take_pending_escape_sequences(&mut self) -> Vec<u8> ⓘ
Take pending escape sequences, clearing the queue
Sourcepub fn take_pending_clipboard(&mut self) -> Option<PendingClipboard>
pub fn take_pending_clipboard(&mut self) -> Option<PendingClipboard>
Take pending clipboard data queued in session mode, clearing the request
Sourcepub fn should_restart(&self) -> bool
pub fn should_restart(&self) -> bool
Check if the editor should restart with a new working directory
Sourcepub fn take_restart_dir(&mut self) -> Option<PathBuf>
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
Sourcepub fn request_full_redraw(&mut self)
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.
Sourcepub fn take_full_redraw_request(&mut self) -> bool
pub fn take_full_redraw_request(&mut self) -> bool
Check if a full redraw was requested, and clear the flag.
pub fn request_restart(&mut self, new_working_dir: PathBuf)
Sourcepub fn is_settings_open(&self) -> bool
pub fn is_settings_open(&self) -> bool
Check if the settings dialog is open and visible
Sourcepub fn focus_gained(&mut self)
pub fn focus_gained(&mut self)
Handle terminal focus gained event
Sourcepub fn resize(&mut self, width: u16, height: u16)
pub fn resize(&mut self, width: u16, height: u16)
Resize all buffers to match new terminal size
Sourcepub fn start_prompt(&mut self, message: String, prompt_type: PromptType)
pub fn start_prompt(&mut self, message: String, prompt_type: PromptType)
Start a new prompt (enter minibuffer mode)
Sourcepub fn start_prompt_with_suggestions(
&mut self,
message: String,
prompt_type: PromptType,
suggestions: Vec<Suggestion>,
)
pub fn start_prompt_with_suggestions( &mut self, message: String, prompt_type: PromptType, suggestions: Vec<Suggestion>, )
Start a new prompt with autocomplete suggestions
Sourcepub fn start_prompt_with_initial_text(
&mut self,
message: String,
prompt_type: PromptType,
initial_text: String,
)
pub fn start_prompt_with_initial_text( &mut self, message: String, prompt_type: PromptType, initial_text: String, )
Start a new prompt with initial text
Sourcepub fn start_quick_open(&mut self)
pub fn start_quick_open(&mut self)
Start Quick Open prompt with command palette as default
Sourcepub fn change_working_dir(&mut self, new_path: PathBuf)
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
Sourcepub fn cancel_prompt(&mut self)
pub fn cancel_prompt(&mut self)
Cancel the current prompt and return to normal mode
Sourcepub fn handle_prompt_scroll(&mut self, delta: i32) -> bool
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.
Sourcepub fn confirm_prompt(&mut self) -> Option<(String, PromptType, Option<usize>)>
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
Sourcepub fn is_prompting(&self) -> bool
pub fn is_prompting(&self) -> bool
Check if currently in prompt mode
Sourcepub fn editor_mode(&self) -> Option<String>
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
Sourcepub fn command_registry(&self) -> &Arc<RwLock<CommandRegistry>>
pub fn command_registry(&self) -> &Arc<RwLock<CommandRegistry>>
Get access to the command registry
Sourcepub fn plugin_manager(&self) -> &PluginManager
pub fn plugin_manager(&self) -> &PluginManager
Get access to the plugin manager
Sourcepub fn plugin_manager_mut(&mut self) -> &mut PluginManager
pub fn plugin_manager_mut(&mut self) -> &mut PluginManager
Get mutable access to the plugin manager
Sourcepub fn file_explorer_is_focused(&self) -> bool
pub fn file_explorer_is_focused(&self) -> bool
Check if file explorer has focus
Sourcepub fn prompt_input(&self) -> Option<&str>
pub fn prompt_input(&self) -> Option<&str>
Get current prompt input (for display)
Sourcepub fn has_active_selection(&self) -> bool
pub fn has_active_selection(&self) -> bool
Check if the active cursor currently has a selection
Sourcepub fn prompt_mut(&mut self) -> Option<&mut Prompt>
pub fn prompt_mut(&mut self) -> Option<&mut Prompt>
Get mutable reference to prompt (for input handling)
Sourcepub fn set_status_message(&mut self, message: String)
pub fn set_status_message(&mut self, message: String)
Set a status message to display in the status bar
Sourcepub fn get_status_message(&self) -> Option<&String>
pub fn get_status_message(&self) -> Option<&String>
Get the current status message
Sourcepub fn get_plugin_errors(&self) -> &[String]
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
Sourcepub fn clear_plugin_errors(&mut self)
pub fn clear_plugin_errors(&mut self)
Clear accumulated plugin errors
Sourcepub fn update_prompt_suggestions(&mut self)
pub fn update_prompt_suggestions(&mut self)
Update prompt suggestions based on current input
Sourcepub fn process_async_messages(&mut self) -> bool
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
Sourcepub fn handle_plugin_command(
&mut self,
command: PluginCommand,
) -> AnyhowResult<()>
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
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>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
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)
fn as_any(&self) -> &(dyn Any + 'static)
&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)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&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> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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 moreSource§impl<D> OwoColorize for D
impl<D> OwoColorize for D
Source§fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
Source§fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
Source§fn black(&self) -> FgColorDisplay<'_, Black, Self>
fn black(&self) -> FgColorDisplay<'_, Black, Self>
Source§fn on_black(&self) -> BgColorDisplay<'_, Black, Self>
fn on_black(&self) -> BgColorDisplay<'_, Black, Self>
Source§fn red(&self) -> FgColorDisplay<'_, Red, Self>
fn red(&self) -> FgColorDisplay<'_, Red, Self>
Source§fn on_red(&self) -> BgColorDisplay<'_, Red, Self>
fn on_red(&self) -> BgColorDisplay<'_, Red, Self>
Source§fn green(&self) -> FgColorDisplay<'_, Green, Self>
fn green(&self) -> FgColorDisplay<'_, Green, Self>
Source§fn on_green(&self) -> BgColorDisplay<'_, Green, Self>
fn on_green(&self) -> BgColorDisplay<'_, Green, Self>
Source§fn yellow(&self) -> FgColorDisplay<'_, Yellow, Self>
fn yellow(&self) -> FgColorDisplay<'_, Yellow, Self>
Source§fn on_yellow(&self) -> BgColorDisplay<'_, Yellow, Self>
fn on_yellow(&self) -> BgColorDisplay<'_, Yellow, Self>
Source§fn blue(&self) -> FgColorDisplay<'_, Blue, Self>
fn blue(&self) -> FgColorDisplay<'_, Blue, Self>
Source§fn on_blue(&self) -> BgColorDisplay<'_, Blue, Self>
fn on_blue(&self) -> BgColorDisplay<'_, Blue, Self>
Source§fn magenta(&self) -> FgColorDisplay<'_, Magenta, Self>
fn magenta(&self) -> FgColorDisplay<'_, Magenta, Self>
Source§fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>
fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>
Source§fn purple(&self) -> FgColorDisplay<'_, Magenta, Self>
fn purple(&self) -> FgColorDisplay<'_, Magenta, Self>
Source§fn on_purple(&self) -> BgColorDisplay<'_, Magenta, Self>
fn on_purple(&self) -> BgColorDisplay<'_, Magenta, Self>
Source§fn cyan(&self) -> FgColorDisplay<'_, Cyan, Self>
fn cyan(&self) -> FgColorDisplay<'_, Cyan, Self>
Source§fn on_cyan(&self) -> BgColorDisplay<'_, Cyan, Self>
fn on_cyan(&self) -> BgColorDisplay<'_, Cyan, Self>
Source§fn white(&self) -> FgColorDisplay<'_, White, Self>
fn white(&self) -> FgColorDisplay<'_, White, Self>
Source§fn on_white(&self) -> BgColorDisplay<'_, White, Self>
fn on_white(&self) -> BgColorDisplay<'_, White, Self>
Source§fn default_color(&self) -> FgColorDisplay<'_, Default, Self>
fn default_color(&self) -> FgColorDisplay<'_, Default, Self>
Source§fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>
fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>
Source§fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>
fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>
Source§fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>
fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>
Source§fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>
fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>
Source§fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>
fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>
Source§fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>
fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>
Source§fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>
fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>
Source§fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>
fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>
Source§fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>
fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>
Source§fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>
fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>
Source§fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>
fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>
Source§fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
Source§fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
Source§fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
Source§fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
Source§fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>
fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>
Source§fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>
fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>
Source§fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>
fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>
Source§fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>
fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>
Source§fn bold(&self) -> BoldDisplay<'_, Self>
fn bold(&self) -> BoldDisplay<'_, Self>
Source§fn dimmed(&self) -> DimDisplay<'_, Self>
fn dimmed(&self) -> DimDisplay<'_, Self>
Source§fn italic(&self) -> ItalicDisplay<'_, Self>
fn italic(&self) -> ItalicDisplay<'_, Self>
Source§fn underline(&self) -> UnderlineDisplay<'_, Self>
fn underline(&self) -> UnderlineDisplay<'_, Self>
Source§fn blink(&self) -> BlinkDisplay<'_, Self>
fn blink(&self) -> BlinkDisplay<'_, Self>
Source§fn blink_fast(&self) -> BlinkFastDisplay<'_, Self>
fn blink_fast(&self) -> BlinkFastDisplay<'_, Self>
Source§fn reversed(&self) -> ReversedDisplay<'_, Self>
fn reversed(&self) -> ReversedDisplay<'_, Self>
Source§fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>
fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>
Source§fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
OwoColorize::fg or
a color-specific method, such as OwoColorize::green, Read moreSource§fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
OwoColorize::bg or
a color-specific method, such as OwoColorize::on_yellow, Read more