Skip to content

Commit

Permalink
Improved visualization and overflows
Browse files Browse the repository at this point in the history
  • Loading branch information
davidmoreno committed Dec 18, 2023
1 parent 029611d commit 208c12a
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions cli/rtpmidid-cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,10 +215,12 @@ def get_latency(self, data):

def print_table(self, table: list[list[str]]):
def format_cell(cell, column):
width = column["width"]
cell = str(cell)[:width]
if column.get("align") == "right":
return "{:>{width}}".format(cell, width=column["width"])
return "{:>{width}}".format(cell, width=width)
else:
return "{:{width}}".format(cell, width=column["width"])
return "{:{width}}".format(cell, width=width)

max_cols = self.max_cols - 1
for rown, row in enumerate(table):
Expand Down Expand Up @@ -381,18 +383,22 @@ def print_row(self, row):

data_rows = len(self.data)
top_area = data_rows + 4
max_col = self.height - top_area - 5
max_col = self.height - top_area

print(self.ANSI_BG_BLUE + self.ANSI_TEXT_WHITE, end="")
self.print_padding(f"Current Row {self.height}: ")
print(self.ANSI_RESET, end="")
width_2 = self.width // 2
max_col2 = max_col * 2
for idx, row in enumerate(text.split("\n")):
if idx >= max_col:
self.terminal_goto(width_2, top_area + idx - max_col)
else:
if idx >= max_col2:
continue # skip too many rows
elif idx < max_col:
self.terminal_goto(0, top_area + idx)
print(row)
print(row)
else:
self.terminal_goto(width_2, top_area + idx - max_col)
print(f"| {row}")

def print_data(self):
data = self.conn.command({"method": "status"})
Expand Down

0 comments on commit 208c12a

Please sign in to comment.