pub trait ReplHandler {
// Required methods
fn prompt(&self, is_continuation: bool) -> &str;
fn is_complete(&self, code: &str) -> bool;
fn handle_line(&mut self, line: &str) -> Result<HandleResult, ReplError>;
// Provided methods
fn highlight<'a>(&self, _code: &'a str) -> Option<HighlightResult<'a>> { ... }
fn get_indent(&self, _code: &str) -> usize { ... }
}Expand description
Interface for language integration in the REPL.
Required Methods§
Sourcefn prompt(&self, is_continuation: bool) -> &str
fn prompt(&self, is_continuation: bool) -> &str
The prompt to display. is_continuation is true for multi-line input.
Sourcefn is_complete(&self, code: &str) -> bool
fn is_complete(&self, code: &str) -> bool
Check if the input is complete (e.g., all brackets are closed). If it returns false, the REPL will enter multi-line input mode.
Sourcefn handle_line(&mut self, line: &str) -> Result<HandleResult, ReplError>
fn handle_line(&mut self, line: &str) -> Result<HandleResult, ReplError>
Execute the given line of code.
Provided Methods§
Sourcefn highlight<'a>(&self, _code: &'a str) -> Option<HighlightResult<'a>>
fn highlight<'a>(&self, _code: &'a str) -> Option<HighlightResult<'a>>
Get syntax highlighting for the given code.
Sourcefn get_indent(&self, _code: &str) -> usize
fn get_indent(&self, _code: &str) -> usize
Get the current indentation level for the next line in multi-line mode.