summaryrefslogtreecommitdiffstats
path: root/src/input.rs
blob: 8a730f3ff266cffd2bb3b56d8bdc251549a81f17 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
/// displays the "input" at the bottom of the screen
/// (reading is managed in the app module)
use std::io::{self, Write};

use crate::commands::Command;
use crate::screens::Screen;

pub trait Input {
    fn write_input(&mut self, cmd: &Command) -> io::Result<()>;
}

impl Input for Screen {
    fn write_input(&mut self, cmd: &Command) -> io::Result<()> {
        write!(
            self.stdout,
            "{}{}{}{} {}",
            termion::cursor::Goto(1, self.h),
            termion::clear::CurrentLine,
            cmd.raw,
            termion::style::Invert,
            termion::style::NoInvert,
        )?;
        self.stdout.flush()?;
        Ok(())
    }
}