Expand description
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
- extra rofi window types usable to create an application, essentially navigation result pages
ItemList
,ActionList
andEntryBox
are additional components or controls you can use to build your application. - errors
- the error(s) returned by this crate
- window
- raw representation of a rofi command, use this to create new components, or your own from-scratch
apps
A
Window
is the closest to an actual binding of a rofi command as is feasible. The types and functions here allow you to construct a rofi of any size or type anywhere on the screen with ease and even allows the construction of rofi’s beyond that with theadditional_args
field.
Structs§
- AppPage
AppPage
displays a single column rofi window and is meant to be used as a main menu of sorts for your application.items
should be associated with a data model, whileactions
should be either operations you can perform on those items, or actions you can take within the app (switch pages for example)- Search
Page SearchPage
displays a multi column rofi window and is meant to be used as a search page of sorts for your application.items
should be associated with a data model, whileactions
should be either operations you can perform on those items, or actions you can take within the app (switch pages for example). Thesearch_callback
allows you to refresh the data models displayed or perform an operation on custom entry
Enums§
- Rustofi
Result - enum declaring all possible return values from a rofi window constructed
using this library. Callbacks should also generally return this type, specifying
Success
,Error
,Exit
orCancel
in most cases
Traits§
- Rustofi
Callback - Wrapper around a callback that returns a RustofiResult
- Rustofi
Component - Trait implemented by
SearchPage
andAppPage
.