diff --git a/kitty/utils.py b/kitty/utils.py index cbab7463c..8408c532f 100644 --- a/kitty/utils.py +++ b/kitty/utils.py @@ -44,7 +44,6 @@ ) from .fast_data_types import WINDOW_FULLSCREEN, WINDOW_MAXIMIZED, WINDOW_MINIMIZED, WINDOW_NORMAL, Color, Shlex, get_options, monotonic, open_tty from .fast_data_types import timed_debug_print as _timed_debug_print -from .rgb import to_color from .types import run_once from .typing import AddressFamily, PopenType, Socket, StartupCtx @@ -164,26 +163,6 @@ def color_from_int(val: int) -> Color: return Color((val >> 16) & 0xFF, (val >> 8) & 0xFF, val & 0xFF) -def parse_color_set(raw: str) -> Generator[Tuple[int, Optional[int]], None, None]: - parts = raw.split(';') - lp = len(parts) - if lp % 2 != 0: - return - for c_, spec in [parts[i:i + 2] for i in range(0, len(parts), 2)]: - try: - c = int(c_) - if c < 0 or c > 255: - continue - if spec == '?': - yield c, None - else: - q = to_color(spec) - if q is not None: - yield c, int(q) & 0xffffff - except Exception: - continue - - class ScreenSize(NamedTuple): rows: int cols: int diff --git a/kitty/window.py b/kitty/window.py index 305c3d383..07debc310 100644 --- a/kitty/window.py +++ b/kitty/window.py @@ -111,7 +111,6 @@ log_error, open_cmd, open_url, - parse_color_set, path_from_osc7_url, resolve_custom_file, resolved_shell, @@ -1293,6 +1292,26 @@ def change(which: DynamicColor, val: str) -> None: def set_color_table_color(self, code: int, bvalue: Optional[memoryview] = None) -> None: value = str(bvalue or b'', 'utf-8', 'replace') cp = self.screen.color_profile + + def parse_color_set(raw: str) -> Generator[Tuple[int, Optional[int]], None, None]: + parts = raw.split(';') + lp = len(parts) + if lp % 2 != 0: + return + for c_, spec in [parts[i:i + 2] for i in range(0, len(parts), 2)]: + try: + c = int(c_) + if c < 0 or c > 255: + continue + if spec == '?': + yield c, None + else: + q = to_color(spec) + if q is not None: + yield c, color_as_int(q) + except Exception: + continue + if code == 4: changed = False for c, val in parse_color_set(value):