pub struct Editor<H: Helper> { /* private fields */ }
Expand description
Line editor
Implementations§
Source§impl<H: Helper> Editor<H>
impl<H: Helper> Editor<H>
Sourcepub fn with_config(config: Config) -> Editor<H>
pub fn with_config(config: Config) -> Editor<H>
Create an editor with a specific configuration.
Sourcepub fn readline(&mut self, prompt: &str) -> Result<String>
pub fn readline(&mut self, prompt: &str) -> Result<String>
This method will read a line from STDIN and will display a prompt
.
It uses terminal-style interaction if stdin
is connected to a
terminal.
Otherwise (e.g., if stdin
is a pipe or the terminal is not supported),
it uses file-style interaction.
Sourcepub fn readline_with_initial(
&mut self,
prompt: &str,
initial: (&str, &str),
) -> Result<String>
pub fn readline_with_initial( &mut self, prompt: &str, initial: (&str, &str), ) -> Result<String>
This function behaves in the exact same manner as readline
, except
that it pre-populates the input area.
The text that resides in the input area is given as a 2-tuple. The string on the left of the tuple is what will appear to the left of the cursor and the string on the right is what will appear to the right of the cursor.
Sourcepub fn load_history<P: AsRef<Path> + ?Sized>(&mut self, path: &P) -> Result<()>
pub fn load_history<P: AsRef<Path> + ?Sized>(&mut self, path: &P) -> Result<()>
Load the history from the specified file.
Sourcepub fn save_history<P: AsRef<Path> + ?Sized>(&self, path: &P) -> Result<()>
pub fn save_history<P: AsRef<Path> + ?Sized>(&self, path: &P) -> Result<()>
Save the history in the specified file.
Sourcepub fn add_history_entry<S: AsRef<str> + Into<String>>(
&mut self,
line: S,
) -> bool
pub fn add_history_entry<S: AsRef<str> + Into<String>>( &mut self, line: S, ) -> bool
Add a new entry in the history.
Sourcepub fn clear_history(&mut self)
pub fn clear_history(&mut self)
Clear history.
Sourcepub fn history_mut(&mut self) -> &mut History
pub fn history_mut(&mut self) -> &mut History
Return a mutable reference to the history object.
Sourcepub fn set_helper(&mut self, helper: Option<H>)
pub fn set_helper(&mut self, helper: Option<H>)
Register a callback function to be called for tab-completion or to show hints to the user at the right of the prompt.
Sourcepub fn helper_mut(&mut self) -> Option<&mut H>
pub fn helper_mut(&mut self) -> Option<&mut H>
Return a mutable reference to the helper.
Sourcepub fn bind_sequence(&mut self, key_seq: KeyPress, cmd: Cmd) -> Option<Cmd>
pub fn bind_sequence(&mut self, key_seq: KeyPress, cmd: Cmd) -> Option<Cmd>
Bind a sequence to a command.
Sourcepub fn unbind_sequence(&mut self, key_seq: KeyPress) -> Option<Cmd>
pub fn unbind_sequence(&mut self, key_seq: KeyPress) -> Option<Cmd>
Remove a binding for the given sequence.
Trait Implementations§
Source§impl<H: Helper> Configurer for Editor<H>
impl<H: Helper> Configurer for Editor<H>
fn config_mut(&mut self) -> &mut Config
Source§fn set_max_history_size(&mut self, max_size: usize)
fn set_max_history_size(&mut self, max_size: usize)
Source§fn set_history_ignore_dups(&mut self, yes: bool)
fn set_history_ignore_dups(&mut self, yes: bool)
Source§fn set_history_ignore_space(&mut self, yes: bool)
fn set_history_ignore_space(&mut self, yes: bool)
Source§fn set_color_mode(&mut self, color_mode: ColorMode)
fn set_color_mode(&mut self, color_mode: ColorMode)
Source§fn set_completion_type(&mut self, completion_type: CompletionType)
fn set_completion_type(&mut self, completion_type: CompletionType)
completion_type
.