Skip to content

Commit 3dc3375

Browse files
committed
docs(textframe): Document display() method
why: Enable users to discover interactive viewer feature what: - Add Interactive Display section with usage example - Document all keyboard controls in table format - Note TTY requirement and RuntimeError behavior
1 parent 90010ab commit 3dc3375

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

docs/internals/textframe.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,30 @@ Output:
5555
+----------+
5656
```
5757

58+
### Interactive Display
59+
60+
For exploring large frames interactively, use `display()` to open a scrollable curses viewer:
61+
62+
```python
63+
frame = TextFrame(content_width=80, content_height=50)
64+
frame.set_content(["line %d" % i for i in range(50)])
65+
frame.display() # Opens interactive viewer
66+
```
67+
68+
**Controls:**
69+
70+
| Key | Action |
71+
|-----|--------|
72+
| ↑/↓ or w/s or k/j | Scroll up/down |
73+
| ←/→ or a/d or h/l | Scroll left/right |
74+
| PgUp/PgDn | Page up/down |
75+
| Home/End | Jump to top/bottom |
76+
| q, Esc, Ctrl-C | Quit |
77+
78+
The viewer shows a status bar at the bottom with scroll position, frame dimensions, and help text.
79+
80+
**Note:** `display()` requires an interactive terminal (TTY). It raises `RuntimeError` if stdout is not a TTY (e.g., when piped or in CI environments).
81+
5882
### Overflow Behavior
5983

6084
TextFrame supports two overflow behaviors:

0 commit comments

Comments
 (0)