Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Force LF line endings for shell scripts and Python so Windows clones
# (with core.autocrlf=true) don't break shebang parsing on bash/WSL.
*.sh text eol=lf
*.py text eol=lf
56 changes: 37 additions & 19 deletions onboard_ui.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
"""ANSI palette, block-char banner, and clack-style layout atoms (stdlib only)."""
import sys, os, shutil, tty, termios
import sys, os, shutil

_WIN = sys.platform == "win32"
if _WIN:
import msvcrt
else:
import tty, termios

# ── Palette ───────────────────────────────────────────────────────────────
def _e(*c): return f"\x1b[{';'.join(map(str,c))}m"
Expand Down Expand Up @@ -58,22 +64,34 @@ def outro(lines):
print(f"{MUTED}└{R}\n")

# ── Raw key reader ────────────────────────────────────────────────────────
def _getch():
fd = sys.stdin.fileno()
old = termios.tcgetattr(fd)
try:
tty.setraw(fd)
return sys.stdin.buffer.read(1).decode("utf-8", errors="replace")
finally:
termios.tcsetattr(fd, termios.TCSADRAIN, old)
if _WIN:
def get_key():
ch = msvcrt.getwch()
if ch in ("\x00", "\xe0"): # arrow-key / function-key prefix
c2 = msvcrt.getwch()
return {"H": "UP", "P": "DOWN", "K": "LEFT", "M": "RIGHT"}.get(c2, "ESC")
if ch in "\r\n": return "ENTER"
if ch == "\x03": raise KeyboardInterrupt
if ch == "\x08": return "BACKSPACE"
if ch == "\x1b": return "ESC"
return ch
else:
def _getch():
fd = sys.stdin.fileno()
old = termios.tcgetattr(fd)
try:
tty.setraw(fd)
return sys.stdin.buffer.read(1).decode("utf-8", errors="replace")
finally:
termios.tcsetattr(fd, termios.TCSADRAIN, old)

def get_key():
ch = _getch()
if ch == "\x1b":
_getch() # consume '['
c2 = _getch()
return {"A": "UP", "B": "DOWN", "C": "RIGHT", "D": "LEFT"}.get(c2, "ESC")
if ch in "\r\n": return "ENTER"
if ch == "\x03": raise KeyboardInterrupt
if ch == "\x7f": return "BACKSPACE"
return ch
def get_key():
ch = _getch()
if ch == "\x1b":
_getch() # consume '['
c2 = _getch()
return {"A": "UP", "B": "DOWN", "C": "RIGHT", "D": "LEFT"}.get(c2, "ESC")
if ch in "\r\n": return "ENTER"
if ch == "\x03": raise KeyboardInterrupt
if ch == "\x7f": return "BACKSPACE"
return ch