diff options
author | Joe Wilm <joe@jwilm.com> | 2016-06-09 08:06:47 -0700 |
---|---|---|
committer | Joe Wilm <joe@jwilm.com> | 2016-06-09 08:06:47 -0700 |
commit | aff56a65a4e49d07ca00636fc33cb2141409f6b3 (patch) | |
tree | b0bd87d5e100b494e8cababed28cedf9a9528492 /src/term.rs | |
parent | 8b1e82f31a7ecaade440b0694c0bbe5a843b48ac (diff) | |
download | alacritty-aff56a65a4e49d07ca00636fc33cb2141409f6b3.tar.gz alacritty-aff56a65a4e49d07ca00636fc33cb2141409f6b3.zip |
Make state updates and rendering event driven
The main thing preventing this system being event driven in the past was
input from the keyboard had to be polled separately from pty activity.
This commit adds a thread for the window event iterator and sends them
on the same channel as pty characters.
With that in place, the render loop looks like
- Block on 1 available input
- Get all remaining available input that won't cause blocking
- Render
Which means that rendering is only performed on state changes. This
obsoleted the need for a `dirty` flag in the Term struct.
Diffstat (limited to 'src/term.rs')
-rw-r--r-- | src/term.rs | 27 |
1 files changed, 0 insertions, 27 deletions
diff --git a/src/term.rs b/src/term.rs index 0bcf6b24..9d92e282 100644 --- a/src/term.rs +++ b/src/term.rs @@ -105,9 +105,6 @@ pub struct Term { /// Cell attributes attr: grid::CellFlags, - /// Whether state has changed and needs to be updated. - dirty: bool, - /// Mode flags mode: TermMode, @@ -136,20 +133,11 @@ impl Term { tty: tty, tabs: tabs, attr: CellFlags::empty(), - dirty: false, mode: TermMode::empty(), scroll_region: scroll_region, } } - pub fn dirty(&self) -> bool { - self.dirty - } - - pub fn clear_dirty(&mut self) { - self.dirty = false; - } - pub fn grid(&self) -> &Grid { &self.grid } @@ -190,7 +178,6 @@ impl Term { /// Set character in current cursor position fn set_char(&mut self, c: char) { - self.dirty = true; if self.cursor.x == self.grid.num_cols() as u16 { println!("wrapping"); self.cursor.y += 1; @@ -253,17 +240,14 @@ impl ansi::Handler for Term { fn goto(&mut self, x: i64, y: i64) { println!("goto: x={}, y={}", x, y); - self.dirty = true; self.cursor.goto(x as u16, y as u16); } fn goto_row(&mut self, y: i64) { - self.dirty = true; println!("goto_row: {}", y); let x = self.cursor_x(); self.cursor.goto(x, y as u16); } fn goto_col(&mut self, x: i64) { - self.dirty = true; println!("goto_col: {}", x); let y = self.cursor_y(); self.cursor.goto(x as u16, y); @@ -272,25 +256,21 @@ impl ansi::Handler for Term { fn insert_blank(&mut self, num: i64) { println!("insert_blank: {}", num); } fn move_up(&mut self, rows: i64) { - self.dirty = true; println!("move_up: {}", rows); self.cursor.advance(-rows, 0); } fn move_down(&mut self, rows: i64) { - self.dirty = true; println!("move_down: {}", rows); self.cursor.advance(rows, 0); } fn move_forward(&mut self, cols: i64) { - self.dirty = true; println!("move_forward: {}", cols); self.cursor.advance(0, cols); } fn move_backward(&mut self, spaces: i64) { - self.dirty = true; println!("move_backward: {}", spaces); self.cursor.advance(0, -spaces); } @@ -299,7 +279,6 @@ impl ansi::Handler for Term { fn move_down_and_cr(&mut self, rows: i64) { println!("move_down_and_cr: {}", rows); } fn move_up_and_cr(&mut self, rows: i64) { println!("move_up_and_cr: {}", rows); } fn put_tab(&mut self, mut count: i64) { - self.dirty = true; println!("put_tab: {}", count); let mut x = self.cursor_x(); @@ -320,7 +299,6 @@ impl ansi::Handler for Term { #[inline] fn backspace(&mut self, count: i64) { println!("backspace"); - self.dirty = true; self.cursor.x -= 1; self.set_char(' '); } @@ -329,14 +307,12 @@ impl ansi::Handler for Term { #[inline] fn carriage_return(&mut self) { println!("carriage_return"); - self.dirty = true; self.cursor.x = 0; } /// Linefeed #[inline] fn linefeed(&mut self) { - self.dirty = true; println!("linefeed"); // TODO handle scroll? not clear what parts of this the pty handle if self.cursor_y() + 1 >= self.scroll_region.end as u16 { @@ -378,7 +354,6 @@ impl ansi::Handler for Term { fn save_cursor_position(&mut self) { println!("save_cursor_position"); } fn restore_cursor_position(&mut self) { println!("restore_cursor_position"); } fn clear_line(&mut self, mode: ansi::LineClearMode) { - self.dirty = true; println!("clear_line: {:?}", mode); match mode { ansi::LineClearMode::Right => { @@ -393,7 +368,6 @@ impl ansi::Handler for Term { } } fn clear_screen(&mut self, mode: ansi::ClearMode) { - self.dirty = true; println!("clear_screen: {:?}", mode); match mode { ansi::ClearMode::Below => { @@ -417,7 +391,6 @@ impl ansi::Handler for Term { fn clear_tabs(&mut self, mode: ansi::TabulationClearMode) { println!("clear_tabs: {:?}", mode); } fn reset_state(&mut self) { println!("reset_state"); } fn reverse_index(&mut self) { - self.dirty = true; println!("reverse_index"); // if cursor is at the top if self.cursor.y == 0 { |