All option instances must not share the same color table
This commit is contained in:
parent
6bfb704f6f
commit
0045244295
@ -182,6 +182,8 @@ def generate_class(defn: Definition, loc: str) -> Tuple[str, str]:
|
|||||||
a(' config_overrides: typing.Tuple[str, ...] = ()')
|
a(' config_overrides: typing.Tuple[str, ...] = ()')
|
||||||
a('')
|
a('')
|
||||||
a(' def __init__(self, options_dict: typing.Optional[typing.Dict[str, typing.Any]] = None) -> None:')
|
a(' def __init__(self, options_dict: typing.Optional[typing.Dict[str, typing.Any]] = None) -> None:')
|
||||||
|
if defn.has_color_table:
|
||||||
|
a(' self.color_table = array(self.color_table.typecode, self.color_table)')
|
||||||
a(' if options_dict is not None:')
|
a(' if options_dict is not None:')
|
||||||
a(' for key in option_names:')
|
a(' for key in option_names:')
|
||||||
a(' setattr(self, key, options_dict[key])')
|
a(' setattr(self, key, options_dict[key])')
|
||||||
|
|||||||
@ -7,12 +7,14 @@ from functools import partial
|
|||||||
from pprint import pformat
|
from pprint import pformat
|
||||||
from typing import Callable, Dict, Generator, Iterable, Set, Tuple
|
from typing import Callable, Dict, Generator, Iterable, Set, Tuple
|
||||||
|
|
||||||
|
from kittens.tui.operations import colored, styled
|
||||||
|
|
||||||
from .cli import version
|
from .cli import version
|
||||||
from .conf.utils import KeyAction
|
from .conf.utils import KeyAction
|
||||||
from .constants import is_macos, is_wayland
|
from .constants import is_macos, is_wayland
|
||||||
from kittens.tui.operations import colored
|
|
||||||
from .options.types import Options as KittyOpts, defaults
|
from .options.types import Options as KittyOpts, defaults
|
||||||
from .options.utils import MouseMap
|
from .options.utils import MouseMap
|
||||||
|
from .rgb import Color, color_as_sharp
|
||||||
from .types import MouseEvent, SingleKey
|
from .types import MouseEvent, SingleKey
|
||||||
from .typing import SequenceMap
|
from .typing import SequenceMap
|
||||||
|
|
||||||
@ -113,6 +115,7 @@ def compare_opts(opts: KittyOpts, print: Callable) -> None:
|
|||||||
]
|
]
|
||||||
field_len = max(map(len, changed_opts)) if changed_opts else 20
|
field_len = max(map(len, changed_opts)) if changed_opts else 20
|
||||||
fmt = '{{:{:d}s}}'.format(field_len)
|
fmt = '{{:{:d}s}}'.format(field_len)
|
||||||
|
colors = []
|
||||||
for f in changed_opts:
|
for f in changed_opts:
|
||||||
val = getattr(opts, f)
|
val = getattr(opts, f)
|
||||||
if isinstance(val, dict):
|
if isinstance(val, dict):
|
||||||
@ -123,7 +126,11 @@ def compare_opts(opts: KittyOpts, print: Callable) -> None:
|
|||||||
else:
|
else:
|
||||||
print(pformat(val))
|
print(pformat(val))
|
||||||
else:
|
else:
|
||||||
print(title(fmt.format(f)), str(getattr(opts, f)))
|
val = getattr(opts, f)
|
||||||
|
if isinstance(val, Color):
|
||||||
|
colors.append(fmt.format(f) + ' ' + color_as_sharp(val) + ' ' + styled(' ', bg=val))
|
||||||
|
else:
|
||||||
|
print(fmt.format(f), str(getattr(opts, f)))
|
||||||
|
|
||||||
compare_mousemaps(opts.mousemap, default_opts.mousemap, print)
|
compare_mousemaps(opts.mousemap, default_opts.mousemap, print)
|
||||||
final_, initial_ = opts.keymap, default_opts.keymap
|
final_, initial_ = opts.keymap, default_opts.keymap
|
||||||
@ -133,6 +140,9 @@ def compare_opts(opts: KittyOpts, print: Callable) -> None:
|
|||||||
final.update(final_s)
|
final.update(final_s)
|
||||||
initial.update(initial_s)
|
initial.update(initial_s)
|
||||||
compare_keymaps(final, initial, print)
|
compare_keymaps(final, initial, print)
|
||||||
|
if colors:
|
||||||
|
print(f'{title("Colors")}:', end='\n\t')
|
||||||
|
print('\n\t'.join(sorted(colors)))
|
||||||
|
|
||||||
|
|
||||||
def debug_config(opts: KittyOpts) -> str:
|
def debug_config(opts: KittyOpts) -> str:
|
||||||
|
|||||||
1
kitty/options/types.py
generated
1
kitty/options/types.py
generated
@ -606,6 +606,7 @@ class Options:
|
|||||||
config_overrides: typing.Tuple[str, ...] = ()
|
config_overrides: typing.Tuple[str, ...] = ()
|
||||||
|
|
||||||
def __init__(self, options_dict: typing.Optional[typing.Dict[str, typing.Any]] = None) -> None:
|
def __init__(self, options_dict: typing.Optional[typing.Dict[str, typing.Any]] = None) -> None:
|
||||||
|
self.color_table = array(self.color_table.typecode, self.color_table)
|
||||||
if options_dict is not None:
|
if options_dict is not None:
|
||||||
for key in option_names:
|
for key in option_names:
|
||||||
setattr(self, key, options_dict[key])
|
setattr(self, key, options_dict[key])
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user