Start work on using the new LineBuf class

This commit is contained in:
Kovid Goyal
2016-11-04 14:44:46 +05:30
parent c14ae0c516
commit 8324ec1c2b
7 changed files with 84 additions and 23 deletions

View File

@@ -8,6 +8,16 @@ from unittest import TestCase
from kitty.screen import Screen
from kitty.tracker import ChangeTracker
from kitty.config import defaults
from kitty.fast_data_types import LineBuf, Cursor
def filled_line_buf(ynum=5, xnum=5, cursor=Cursor()):
ans = LineBuf(ynum, xnum)
cursor.x = 0
for i in range(ynum):
t = ('{}'.format(i)) * xnum
ans.line(i).set_text(t, 0, xnum, cursor)
return ans
class BaseTest(TestCase):

View File

@@ -4,7 +4,7 @@
import codecs
from . import BaseTest
from . import BaseTest, filled_line_buf
from kitty.utils import is_simple_string, wcwidth, sanitize_title
from kitty.fast_data_types import LineBuf, Cursor as C
@@ -12,6 +12,12 @@ from kitty.fast_data_types import LineBuf, Cursor as C
class TestDataTypes(BaseTest):
def test_linebuf(self):
old = filled_line_buf(2, 3)
new = LineBuf(1, 3)
new.copy_old(old)
self.ae(str(new.line(0)), str(old.line(1)))
def test_line(self):
lb = LineBuf(2, 3)
for y in range(2):

View File

@@ -9,7 +9,7 @@ from kitty.screen import mo
class TestScreen(BaseTest):
def test_draw_fast(self):
def xtest_draw_fast(self):
# Test in line-wrap, non-insert mode
s, t = self.create_screen()
s.draw(b'a' * 5)
@@ -52,7 +52,7 @@ class TestScreen(BaseTest):
self.ae((s.cursor.x, s.cursor.y), (2, 4))
self.assertChanges(t, ignore='cursor', cells={4: ((0, 4),)})
def test_draw_char(self):
def xtest_draw_char(self):
# Test in line-wrap, non-insert mode
s, t = self.create_screen()
s.draw('ココx'.encode('utf-8'))
@@ -101,7 +101,7 @@ class TestScreen(BaseTest):
self.ae((s.cursor.x, s.cursor.y), (2, 4))
self.assertChanges(t, ignore='cursor', cells={4: ((0, 4),)})
def test_char_manipulation(self):
def xtest_char_manipulation(self):
s, t = self.create_screen()
def init():
@@ -162,7 +162,7 @@ class TestScreen(BaseTest):
s.erase_in_line(2, private=True)
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):
def xtest_erase_in_screen(self):
s, t = self.create_screen()
def init():
@@ -193,7 +193,7 @@ class TestScreen(BaseTest):
self.assertChanges(t, lines=set(range(5)))
self.assertFalse(s.line(0).cursor_from(1).bold)
def test_cursor_movement(self):
def xtest_cursor_movement(self):
s, t = self.create_screen()
s.draw(b'12345' * 5)
t.reset()