From 6fab77264c0cca72018c21784904b9f6bf221574 Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Sat, 2 Apr 2022 07:33:50 -0400 Subject: [PATCH] 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 --- misc/logreader.py | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/misc/logreader.py b/misc/logreader.py index ca912c90..223b0815 100644 --- a/misc/logreader.py +++ b/misc/logreader.py @@ -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)