[1/2] knotty: Correctly handle multiple line items

Message ID 20220306133526.442843-1-richard.purdie@linuxfoundation.org
State Accepted, archived
Commit 8eeccf73185d986c6abd6426b1d1e72da3a982df
Headers show
Series [1/2] knotty: Correctly handle multiple line items | expand

Commit Message

Richard Purdie March 6, 2022, 1:35 p.m. UTC
Currently the footer code doesn't quite handle multiline items correct.
Fix this to do so.

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
---
 lib/bb/ui/knotty.py | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

Patch

diff --git a/lib/bb/ui/knotty.py b/lib/bb/ui/knotty.py
index 528b8a0760..1bcdc0023a 100644
--- a/lib/bb/ui/knotty.py
+++ b/lib/bb/ui/knotty.py
@@ -292,9 +292,9 @@  class TerminalFilter(object):
                 progress = 0
             content = self.main_progress.update(progress)
             print('')
-        lines = 1 + int(len(content) / (self.columns + 1))
+        lines = self.getlines(content)
         if self.quiet == 0:
-            for tasknum, task in enumerate(tasks[:(self.rows - 2)]):
+            for tasknum, task in enumerate(tasks[:(self.rows - 1 - lines)]):
                 if isinstance(task, tuple):
                     pbar, progress, rate, start_time = task
                     if not pbar.start_time:
@@ -311,11 +311,17 @@  class TerminalFilter(object):
                 else:
                     content = "%s: %s" % (tasknum, task)
                     print(content)
-                lines = lines + 1 + int(len(content) / (self.columns + 1))
+                lines = lines + self.getlines(content)
         self.footer_present = lines
         self.lastpids = runningpids[:]
         self.lastcount = self.helper.tasknumber_current
 
+    def getlines(self, content):
+        lines = 0
+        for line in content.split("\n"):
+            lines = lines + 1 + int(len(line) / (self.columns + 1))
+        return lines
+
     def finish(self):
         if self.stdinbackup:
             fd = sys.stdin.fileno()