aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Eklöf <daniel@ekloef.se>2019-07-05 18:12:40 +0000
committerDaniel Eklöf <daniel@ekloef.se>2019-07-05 18:12:40 +0000
commitb26e03fced0100192238063b5baf988954500d3b (patch)
tree7a19c7d96dc7f8600effa45140336c51746534ac
parentcsi: implement URXVT style mouse event reporting (diff)
csi: implement reverse video
-rw-r--r--csi.c6
-rw-r--r--render.c19
-rw-r--r--terminal.h1
3 files changed, 18 insertions, 8 deletions
diff --git a/csi.c b/csi.c
index 09d76d52..de7d8a89 100644
--- a/csi.c
+++ b/csi.c
@@ -577,7 +577,8 @@ csi_dispatch(struct terminal *term, uint8_t final)
break;
case 5:
- LOG_WARN("unimplemented: flash");
+ term->reverse = true;
+ term_damage_all(term);
break;
case 7:
@@ -655,7 +656,8 @@ csi_dispatch(struct terminal *term, uint8_t final)
break;
case 5:
- LOG_WARN("unimplemented: flash");
+ term->reverse = false;
+ term_damage_all(term);
break;
case 7:
diff --git a/render.c b/render.c
index 6f70309b..68f25cd1 100644
--- a/render.c
+++ b/render.c
@@ -92,6 +92,12 @@ grid_render_update(struct terminal *term, struct buffer *buf, const struct damag
struct rgba background = cell->attrs.have_background
? cell->attrs.background : term->background;
+ if (term->reverse) {
+ struct rgba swap = foreground;
+ foreground = background;
+ background = swap;
+ }
+
if (has_cursor) {
struct rgba swap = foreground;
foreground = background;
@@ -186,9 +192,10 @@ grid_render_erase(struct terminal *term, struct buffer *buf, const struct damage
assert(dmg->range.start >= term->grid->offset);
- cairo_set_source_rgba(
- buf->cairo, term->background.r, term->background.g,
- term->background.b, term->background.a);
+ const struct rgba *bg = !term->reverse ?
+ &term->background : &term->foreground;
+
+ cairo_set_source_rgba(buf->cairo, bg->r, bg->g, bg->b, bg->a);
const int cols = term->cols;
@@ -375,9 +382,9 @@ grid_render(struct terminal *term)
int rmargin_width = term->width - rmargin;
int bmargin_height = term->height - bmargin;
- cairo_set_source_rgba(
- buf->cairo, term->background.r, term->background.g,
- term->background.b, term->background.a);
+ const struct rgba *bg = !term->reverse ?
+ &term->background : &term->foreground;
+ cairo_set_source_rgba(buf->cairo, bg->r, bg->g, bg->b, bg->a);
cairo_rectangle(buf->cairo, rmargin, 0, rmargin_width, term->height);
cairo_rectangle(buf->cairo, 0, bmargin, term->width, bmargin_height);
diff --git a/terminal.h b/terminal.h
index 4642bbae..099e384a 100644
--- a/terminal.h
+++ b/terminal.h
@@ -184,6 +184,7 @@ struct terminal {
enum decckm decckm;
enum keypad_mode keypad_mode;
+ bool reverse;
bool hide_cursor;
bool auto_margin;
bool insert_mode;