mirror of
https://github.com/kovidgoyal/kitty
synced 2026-07-26 18:22:09 +02:00
Use a more efficient representation of the color table on the Options object
This commit is contained in:
@@ -25,17 +25,13 @@ def option_names_for_completion() -> Tuple[str, ...]:
|
||||
no_op_actions = frozenset({'noop', 'no-op', 'no_op'})
|
||||
|
||||
|
||||
def build_ansi_color_table(opts: Optional[Options] = None) -> List[int]:
|
||||
def build_ansi_color_table(opts: Optional[Options] = None) -> int:
|
||||
if opts is None:
|
||||
opts = defaults
|
||||
|
||||
def as_int(x: Tuple[int, int, int]) -> int:
|
||||
return (x[0] << 16) | (x[1] << 8) | x[2]
|
||||
|
||||
def col(i: int) -> int:
|
||||
return as_int(getattr(opts, 'color{}'.format(i)))
|
||||
|
||||
return list(map(col, range(256)))
|
||||
addr, length = opts.color_table.buffer_info()
|
||||
if length != 256 or opts.color_table.typecode != 'L':
|
||||
raise TypeError(f'The color table has incorrect size length: {length} typecode: {opts.color_table.typecode}')
|
||||
return addr
|
||||
|
||||
|
||||
def atomic_save(data: bytes, path: str) -> None:
|
||||
|
||||
Reference in New Issue
Block a user