Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix command_bar example warnings #204

Merged
merged 1 commit into from
Sep 12, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 18 additions & 11 deletions examples/command_bar.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
extern crate crossterm;

use crossterm::{
cursor, input, terminal, AlternateScreen, ClearType, Crossterm, InputEvent, KeyEvent,
RawScreen, Terminal, TerminalCursor,
cursor, input, terminal, ClearType, Crossterm, InputEvent, KeyEvent, RawScreen, Terminal,
TerminalCursor,
};

use std::sync::{Arc, Mutex};
use std::{thread, time};

fn main() {
let screen = RawScreen::into_raw_mode();
cursor().hide();
let _screen = RawScreen::into_raw_mode();
cursor().hide().expect("Couldn't hide cursor");

let input_buf = Arc::new(Mutex::new(String::new()));

Expand All @@ -37,13 +37,14 @@ fn main() {
count += 1;
}
})
.join();
.join()
.expect("Couldn't join");

for thread in threads {
thread.join();
thread.join().expect("Couldn't join");
}

cursor().show();
cursor().show().expect("Couldn't show cursor");
}

fn log(input_buf: Arc<Mutex<String>>) -> Vec<thread::JoinHandle<()>> {
Expand Down Expand Up @@ -85,8 +86,14 @@ pub fn swap_write(
cursor: &TerminalCursor,
term_height: u16,
) {
cursor.goto(0, term_height);
terminal.clear(ClearType::CurrentLine);
terminal.write(format!("{}\r\n", msg));
terminal.write(format!("> {}", input_buf));
cursor.goto(0, term_height).expect("Couldn't goto");
terminal
.clear(ClearType::CurrentLine)
.expect("Couldn't clear current line");
terminal
.write(format!("{}\r\n", msg))
.expect("Couldn't write message");
terminal
.write(format!("> {}", input_buf))
.expect("Couldn't write prompt");
}