2
0
mirror of https://github.com/xcat2/confluent.git synced 2024-11-21 17:11:58 +00:00

Make paginate to handle multiple screen clear

Grub moves cursor and clears as two separate commands,
so recognize that sequence as clear screen as well
This commit is contained in:
Jarrod Johnson 2022-04-02 07:33:50 -04:00
parent ab7f0e0528
commit 6fab77264c

View File

@ -99,10 +99,8 @@ class LogReplay(object):
if reverse and self.bin.tell() < endoffset:
output += txtout
continue
if b'\x1b[2J' in txtout:
self.cleardata = txtout.split(b'\x1b[2J')
for idx in range(1, len(self.cleardata)):
self.cleardata[idx] = b'\x1b[2J' + self.cleardata[idx]
self.paginate(txtout)
if self.cleardata:
self.clearidx = 0
if not self.cleardata[0]:
self.cleardata = self.cleardata[1:]
@ -120,6 +118,21 @@ class LogReplay(object):
self.bin.seek(endoffset)
return output, 1
def paginate(self, txtout):
cleardata = [txtout]
nextcleardata = []
for sep in (b'\x1b[2J', b'\x1b[H\x1b[J'):
for txtout in cleardata:
nextcleardata = cleardata.split(sep)
if len(nextcleardata) > 1:
for idx in range(1, len(nextcleardata)):
nextcleardata[idx] = sep + nextcleardata[idx]
cleardata = nextcleardata
nextcleardata = []
if len(cleardata) > 1:
self.cleardata = cleardata
return
def begin(self):
self.needclear = True
self.bin.seek(0)