pub struct ChatEditor {
pub editor: Editor,
/* private fields */
}Expand description
Rab-specific chat editor that wraps the core tui::Editor.
Mirrors pi’s CustomEditor pattern: ChatEditor handles keyboard input and dispatches app-level actions (escape, submit, model selector, etc.) as an InputAction enum, while text-editing keys are delegated to the inner Editor. The app layer matches on InputAction to perform side effects.
Key differences from pi’s CustomEditor:
- Text-editing keys (Ctrl+Z undo, Ctrl+J newline, Up/Down history, Tab, PageUp/PageDown, etc.) are delegated entirely to the inner Editor, matching pi’s editor-centric handling.
- Only app-level keybindings (interrupt, exit, model selector, help, etc.) are intercepted here.
Fields§
§editor: EditorImplementations§
Source§impl ChatEditor
impl ChatEditor
pub fn new(_theme: &dyn Theme, cwd: PathBuf) -> Self
Sourcepub fn set_slash_commands(&mut self, commands: Vec<SlashCommand>)
pub fn set_slash_commands(&mut self, commands: Vec<SlashCommand>)
Set the available slash commands for autocomplete.
Sourcepub fn set_extension_shortcut_handler(
&mut self,
handler: Box<dyn FnMut(&KeyEvent) -> bool + Send>,
)
pub fn set_extension_shortcut_handler( &mut self, handler: Box<dyn FnMut(&KeyEvent) -> bool + Send>, )
Set a handler for extension-registered shortcuts (pi-style). The handler receives the key event and returns true if the key was handled.
Sourcepub fn on_action(&mut self, action: &str, handler: Box<dyn FnMut() + Send>)
pub fn on_action(&mut self, action: &str, handler: Box<dyn FnMut() + Send>)
Register a dynamic app action handler (pi-style).
When the keybinding for action is pressed, handler is called.
Does NOT override built-in actions (Escape, Ctrl+C, Ctrl+D, Enter).
Sourcepub fn check_autocomplete(&mut self)
pub fn check_autocomplete(&mut self)
After programmatic set_text, trigger autocomplete check (pi-style).
Sourcepub fn update_border_color(
&mut self,
thinking_level: Option<&str>,
theme: &dyn Theme,
)
pub fn update_border_color( &mut self, thinking_level: Option<&str>, theme: &dyn Theme, )
Handle keyboard input. Mirrors pi’s CustomEditor.handleInput:
- Checks app-level keys (escape, clear, submit, model selector, etc.) and returns the corresponding InputAction for the app layer to handle.
- All other keys are delegated to the inner Editor for text editing, including Ctrl+Z (undo), Ctrl+J (newline), Up/Down (history), Tab (autocomplete), PageUp/PageDown (scroll), etc.
This keeps app-level side effects (aborting agent, opening overlays, etc.)
in the app layer while keeping text-editing logic in the Editor component.
Update editor border color based on thinking level or bash mode.
Matches pi’s updateEditorBorderColor().
- Bash mode (text starts with
!): usesbashModecolor - Otherwise: uses thinking level color (
thinkingOff..thinkingXhigh)