pub struct Rofi<'a, T>{ /* private fields */ }
Expand description
Rofi Window Builder
Rofi struct for displaying user interfaces. This struct is build after the
non-consuming builder pattern. You can prepare a window, and draw it
multiple times without reconstruction and reallocation. You can choose to
return a handle to the child process RofiChild
, which allows you to kill
the process.
Implementations§
source§impl<'a, T> Rofi<'a, T>
impl<'a, T> Rofi<'a, T>
sourcepub fn new(elements: &'a [T]) -> Self
pub fn new(elements: &'a [T]) -> Self
Generate a new, unconfigured Rofi window based on the elements provided.
sourcepub fn run(&self) -> Result<String, Error>
pub fn run(&self) -> Result<String, Error>
Show the window, and return the selected string, including pango formatting if available
sourcepub fn run_index(&mut self) -> Result<usize, Error>
pub fn run_index(&mut self) -> Result<usize, Error>
show the window, and return the index of the selected string This
function will overwrite any subsequent calls to self.format
.
sourcepub fn message_only(
&mut self,
message: impl Into<String>
) -> Result<&mut Self, Error>
pub fn message_only( &mut self, message: impl Into<String> ) -> Result<&mut Self, Error>
enable message dialog mode (-e)
sourcepub fn lines(&mut self, l: usize) -> &mut Self
pub fn lines(&mut self, l: usize) -> &mut Self
Sets the number of lines. If this function is not called, use the number of lines provided in the elements vector.
sourcepub fn width(&mut self, w: Width) -> Result<&mut Self, Error>
pub fn width(&mut self, w: Width) -> Result<&mut Self, Error>
Set the width of the window (overwrite the theme settings)
sourcepub fn case_sensitive(&mut self, sensitivity: bool) -> &mut Self
pub fn case_sensitive(&mut self, sensitivity: bool) -> &mut Self
Sets the case sensitivity (disabled by default)
sourcepub fn prompt(&mut self, prompt: impl Into<String>) -> &mut Self
pub fn prompt(&mut self, prompt: impl Into<String>) -> &mut Self
Set the prompt of the rofi window
sourcepub fn message(&mut self, message: impl Into<String>) -> &mut Self
pub fn message(&mut self, message: impl Into<String>) -> &mut Self
Set the message of the rofi window (-mesg). Only available in dmenu mode. Docs: https://github.com/davatorium/rofi/blob/next/doc/rofi-dmenu.5.markdown#dmenu-specific-commandline-flags
sourcepub fn theme(&mut self, theme: Option<impl Into<String>>) -> &mut Self
pub fn theme(&mut self, theme: Option<impl Into<String>>) -> &mut Self
Set the rofi theme
This will make sure that rofi uses ~/.config/rofi/{theme}.rasi
sourcepub fn return_format(&mut self, format: Format) -> &mut Self
pub fn return_format(&mut self, format: Format) -> &mut Self
Set the return format of the rofi call. Default is Format::Text
. If
you call self.spawn_index
later, the format will be overwritten with
Format::Index
.
sourcepub fn kb_custom(
&mut self,
id: u32,
shortcut: &str
) -> Result<&mut Self, String>
pub fn kb_custom( &mut self, id: u32, shortcut: &str ) -> Result<&mut Self, String>
Set a custom keyboard shortcut. Rofi supports up to 19 custom keyboard shortcuts.
id
must be in the [1,19] range and identifies the keyboard shortcut
shortcut
can be any modifiers separated by "+"
, with a letter or number at the end.
Ex: “Control+Shift+n”, “Alt+s”, “Control+Alt+Shift+1
https://github.com/davatorium/rofi/blob/next/source/keyb.c#L211