Skip to content

Commit 6a36881

Browse files
committed
chore: add some functions for Listbox
1 parent 584743a commit 6a36881

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

promkit/src/core/listbox.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,14 @@ impl Listbox {
3333
))
3434
}
3535

36+
pub fn len(&self) -> usize {
37+
self.0.contents().len()
38+
}
39+
40+
pub fn push_string(&mut self, item: String) {
41+
self.0.contents_mut().push(StyledGraphemes::from(item));
42+
}
43+
3644
/// Creates a new `Listbox` from a vector of `StyledGraphemes`.
3745
pub fn from_styled_graphemes(items: Vec<StyledGraphemes>) -> Self {
3846
Self(Cursor::new(items, 0, false))
@@ -79,4 +87,8 @@ impl Listbox {
7987
pub fn move_to_tail(&mut self) {
8088
self.0.move_to_tail()
8189
}
90+
91+
pub fn is_tail(&self) -> bool {
92+
self.0.is_tail()
93+
}
8294
}

0 commit comments

Comments
 (0)