Struct cursive::Cursive
[−]
[src]
pub struct Cursive { // some fields omitted }
Central part of the cursive library.
It initializes ncurses on creation and cleans up on drop. To use it, you should populate it with views, layouts and callbacks, then start the event loop with run().
It uses a list of screen, with one screen active at a time.
Methods
impl Cursive
[src]
fn new() -> Self
Creates a new Cursive root, and initialize ncurses.
fn select_menubar(&mut self)
Selects the menubar
fn set_autohide_menu(&mut self, autohide: bool)
Sets the menubar autohide_menubar feature.
- When enabled, the menu is only visible when selected.
- When disabled, the menu is always visible and reserves the top row.
fn menubar(&mut self) -> &mut Menubar
Retrieve the menu tree used by the menubar.
fn current_theme(&self) -> &Theme
Returns the currently used theme
fn load_theme<P: AsRef<Path>>(&mut self, filename: P) -> bool
Loads a theme from the given file.
Returns TRUE if the theme was successfully loaded.
fn set_fps(&self, fps: u32)
Sets the refresh rate, in frames per second.
Regularly redraws everything, even when no input is given. Between 0 and 1000. Call with fps=0 to disable (default value).
fn screen_mut(&mut self) -> &mut StackView
Returns a mutable reference to the currently active screen.
fn add_screen(&mut self) -> ScreenId
Adds a new screen, and returns its ID.
fn add_active_screen(&mut self) -> ScreenId
Convenient method to create a new screen, and set it as active.
fn set_screen(&mut self, screen_id: ScreenId)
Sets the active screen. Panics if no such screen exist.
fn find<V: View + Any>(&mut self, sel: &Selector) -> Option<&mut V>
Tries to find the view pointed to by the given path. If the view is not found, or if it is not of the asked type, it returns None.
fn find_id<V: View + Any>(&mut self, id: &str) -> Option<&mut V>
Convenient method to use find
with a Selector::Id
.
fn add_global_callback<F, E: ToEvent>(&mut self, event: E, cb: F) where F: Fn(&mut Cursive) + 'static
Adds a global callback.
Will be triggered on the given key press when no view catches it.
fn add_layer<T: 'static + View>(&mut self, view: T)
Convenient method to add a layer to the current screen.
fn pop_layer(&mut self)
Convenient method to remove a layer from the current screen.
fn screen_size(&self) -> Vec2
Returns the size of the screen, in characters.
fn run(&mut self)
Runs the event loop.
It will wait for user input (key presses) and trigger callbacks accordingly.
Blocks until quit() is called.
fn quit(&mut self)
Stops the event loop.