Implement grapheme segmentation in the terminal layer

This commit is contained in:
Kovid Goyal
2025-04-03 12:37:04 +05:30
parent 167e6e73f7
commit f5e8de2e4f
2 changed files with 84 additions and 86 deletions

View File

@@ -84,8 +84,10 @@ class TestScreen(BaseTest):
# Now test in insert mode
s.reset(), s.reset_dirty()
text = '1\u03062345'
s.set_mode(IRM)
s.draw('1\u03062345' * 5)
s.draw(text * 5)
self.ae(str(s.line(0)), text)
s.cursor_back(5)
self.ae(s.cursor.x, 0), self.ae(s.cursor.y, 4)
s.reset_dirty()
@@ -127,9 +129,9 @@ class TestScreen(BaseTest):
q = '\U0001f468\u200d\U0001f469\u200d\U0001f467\u200d\U0001f466'
s.draw(q)
self.ae(q, str(s.line(0)))
self.ae(s.cursor.x, 8)
self.ae(s.cursor.x, 2)
for x in '\u200b\u200c\u200d':
s = self.create_screen()
s.reset()
q = f'X{x}Y'
s.draw(q)
self.ae(q, str(s.line(0)))