mirror of
https://github.com/FliegendeWurst/cursive.git
synced 2024-11-24 01:46:31 +00:00
f28ac264f1
Update examples to use it.
28 lines
1.0 KiB
Rust
28 lines
1.0 KiB
Rust
extern crate cursive;
|
|
|
|
use cursive::prelude::*;
|
|
use cursive::align::HAlign;
|
|
|
|
fn main() {
|
|
let mut siv = Cursive::new();
|
|
|
|
// Some description text
|
|
let text = "This is a very simple example of linear layout. Two views \
|
|
are present, a short title above, and this text. The text \
|
|
has a fixed width, and the title is centered horizontally.";
|
|
|
|
// We'll create a dialog with a TextView serving as a title
|
|
siv.add_layer(Dialog::new(LinearLayout::vertical()
|
|
.child(TextView::new("Title").h_align(HAlign::Center))
|
|
// Box the textview, so it doesn't get too wide.
|
|
// A 0 height value means it will be unconstrained.
|
|
.child(BoxView::fixed_width(30, TextView::new(text).scrollable(false)))
|
|
.child(BoxView::fixed_width(30, TextView::new(text)))
|
|
.child(BoxView::fixed_width(30, TextView::new(text)))
|
|
.child(BoxView::fixed_width(30, TextView::new(text))))
|
|
.button("Quit", |s| s.quit())
|
|
.h_align(HAlign::Center));
|
|
|
|
siv.run();
|
|
}
|