Struct linefeed::writer::PromptData
[−]
[src]
pub struct PromptData<'a, 'b: 'a> { /* fields omitted */ }
Enables modification of prompt input data before a call to read_line
.
Prompt data is reset when a read_line
call completes.
An instance of this type can be constructed using the
Reader::lock_prompt_data
method.
Methods
impl<'a, 'b: 'a> PromptData<'a, 'b>
[src]
pub fn buffer(&self) -> &str
[src]
Returns the current contents of the input buffer.
pub fn buffer_mut(&mut self) -> &mut String
[src]
Returns a mutable reference to the current input buffer.
Notes
To prevent invalidating the cursor, this method sets the cursor
position to 0
.
pub fn set_buffer(&mut self, s: &str)
[src]
Sets the input buffer to the given string.
Notes
To prevent invalidating the cursor, this method sets the cursor
position to 0
.
pub fn cursor(&self) -> usize
[src]
Returns the current cursor position.
pub fn set_cursor(&mut self, pos: usize)
[src]
Sets the cursor position in the input buffer.
Panics
If the given position is out of bounds or not on a char
boundary.
pub fn set_prompt(&mut self, prompt: &str)
[src]
Sets the prompt that will be displayed when read_line
is called.
Notes
If prompt
contains any terminal escape sequences (e.g. color codes),
such escape sequences should be immediately preceded by the character
'\x01'
and immediately followed by the character '\x02'
.