[−][src]Crate rustofi
This Rust library enables the construction of complex multipage applications that use Rofi to
display their UI. The basic idea is to create a AppPage
or SearchPage
as an application
main menu and feed it in possible selections and actions. These selections and actions can
then navigate you to an ItemList
, an EntryBox
an ActionList
or another main menu.
Typically you will want to create an AppPage with some options and actions,
then display it in a loop checking the return for the RustofiOptionType
to exit on.
AppPage
and SearchPage
will automatically add an exit option to simplify the loop exit cases, while
ItemList
and ActionList
will add a cancel option.
Simplest Possible Example
The below example gets even simpler than creating an AppRoot, just displaying a list of strings and utilizing a callback to print the selected item. Notice the loop in main checking the return variant of the rofi window
use rustofi::components::ItemList; use rustofi::RustofiResult; fn simple_app() -> RustofiResult { let rustofi_entries = vec![ "Entry 1".to_string(), "Entry 2".to_string(), "Entry 3".to_string(), ]; ItemList::new(rustofi_entries, Box::new(simple_callback)).display("Select an entry".to_string()) } pub fn simple_callback(s: &String) -> RustofiResult { println!("Clicked on item: {}", s); RustofiResult::Success } fn main() { loop { match simple_app() { RustofiResult::Error => break, RustofiResult::Exit => break, RustofiResult::Cancel => break, RustofiResult::Blank => break, _ => {} } } }
Modules
components | |
window |
Structs
AppPage |
|
SearchPage |
|
Enums
RustofiResult | enum declaring all possible return values from a rofi window constructed
using this library. Callbacks should also generally return this type, specifying
|
Traits
RustofiCallback | Wrapper around a callback that returns a RustofiResult |
RustofiComponent | Trait implemented by |