mirror of
https://github.com/kovidgoyal/kitty
synced 2026-07-11 18:32:12 +02:00
DRYer
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
import os
|
||||
from typing import Any, Dict, Iterable, Optional, Tuple, Type, Union
|
||||
|
||||
from kitty.cli_stub import DiffCLIOptions
|
||||
from kitty.conf.definition import config_lines
|
||||
from kitty.conf.utils import (
|
||||
init_config as _init_config, key_func, load_config as _load_config,
|
||||
@@ -12,10 +13,9 @@ from kitty.conf.utils import (
|
||||
)
|
||||
from kitty.constants import config_dir
|
||||
from kitty.options_stub import DiffOptions
|
||||
from kitty.cli_stub import DiffCLIOptions
|
||||
from kitty.rgb import color_as_sgr
|
||||
|
||||
from .config_data import all_options, type_convert
|
||||
from .config_data import all_options
|
||||
|
||||
defaults: Optional[DiffOptions] = None
|
||||
|
||||
@@ -96,7 +96,7 @@ def parse_config(lines: Iterable[str], check_keys: bool = True) -> Dict[str, Any
|
||||
parse_config_base(
|
||||
lines,
|
||||
defaults,
|
||||
type_convert,
|
||||
all_options,
|
||||
special_handling,
|
||||
ans,
|
||||
check_keys=check_keys
|
||||
|
||||
@@ -122,10 +122,3 @@ k('next_match', '>', 'scroll_to next-match', _('Scroll to next search match'))
|
||||
k('prev_match', '<', 'scroll_to prev-match', _('Scroll to previous search match'))
|
||||
k('search_forward_simple', 'f', 'start_search substring forward', _('Search forward (no regex)'))
|
||||
k('search_backward_simple', 'b', 'start_search substring backward', _('Search backward (no regex)'))
|
||||
|
||||
|
||||
def type_convert(name: str, val: Any) -> Any:
|
||||
o = all_options.get(name)
|
||||
if isinstance(o, Option):
|
||||
val = o.option_type(val)
|
||||
return val
|
||||
|
||||
Reference in New Issue
Block a user