pub struct ColorScheme { /* private fields */ }Expand description
colorscheme of the menu
combination of FontStyle
Implementations§
Source§impl ColorScheme
impl ColorScheme
pub fn new() -> Self
Sourcepub fn set_title_style(&mut self, style: FontStyle) -> &mut Self
pub fn set_title_style(&mut self, style: FontStyle) -> &mut Self
set the style of the title
Examples found in repository?
examples/complex.rs (lines 26-31)
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
fn main() {
let mut menu = Menu::new().unwrap_or_else(|e| {
quit_now!("Error: {}", e);
});
// build item list
let mut item_list = Vec::new();
for i in 1..=100 {
item_list.push(Item::new(format!("{}th item", i).as_str(), i));
}
// build colorscheme, you can skip this step to use the default colorscheme
// NOTE: sometimes your terminal might not support all the colors, so you may need to adjust
// the colorscheme
let mut colorscheme = termenu::ColorScheme::default();
colorscheme
.set_title_style(
FontStyle::default()
.set_shape(FontShape::Bold | FontShape::Underline)
.set_fg_color(colored::Color::Green)
.build(),
)
.set_query_style(FontStyle::default().set_shape(FontShape::Italic).build())
.set_chosen_ln_style(
FontStyle::default()
.set_shape(FontShape::Underline)
.set_fg_color(colored::Color::Black)
.set_bg_color_256((215, 255, 0))
.build(),
)
.set_more_tag_style(
FontStyle::default()
.set_fg_color(colored::Color::Magenta)
.build(),
);
// run
let selection = menu
.set_title("test selection:")
.show_end_tag(true)
.set_max_height(0.3)
.set_colorscheme(colorscheme)
.add_list(item_list)
.select() // this is the menu entry
.unwrap_or_else(|e| {
quit_now!("Error: {}", e);
});
// handle selection
if let Some(selection) = selection {
println!("You selected: {}", selection);
} else {
println!("You didn't select anything");
}
}Sourcepub fn set_query_style(&mut self, style: FontStyle) -> &mut Self
pub fn set_query_style(&mut self, style: FontStyle) -> &mut Self
set the style of the query, which is the input of the user in query mode
Examples found in repository?
examples/complex.rs (line 32)
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
fn main() {
let mut menu = Menu::new().unwrap_or_else(|e| {
quit_now!("Error: {}", e);
});
// build item list
let mut item_list = Vec::new();
for i in 1..=100 {
item_list.push(Item::new(format!("{}th item", i).as_str(), i));
}
// build colorscheme, you can skip this step to use the default colorscheme
// NOTE: sometimes your terminal might not support all the colors, so you may need to adjust
// the colorscheme
let mut colorscheme = termenu::ColorScheme::default();
colorscheme
.set_title_style(
FontStyle::default()
.set_shape(FontShape::Bold | FontShape::Underline)
.set_fg_color(colored::Color::Green)
.build(),
)
.set_query_style(FontStyle::default().set_shape(FontShape::Italic).build())
.set_chosen_ln_style(
FontStyle::default()
.set_shape(FontShape::Underline)
.set_fg_color(colored::Color::Black)
.set_bg_color_256((215, 255, 0))
.build(),
)
.set_more_tag_style(
FontStyle::default()
.set_fg_color(colored::Color::Magenta)
.build(),
);
// run
let selection = menu
.set_title("test selection:")
.show_end_tag(true)
.set_max_height(0.3)
.set_colorscheme(colorscheme)
.add_list(item_list)
.select() // this is the menu entry
.unwrap_or_else(|e| {
quit_now!("Error: {}", e);
});
// handle selection
if let Some(selection) = selection {
println!("You selected: {}", selection);
} else {
println!("You didn't select anything");
}
}Sourcepub fn set_items_style(&mut self, style: FontStyle) -> &mut Self
pub fn set_items_style(&mut self, style: FontStyle) -> &mut Self
set the style of the items, which is the list of items which are displayed in the menu and not chosen yet
Sourcepub fn set_chosen_ln_style(&mut self, style: FontStyle) -> &mut Self
pub fn set_chosen_ln_style(&mut self, style: FontStyle) -> &mut Self
set the style of the chosen line, which is the line that the cursor is pointing to
Examples found in repository?
examples/complex.rs (lines 33-39)
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
fn main() {
let mut menu = Menu::new().unwrap_or_else(|e| {
quit_now!("Error: {}", e);
});
// build item list
let mut item_list = Vec::new();
for i in 1..=100 {
item_list.push(Item::new(format!("{}th item", i).as_str(), i));
}
// build colorscheme, you can skip this step to use the default colorscheme
// NOTE: sometimes your terminal might not support all the colors, so you may need to adjust
// the colorscheme
let mut colorscheme = termenu::ColorScheme::default();
colorscheme
.set_title_style(
FontStyle::default()
.set_shape(FontShape::Bold | FontShape::Underline)
.set_fg_color(colored::Color::Green)
.build(),
)
.set_query_style(FontStyle::default().set_shape(FontShape::Italic).build())
.set_chosen_ln_style(
FontStyle::default()
.set_shape(FontShape::Underline)
.set_fg_color(colored::Color::Black)
.set_bg_color_256((215, 255, 0))
.build(),
)
.set_more_tag_style(
FontStyle::default()
.set_fg_color(colored::Color::Magenta)
.build(),
);
// run
let selection = menu
.set_title("test selection:")
.show_end_tag(true)
.set_max_height(0.3)
.set_colorscheme(colorscheme)
.add_list(item_list)
.select() // this is the menu entry
.unwrap_or_else(|e| {
quit_now!("Error: {}", e);
});
// handle selection
if let Some(selection) = selection {
println!("You selected: {}", selection);
} else {
println!("You didn't select anything");
}
}Sourcepub fn set_matched_style(&mut self, style: FontStyle) -> &mut Self
pub fn set_matched_style(&mut self, style: FontStyle) -> &mut Self
set the style of the matched part of the items in query mode
Sourcepub fn set_more_tag_style(&mut self, style: FontStyle) -> &mut Self
pub fn set_more_tag_style(&mut self, style: FontStyle) -> &mut Self
set the style of the ‘—more—’ tag, which is displayed at the bottom of the menu when there are more items than the screen can display
Examples found in repository?
examples/complex.rs (lines 40-44)
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
fn main() {
let mut menu = Menu::new().unwrap_or_else(|e| {
quit_now!("Error: {}", e);
});
// build item list
let mut item_list = Vec::new();
for i in 1..=100 {
item_list.push(Item::new(format!("{}th item", i).as_str(), i));
}
// build colorscheme, you can skip this step to use the default colorscheme
// NOTE: sometimes your terminal might not support all the colors, so you may need to adjust
// the colorscheme
let mut colorscheme = termenu::ColorScheme::default();
colorscheme
.set_title_style(
FontStyle::default()
.set_shape(FontShape::Bold | FontShape::Underline)
.set_fg_color(colored::Color::Green)
.build(),
)
.set_query_style(FontStyle::default().set_shape(FontShape::Italic).build())
.set_chosen_ln_style(
FontStyle::default()
.set_shape(FontShape::Underline)
.set_fg_color(colored::Color::Black)
.set_bg_color_256((215, 255, 0))
.build(),
)
.set_more_tag_style(
FontStyle::default()
.set_fg_color(colored::Color::Magenta)
.build(),
);
// run
let selection = menu
.set_title("test selection:")
.show_end_tag(true)
.set_max_height(0.3)
.set_colorscheme(colorscheme)
.add_list(item_list)
.select() // this is the menu entry
.unwrap_or_else(|e| {
quit_now!("Error: {}", e);
});
// handle selection
if let Some(selection) = selection {
println!("You selected: {}", selection);
} else {
println!("You didn't select anything");
}
}Trait Implementations§
Source§impl Clone for ColorScheme
impl Clone for ColorScheme
Source§fn clone(&self) -> ColorScheme
fn clone(&self) -> ColorScheme
Returns a copy of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Default for ColorScheme
impl Default for ColorScheme
impl Copy for ColorScheme
Auto Trait Implementations§
impl Freeze for ColorScheme
impl RefUnwindSafe for ColorScheme
impl Send for ColorScheme
impl Sync for ColorScheme
impl Unpin for ColorScheme
impl UnwindSafe for ColorScheme
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit)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>
Converts
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>
Converts
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