From 6a36881323ec492fa5b681d7115640a3285b8d44 Mon Sep 17 00:00:00 2001 From: ynqa Date: Mon, 23 Dec 2024 00:10:07 +0900 Subject: [PATCH] chore: add some functions for Listbox --- promkit/src/core/listbox.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/promkit/src/core/listbox.rs b/promkit/src/core/listbox.rs index 19b74717..e3af8fdc 100644 --- a/promkit/src/core/listbox.rs +++ b/promkit/src/core/listbox.rs @@ -33,6 +33,14 @@ impl Listbox { )) } + pub fn len(&self) -> usize { + 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) -> Self { Self(Cursor::new(items, 0, false)) @@ -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() + } }