[−][src]Struct dmenu_facade::DMenu
DISCLAIMER! This crate uses the shell to pipe strings into dmenu.
The dmenu wrapper. This struct is built using a builder pattern and finally executed. The items must implement Display to be displayed by dmenu.
The item's Display output must be unique, otherwise the latest in the list will be returned if the key is selected.
Example
use dmenu_facade::*; let items = vec!["Hello", "World", "!"]; let chosen = DMenu::default() .vertical_with_lines(2) .execute(&items); //Prints selected item to stdout if let Ok(item) = chosen { println!("{}", chosen); }
Implementations
impl<'a> DMenu<'a>
[src]
pub fn display_bottom(self) -> Self
[src]
Display dmenu on the bottom of the screen instead of the top
Example
use dmenu_facade::*; let dmenu = DMenu::default() .display_bottom();
pub fn case_insensitive(self) -> Self
[src]
Dmenu will search the list case insensetively
Example
use dmenu_facade::*; let dmenu = DMenu::default() .case_insensitive();
pub fn vertical_with_lines(self, amount: i32) -> Self
[src]
Display items vertically, with an amount of lines
Example
//Display dmenu with 5 linex vertically use dmenu_facade::*; let dmenu = DMenu::default() .vertical_with_lines(5);
pub fn display_on_monitor(self, monitor_id: i32) -> Self
[src]
Display on a specific monitor. Index starts with 0
Example
// To display on the second monitor use dmenu_facade::*; let dmenu = DMenu::default() .display_on_monitor(1);
pub fn with_prompt(self, prompt: &'a str) -> Self
[src]
Displays a prompt/title to the left of the selections.
Example
use dmenu_facade::*; let dmenu = DMenu::default() .with_prompt("Select an item:");
pub fn with_font(self, font: &'a str) -> Self
[src]
Specifies which font should be used
Example
use dmenu_facade::*; let dmenu = DMenu::default() .with_font("FiraCodeNerdFont:size=13");
pub fn with_colors(
self,
normal_background_color: Option<Color<'a>>,
normal_foreground_color: Option<Color<'a>>,
selected_background_color: Option<Color<'a>>,
selected_foreground_color: Option<Color<'a>>
) -> Self
[src]
self,
normal_background_color: Option<Color<'a>>,
normal_foreground_color: Option<Color<'a>>,
selected_background_color: Option<Color<'a>>,
selected_foreground_color: Option<Color<'a>>
) -> Self
Sets the colors for dmenu.
If only specific colors are wanted, the rest can be set to None to use defaults
Examples
use dmenu_facade::*; //To set normal background to white, normal foreground to black, selected background to red and selected foreground to blue. let dmenu = DMenu::default() .with_colors(Some(Color("#ffffff")), Some(Color("#000000")), Some(Color("#ff0000")), Some(Color("#0000ff")));
use dmenu_facade::*; //To set normal background to white, normal foreground to black, selected background and selected foreground to default. let dmenu = DMenu::default() .with_colors(Some(Color("#ffffff")), Some(Color("#000000")), None, None);
pub fn execute<T: Display>(self, list: &Vec<T>) -> Result<&T, Box<dyn Error>>
[src]
Execute the dmenu struct as a command. Blocks the program till the user completes
Takes a reference to a list of items with the Display trait, and returns a Result containing a reference to the chosen item.
Example
use dmenu_facade::*; let items = vec!["Hello", "There", "Hope you", "Like my", "Docs :)"]; let chosen = DMenu::default() .vertical_with_lines(4) .case_insensitive() .with_font("FiraCodeNerdFont:size=13") .with_prompt("Select an item!") .execute(&items); if let Ok(item) = chosen { println!("{}", item); }
pub fn execute_consume<T: Display>(
self,
list: Vec<T>
) -> Result<T, Box<dyn Error>>
[src]
self,
list: Vec<T>
) -> Result<T, Box<dyn Error>>
Like execute, but consumes the list to return an owned item after the user chooses.
pub fn execute_as_input(self) -> Result<String, Box<dyn Error>>
[src]
Will launch the configured DMenu without any items and return the string typed by the user
Trait Implementations
impl<'a> Clone for DMenu<'a>
[src]
impl<'a> Debug for DMenu<'a>
[src]
impl<'_> Default for DMenu<'_>
[src]
impl<'a> Eq for DMenu<'a>
[src]
impl<'a> Ord for DMenu<'a>
[src]
pub fn cmp(&self, other: &DMenu<'a>) -> Ordering
[src]
#[must_use]pub fn max(self, other: Self) -> Self
1.21.0[src]
#[must_use]pub fn min(self, other: Self) -> Self
1.21.0[src]
#[must_use]pub fn clamp(self, min: Self, max: Self) -> Self
1.50.0[src]
impl<'a> PartialEq<DMenu<'a>> for DMenu<'a>
[src]
impl<'a> PartialOrd<DMenu<'a>> for DMenu<'a>
[src]
pub fn partial_cmp(&self, other: &DMenu<'a>) -> Option<Ordering>
[src]
pub fn lt(&self, other: &DMenu<'a>) -> bool
[src]
pub fn le(&self, other: &DMenu<'a>) -> bool
[src]
pub fn gt(&self, other: &DMenu<'a>) -> bool
[src]
pub fn ge(&self, other: &DMenu<'a>) -> bool
[src]
impl<'a> StructuralEq for DMenu<'a>
[src]
impl<'a> StructuralPartialEq for DMenu<'a>
[src]
Auto Trait Implementations
impl<'a> RefUnwindSafe for DMenu<'a>
impl<'a> Send for DMenu<'a>
impl<'a> Sync for DMenu<'a>
impl<'a> Unpin for DMenu<'a>
impl<'a> UnwindSafe for DMenu<'a>
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,