diff --git a/src/console.c b/src/console.c index 177c182..ebc67b9 100644 --- a/src/console.c +++ b/src/console.c @@ -763,8 +763,17 @@ static void kmscon_buffer_draw(struct kmscon_buffer *buf, for (j = 0; j < num; ++j) { cell = &line->cells[j]; + + /* TODO: do some more sophisticated inverse here. When + * INVERSE mode is set, we should instead just select + * inverse colors instead of switching background and + * foreground */ + if (buf->flags & KMSCON_CONSOLE_INVERSE) + cell->attr.inverse = !cell->attr.inverse; font_screen_draw_char(fscr, cell->ch, &cell->attr, j, i, 1, 1); + if (buf->flags & KMSCON_CONSOLE_INVERSE) + cell->attr.inverse = !cell->attr.inverse; } } diff --git a/src/console.h b/src/console.h index d48bc06..bdeefba 100644 --- a/src/console.h +++ b/src/console.h @@ -49,6 +49,7 @@ struct kmscon_console; #define KMSCON_CONSOLE_WRAP 0x02 /* modes for kmscon_console_re/set() */ #define KMSCON_CONSOLE_REL_ORIGIN 0x04 +#define KMSCON_CONSOLE_INVERSE 0x08 int kmscon_console_new(struct kmscon_console **out); void kmscon_console_ref(struct kmscon_console *con); diff --git a/src/terminal.c b/src/terminal.c index 87e54dd..6f5f4f0 100644 --- a/src/terminal.c +++ b/src/terminal.c @@ -86,9 +86,11 @@ static void draw_all(struct ev_eloop *eloop, void *unused, void *data) struct screen *iter; struct uterm_screen *screen; int ret; + unsigned int cflags; ev_eloop_unregister_idle_cb(term->eloop, draw_all, term); term->redraw = false; + cflags = kmscon_console_get_flags(term->console); iter = term->screens; for (; iter; iter = iter->next) { @@ -99,7 +101,10 @@ static void draw_all(struct ev_eloop *eloop, void *unused, void *data) continue; gl_viewport(screen); - glClearColor(0.0, 0.0, 0.0, 1.0); + if (cflags & KMSCON_CONSOLE_INVERSE) + glClearColor(1.0, 1.0, 1.0, 1.0); + else + glClearColor(0.0, 0.0, 0.0, 1.0); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); kmscon_console_draw(term->console, iter->fscr); uterm_screen_swap(screen); diff --git a/src/vte.c b/src/vte.c index 160868d..1c75855 100644 --- a/src/vte.c +++ b/src/vte.c @@ -907,6 +907,12 @@ static void csi_mode(struct kmscon_vte *vte, bool set) continue; case 5: /* DECSCNM */ set_reset_flag(vte, set, FLAG_INVERSE_SCREEN_MODE); + if (set) + kmscon_console_set_flags(vte->con, + KMSCON_CONSOLE_INVERSE); + else + kmscon_console_reset_flags(vte->con, + KMSCON_CONSOLE_INVERSE); continue; case 6: /* DECOM */ set_reset_flag(vte, set, FLAG_ORIGIN_MODE);