Module unsegen::widget [−][src]
Expand description
Widget abstraction and some basic Widgets useful for creating basic building blocks of text user interfaces.
Example:
use unsegen::base::*; use unsegen::widget::*; use unsegen::widget::builtin::*; use std::io::stdout; struct MyWidget { prompt: PromptLine, buffer: LogViewer, } impl MyWidget { fn as_widget<'a>(&'a self) -> impl Widget + 'a { VLayout::new().alternating(StyleModifier::new().invert(true)) .widget("Some text on top") .widget(self.prompt.as_widget()) .widget(self.buffer.as_widget()) .widget("Some text below") } } fn main() { let stdout = stdout(); let mut term = Terminal::new(stdout.lock()).unwrap(); let mut widget = MyWidget { prompt: PromptLine::with_prompt(" > ".to_owned()), buffer: LogViewer::new(), }; loop { // Put application logic here: read input, chain behavior, react to other stuff { let win = term.create_root_window(); widget.as_widget().draw(win, RenderingHints::new().active(true)); } term.present(); } }
Re-exports
pub use self::layouts::*; | |
pub use self::widget::*; |
Modules
builtin | This module contains several basic widgets that are built into the core library. |
layouts | Basic linear layouting for |
widget | The |
Functions
count_grapheme_clusters | Count the number of grapheme clusters in the given string. |
text_width | Calculate the (monospace) width of the given string. |