mirror of
https://github.com/kovidgoyal/kitty
synced 2026-07-17 22:14:53 +02:00
Fast function to replace c0 codes
This commit is contained in:
@@ -13,6 +13,7 @@ from kitty.fast_data_types import (
|
||||
LineBuf,
|
||||
expand_ansi_c_escapes,
|
||||
parse_input_from_terminal,
|
||||
replace_c0_codes_except_for_newline_and_space,
|
||||
strip_csi,
|
||||
truncate_point_for_length,
|
||||
wcswidth,
|
||||
@@ -37,6 +38,17 @@ def create_lbuf(*lines):
|
||||
|
||||
class TestDataTypes(BaseTest):
|
||||
|
||||
|
||||
def test_replace_c0_codes(self):
|
||||
def t(x: str, expected: str):
|
||||
q = replace_c0_codes_except_for_newline_and_space(x)
|
||||
self.ae(expected, q)
|
||||
q = replace_c0_codes_except_for_newline_and_space(x.encode('utf-8'))
|
||||
self.ae(expected.encode('utf-8'), q)
|
||||
t('abc', 'abc')
|
||||
t('a\0\x01b\x03\x04\t\rc', 'a\u2400\u2401b\u2403\u2404\u2409\u240dc')
|
||||
t('a\0\x01😸\x03\x04\t\rc', 'a\u2400\u2401😸\u2403\u2404\u2409\u240dc')
|
||||
|
||||
def test_to_color(self):
|
||||
for x in 'xxx #12 #1234 rgb:a/b'.split():
|
||||
self.assertIsNone(to_color(x))
|
||||
|
||||
Reference in New Issue
Block a user