mirror of
https://github.com/kovidgoyal/kitty.git
synced 2024-11-13 12:09:35 +03:00
...
This commit is contained in:
parent
088f6aad25
commit
5bd728fe2f
@ -13,30 +13,30 @@ class TestScreen(BaseTest):
|
||||
# Test in line-wrap, non-insert mode
|
||||
s, t = self.create_screen()
|
||||
s.draw(b'a' * 5)
|
||||
self.ae(str(s.linebuf[0]), 'a' * 5)
|
||||
self.ae(str(s.line(0)), 'a' * 5)
|
||||
self.ae(s.cursor.x, 5), self.ae(s.cursor.y, 0)
|
||||
self.assertChanges(t, ignore='cursor', cells={0: ((0, 4),)})
|
||||
s.draw(b'b' * 7)
|
||||
self.assertTrue(s.linebuf[1].continued)
|
||||
self.assertTrue(s.linebuf[2].continued)
|
||||
self.ae(str(s.linebuf[0]), 'a' * 5)
|
||||
self.ae(str(s.linebuf[1]), 'b' * 5)
|
||||
self.ae(str(s.linebuf[2]), 'b' * 2 + ' ' * 3)
|
||||
self.assertTrue(s.line(1).continued)
|
||||
self.assertTrue(s.line(2).continued)
|
||||
self.ae(str(s.line(0)), 'a' * 5)
|
||||
self.ae(str(s.line(1)), 'b' * 5)
|
||||
self.ae(str(s.line(2)), 'b' * 2 + ' ' * 3)
|
||||
self.ae(s.cursor.x, 2), self.ae(s.cursor.y, 2)
|
||||
self.assertChanges(t, ignore='cursor', cells={1: ((0, 4),), 2: ((0, 1),)})
|
||||
s.draw(b'c' * 15)
|
||||
self.ae(str(s.linebuf[0]), 'b' * 5)
|
||||
self.ae(str(s.linebuf[1]), 'bbccc')
|
||||
self.ae(str(s.line(0)), 'b' * 5)
|
||||
self.ae(str(s.line(1)), 'bbccc')
|
||||
|
||||
# Now test without line-wrap
|
||||
s.reset(), t.reset()
|
||||
s.reset_mode(mo.DECAWM)
|
||||
s.draw(b'0123456789')
|
||||
self.ae(str(s.linebuf[0]), '01239')
|
||||
self.ae(str(s.line(0)), '01239')
|
||||
self.ae(s.cursor.x, 5), self.ae(s.cursor.y, 0)
|
||||
self.assertChanges(t, ignore='cursor', cells={0: ((0, 4),)})
|
||||
s.draw(b'ab')
|
||||
self.ae(str(s.linebuf[0]), '0123b')
|
||||
self.ae(str(s.line(0)), '0123b')
|
||||
self.ae(s.cursor.x, 5), self.ae(s.cursor.y, 0)
|
||||
self.assertChanges(t, ignore='cursor', cells={0: ((4, 4),)})
|
||||
|
||||
@ -48,7 +48,7 @@ class TestScreen(BaseTest):
|
||||
self.ae(s.cursor.x, 0), self.ae(s.cursor.y, 4)
|
||||
t.reset()
|
||||
s.draw(b'ab')
|
||||
self.ae(str(s.linebuf[4]), 'ab123')
|
||||
self.ae(str(s.line(4)), 'ab123')
|
||||
self.ae((s.cursor.x, s.cursor.y), (2, 4))
|
||||
self.assertChanges(t, ignore='cursor', cells={4: ((0, 4),)})
|
||||
|
||||
@ -56,36 +56,36 @@ class TestScreen(BaseTest):
|
||||
# Test in line-wrap, non-insert mode
|
||||
s, t = self.create_screen()
|
||||
s.draw('ココx'.encode('utf-8'))
|
||||
self.ae(str(s.linebuf[0]), 'ココx')
|
||||
self.ae(tuple(map(s.linebuf[0].width, range(5))), (2, 0, 2, 0, 1))
|
||||
self.ae(str(s.line(0)), 'ココx')
|
||||
self.ae(tuple(map(s.line(0).width, range(5))), (2, 0, 2, 0, 1))
|
||||
self.ae(s.cursor.x, 5), self.ae(s.cursor.y, 0)
|
||||
self.assertChanges(t, ignore='cursor', cells={0: ((0, 4),)})
|
||||
s.draw('ニチハ'.encode('utf-8'))
|
||||
self.ae(str(s.linebuf[0]), 'ココx')
|
||||
self.ae(str(s.linebuf[1]), 'ニチ ')
|
||||
self.ae(str(s.linebuf[2]), 'ハ ')
|
||||
self.ae(str(s.line(0)), 'ココx')
|
||||
self.ae(str(s.line(1)), 'ニチ ')
|
||||
self.ae(str(s.line(2)), 'ハ ')
|
||||
self.assertChanges(t, ignore='cursor', cells={1: ((0, 3),), 2: ((0, 1),)})
|
||||
self.ae(s.cursor.x, 2), self.ae(s.cursor.y, 2)
|
||||
s.draw('Ƶ̧\u0308'.encode('utf-8'))
|
||||
self.ae(str(s.linebuf[2]), 'ハƵ̧\u0308 ')
|
||||
self.ae(str(s.line(2)), 'ハƵ̧\u0308 ')
|
||||
self.ae(s.cursor.x, 3), self.ae(s.cursor.y, 2)
|
||||
self.assertChanges(t, ignore='cursor', cells={2: ((2, 2),)})
|
||||
s.draw(b'xy'), s.draw('\u0306'.encode('utf-8'))
|
||||
self.ae(str(s.linebuf[2]), 'ハƵ̧\u0308xy\u0306')
|
||||
self.ae(str(s.line(2)), 'ハƵ̧\u0308xy\u0306')
|
||||
self.ae(s.cursor.x, 5), self.ae(s.cursor.y, 2)
|
||||
self.assertChanges(t, ignore='cursor', cells={2: ((3, 4),)})
|
||||
s.draw(b'c' * 15)
|
||||
self.ae(str(s.linebuf[0]), 'ニチ ')
|
||||
self.ae(str(s.line(0)), 'ニチ ')
|
||||
|
||||
# Now test without line-wrap
|
||||
s.reset(), t.reset()
|
||||
s.reset_mode(mo.DECAWM)
|
||||
s.draw('0\u030612345\u03066789\u0306'.encode('utf-8'))
|
||||
self.ae(str(s.linebuf[0]), '0\u03061239\u0306')
|
||||
self.ae(str(s.line(0)), '0\u03061239\u0306')
|
||||
self.ae(s.cursor.x, 5), self.ae(s.cursor.y, 0)
|
||||
self.assertChanges(t, ignore='cursor', cells={0: ((0, 4),)})
|
||||
s.draw('ab\u0306'.encode('utf-8'))
|
||||
self.ae(str(s.linebuf[0]), '0\u0306123b\u0306')
|
||||
self.ae(str(s.line(0)), '0\u0306123b\u0306')
|
||||
self.ae(s.cursor.x, 5), self.ae(s.cursor.y, 0)
|
||||
self.assertChanges(t, ignore='cursor', cells={0: ((4, 4),)})
|
||||
|
||||
@ -97,7 +97,7 @@ class TestScreen(BaseTest):
|
||||
self.ae(s.cursor.x, 0), self.ae(s.cursor.y, 4)
|
||||
t.reset()
|
||||
s.draw('a\u0306b'.encode('utf-8'))
|
||||
self.ae(str(s.linebuf[4]), 'a\u0306b1\u030623')
|
||||
self.ae(str(s.line(4)), 'a\u0306b1\u030623')
|
||||
self.ae((s.cursor.x, s.cursor.y), (2, 4))
|
||||
self.assertChanges(t, ignore='cursor', cells={4: ((0, 4),)})
|
||||
|
||||
@ -114,53 +114,53 @@ class TestScreen(BaseTest):
|
||||
|
||||
init()
|
||||
s.insert_characters(2)
|
||||
self.ae(str(s.linebuf[0]), 'a bc')
|
||||
self.assertTrue(s.linebuf[0].cursor_from(1).bold)
|
||||
self.ae(str(s.line(0)), 'a bc')
|
||||
self.assertTrue(s.line(0).cursor_from(1).bold)
|
||||
self.assertChanges(t, ignore='cursor', cells={0: ((1, 4),)})
|
||||
s.cursor_back(1)
|
||||
s.insert_characters(20)
|
||||
self.ae(str(s.linebuf[0]), ' ')
|
||||
self.ae(str(s.line(0)), ' ')
|
||||
self.assertChanges(t, ignore='cursor', cells={0: ((0, 4),)})
|
||||
s.draw('xココ'.encode('utf-8'))
|
||||
s.cursor_back(5)
|
||||
t.reset()
|
||||
s.insert_characters(1)
|
||||
self.ae(str(s.linebuf[0]), ' xコ ')
|
||||
self.ae(str(s.line(0)), ' xコ ')
|
||||
self.assertChanges(t, ignore='cursor', cells={0: ((0, 4),)})
|
||||
|
||||
init()
|
||||
s.delete_characters(2)
|
||||
self.ae(str(s.linebuf[0]), 'ade ')
|
||||
self.assertTrue(s.linebuf[0].cursor_from(4).bold)
|
||||
self.assertFalse(s.linebuf[0].cursor_from(2).bold)
|
||||
self.ae(str(s.line(0)), 'ade ')
|
||||
self.assertTrue(s.line(0).cursor_from(4).bold)
|
||||
self.assertFalse(s.line(0).cursor_from(2).bold)
|
||||
self.assertChanges(t, ignore='cursor', cells={0: ((1, 4),)})
|
||||
|
||||
init()
|
||||
s.erase_characters(2)
|
||||
self.ae(str(s.linebuf[0]), 'a de')
|
||||
self.assertTrue(s.linebuf[0].cursor_from(1).bold)
|
||||
self.assertFalse(s.linebuf[0].cursor_from(4).bold)
|
||||
self.ae(str(s.line(0)), 'a de')
|
||||
self.assertTrue(s.line(0).cursor_from(1).bold)
|
||||
self.assertFalse(s.line(0).cursor_from(4).bold)
|
||||
self.assertChanges(t, cells={0: ((1, 2),)})
|
||||
s.erase_characters(20)
|
||||
self.ae(str(s.linebuf[0]), 'a ')
|
||||
self.ae(str(s.line(0)), 'a ')
|
||||
|
||||
init()
|
||||
s.erase_in_line()
|
||||
self.ae(str(s.linebuf[0]), 'a ')
|
||||
self.assertTrue(s.linebuf[0].cursor_from(1).bold)
|
||||
self.assertFalse(s.linebuf[0].cursor_from(0).bold)
|
||||
self.ae(str(s.line(0)), 'a ')
|
||||
self.assertTrue(s.line(0).cursor_from(1).bold)
|
||||
self.assertFalse(s.line(0).cursor_from(0).bold)
|
||||
self.assertChanges(t, cells={0: ((1, 4),)})
|
||||
init()
|
||||
s.erase_in_line(1)
|
||||
self.ae(str(s.linebuf[0]), ' cde')
|
||||
self.ae(str(s.line(0)), ' cde')
|
||||
self.assertChanges(t, cells={0: ((0, 1),)})
|
||||
init()
|
||||
s.erase_in_line(2)
|
||||
self.ae(str(s.linebuf[0]), ' ')
|
||||
self.ae(str(s.line(0)), ' ')
|
||||
self.assertChanges(t, cells={0: ((0, 4),)})
|
||||
init()
|
||||
s.erase_in_line(2, private=True)
|
||||
self.ae((False, False, False, False, False), tuple(map(lambda i: s.linebuf[0].cursor_from(i).bold, range(5))))
|
||||
self.ae((False, False, False, False, False), tuple(map(lambda i: s.line(0).cursor_from(i).bold, range(5))))
|
||||
|
||||
def test_erase_in_screen(self):
|
||||
s, t = self.create_screen()
|
||||
@ -186,12 +186,12 @@ class TestScreen(BaseTest):
|
||||
s.erase_in_display(2)
|
||||
self.ae(s.display, (' ', ' ', ' ', ' ', ' '))
|
||||
self.assertChanges(t, lines=set(range(5)))
|
||||
self.assertTrue(s.linebuf[0].cursor_from(1).bold)
|
||||
self.assertTrue(s.line(0).cursor_from(1).bold)
|
||||
init()
|
||||
s.erase_in_display(2, private=True)
|
||||
self.ae(s.display, (' ', ' ', ' ', ' ', ' '))
|
||||
self.assertChanges(t, lines=set(range(5)))
|
||||
self.assertFalse(s.linebuf[0].cursor_from(1).bold)
|
||||
self.assertFalse(s.line(0).cursor_from(1).bold)
|
||||
|
||||
def test_cursor_movement(self):
|
||||
s, t = self.create_screen()
|
||||
|
Loading…
Reference in New Issue
Block a user