aboutsummaryrefslogtreecommitdiffstats
path: root/src/buffer/mod.rs
diff options
context:
space:
mode:
authorGustav Sörnäs <gustav@sornas.net>2021-05-04 00:35:37 +0200
committerGustav Sörnäs <gustav@sornas.net>2021-05-04 00:35:37 +0200
commit882dacc3e7a7d517d1a317a9fef3514236c6e89c (patch)
tree206d8a8d95c68eb9d6975f9c7eb8f27ad704c0cf /src/buffer/mod.rs
parentff52420876fb4e9a2d205d5a819db0234fc36b89 (diff)
downloadmail-882dacc3e7a7d517d1a317a9fef3514236c6e89c.tar.gz
basic statusbar and inner output buffer
Closes #2
Diffstat (limited to 'src/buffer/mod.rs')
-rw-r--r--src/buffer/mod.rs32
1 files changed, 28 insertions, 4 deletions
diff --git a/src/buffer/mod.rs b/src/buffer/mod.rs
index 3cff6f5..1d7d22e 100644
--- a/src/buffer/mod.rs
+++ b/src/buffer/mod.rs
@@ -1,6 +1,6 @@
mod threads;
-use crate::window::{Area, Window};
+use crate::window::{Area, Statusbar, Window};
use std::io::{Stdin, Write};
use termion::event::Key;
@@ -12,28 +12,41 @@ pub use threads::Threads;
pub struct Client {
window: Window,
buffers: Vec<Buffer>,
+ statusbar: Statusbar,
}
impl Client {
pub fn new<W: Write>(initial_buffer: Buffer, out: &mut W) -> Self {
let size = termion::terminal_size().unwrap();
let mut window = Window::new();
+ let statusbar = Statusbar::new(String::from("Hello world!"));
+
match &initial_buffer {
Buffer::Threads(t) => t.fill_window(&mut window),
}
+
window.draw(out, Area {
x: 1,
y: 1,
w: size.0,
- h: size.1,
+ h: size.1 - 2,
+ }).unwrap();
+ statusbar.draw(out, Area {
+ x: 1,
+ y: size.1,
+ w: size.0,
+ h: 1,
}).unwrap();
+
Self {
window,
buffers: vec![initial_buffer],
+ statusbar,
}
}
pub fn run<W: Write>(mut self, out: &mut W, stdin: Stdin) {
+ let mut buffer = Vec::new();
for c in stdin.keys() {
let c = c.unwrap();
// Global keybinds
@@ -58,12 +71,23 @@ impl Client {
write!(out, "{}", termion::clear::All).unwrap();
let size = termion::terminal_size().unwrap();
- self.window.draw(out, Area {
+ self.window.draw(&mut buffer, Area {
x: 1,
y: 1,
w: size.0,
- h: size.1,
+ h: size.1 - 2,
}).unwrap();
+
+ self.statusbar.draw(&mut buffer, Area {
+ x: 1,
+ y: size.1,
+ w: size.0,
+ h: 1,
+ }).unwrap();
+
+ out.write(&buffer).unwrap();
+ out.flush().unwrap();
+ buffer.clear();
}
}
}