Reverse video

This commit is contained in:
Michael Jumper 2011-08-05 13:49:47 -07:00
parent 18cdf2808d
commit e0f38ded99
3 changed files with 20 additions and 2 deletions

View File

@ -71,6 +71,7 @@ struct ssh_guac_terminal {
int foreground;
int background;
int reverse;
int default_foreground;
int default_background;

View File

@ -85,6 +85,7 @@ ssh_guac_terminal* ssh_guac_terminal_create(guac_client* client) {
term->foreground = term->default_foreground = 7; /* White */
term->background = term->default_background = 0; /* Black */
term->reverse = 0; /* Normal video */
term->cursor_row = 0;
term->cursor_col = 0;
@ -195,10 +196,17 @@ int ssh_guac_terminal_set(ssh_guac_terminal* term, int row, int col,
GUACIO* io = term->client->io;
guac_layer* glyph = __ssh_guac_terminal_get_glyph(term, c);
const ssh_guac_terminal_color* background_color;
/* Handle reverse video */
if (term->reverse) {
int swap = background;
background = foreground;
foreground = swap;
}
/* Get background color */
const ssh_guac_terminal_color* background_color =
&ssh_guac_terminal_palette[background];
background_color = &ssh_guac_terminal_palette[background];
guac_send_copy(io,
glyph, 0, 0, term->char_width, term->char_height,

View File

@ -186,6 +186,7 @@ int ssh_guac_terminal_csi(ssh_guac_terminal* term, char c) {
if (value == 0) {
term->foreground = term->default_foreground;
term->background = term->default_background;
term->reverse = 0;
}
/* Foreground */
@ -196,6 +197,14 @@ int ssh_guac_terminal_csi(ssh_guac_terminal* term, char c) {
else if (value >= 40 && value <= 47)
term->background = value - 40;
/* Reverse video */
else if (value == 7)
term->reverse = 1;
/* Reset reverse video */
else if (value == 27)
term->reverse = 0;
else
guac_log_info("Unhandled graphics rendition: %i", value);