Allow setting color table value to none via OSC 21
This commit is contained in:
parent
0a3a9031c5
commit
7e5aac2e2b
3 changed files with 16 additions and 3 deletions
|
|
@ -586,6 +586,11 @@ set_color(ColorProfile *self, PyObject *args) {
|
|||
if (!PyArg_ParseTuple(args, "Bk", &i, &val)) return NULL;
|
||||
self->color_table[i] = val;
|
||||
self->dirty = true;
|
||||
if (val == NULL_COLOR_VALUE) {
|
||||
bool semantic, dynamic = palette_generation_is_dynamic(global_state.options_object, &semantic);
|
||||
if (dynamic) generate_256_palette(self, self->color_table, semantic);
|
||||
else self->color_table[i] = FG_BG_256[i];
|
||||
}
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -49,6 +49,7 @@
|
|||
GLFW_RELEASE,
|
||||
GLFW_REPEAT,
|
||||
NO_CURSOR_SHAPE,
|
||||
NULL_COLOR_VALUE,
|
||||
SCROLL_FULL,
|
||||
SCROLL_LINE,
|
||||
SCROLL_PAGE,
|
||||
|
|
@ -577,9 +578,13 @@ def serialize_color(c: Color | None) -> str:
|
|||
else:
|
||||
if 0 <= colnum <= 255:
|
||||
val = val.partition('@')[0]
|
||||
col = to_color(val)
|
||||
if col is not None:
|
||||
cp.set_color(colnum, color_as_int(col))
|
||||
if val:
|
||||
if (col := to_color(val)) is not None:
|
||||
cp.set_color(colnum, color_as_int(col))
|
||||
elif colnum > 15:
|
||||
cp.set_color(colnum, NULL_COLOR_VALUE)
|
||||
else:
|
||||
cp.set_color(colnum, get_options().color_table[colnum])
|
||||
else:
|
||||
if attr:
|
||||
delattr(cp, attr)
|
||||
|
|
|
|||
|
|
@ -1616,6 +1616,9 @@ def q(send, expected=None):
|
|||
q({'selection_background': ''})
|
||||
self.assertIsNone(s.color_profile.highlight_bg)
|
||||
q({'selection_background': '?'}, {'selection_background': ''})
|
||||
opts = self.set_options({'palette_generate': 'semantic'})
|
||||
q({'213': ''})
|
||||
q({'213': '?'}, {'213': Color(216, 125, 215)})
|
||||
s.color_profile.reload_from_opts(opts)
|
||||
q({'transparent_background_color9': '?'}, {'transparent_background_color9': '?'})
|
||||
q({'transparent_background_color2': '?'}, {'transparent_background_color2': ''})
|
||||
|
|
|
|||
Loading…
Reference in a new issue