aboutsummaryrefslogtreecommitdiffstats
path: root/src/buffer/mod.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/buffer/mod.rs')
-rw-r--r--src/buffer/mod.rs47
1 files changed, 47 insertions, 0 deletions
diff --git a/src/buffer/mod.rs b/src/buffer/mod.rs
new file mode 100644
index 0000000..fe83a97
--- /dev/null
+++ b/src/buffer/mod.rs
@@ -0,0 +1,47 @@
+mod threads;
+
+use std::io::{Stdin, Write};
+use termion::event::Key;
+use termion::input::TermRead;
+
+pub use threads::Threads;
+
+pub struct Client {
+ buffers: Vec<Buffer>,
+}
+
+impl Client {
+ pub fn new(initial_buffer: Buffer) -> Self {
+ Self {
+ buffers: vec![initial_buffer],
+ }
+ }
+
+ pub fn run<W: Write>(mut self, mut screen: W, stdin: Stdin) {
+ for c in stdin.keys() {
+ let c = c.unwrap();
+ // Global keybinds
+ match c {
+ Key::Char('q') => {
+ self.buffers.pop().unwrap();
+ if self.buffers.is_empty() {
+ break;
+ }
+ },
+ _ => ()
+ }
+
+ let next_buffer = match self.buffers.last_mut().unwrap() {
+ Buffer::Threads(s) => s.tick(&mut screen, c),
+ };
+
+ if let Some(next_buffer) = next_buffer {
+ self.buffers.push(next_buffer);
+ }
+ }
+ }
+}
+
+pub enum Buffer {
+ Threads(Threads),
+}