Dynamically allocate the scrollback history buffer

Reduces startup memory consumption when using very large scrollback
buffer sizes.
This commit is contained in:
Kovid Goyal
2018-05-03 15:17:02 +05:30
parent 14459a7d18
commit 3f316c39d1
6 changed files with 100 additions and 86 deletions

View File

@@ -400,6 +400,15 @@ class TestDataTypes(BaseTest):
hb.push(lb.line(2))
self.ae(str(hb.line(0)), '2' * hb.xnum)
self.ae(str(hb.line(4)), '1' * hb.xnum)
hb = large_hb = HistoryBuf(3000, 5)
c = filled_cursor()
for i in range(3000):
line = lb.line(1)
t = str(i).ljust(5)
line.set_text(t, 0, 5, c)
hb.push(line)
for i in range(3000):
self.ae(str(hb.line(i)).rstrip(), str(3000 - 1 - i))
# rewrap
hb = filled_history_buf(5, 5)
@@ -427,6 +436,11 @@ class TestDataTypes(BaseTest):
for i in range(hb.ynum):
self.ae(hb.line(i), hb3.line(i))
hb2 = HistoryBuf(hb.ynum, hb.xnum)
large_hb.rewrap(hb2)
hb2 = HistoryBuf(large_hb.ynum, large_hb.xnum)
large_hb.rewrap(hb2)
def test_ansi_repr(self):
lb = filled_line_buf()
l0 = lb.line(0)