pub struct Readline { /* private fields */ }
Expand description
A struct representing a context for reading a line using libreadline.
Implementations§
source§impl Readline
impl Readline
sourcepub fn feed(&mut self, key: impl AsRef<[u8]>) -> Option<CString>
pub fn feed(&mut self, key: impl AsRef<[u8]>) -> Option<CString>
Feed a key to libreadline.
The provided buffer should comprise not more than a single key, which may be a single byte only or an escape sequence.
Panics
Panics if too many bytes are supplied. libreadline’s internal buffer is said to hold 512 bytes, so any slice of equal or greater size may cause a panic.
sourcepub fn reset<S>(&mut self, line: S, cursor: usize, clear_undo: bool)where
S: AsRef<CStr>,
pub fn reset<S>(&mut self, line: S, cursor: usize, clear_undo: bool)where S: AsRef<CStr>,
Reset libreadline’s line state to the given line with the given
cursor position. If clear_undo
is set, the undo list associated
with the current line is cleared
Note that this method does not deal with input related modes. For
example, libreadline always starts in input mode, but, depending
on user configuration, it can be transitioned to vi-movement-mode
in which key bindings behave differently (other similar modes
exist). When reseting the line using this method the input mode is
unaffected. If you truly need to manually force libreadline into
input mode, a new Readline
will help:
current = Readline::new();
Panics
Panics if the cursor is not less than or equal to the number of characters in the given line.