A new option narrow_symbols to turn off opportunistic wide rendering of private use codepoints

This commit is contained in:
Kovid Goyal
2022-02-11 13:04:44 +05:30
parent b2317e0f12
commit 01b4654461
9 changed files with 100 additions and 42 deletions

View File

@@ -818,19 +818,19 @@ def action_alias(val: str) -> Iterable[Tuple[str, str]]:
kitten_alias = action_alias
def symbol_map(val: str) -> Iterable[Tuple[Tuple[int, int], str]]:
def symbol_map(val: str, min_size: int = 2) -> Iterable[Tuple[Tuple[int, int], str]]:
parts = val.split()
def abort() -> None:
log_error(f'Symbol map: {val} is invalid, ignoring')
if len(parts) < 2:
if len(parts) < min_size:
return abort()
family = ' '.join(parts[1:])
def to_chr(x: str) -> int:
if not x.startswith('U+'):
raise ValueError()
raise ValueError(f'{x} is not a unicode codepoint of the form U+number')
return int(x[2:], 16)
for x in parts[0].split(','):
@@ -845,6 +845,11 @@ def symbol_map(val: str) -> Iterable[Tuple[Tuple[int, int], str]]:
yield (a, b), family
def narrow_symbols(val: str) -> Iterable[Tuple[Tuple[int, int], int]]:
for x, y in symbol_map(val, min_size=1):
yield x, int(y or 1)
def parse_key_action(action: str, action_type: str = 'map') -> KeyAction:
parts = action.strip().split(maxsplit=1)
func = parts[0]