mirror of
https://github.com/kovidgoyal/kitty
synced 2026-06-08 14:18:26 +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 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 .fast_data_types import timed_debug_print as _timed_debug_print
|
||||||
from .rgb import to_color
|
|
||||||
from .types import run_once
|
from .types import run_once
|
||||||
from .typing import AddressFamily, PopenType, Socket, StartupCtx
|
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)
|
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):
|
class ScreenSize(NamedTuple):
|
||||||
rows: int
|
rows: int
|
||||||
cols: int
|
cols: int
|
||||||
|
|||||||
@@ -111,7 +111,6 @@ from .utils import (
|
|||||||
log_error,
|
log_error,
|
||||||
open_cmd,
|
open_cmd,
|
||||||
open_url,
|
open_url,
|
||||||
parse_color_set,
|
|
||||||
path_from_osc7_url,
|
path_from_osc7_url,
|
||||||
resolve_custom_file,
|
resolve_custom_file,
|
||||||
resolved_shell,
|
resolved_shell,
|
||||||
@@ -1293,6 +1292,26 @@ class Window:
|
|||||||
def set_color_table_color(self, code: int, bvalue: Optional[memoryview] = None) -> None:
|
def set_color_table_color(self, code: int, bvalue: Optional[memoryview] = None) -> None:
|
||||||
value = str(bvalue or b'', 'utf-8', 'replace')
|
value = str(bvalue or b'', 'utf-8', 'replace')
|
||||||
cp = self.screen.color_profile
|
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:
|
if code == 4:
|
||||||
changed = False
|
changed = False
|
||||||
for c, val in parse_color_set(value):
|
for c, val in parse_color_set(value):
|
||||||
|
|||||||
Reference in New Issue
Block a user