mirror of
https://github.com/FliegendeWurst/cursive.git
synced 2024-11-23 17:35:00 +00:00
Apply rustfmt to examples
This commit is contained in:
parent
a120b2cfe2
commit
654223411d
@ -21,13 +21,13 @@ cursive = "0.0.1"
|
||||
extern crate cursive;
|
||||
|
||||
use cursive::Cursive;
|
||||
use cursive::view::{Dialog,TextView};
|
||||
use cursive::view::{TextView, Dialog};
|
||||
|
||||
fn main() {
|
||||
// Creates the cursive root - required for every application.
|
||||
let mut siv = Cursive::new();
|
||||
|
||||
// Create a popup window with a button that quits the application
|
||||
// Creates a dialog with a single "Quit" button
|
||||
siv.add_layer(Dialog::new(TextView::new("Hello Dialog!"))
|
||||
.title("Cursive")
|
||||
.button("Quit", |s| s.quit()));
|
||||
|
@ -4,6 +4,7 @@ use cursive::Cursive;
|
||||
use cursive::view::{TextView, Dialog};
|
||||
|
||||
fn main() {
|
||||
// Creates the cursive root - required for every application.
|
||||
let mut siv = Cursive::new();
|
||||
|
||||
// Creates a dialog with a single "Quit" button
|
||||
@ -11,5 +12,6 @@ fn main() {
|
||||
.title("Cursive")
|
||||
.button("Quit", |s| s.quit()));
|
||||
|
||||
// Starts the event loop.
|
||||
siv.run();
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
extern crate cursive;
|
||||
|
||||
use cursive::{Cursive};
|
||||
use cursive::Cursive;
|
||||
use cursive::view::{Dialog, EditView, TextView};
|
||||
|
||||
fn main() {
|
||||
@ -12,7 +12,10 @@ fn main() {
|
||||
.title("Enter your name")
|
||||
.button("Ok", |s| {
|
||||
// When the button is clicked, read the text and print it in a new dialog.
|
||||
let name = s.find_id::<EditView>("edit").unwrap().get_content().to_string();
|
||||
let name = s.find_id::<EditView>("edit")
|
||||
.unwrap()
|
||||
.get_content()
|
||||
.to_string();
|
||||
if name.is_empty() {
|
||||
s.add_layer(Dialog::new(TextView::new("Please enter a name!"))
|
||||
.dismiss_button("Ok"));
|
||||
|
@ -49,4 +49,3 @@ impl View for KeyCodeView {
|
||||
EventResult::Consumed(None)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -20,7 +20,9 @@ fn main() {
|
||||
let (tx, rx) = mpsc::channel();
|
||||
|
||||
// Generate data in a separate thread.
|
||||
thread::spawn(|| { generate_logs(tx); });
|
||||
thread::spawn(|| {
|
||||
generate_logs(tx);
|
||||
});
|
||||
|
||||
// And sets the view to read from the other end of the channel.
|
||||
// (We use FullView to force fullscreen because
|
||||
@ -80,7 +82,8 @@ impl BufferView {
|
||||
// Chain together the two parts of the buffer to appear as a circular one.
|
||||
// The signature is quite ugly, but basically we return an iterator:
|
||||
// a Chain of two slice iterators.
|
||||
fn ring<'a>(&'a self) -> std::iter::Chain<std::slice::Iter<'a,String>, std::slice::Iter<'a,String>> {
|
||||
fn ring<'a>(&'a self)
|
||||
-> std::iter::Chain<std::slice::Iter<'a, String>, std::slice::Iter<'a, String>> {
|
||||
// The main buffer is "circular" starting at self.pos
|
||||
// So we chain the two parts as one
|
||||
self.buffer[self.pos..].iter().chain(self.buffer[..self.pos].iter())
|
||||
|
@ -24,9 +24,9 @@ fn main() {
|
||||
.h_align(HAlign::Center)
|
||||
.button("Quit", |s| s.quit()));
|
||||
// Show a popup on top of the view.
|
||||
siv.add_layer(Dialog::new(TextView::new("Try resizing the terminal!\n(Press 'q' to quit when you're done.)"))
|
||||
siv.add_layer(Dialog::new(TextView::new("Try resizing the terminal!\n(Press 'q' to quit \
|
||||
when you're done.)"))
|
||||
.dismiss_button("Ok"));
|
||||
|
||||
siv.run();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user