mirror of
https://github.com/kovidgoyal/kitty
synced 2026-06-06 01:05:48 +02:00
Move function used only in one place to that place
This commit is contained in:
@@ -44,7 +44,6 @@ from .constants import (
|
||||
)
|
||||
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
|
||||
|
||||
@@ -111,7 +111,6 @@ from .utils import (
|
||||
log_error,
|
||||
open_cmd,
|
||||
open_url,
|
||||
parse_color_set,
|
||||
path_from_osc7_url,
|
||||
resolve_custom_file,
|
||||
resolved_shell,
|
||||
@@ -1293,6 +1292,26 @@ class Window:
|
||||
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):
|
||||
|
||||
Reference in New Issue
Block a user