Skip to content

Commit

Permalink
Unify format of responses to OSC 10 and OSC 11 / 12 queries
Browse files Browse the repository at this point in the history
  • Loading branch information
bash committed Apr 9, 2024
1 parent 6e064dd commit 881999f
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions src/bin/termptyesc.c
Original file line number Diff line number Diff line change
Expand Up @@ -4221,6 +4221,14 @@ _handle_xterm_777_command(Termpty *ty,
*title_end = ';';
}

static void
_write_xterm_color_response(Termpty *ty, uint8_t number, int r, int g, int b)
{
char buf[64];
int l = snprintf(buf, sizeof(buf), "\033]%d;rgb:%.2x%.2x/%.2x%.2x/%.2x%.2x\033\\", number, r, r, g, g, b, b);
termpty_write(ty, buf, l);
}

static void
_handle_xterm_10_command(Termpty *ty, Eina_Unicode *p, int len)
{
Expand All @@ -4229,8 +4237,6 @@ _handle_xterm_10_command(Termpty *ty, Eina_Unicode *p, int len)
if (*p == '?')
{
int r, g, b;
char bf[32];
int l;
#if !defined(BINARY_TYFUZZ) && !defined(BINARY_TYTEST)
evas_object_textgrid_palette_get(
termio_textgrid_get(ty->obj),
Expand All @@ -4242,8 +4248,7 @@ _handle_xterm_10_command(Termpty *ty, Eina_Unicode *p, int len)
g = config->colors[0].g;
b = config->colors[0].b;
#endif
l = snprintf(bf, sizeof(bf), "\033]10;#%.2X%.2X%.2X\007", r, g, b);
termpty_write(ty, bf, l);
_write_xterm_color_response(ty, 10, r, g, b);
}
else
{
Expand Down Expand Up @@ -4278,19 +4283,14 @@ _handle_xterm_set_color_class(Termpty *ty, Eina_Unicode *p, int len,
if (*p == '?')
{
int r = 0, g = 0, b = 0;
char buf[64];
int l;

if (edje_object_color_class_get(obj, color_class, &r, &g, &b, NULL,
NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL) != EINA_TRUE)
{
ERR("error getting color class '%s' on obj %p", color_class, obj);
}
l = snprintf(buf, sizeof(buf),
"\033]%d;rgb:%.2x%.2x/%.2x%.2x/%.2x%.2x\033\\",
number, r, r, g, g, b, b);
termpty_write(ty, buf, l);
_write_xterm_color_response(ty, number, r, g, b);
}
else
{
Expand Down

0 comments on commit 881999f

Please sign in to comment.