Allow setting color table value to none via OSC 21
This commit is contained in:
@@ -586,6 +586,11 @@ set_color(ColorProfile *self, PyObject *args) {
|
|||||||
if (!PyArg_ParseTuple(args, "Bk", &i, &val)) return NULL;
|
if (!PyArg_ParseTuple(args, "Bk", &i, &val)) return NULL;
|
||||||
self->color_table[i] = val;
|
self->color_table[i] = val;
|
||||||
self->dirty = true;
|
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;
|
Py_RETURN_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -49,6 +49,7 @@ from .fast_data_types import (
|
|||||||
GLFW_RELEASE,
|
GLFW_RELEASE,
|
||||||
GLFW_REPEAT,
|
GLFW_REPEAT,
|
||||||
NO_CURSOR_SHAPE,
|
NO_CURSOR_SHAPE,
|
||||||
|
NULL_COLOR_VALUE,
|
||||||
SCROLL_FULL,
|
SCROLL_FULL,
|
||||||
SCROLL_LINE,
|
SCROLL_LINE,
|
||||||
SCROLL_PAGE,
|
SCROLL_PAGE,
|
||||||
@@ -577,9 +578,13 @@ def color_control(cp: ColorProfile, code: int, value: str | bytes | memoryview =
|
|||||||
else:
|
else:
|
||||||
if 0 <= colnum <= 255:
|
if 0 <= colnum <= 255:
|
||||||
val = val.partition('@')[0]
|
val = val.partition('@')[0]
|
||||||
col = to_color(val)
|
if val:
|
||||||
if col is not None:
|
if (col := to_color(val)) is not None:
|
||||||
cp.set_color(colnum, color_as_int(col))
|
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:
|
else:
|
||||||
if attr:
|
if attr:
|
||||||
delattr(cp, attr)
|
delattr(cp, attr)
|
||||||
|
|||||||
@@ -1616,6 +1616,9 @@ class TestScreen(BaseTest):
|
|||||||
q({'selection_background': ''})
|
q({'selection_background': ''})
|
||||||
self.assertIsNone(s.color_profile.highlight_bg)
|
self.assertIsNone(s.color_profile.highlight_bg)
|
||||||
q({'selection_background': '?'}, {'selection_background': ''})
|
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)
|
s.color_profile.reload_from_opts(opts)
|
||||||
q({'transparent_background_color9': '?'}, {'transparent_background_color9': '?'})
|
q({'transparent_background_color9': '?'}, {'transparent_background_color9': '?'})
|
||||||
q({'transparent_background_color2': '?'}, {'transparent_background_color2': ''})
|
q({'transparent_background_color2': '?'}, {'transparent_background_color2': ''})
|
||||||
|
|||||||
Reference in New Issue
Block a user