pub struct InputBar {
pub prefix: String,
pub buffer: String,
pub cursor: usize,
pub suggestions: Vec<Suggestion>,
pub selected: Option<usize>,
pub palette: Palette,
pub cursor_visible: bool,
}Expand description
Single-line text input + dropdown.
Fields§
§prefix: String§buffer: String§cursor: usizeByte index into Self::buffer where the next character would
be inserted. 0..=buffer.len() always; never points into the
middle of a UTF-8 codepoint.
suggestions: Vec<Suggestion>§selected: Option<usize>Index into Self::suggestions. None means “no selection,
Enter uses the typed buffer verbatim”.
palette: Palette§cursor_visible: boolCaller-managed cursor blink. Flip every 500ms or so.
Implementations§
Source§impl InputBar
impl InputBar
Sourcepub fn with_prefix(prefix: impl Into<String>) -> Self
pub fn with_prefix(prefix: impl Into<String>) -> Self
Build an empty input bar with the given prefix string.
Sourcepub fn current_value(&self) -> &str
pub fn current_value(&self) -> &str
What the caller should treat as the “confirmed value” on Enter.
If a suggestion is selected, returns its value; else returns
the raw buffer.
Sourcepub fn clear(&mut self)
pub fn clear(&mut self)
Reset to “empty + prefix only” state. Doesn’t clear the prefix itself — callers swap the widget for one with a new prefix when transitioning between command line / omnibar.
Sourcepub fn handle_text(&mut self, ch: char)
pub fn handle_text(&mut self, ch: char)
Insert ch at the cursor and advance.
Sourcepub fn handle_back(&mut self)
pub fn handle_back(&mut self)
Backspace — delete the codepoint before the cursor.
Sourcepub fn handle_delete_word(&mut self)
pub fn handle_delete_word(&mut self)
Delete the word before the cursor (<C-w>). A “word” is a run
of non-whitespace, optionally preceded by whitespace.
Sourcepub fn handle_clear_line(&mut self)
pub fn handle_clear_line(&mut self)
Clear the buffer entirely (<C-u>).
Sourcepub fn handle_left(&mut self)
pub fn handle_left(&mut self)
Move cursor one codepoint left.
Sourcepub fn handle_right(&mut self)
pub fn handle_right(&mut self)
Move cursor one codepoint right.
Sourcepub fn handle_up(&mut self)
pub fn handle_up(&mut self)
Move suggestion selection one row up. Wraps from 0 → no-op.
<Up> arrow / <S-Tab>.
Sourcepub fn handle_down(&mut self)
pub fn handle_down(&mut self)
Move suggestion selection one row down. <Down> / <Tab>.
Sourcepub fn set_suggestions(&mut self, suggestions: Vec<Suggestion>)
pub fn set_suggestions(&mut self, suggestions: Vec<Suggestion>)
Replace the suggestion list. Resets selected to None.
Sourcepub fn total_height(&self) -> u32
pub fn total_height(&self) -> u32
Total pixel height when fully expanded with n visible
suggestions, where n = min(suggestions.len(), MAX_SUGGESTIONS).
Used by the host to compute the CEF child rect.
Sourcepub fn paint(&self, buffer: &mut [u32], width: usize, height: usize)
pub fn paint(&self, buffer: &mut [u32], width: usize, height: usize)
Paint the input bar into the top INPUT_HEIGHT rows of
buffer, then any visible suggestion rows below that. Rows
below total_height() are left untouched — the caller has
either reserved that space or has nothing else to draw there.
Sourcepub fn paint_at(
&self,
buffer: &mut [u32],
buf_w: usize,
buf_h: usize,
x: usize,
y: usize,
w: usize,
h: usize,
)
pub fn paint_at( &self, buffer: &mut [u32], buf_w: usize, buf_h: usize, x: usize, y: usize, w: usize, h: usize, )
Paint into a sub-rectangle of the surface buffer. x, y, w, h
are pixel positions in the full surface (stride = buf_w). The bar
draws at the top of the rect; suggestions extend downward within it.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for InputBar
impl RefUnwindSafe for InputBar
impl Send for InputBar
impl Sync for InputBar
impl Unpin for InputBar
impl UnsafeUnpin for InputBar
impl UnwindSafe for InputBar
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more