Refactor: More f-string for kitty fonts and rc send_text
This commit is contained in:
parent
1ca1c2edad
commit
c21f00c476
@ -29,7 +29,7 @@ def create_font_map(all_fonts: Iterable[CoreTextFont]) -> FontMap:
|
||||
ps = (x['postscript_name'] or '').lower()
|
||||
ans['family_map'].setdefault(f, []).append(x)
|
||||
ans['ps_map'].setdefault(ps, []).append(x)
|
||||
ans['full_map'].setdefault(f + ' ' + s, []).append(x)
|
||||
ans['full_map'].setdefault(f'{f} {s}', []).append(x)
|
||||
return ans
|
||||
|
||||
|
||||
@ -45,7 +45,7 @@ def list_fonts() -> Generator[ListedFont, None, None]:
|
||||
for fd in coretext_all_fonts():
|
||||
f = fd['family']
|
||||
if f:
|
||||
fn = (f + ' ' + (fd['style'] or '')).strip()
|
||||
fn = f'{f} {fd.get("style", "")}'.strip()
|
||||
is_mono = bool(fd['monospace'])
|
||||
yield {'family': f, 'full_name': fn, 'postscript_name': fd['postscript_name'] or '', 'is_monospace': is_mono}
|
||||
|
||||
|
||||
@ -58,7 +58,7 @@ def list_fonts() -> Generator[ListedFont, None, None]:
|
||||
if fn_:
|
||||
fn = str(fn_)
|
||||
else:
|
||||
fn = (f + ' ' + str(fd.get('style', ''))).strip()
|
||||
fn = f'{f} {fd.get("style", "")}'.strip()
|
||||
is_mono = fd.get('spacing') in ('MONO', 'DUAL')
|
||||
yield {'family': f, 'full_name': fn, 'postscript_name': str(fd.get('postscript_name', '')), 'is_monospace': is_mono}
|
||||
|
||||
|
||||
@ -28,13 +28,13 @@ def main(argv: Sequence[str]) -> None:
|
||||
groups = create_family_groups()
|
||||
for k in sorted(groups, key=lambda x: x.lower()):
|
||||
if isatty:
|
||||
print('\033[1;32m' + k + '\033[m')
|
||||
print(f'\033[1;32m{k}\033[m')
|
||||
else:
|
||||
print(k)
|
||||
for f in sorted(groups[k], key=lambda x: x['full_name'].lower()):
|
||||
p = f['full_name']
|
||||
if isatty:
|
||||
p = '\033[3m' + p + '\033[m'
|
||||
p = f'\033[3m{p}\033[m'
|
||||
if psnames:
|
||||
p += ' ({})'.format(f['postscript_name'])
|
||||
print(' ', p)
|
||||
|
||||
@ -515,7 +515,7 @@ def test_fallback_font(qtext: Optional[str] = None, bold: bool = False, italic:
|
||||
try:
|
||||
print(text, f)
|
||||
except UnicodeEncodeError:
|
||||
sys.stdout.buffer.write((text + ' %s\n' % f).encode('utf-8'))
|
||||
sys.stdout.buffer.write(f'{text} {f}\n'.encode('utf-8'))
|
||||
|
||||
|
||||
def showcase() -> None:
|
||||
|
||||
@ -107,20 +107,20 @@ Do not send text to the active window, even if it is one of the matched windows.
|
||||
if '\x04' in decoded_data:
|
||||
decoded_data = decoded_data[:decoded_data.index('\x04')]
|
||||
keep_going = False
|
||||
ret['data'] = 'text:' + decoded_data
|
||||
ret['data'] = f'text:{decoded_data}'
|
||||
yield ret
|
||||
else:
|
||||
while True:
|
||||
data = sys.stdin.buffer.read(limit)
|
||||
if not data:
|
||||
break
|
||||
ret['data'] = 'base64:' + base64.standard_b64encode(data).decode('ascii')
|
||||
ret['data'] = f'base64:{base64.standard_b64encode(data).decode("ascii")}'
|
||||
yield ret
|
||||
|
||||
def chunks(text: str) -> CmdGenerator:
|
||||
data = parse_send_text_bytes(text).decode('utf-8')
|
||||
while data:
|
||||
ret['data'] = 'text:' + data[:limit]
|
||||
ret['data'] = f'text:{data[:limit]}'
|
||||
yield ret
|
||||
data = data[limit:]
|
||||
|
||||
@ -130,7 +130,7 @@ Do not send text to the active window, even if it is one of the matched windows.
|
||||
data = f.read(limit)
|
||||
if not data:
|
||||
break
|
||||
ret['data'] = 'base64:' + base64.standard_b64encode(data).decode('ascii')
|
||||
ret['data'] = f'base64:{base64.standard_b64encode(data).decode("ascii")}'
|
||||
yield ret
|
||||
|
||||
sources = []
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user