Skip to content

Commit

Permalink
chore: add some functions for Listbox
Browse files Browse the repository at this point in the history
  • Loading branch information
ynqa committed Dec 22, 2024
1 parent 584743a commit 6a36881
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions promkit/src/core/listbox.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,14 @@ impl Listbox {
))
}

pub fn len(&self) -> usize {

Check warning on line 36 in promkit/src/core/listbox.rs

View workflow job for this annotation

GitHub Actions / test

struct `Listbox` has a public `len` method, but no `is_empty` method
self.0.contents().len()
}

pub fn push_string(&mut self, item: String) {
self.0.contents_mut().push(StyledGraphemes::from(item));
}

/// Creates a new `Listbox` from a vector of `StyledGraphemes`.
pub fn from_styled_graphemes(items: Vec<StyledGraphemes>) -> Self {
Self(Cursor::new(items, 0, false))
Expand Down Expand Up @@ -79,4 +87,8 @@ impl Listbox {
pub fn move_to_tail(&mut self) {
self.0.move_to_tail()
}

pub fn is_tail(&self) -> bool {
self.0.is_tail()
}
}

0 comments on commit 6a36881

Please sign in to comment.