Struct rofi::Rofi

source ·
pub struct Rofi<'a, T>
where T: AsRef<str>,
{ /* 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>
where T: AsRef<str>,

source

pub fn new(elements: &'a [T]) -> Self

Generate a new, unconfigured Rofi window based on the elements provided.

source

pub fn run(&self) -> Result<String, Error>

Show the window, and return the selected string, including pango formatting if available

source

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.

source

pub fn set_sort(&mut self) -> &mut Self

Set sort flag

source

pub fn pango(&mut self) -> &mut Self

enable pango markup

source

pub fn password(&mut self) -> &mut Self

enable password mode

source

pub fn message_only( &mut self, message: impl Into<String> ) -> Result<&mut Self, Error>

enable message dialog mode (-e)

source

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.

source

pub fn width(&mut self, w: Width) -> Result<&mut Self, Error>

Set the width of the window (overwrite the theme settings)

source

pub fn case_sensitive(&mut self, sensitivity: bool) -> &mut Self

Sets the case sensitivity (disabled by default)

source

pub fn prompt(&mut self, prompt: impl Into<String>) -> &mut Self

Set the prompt of the rofi window

source

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

source

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

source

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.

source

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

source

pub fn spawn(&self) -> Result<RofiChild<String>, Error>

Returns a child process with the pre-prepared rofi window The child will produce the exact output as provided in the elements vector.

source

pub fn spawn_index(&mut self) -> Result<RofiChild<usize>, Error>

Returns a child process with the pre-prepared rofi window. The child will produce the index of the chosen element in the vector. This function will overwrite any subsequent calls to self.format.

source§

impl<'a> Rofi<'a, String>

source

pub fn new_message(message: impl Into<String>) -> Self

Generate a new, Rofi window in “message only” mode with the given message.

Trait Implementations§

source§

impl<'a, T> Clone for Rofi<'a, T>
where T: AsRef<str> + Clone,

source§

fn clone(&self) -> Rofi<'a, T>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<'a, T> Debug for Rofi<'a, T>
where T: AsRef<str> + Debug,

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a, T> RefUnwindSafe for Rofi<'a, T>
where T: RefUnwindSafe,

§

impl<'a, T> Send for Rofi<'a, T>
where T: Sync,

§

impl<'a, T> Sync for Rofi<'a, T>
where T: Sync,

§

impl<'a, T> Unpin for Rofi<'a, T>

§

impl<'a, T> UnwindSafe for Rofi<'a, T>
where T: RefUnwindSafe,

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.