Display status as a percentage
This commit is contained in:
parent
7f150109bd
commit
ffdef8d92d
|
|
@ -53,9 +53,19 @@ def main(stdscr, filename):
|
||||||
for i, line in enumerate(visible_lines):
|
for i, line in enumerate(visible_lines):
|
||||||
stdscr.addnstr(i, divider_col + 2, line, width - divider_col - 3)
|
stdscr.addnstr(i, divider_col + 2, line, width - divider_col - 3)
|
||||||
|
|
||||||
# Status bar for right pane (line N/M)
|
# Status bar for right pane
|
||||||
status = f"line {scroll_offset + 1}/{len(file_lines)}"
|
visible_height = height - 1 # Reserve 1 line for the status bar
|
||||||
stdscr.addnstr(height - 1, divider_col + 2, status, width - divider_col - 3, curses.A_DIM)
|
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()
|
stdscr.refresh()
|
||||||
key = stdscr.getch()
|
key = stdscr.getch()
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue