summaryrefslogtreecommitdiffstats
path: root/src/term.rs
diff options
context:
space:
mode:
authorrabite <rabite@posteo.de>2019-03-02 19:39:24 +0100
committerrabite <rabite@posteo.de>2019-03-02 23:28:03 +0100
commiteb5a86b7cd37dc39d20f6ce122f671f94f51b75a (patch)
treea60e83dca33a46ebcc367dbfe98c2e8250210289 /src/term.rs
parente2acef5ddfa5c7bf470aee5e24f429eabfb17951 (diff)
moved window stuff to widget itself
Diffstat (limited to 'src/term.rs')
-rw-r--r--src/term.rs30
1 files changed, 23 insertions, 7 deletions
diff --git a/src/term.rs b/src/term.rs
index 950a410..317f5d5 100644
--- a/src/term.rs
+++ b/src/term.rs
@@ -1,20 +1,36 @@
-use std::io::{Stdout, Write};
+use std::io::{Stdout, Write, BufWriter};
+
use termion;
use termion::screen::AlternateScreen;
+use crate::fail::HResult;
+
pub trait ScreenExt: Write {
- fn cursor_hide(&mut self) {
- write!(self, "{}", termion::cursor::Hide).unwrap();
+ fn cursor_hide(&mut self) -> HResult<()> {
+ write!(self, "{}", termion::cursor::Hide)?;
+ self.flush()?;
+ Ok(())
+ }
+ fn cursor_show(&mut self) -> HResult<()> {
+ write!(self, "{}", termion::cursor::Show)?;
+ self.flush()?;
+ Ok(())
}
- fn cursor_show(&mut self) {
- write!(self, "{}", termion::cursor::Show).unwrap();
+ fn reset(&mut self) -> HResult<()> {
+ write!(self, "{}", termion::style::Reset)?;
+ self.flush()?;
+ Ok(())
}
- fn reset(&mut self) {
- write!(self, "{}", termion::style::Reset).unwrap();
+ fn write_str(&mut self, str: &str) -> HResult<()> {
+ write!(self, "{}", str)?;
+ self.flush()?;
+ Ok(())
}
}
impl ScreenExt for AlternateScreen<Box<Stdout>> {}
+impl ScreenExt for AlternateScreen<Stdout> {}
+impl ScreenExt for AlternateScreen<BufWriter<Stdout>> {}
pub fn xsize() -> u16 {
let (xsize, _) = termion::terminal_size().unwrap();