Struct unsegen::widget::builtin::promptline::PromptLine [−][src]
pub struct PromptLine { pub line: LineEdit, // some fields omitted }
Expand description
A widget implementing “readline”-like functionality.
Basically a more sophisticated version of LineEdit
with history.
Fields
line: LineEdit
Implementations
impl PromptLine
[src]
impl PromptLine
[src]pub fn with_prompt(prompt: String) -> Self
[src]
pub fn with_prompt(prompt: String) -> Self
[src]Construct a PromptLine with the given symbol that will be displayed left of the LineEdit
for user interaction.
pub fn set_prompt(&mut self, prompt: String)
[src]
pub fn set_prompt(&mut self, prompt: String)
[src]Change the symbol left of the user editable section (for editing, search and scrolling).
pub fn set_edit_prompt(&mut self, prompt: String)
[src]
pub fn set_edit_prompt(&mut self, prompt: String)
[src]Change the symbol left of the user editable section (only for edit operations).
pub fn set_search_prompt(&mut self, prompt: String)
[src]
pub fn set_search_prompt(&mut self, prompt: String)
[src]Change the symbol left of the user editable section (only while searching).
pub fn set_scroll_prompt(&mut self, prompt: String)
[src]
pub fn set_scroll_prompt(&mut self, prompt: String)
[src]Change the symbol left of the user editable section (only while scrolling).
pub fn previous_line(&self, n: usize) -> Option<&str>
[src]
pub fn previous_line(&self, n: usize) -> Option<&str>
[src]Get the n
’th line from the history.
pub fn active_line(&self) -> &str
[src]
pub fn active_line(&self) -> &str
[src]Get the current content of the LineEdit
pub fn finish_line(&mut self) -> &str
[src]
pub fn finish_line(&mut self) -> &str
[src]Mark the current content as “accepted”, e.g., if the user has entered and submitted a command.
This adds the current line to the front of the history buffer.
pub fn enter_search(&mut self)
[src]
pub fn enter_search(&mut self)
[src]Switch state to “searching”.
This means that that character inputs will instead be consumed for the search pattern and up/down naviation will cycle through matching items from the history.
Methods from Deref<Target = LineEdit>
pub fn set(&mut self, text: impl Into<String>)
[src]
pub fn set(&mut self, text: impl Into<String>)
[src]Set (and overwrite) the current content. The cursor will be placed at the very end of the line.
pub fn move_cursor_to_end_of_line(&mut self)
[src]
pub fn move_cursor_to_end_of_line(&mut self)
[src]Move the cursor to the end, i.e., behind the last grapheme cluster.
pub fn move_cursor_to_beginning_of_line(&mut self)
[src]
pub fn move_cursor_to_beginning_of_line(&mut self)
[src]Move the cursor to the beginning, i.e., onto the first grapheme cluster.
pub fn move_cursor_right(&mut self) -> Result<(), ()>
[src]
pub fn move_cursor_right(&mut self) -> Result<(), ()>
[src]Move the cursor one grapheme cluster to the right if possible.
pub fn move_cursor_left(&mut self) -> Result<(), ()>
[src]
pub fn move_cursor_left(&mut self) -> Result<(), ()>
[src]Move the cursor one grapheme cluster to the left if possible.
pub fn cursor_pos(&self) -> usize
[src]
pub fn cursor_pos(&self) -> usize
[src]Returns the byte position of the cursor in the current text (obtainable by get
)
pub fn set_cursor_pos(&mut self, pos: usize) -> Result<(), ()>
[src]
pub fn set_cursor_pos(&mut self, pos: usize) -> Result<(), ()>
[src]Set the cursor by specifying its position as the byte position in the displayed string.
If the byte position does not correspond to (the start of) a grapheme cluster in the string or the end of the string, an error is returned and the cursor position is left unchanged.
Examples:
use unsegen::widget::builtin::LineEdit; let mut l = LineEdit::new(); l.set("löl"); assert!(l.set_cursor_pos(0).is_ok()); // |löl assert!(l.set_cursor_pos(1).is_ok()); // l|öl assert!(l.set_cursor_pos(2).is_err()); assert!(l.set_cursor_pos(3).is_ok()); // lö|l assert!(l.set_cursor_pos(4).is_ok()); // löl| assert!(l.set_cursor_pos(5).is_err());
pub fn as_widget<'a>(&'a self) -> LineEditWidget<'a>
[src]
pub fn as_widget<'a>(&'a self) -> LineEditWidget<'a>
[src]Prepare for drawing as a Widget
.
Trait Implementations
impl Deref for PromptLine
[src]
impl Deref for PromptLine
[src]impl DerefMut for PromptLine
[src]
impl DerefMut for PromptLine
[src]impl Editable for PromptLine
[src]
impl Editable for PromptLine
[src]fn delete_forwards(&mut self) -> OperationResult
[src]
fn delete_forwards(&mut self) -> OperationResult
[src]In the sense of pressing the “Delete” key.
fn delete_backwards(&mut self) -> OperationResult
[src]
fn delete_backwards(&mut self) -> OperationResult
[src]In the sense of pressing the “Backspace” key.
fn go_to_beginning_of_line(&mut self) -> OperationResult
[src]
fn go_to_beginning_of_line(&mut self) -> OperationResult
[src]In the sense of pressing the “Home” key.
fn go_to_end_of_line(&mut self) -> OperationResult
[src]
fn go_to_end_of_line(&mut self) -> OperationResult
[src]In the sense of pressing the “End” key.
fn clear(&mut self) -> OperationResult
[src]
fn clear(&mut self) -> OperationResult
[src]Remove all content.
impl Navigatable for PromptLine
[src]
impl Navigatable for PromptLine
[src]fn move_up(&mut self) -> OperationResult
[src]
fn move_down(&mut self) -> OperationResult
[src]
fn move_left(&mut self) -> OperationResult
[src]
fn move_right(&mut self) -> OperationResult
[src]
impl Scrollable for PromptLine
[src]
impl Scrollable for PromptLine
[src]fn scroll_forwards(&mut self) -> OperationResult
[src]
fn scroll_backwards(&mut self) -> OperationResult
[src]
fn scroll_to_beginning(&mut self) -> OperationResult
[src]
fn scroll_to_end(&mut self) -> OperationResult
[src]
impl Writable for PromptLine
[src]
impl Writable for PromptLine
[src]fn write(&mut self, c: char) -> OperationResult
[src]
fn write(&mut self, c: char) -> OperationResult
[src]Process the provided char and report if it was processed successfully.