Display status as a percentage

This commit is contained in:
n loewen 2025-04-23 22:27:41 +01:00
parent 7f150109bd
commit ffdef8d92d
1 changed files with 13 additions and 3 deletions

View File

@ -53,9 +53,19 @@ def main(stdscr, filename):
for i, line in enumerate(visible_lines):
stdscr.addnstr(i, divider_col + 2, line, width - divider_col - 3)
# Status bar for right pane (line N/M)
status = f"line {scroll_offset + 1}/{len(file_lines)}"
stdscr.addnstr(height - 1, divider_col + 2, status, width - divider_col - 3, curses.A_DIM)
# Status bar for right pane
visible_height = height - 1 # Reserve 1 line for the status bar
last_visible_line = scroll_offset + visible_height
if len(file_lines) > 0:
percent = int((last_visible_line / len(file_lines)) * 100)
percent = 100 if last_visible_line >= len(file_lines) else percent
else:
percent = 0
status = f"{percent}%"
x = width - len(status) - 1
stdscr.addnstr(height - 1, x, status, len(status), curses.A_REVERSE)
stdscr.refresh()
key = stdscr.getch()