dwgx/SmartCLI / skills/tui-ui
tui-ui
VerifiedDesign web-like user interfaces in the terminal and inside tmux with a cell-grid Canvas, CSS-like box model, flexbox/grid layout, and 17 reusable widgets such as Panel, Table, Card, ProgressBar, Meter, Tabs, Tree, Badge, Banner, and a braille line chart. Use when an agent needs a dashboard, panel, table, status page, TUI layout, tmux dashboard, screenshot-driven CLI/TUI replica, ANSI frame, truecolor render, pyte PNG screenshot smoke test, wide-character alignment, or a new terminal widget.
| File | Kind | Size |
|---|---|---|
| SKILL.md | skill md | 18.0 KB |
| _selftest_effort_widgets.py | script | 4.9 KB |
| _shot_effort_widgets.py | script | 4.7 KB |
| examples/effort_selector.py | script | 22.1 KB |
| references/HARD-LESSONS.md | markdown | 7.5 KB |
| references/RENDERING-MODEL.md | markdown | 5.4 KB |
| references/effort-replica-spec.md | markdown | 11.8 KB |
| self_test.py | script | 5.7 KB |
| ui/__init__.py | script | 1.4 KB |
| ui/__main__.py | script | 183 B |
| ui/box.py | script | 9.2 KB |
| ui/cli.py | script | 8.7 KB |
| ui/core.py | script | 26.0 KB |
| ui/field.py | script | 19.7 KB |
| ui/layout.py | script | 11.1 KB |
| ui/raster.py | script | 27.9 KB |
| ui/registry.py | script | 2.7 KB |
| ui/sixel.py | script | 9.2 KB |
| ui/widgets.py | script | 24.3 KB |
| ui/widgets_ext/__init__.py | script | 207 B |
| ui/widgets_ext/braille_chart.py | script | 6.7 KB |
| ui/widgets_ext/fuzzy_filter_list.py | script | 5.0 KB |
| ui/widgets_ext/gradient_rule.py | script | 3.5 KB |
| ui/widgets_ext/preview_pane.py | script | 3.1 KB |
| ui/widgets_ext/radial_glow.py | script | 8.8 KB |
| ui/widgets_ext/slider_track.py | script | 7.7 KB |
ui/widgets_ext/preview_pane.py
View on GitHub"""preview_pane.py — content preview widget (fzf --preview style).
The natural companion to a fuzzy list: show the content of the selected item in
a side pane, with an optional title bar and line numbers. A drop-in tui-ui
widget; renders text content to a Canvas, wrapping/clipping to the region.
"""
from __future__ import annotations
from typing import Optional
from ..core import Canvas, DIM, BOLD
from ..registry import register
from ..widgets import Widget
@register
class PreviewPane(Widget):
"""A titled pane that previews multi-line text content with line numbers.
Pair it with fuzzy_filter_list: as the selection changes, feed the selected
item's content in as ``content``. Long lines are clipped; a scroll offset
keeps a target line in view.
"""
key = "preview_pane"
summary = "content preview pane (title + line numbers), pairs with fuzzy list"
def __init__(self, content: str = "", title: str = "", top: int = 0,
line_numbers: bool = True, width: Optional[int] = None,
height: Optional[int] = None, theme=None):
from ..core import get_theme
self.content = content
self.title = title
self.top = top # first visible line (scroll offset)
self.line_numbers = line_numbers
self.width = width
self.height = height
self.theme = theme or get_theme("dashboard")
def measure(self, avail_w, avail_h):
return (self.width or avail_w, self.height or avail_h)
def render(self, region_w, region_h):
th = self.theme
cv = Canvas(region_w, max(1, region_h), bg=th.bg)
y = 0
body_top = 0
if self.title:
accent = getattr(th, "accent", th.fg)
cv.fill_rect(0, 0, region_w, 1, " ", fg=th.fg, bg=th.bg)
cv.put_text(0, 0, self.title[:region_w], fg=accent, bg=th.bg, attrs=BOLD)
body_top = 1
lines = self.content.split("\n")
gutter = 0
if self.line_numbers and lines:
gutter = len(str(len(lines))) + 1 # width of the line-number column
n_body = region_h - body_top
top = max(0, self.top) # negative scroll would wrap via -index
for i in range(n_body):
li = top + i
if li >= len(lines):
break
y = body_top + i
x = 0
if self.line_numbers:
num = str(li + 1).rjust(gutter - 1)
cv.put_text(0, y, num, fg=th.fg, bg=th.bg, attrs=DIM)
x = gutter
cv.put_text(x, y, lines[li][:max(0, region_w - x)], fg=th.fg, bg=th.bg)
return cv
@classmethod
def sample(cls, theme):
content = ("def render(self, ctx):\n"
" grid = new_grid(w, h)\n"
" for cell in cells:\n"
" grid[y][x] = shade(cell)\n"
" return grid_to_str(grid)\n"
"\n"
"# preview pane pairs with the\n"
"# fuzzy list to the left.")
return cls(content, title="src/core/render.py", theme=theme)
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| finishing-a-development-branchobra/superpowersUse when implementation is complete, all tests pass, and you need to decide how to integrate the work | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| systematic-debuggingobra/superpowersUse when encountering any bug, test failure, or unexpected behavior, before proposing fixes | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| test-driven-developmentobra/superpowersUse when implementing any feature or bugfix, before writing implementation code | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| skill-creatoranthropics/skillsCreate new skills, modify and improve existing skills, and measure skill performance. Use when users want to create a skill from scratch, edit, or optimize an existing skill, run evals to test a skill, benchmark skill performance with variance analysis, or optimize a skill's description for better triggering accuracy. | Stars: 197k | Updated | Claude CodeCodex | Verified | Install |