summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVille Hakulinen <ville.hakulinen@gmail.com>2020-07-06 13:54:49 +0300
committerVille Hakulinen <ville.hakulinen@gmail.com>2020-07-12 01:57:30 +0300
commitd1f612b5aa6479e55117abe3548c878f7493d176 (patch)
tree4a1ee7388bb5ac1a9ce8f3da0c66bec33b20a9cf
parent33f0dded6d2dc8ec99767de92ae1f6abf1e0fc55 (diff)
Stream line cursor handling on flush
-rw-r--r--src/ui/grid/grid.rs46
1 files changed, 19 insertions, 27 deletions
diff --git a/src/ui/grid/grid.rs b/src/ui/grid/grid.rs
index 02fcc76..06963d6 100644
--- a/src/ui/grid/grid.rs
+++ b/src/ui/grid/grid.rs
@@ -122,28 +122,26 @@ impl Grid {
pub fn flush(&self, hl_defs: &HlDefs) {
let mut ctx = self.context.borrow_mut();
- // If cursor isn't blinking, drawn the inverted cell into the cursor's
- // cairo context.
- if ctx.cursor_blink_on == 0 {
- if let Some(row) = ctx.rows.get(ctx.cursor.0 as usize) {
- if let Some(cell) = row.cell_at(ctx.cursor.1 as usize) {
- render::cursor_cell(
- &ctx.cursor_context,
- &self.da.get_pango_context().unwrap(),
- &cell,
- &ctx.cell_metrics,
- hl_defs,
- );
- }
+ if let Some(Some(cell)) = ctx
+ .rows
+ .get(ctx.cursor.0 as usize)
+ .map(|row| row.cell_at(ctx.cursor.1 as usize))
+ {
+ // If cursor isn't blinking, drawn the inverted cell into
+ // the cursor's cairo context.
+ if ctx.cursor_blink_on == 0 {
+ render::cursor_cell(
+ &ctx.cursor_context,
+ &self.da.get_pango_context().unwrap(),
+ &cell,
+ &ctx.cell_metrics,
+ hl_defs,
+ );
}
- }
- // Update cursor color.
- if let Some(row) = ctx.rows.get(ctx.cursor.0 as usize) {
- if let Some(cell) = row.cell_at(ctx.cursor.1 as usize) {
- let hl = hl_defs.get(&cell.hl_id).unwrap();
- ctx.cursor_color = hl.foreground.unwrap_or(hl_defs.default_fg);
- }
+ // Update cursor color.
+ let hl = hl_defs.get(&cell.hl_id).unwrap();
+ ctx.cursor_color = hl.foreground.unwrap_or(hl_defs.default_fg);
}
while let Some(area) = ctx.queue_draw_area.pop() {
@@ -410,13 +408,7 @@ impl Grid {
hl_defs: &HlDefs,
) {
let mut ctx = self.context.borrow_mut();
- ctx.resize(
- &self.da,
- win,
- cols as usize,
- rows as usize,
- hl_defs,
- );
+ ctx.resize(&self.da, win, cols as usize, rows as usize, hl_defs);
}
pub fn clear(&self, hl_defs: &HlDefs) {