mirror of
https://github.com/FliegendeWurst/cursive.git
synced 2024-11-09 19:00:46 +00:00
Fix examples and tests
This commit is contained in:
parent
40f9a91a7a
commit
d12622b56a
@ -14,7 +14,7 @@ fn main() {
|
||||
|
||||
// The text is too long to fit on a line, so the view will wrap lines,
|
||||
// and will adapt to the terminal size.
|
||||
siv.add_layer(Dialog::new(TextView::new(&content))
|
||||
siv.add_layer(Dialog::new(TextView::new(content))
|
||||
.h_align(HAlign::Center)
|
||||
.button("Quit", |s| s.quit()));
|
||||
// Show a popup on top of the view.
|
||||
|
@ -13,7 +13,7 @@ fn show_popup(siv: &mut Cursive) {
|
||||
// Look for a view tagged "text". We _know_ it's there, so unwrap it.
|
||||
let view = s.find_id::<TextView>("text").unwrap();
|
||||
let content: String = view.get_content().chars().rev().collect();
|
||||
view.set_content(&content);
|
||||
view.set_content(content);
|
||||
})
|
||||
.dismiss_button("Ok"));
|
||||
|
||||
|
@ -26,6 +26,6 @@ fn main() {
|
||||
// Let's put the callback in a separate function to keep it clean, but it's not required.
|
||||
fn show_next_window(siv: &mut Cursive, city: &String) {
|
||||
siv.pop_layer();
|
||||
siv.add_layer(Dialog::new(TextView::new(&format!("{} is a great city!", city)))
|
||||
siv.add_layer(Dialog::new(TextView::new(format!("{} is a great city!", city)))
|
||||
.button("Quit", |s| s.quit()));
|
||||
}
|
||||
|
@ -43,7 +43,7 @@ use utils::suffix_length;
|
||||
/// } else {
|
||||
/// let content = format!("Hello {}!", name);
|
||||
/// s.pop_layer();
|
||||
/// s.add_layer(Dialog::new(TextView::new(&content))
|
||||
/// s.add_layer(Dialog::new(TextView::new(content))
|
||||
/// .button("Quit", |s| s.quit()));
|
||||
/// }
|
||||
/// }));
|
||||
|
@ -35,7 +35,7 @@ use unicode_width::UnicodeWidthStr;
|
||||
/// time_select.set_on_submit(|s, time| {
|
||||
/// s.pop_layer();
|
||||
/// let text = format!("You will wait for {} minutes...", time);
|
||||
/// s.add_layer(Dialog::new(TextView::new(&text))
|
||||
/// s.add_layer(Dialog::new(TextView::new(text))
|
||||
/// .button("Quit", |s| s.quit()));
|
||||
/// });
|
||||
///
|
||||
|
Loading…
Reference in New Issue
Block a user