blob: 2769cf07ca3e7aa43fdba81d273a07b85531e683 [file] [log] [blame]
//! Completion API
/// To be called for tab-completion.
pub trait Completer {
/// Takes the currently edited `line` with the cursor `pos`ition and
/// returns the completion candidates for the partial word to be completed.
fn complete(&self, line: &str, pos: usize) -> Vec<String>;
/// Takes the currently edited `line` with the cursor `pos`ition and
/// the `elected` candidate.
/// Returns the new line content and cursor position.
fn update(&self, _line: &str, _pos: usize, elected: &str) -> (String, usize) {
// line completion (vs word completion)
(String::from(elected), elected.len())
}
}