40 lines
1.1 KiB
Python
40 lines
1.1 KiB
Python
"""Self-contained curses TUI used to exercise the tmux-shot pipeline.
|
|
|
|
Arrow keys move the '@' cursor, 'q' quits. No external dependencies beyond
|
|
the standard library, so the demo works without any other TUI installed.
|
|
"""
|
|
import curses
|
|
|
|
|
|
def main(stdscr: "curses._CursesWindow") -> None:
|
|
curses.curs_set(0)
|
|
curses.start_color()
|
|
curses.use_default_colors()
|
|
for i in range(1, 8):
|
|
curses.init_pair(i, i, -1)
|
|
|
|
y, x = 5, 10
|
|
while True:
|
|
stdscr.erase()
|
|
stdscr.addstr(0, 0, "tmux-shot demo TUI -- arrows to move, q to quit", curses.A_BOLD)
|
|
for i in range(1, 8):
|
|
stdscr.addstr(2, i * 4, f" {i} ", curses.color_pair(i) | curses.A_REVERSE)
|
|
stdscr.addstr(y, x, "@", curses.color_pair(2) | curses.A_BOLD)
|
|
stdscr.refresh()
|
|
|
|
ch = stdscr.getch()
|
|
if ch in (ord("q"), ord("Q")):
|
|
break
|
|
elif ch == curses.KEY_UP:
|
|
y = max(3, y - 1)
|
|
elif ch == curses.KEY_DOWN:
|
|
y += 1
|
|
elif ch == curses.KEY_LEFT:
|
|
x = max(0, x - 1)
|
|
elif ch == curses.KEY_RIGHT:
|
|
x += 1
|
|
|
|
|
|
if __name__ == "__main__":
|
|
curses.wrapper(main)
|