|
|
|
@ -12,16 +12,19 @@ extern crate failure;
|
|
|
|
|
/// messages
|
|
|
|
|
extern crate termion;
|
|
|
|
|
extern crate tui;
|
|
|
|
|
extern crate unicode_width;
|
|
|
|
|
|
|
|
|
|
#[allow(dead_code)]
|
|
|
|
|
mod util;
|
|
|
|
|
|
|
|
|
|
use std::io;
|
|
|
|
|
use std::io::{self, Write};
|
|
|
|
|
|
|
|
|
|
use unicode_width::UnicodeWidthStr;
|
|
|
|
|
use termion::event::Key;
|
|
|
|
|
use termion::input::MouseTerminal;
|
|
|
|
|
use termion::raw::IntoRawMode;
|
|
|
|
|
use termion::screen::AlternateScreen;
|
|
|
|
|
use termion::cursor::Goto;
|
|
|
|
|
use tui::backend::TermionBackend;
|
|
|
|
|
use tui::layout::{Constraint, Direction, Layout, Rect};
|
|
|
|
|
use tui::style::{Color, Style};
|
|
|
|
@ -57,7 +60,6 @@ fn main() -> Result<(), failure::Error> {
|
|
|
|
|
let stdout = AlternateScreen::from(stdout);
|
|
|
|
|
let backend = TermionBackend::new(stdout);
|
|
|
|
|
let mut terminal = Terminal::new(backend)?;
|
|
|
|
|
terminal.hide_cursor()?;
|
|
|
|
|
|
|
|
|
|
// Setup event handlers
|
|
|
|
|
let events = Events::new();
|
|
|
|
@ -94,6 +96,9 @@ fn main() -> Result<(), failure::Error> {
|
|
|
|
|
.render(&mut f, chunks[1]);
|
|
|
|
|
})?;
|
|
|
|
|
|
|
|
|
|
// Put the cursor back inside the input box
|
|
|
|
|
write!(terminal.backend_mut(), "{}", Goto(4 + app.input.width() as u16, 4))?;
|
|
|
|
|
|
|
|
|
|
// Handle input
|
|
|
|
|
match events.next()? {
|
|
|
|
|
Event::Input(input) => match input {
|
|
|
|
|