mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-04-09 08:21:01 -04:00
csi: implement reverse video
This commit is contained in:
parent
c76e620d71
commit
b26e03fced
3 changed files with 18 additions and 8 deletions
6
csi.c
6
csi.c
|
|
@ -577,7 +577,8 @@ csi_dispatch(struct terminal *term, uint8_t final)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 5:
|
case 5:
|
||||||
LOG_WARN("unimplemented: flash");
|
term->reverse = true;
|
||||||
|
term_damage_all(term);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 7:
|
case 7:
|
||||||
|
|
@ -655,7 +656,8 @@ csi_dispatch(struct terminal *term, uint8_t final)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 5:
|
case 5:
|
||||||
LOG_WARN("unimplemented: flash");
|
term->reverse = false;
|
||||||
|
term_damage_all(term);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 7:
|
case 7:
|
||||||
|
|
|
||||||
19
render.c
19
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
|
struct rgba background = cell->attrs.have_background
|
||||||
? cell->attrs.background : term->background;
|
? cell->attrs.background : term->background;
|
||||||
|
|
||||||
|
if (term->reverse) {
|
||||||
|
struct rgba swap = foreground;
|
||||||
|
foreground = background;
|
||||||
|
background = swap;
|
||||||
|
}
|
||||||
|
|
||||||
if (has_cursor) {
|
if (has_cursor) {
|
||||||
struct rgba swap = foreground;
|
struct rgba swap = foreground;
|
||||||
foreground = background;
|
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);
|
assert(dmg->range.start >= term->grid->offset);
|
||||||
|
|
||||||
cairo_set_source_rgba(
|
const struct rgba *bg = !term->reverse ?
|
||||||
buf->cairo, term->background.r, term->background.g,
|
&term->background : &term->foreground;
|
||||||
term->background.b, term->background.a);
|
|
||||||
|
cairo_set_source_rgba(buf->cairo, bg->r, bg->g, bg->b, bg->a);
|
||||||
|
|
||||||
const int cols = term->cols;
|
const int cols = term->cols;
|
||||||
|
|
||||||
|
|
@ -375,9 +382,9 @@ grid_render(struct terminal *term)
|
||||||
int rmargin_width = term->width - rmargin;
|
int rmargin_width = term->width - rmargin;
|
||||||
int bmargin_height = term->height - bmargin;
|
int bmargin_height = term->height - bmargin;
|
||||||
|
|
||||||
cairo_set_source_rgba(
|
const struct rgba *bg = !term->reverse ?
|
||||||
buf->cairo, term->background.r, term->background.g,
|
&term->background : &term->foreground;
|
||||||
term->background.b, term->background.a);
|
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, rmargin, 0, rmargin_width, term->height);
|
||||||
cairo_rectangle(buf->cairo, 0, bmargin, term->width, bmargin_height);
|
cairo_rectangle(buf->cairo, 0, bmargin, term->width, bmargin_height);
|
||||||
|
|
|
||||||
|
|
@ -184,6 +184,7 @@ struct terminal {
|
||||||
|
|
||||||
enum decckm decckm;
|
enum decckm decckm;
|
||||||
enum keypad_mode keypad_mode;
|
enum keypad_mode keypad_mode;
|
||||||
|
bool reverse;
|
||||||
bool hide_cursor;
|
bool hide_cursor;
|
||||||
bool auto_margin;
|
bool auto_margin;
|
||||||
bool insert_mode;
|
bool insert_mode;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue