pub struct MenuItem<'a> {
pub item: Cow<'a, str>,
pub highlight: Option<Range<usize>>,
pub navchar: Option<char>,
pub right: Cow<'a, str>,
pub disabled: bool,
pub separator: Option<Separator>,
pub non_exhaustive: NonExhaustive,
}Expand description
A menu item.
Fields§
§item: Cow<'a, str>Menuitem text
highlight: Option<Range<usize>>Text range to highlight. This is a byte-range into item.
Navigation key char.
right: Cow<'a, str>Right aligned text. To show the hotkey, or whatever. Hotkey handling is not included in this crate.
disabled: boolDisabled item.
separator: Option<Separator>Separator after the item.
non_exhaustive: NonExhaustiveImplementations§
Source§impl<'a> MenuItem<'a>
impl<'a> MenuItem<'a>
pub fn new() -> Self
Sourcepub fn new_parsed(s: &'a str) -> Self
pub fn new_parsed(s: &'a str) -> Self
Uses ‘_’ as special character.
Item
The first ‘_’ marks the navigation-char. Pipe ‘|’ separates the item text and the right text.
Separator
\\ (underscore) is used as prefix and then
a fixed string to identify the separator:
\\- three blanks -> empty separator\\___- three underscores -> plain line\\______- six underscore -> thick line\\===- three equals -> double line\\---- three hyphen -> dashed line\\...- three dots -> dotted line
Sourcepub fn new_string(text: String) -> Self
pub fn new_string(text: String) -> Self
New with owned string as item text.
New with navigation char and highlight. Highlight here is a byte range into the text.
New with navigation char and highlight. Highlight here is a byte range into the text.
Sourcepub fn new_sep(separator: Separator) -> Self
pub fn new_sep(separator: Separator) -> Self
New separator.
Such a menu item will be merged with the one before, unless you set some item-text later.
Sourcepub fn item_width(&self) -> u16
pub fn item_width(&self) -> u16
Text-width in graphemes for item.
Sourcepub fn right_width(&self) -> u16
pub fn right_width(&self) -> u16
Text-width in graphemes for right.
Trait Implementations§
Auto Trait Implementations§
impl<'a> Freeze for MenuItem<'a>
impl<'a> RefUnwindSafe for MenuItem<'a>
impl<'a> Send for MenuItem<'a>
impl<'a> Sync for MenuItem<'a>
impl<'a> Unpin for MenuItem<'a>
impl<'a> UnwindSafe for MenuItem<'a>
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