Add .gitignore and initial project files
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
"""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)
|
||||
@@ -0,0 +1,28 @@
|
||||
"""Drives examples/demo_tui.py inside tmux and captures a couple of PNG frames.
|
||||
|
||||
Run with: uv run python examples/run_demo.py
|
||||
"""
|
||||
import time
|
||||
from pathlib import Path
|
||||
|
||||
from tmux_shot import TmuxApp
|
||||
|
||||
ROOT = Path(__file__).resolve().parent.parent
|
||||
OUT = ROOT / "out"
|
||||
OUT.mkdir(exist_ok=True)
|
||||
DEMO_SCRIPT = Path(__file__).resolve().parent / "demo_tui.py"
|
||||
|
||||
app = TmuxApp("tmux_shot_demo", command=f"python3 {DEMO_SCRIPT}", width=80, height=24)
|
||||
time.sleep(0.3) # let curses draw the first frame
|
||||
app.screenshot(OUT / "demo_1.png")
|
||||
|
||||
for key in ("Down", "Down", "Right", "Right", "Right"):
|
||||
app.send_keys(key, enter=False)
|
||||
time.sleep(0.2)
|
||||
app.screenshot(OUT / "demo_2.png")
|
||||
|
||||
app.send_keys("q")
|
||||
app.kill()
|
||||
|
||||
print(f"wrote {OUT / 'demo_1.png'}")
|
||||
print(f"wrote {OUT / 'demo_2.png'}")
|
||||
Reference in New Issue
Block a user