mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-02-05 04:06:08 -05:00
osc: merge OSC 10/11/12/17/19 handling
10/11/17/19 were already merged, so this patch just stops special casing 12 (cursor color). In preparation for XTPUSHCOLORS/XTPOPCOLORS, the cursor colors are moved from their own struct, into the 'colors' struct. Also fix a bug where OSC 17/19 queries returned OSC-11 data.
This commit is contained in:
parent
e708d19ea3
commit
5d4a002413
4 changed files with 33 additions and 58 deletions
67
osc.c
67
osc.c
|
|
@ -712,15 +712,25 @@ osc_dispatch(struct terminal *term)
|
|||
osc_notify(term, string);
|
||||
break;
|
||||
|
||||
case 10:
|
||||
case 11:
|
||||
case 17:
|
||||
case 19: {
|
||||
case 10: /* fg */
|
||||
case 11: /* bg */
|
||||
case 12: /* cursor */
|
||||
case 17: /* highlight (selection) fg */
|
||||
case 19: { /* highlight (selection) bg */
|
||||
/* Set default foreground/background/highlight-bg/highlight-fg color */
|
||||
|
||||
/* Client queried for current value */
|
||||
if (string[0] == '?' && string[1] == '\0') {
|
||||
uint32_t color = param == 10 ? term->colors.fg : term->colors.bg;
|
||||
uint32_t color = param == 10
|
||||
? term->colors.fg
|
||||
: param == 11
|
||||
? term->colors.bg
|
||||
: param == 12
|
||||
? term->colors.cursor_bg
|
||||
: param == 17
|
||||
? term->colors.selection_bg
|
||||
: term->colors.selection_fg;
|
||||
|
||||
uint8_t r = (color >> 16) & 0xff;
|
||||
uint8_t g = (color >> 8) & 0xff;
|
||||
uint8_t b = (color >> 0) & 0xff;
|
||||
|
|
@ -754,6 +764,7 @@ osc_dispatch(struct terminal *term)
|
|||
LOG_DBG("change color definition for %s to %06x",
|
||||
param == 10 ? "foreground" :
|
||||
param == 11 ? "background" :
|
||||
param == 12 ? "cursor" :
|
||||
param == 17 ? "selection background" :
|
||||
"selection foreground",
|
||||
color);
|
||||
|
|
@ -776,6 +787,11 @@ osc_dispatch(struct terminal *term)
|
|||
}
|
||||
break;
|
||||
|
||||
case 12:
|
||||
term->colors.cursor_bg = 1u << 31 | color;
|
||||
term_damage_cursor(term);
|
||||
break;
|
||||
|
||||
case 17:
|
||||
term->colors.selection_bg = color;
|
||||
term->colors.use_custom_selection = true;
|
||||
|
|
@ -792,43 +808,6 @@ osc_dispatch(struct terminal *term)
|
|||
break;
|
||||
}
|
||||
|
||||
case 12: /* Set cursor color */
|
||||
|
||||
/* Client queried for current value */
|
||||
if (string[0] == '?' && string[1] == '\0') {
|
||||
uint8_t r = (term->cursor_color.cursor >> 16) & 0xff;
|
||||
uint8_t g = (term->cursor_color.cursor >> 8) & 0xff;
|
||||
uint8_t b = (term->cursor_color.cursor >> 0) & 0xff;
|
||||
const char *terminator = term->vt.osc.bel ? "\a" : "\033\\";
|
||||
|
||||
char reply[32];
|
||||
size_t n = xsnprintf(
|
||||
reply, sizeof(reply), "\033]12;rgb:%02x/%02x/%02x%s",
|
||||
r, g, b, terminator);
|
||||
|
||||
term_to_slave(term, reply, n);
|
||||
break;
|
||||
}
|
||||
|
||||
uint32_t color;
|
||||
|
||||
if (string[0] == '#' || string[0] == '['
|
||||
? !parse_legacy_color(string, &color, NULL, NULL)
|
||||
: !parse_rgb(string, &color, NULL, NULL))
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
LOG_DBG("change cursor color to %06x", color);
|
||||
|
||||
if (color == 0)
|
||||
term->cursor_color.cursor = 0; /* Invert fg/bg */
|
||||
else
|
||||
term->cursor_color.cursor = 1u << 31 | color;
|
||||
|
||||
term_damage_cursor(term);
|
||||
break;
|
||||
|
||||
case 22: /* Set mouse cursor */
|
||||
term_set_user_mouse_cursor(term, string);
|
||||
break;
|
||||
|
|
@ -895,8 +874,8 @@ osc_dispatch(struct terminal *term)
|
|||
|
||||
case 112:
|
||||
LOG_DBG("resetting cursor color");
|
||||
term->cursor_color.text = term->conf->cursor.color.text;
|
||||
term->cursor_color.cursor = term->conf->cursor.color.cursor;
|
||||
term->colors.cursor_fg = term->conf->cursor.color.text;
|
||||
term->colors.cursor_bg = term->conf->cursor.color.cursor;
|
||||
term_damage_cursor(term);
|
||||
break;
|
||||
|
||||
|
|
|
|||
8
render.c
8
render.c
|
|
@ -557,13 +557,13 @@ cursor_colors_for_cell(const struct terminal *term, const struct cell *cell,
|
|||
const pixman_color_t *fg, const pixman_color_t *bg,
|
||||
pixman_color_t *cursor_color, pixman_color_t *text_color)
|
||||
{
|
||||
if (term->cursor_color.cursor >> 31)
|
||||
*cursor_color = color_hex_to_pixman(term->cursor_color.cursor);
|
||||
if (term->colors.cursor_bg >> 31)
|
||||
*cursor_color = color_hex_to_pixman(term->colors.cursor_bg);
|
||||
else
|
||||
*cursor_color = *fg;
|
||||
|
||||
if (term->cursor_color.text >> 31)
|
||||
*text_color = color_hex_to_pixman(term->cursor_color.text);
|
||||
if (term->colors.cursor_fg >> 31)
|
||||
*text_color = color_hex_to_pixman(term->colors.cursor_fg);
|
||||
else {
|
||||
*text_color = *bg;
|
||||
|
||||
|
|
|
|||
10
terminal.c
10
terminal.c
|
|
@ -1221,6 +1221,8 @@ term_init(const struct config *conf, struct fdm *fdm, struct reaper *reaper,
|
|||
.fg = conf->colors.fg,
|
||||
.bg = conf->colors.bg,
|
||||
.alpha = conf->colors.alpha,
|
||||
.cursor_fg = conf->cursor.color.text,
|
||||
.cursor_bg = conf->cursor.color.cursor,
|
||||
.selection_fg = conf->colors.selection_fg,
|
||||
.selection_bg = conf->colors.selection_bg,
|
||||
.use_custom_selection = conf->colors.use_custom.selection,
|
||||
|
|
@ -1233,10 +1235,6 @@ term_init(const struct config *conf, struct fdm *fdm, struct reaper *reaper,
|
|||
.state = CURSOR_BLINK_ON,
|
||||
.fd = -1,
|
||||
},
|
||||
.cursor_color = {
|
||||
.text = conf->cursor.color.text,
|
||||
.cursor = conf->cursor.color.cursor,
|
||||
},
|
||||
.selection = {
|
||||
.coords = {
|
||||
.start = {-1, -1},
|
||||
|
|
@ -2035,6 +2033,8 @@ term_reset(struct terminal *term, bool hard)
|
|||
term->colors.fg = term->conf->colors.fg;
|
||||
term->colors.bg = term->conf->colors.bg;
|
||||
term->colors.alpha = term->conf->colors.alpha;
|
||||
term->colors.cursor_fg = term->conf->cursor.color.text;
|
||||
term->colors.cursor_bg = term->conf->cursor.color.cursor;
|
||||
term->colors.selection_fg = term->conf->colors.selection_fg;
|
||||
term->colors.selection_bg = term->conf->colors.selection_bg;
|
||||
term->colors.use_custom_selection = term->conf->colors.use_custom.selection;
|
||||
|
|
@ -2051,8 +2051,6 @@ term_reset(struct terminal *term, bool hard)
|
|||
term->cursor_blink.decset = false;
|
||||
term->cursor_blink.deccsusr = term->conf->cursor.blink.enabled;
|
||||
term_cursor_blink_update(term);
|
||||
term->cursor_color.text = term->conf->cursor.color.text;
|
||||
term->cursor_color.cursor = term->conf->cursor.color.cursor;
|
||||
selection_cancel(term);
|
||||
term->normal.offset = term->normal.view = 0;
|
||||
term->alt.offset = term->alt.view = 0;
|
||||
|
|
|
|||
|
|
@ -568,6 +568,8 @@ struct terminal {
|
|||
uint32_t bg;
|
||||
uint32_t table[256];
|
||||
uint16_t alpha;
|
||||
uint32_t cursor_fg; /* Text color */
|
||||
uint32_t cursor_bg; /* cursor color */
|
||||
uint32_t selection_fg;
|
||||
uint32_t selection_bg;
|
||||
bool use_custom_selection;
|
||||
|
|
@ -580,10 +582,6 @@ struct terminal {
|
|||
int fd;
|
||||
enum { CURSOR_BLINK_ON, CURSOR_BLINK_OFF } state;
|
||||
} cursor_blink;
|
||||
struct {
|
||||
uint32_t text;
|
||||
uint32_t cursor;
|
||||
} cursor_color;
|
||||
|
||||
struct {
|
||||
enum selection_kind kind;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue