Skip to main content

simple/
simple.rs

1use {
2    cursive::{view::*, views::*, *},
3    cursive_split_panel::*,
4};
5
6// We've added some actions (not enabled to default) to let you play around with
7// the various features of split panel
8
9// In addition to the default keys (shift left/right, up/down), try pressing the
10// 'b', 'd', and 'o' keys
11
12// And don't forget to try dragging the divider with the mouse!
13
14fn main() {
15    let mut cursive = default();
16
17    cursive.add_fullscreen_layer(
18        SplitPanel::default()
19            .with_front(text_view().scrollable())
20            .with_back(text_view().scrollable())
21            .with_action(Action::ToggleBorder, 'b')
22            .with_action(Action::ToggleVisibleDivider, 'd')
23            .with_action(Action::ToggleOrientation, 'o')
24            .full_screen(),
25    );
26
27    cursive.add_global_callback('q', |cursive| cursive.quit());
28
29    cursive.run();
30}
31
32fn text_view() -> TextView {
33    TextView::new(
34        "Did you ever hear the tragedy of Darth Plagueis the Wise? I thought not. It's not a \
35story the Jedi would tell you. It's a Sith legend. Darth Plagueis was a Dark Lord of the Sith, \
36so powerful and so wise he could use the Force to influence the midichlorians to create life... \
37He had such a knowledge of the dark side, he could even keep the ones he cared about from dying. \
38The dark side of the Force is a pathway to many abilities some consider to be unnatural. He \
39became so powerful... the only thing he was afraid of was losing his power, which eventually, of \
40course, he did. Unfortunately, he taught his apprentice everything he knew, then his apprentice \
41killed him in his sleep. Ironic. He could save others from death, but not himself.",
42    )
43}