terminal/vte/console: support inverse-screen-mode

In inverse screen mode we switch background and foreground colors. As our
console layer supports transparent backgrounds, we have to do this in the
terminal layer.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
This commit is contained in:
David Herrmann 2012-05-30 18:19:49 +02:00
parent 2630ee585b
commit 7129a9038c
4 changed files with 22 additions and 1 deletions

View File

@ -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;
}
}

View File

@ -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);

View File

@ -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);

View File

@ -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);