GUACAMOLE-630: Persist details of color scheme and font changes.

This commit is contained in:
Michael Jumper 2019-08-04 12:44:43 -07:00
parent 4dabea37af
commit ccfcfb116d
2 changed files with 52 additions and 0 deletions

View File

@ -343,6 +343,11 @@ guac_terminal* guac_terminal_create(guac_client* client,
term->upload_path_handler = NULL;
term->file_download_handler = NULL;
/* Copy initially-provided color scheme and font details */
term->color_scheme = strdup(color_scheme);
term->font_name = strdup(font_name);
term->font_size = font_size;
/* Set size of available screen area */
term->outer_width = width;
term->outer_height = height;
@ -511,6 +516,10 @@ void guac_terminal_free(guac_terminal* term) {
/* Free scrollbar */
guac_terminal_scrollbar_free(term->scrollbar);
/* Free copies of font and color scheme information */
free((char*) term->color_scheme);
free((char*) term->font_name);
/* Free the terminal itself */
free(term);
@ -1955,6 +1964,16 @@ void guac_terminal_apply_color_scheme(guac_terminal* terminal,
terminal->term_height - 1,
terminal->term_width - 1);
/* Acquire exclusive access to terminal */
guac_terminal_lock(terminal);
/* Update stored copy of color scheme */
free((char*) terminal->color_scheme);
terminal->color_scheme = strdup(color_scheme);
/* Release terminal */
guac_terminal_unlock(terminal);
guac_terminal_notify(terminal);
}
@ -1979,6 +1998,20 @@ void guac_terminal_apply_font(guac_terminal* terminal, const char* font_name,
terminal->term_height - 1,
terminal->term_width - 1);
/* Acquire exclusive access to terminal */
guac_terminal_lock(terminal);
/* Update stored copy of font name, if changed */
if (font_name != NULL)
terminal->font_name = strdup(font_name);
/* Update stored copy of font size, if changed */
if (font_size != -1)
terminal->font_size = font_size;
/* Release terminal */
guac_terminal_unlock(terminal);
guac_terminal_notify(terminal);
}

View File

@ -506,6 +506,25 @@ struct guac_terminal {
*/
guac_common_clipboard* clipboard;
/**
* The name of the font to use when rendering glyphs, as requested at
* creation time or via guac_terminal_apply_font().
*/
const char* font_name;
/**
* The size of each glyph, in points, as requested at creation time or via
* guac_terminal_apply_font().
*/
int font_size;
/**
* The name of the color scheme to use, as requested at creation time or
* via guac_terminal_apply_color_scheme(). This string must be in the
* format accepted by guac_terminal_parse_color_scheme().
*/
const char* color_scheme;
/**
* ASCII character to send when backspace is pressed.
*/