-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgen_screenshots.py
More file actions
334 lines (283 loc) · 11.5 KB
/
Copy pathgen_screenshots.py
File metadata and controls
334 lines (283 loc) · 11.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
#!/usr/bin/env python3
"""
Generate PNG screenshots and animated GIF of vibePDA TUI for documentation.
Renders terminal-style UI without requiring a display.
"""
import os
import sys
from pathlib import Path
try:
from PIL import Image, ImageDraw, ImageFont
except ImportError:
print("Requires Pillow: pip install Pillow")
sys.exit(1)
# Output directory
SCRIPT_DIR = Path(__file__).resolve().parent
REPO_ROOT = SCRIPT_DIR.parent
OUT_DIR = REPO_ROOT / "docs" / "images"
OUT_DIR.mkdir(parents=True, exist_ok=True)
# Terminal dimensions (80x25 classic)
COLS = 80
ROWS = 25
CELL_W = 10
CELL_H = 18
PADDING = 4
BORDER = 2
# Layout: sidebar 18 chars (matches app.c sidebar_width)
SIDEBAR_WIDTH = 18
MAIN_X = SIDEBAR_WIDTH * CELL_W + PADDING + BORDER # Content starts after sidebar
# Colors (approximate terminal)
BG = (0, 0, 0)
FG = (170, 170, 170)
TITLE_BG = (0, 0, 128)
TITLE_FG = (255, 255, 255)
MENU_FG = (255, 255, 0)
SIDEBAR_SEL_BG = (0, 0, 128)
SIDEBAR_SEL_FG = (255, 255, 255)
CARD_TITLE = (100, 200, 255)
STATUS_BG = (50, 50, 50)
STATUS_FG = (200, 200, 200)
MODULES = ["Notes", "Tasks", "Contacts", "Calendar", "Facts", "Finances", "Documents", "Trash"]
def find_mono_font():
"""Find a suitable monospace font."""
candidates = [
"/usr/share/fonts/truetype/dejavu/DejaVuSansMono.ttf",
"/usr/share/fonts/truetype/liberation/LiberationMono-Regular.ttf",
"/usr/share/fonts/TTF/DejaVuSansMono.ttf",
"/usr/share/fonts/truetype/freefont/FreeMono.ttf",
]
for p in candidates:
if os.path.exists(p):
return p
return None
def create_image(width, height):
"""Create image with terminal-like dimensions."""
img_w = width * CELL_W + PADDING * 2 + BORDER * 2
img_h = height * CELL_H + PADDING * 2 + BORDER * 2
return Image.new("RGB", (img_w, img_h), color=(30, 30, 30))
def draw_frame(draw, font, font_bold, lines, start_row=0):
"""Draw text lines onto the image draw context."""
for r, line in enumerate(lines):
row = start_row + r
if row >= ROWS:
break
y = PADDING + BORDER + row * CELL_H
draw.text((PADDING + BORDER, y), line, font=font, fill=FG)
def render_notes_view(module_idx=0, ascii_box=False):
"""Render Notes module view. ascii_box=True uses +-| instead of Unicode box-drawing."""
img = create_image(COLS, ROWS)
draw = ImageDraw.Draw(img)
font_path = find_mono_font()
font = ImageFont.truetype(font_path, 14) if font_path else ImageFont.load_default()
font_bold = ImageFont.truetype(font_path, 14) if font_path else font
# Title bar
title = f" vibePDA | {MODULES[module_idx]} "
draw.rectangle(
[(0, 0), (img.width, CELL_H + PADDING)],
fill=TITLE_BG,
)
draw.text((PADDING + BORDER, PADDING), title, font=font, fill=TITLE_FG)
# Menu bar
menu = " F1 Help | F2 New | F3 Edit | F4 Delete | F5 Search | F10 Quit "
draw.rectangle(
[(0, CELL_H + PADDING), (img.width, 2 * CELL_H + PADDING)],
fill=(40, 40, 40),
)
draw.text((PADDING + BORDER, CELL_H + PADDING), menu, font=font, fill=MENU_FG)
# Sidebar (18 chars wide, matches app)
content_top = 2 * CELL_H + PADDING
sidebar_right = SIDEBAR_WIDTH * CELL_W + PADDING + BORDER
for i, mod in enumerate(MODULES):
y = content_top + (i + 1) * CELL_H
prefix = "> " if i == module_idx else " "
text = prefix + mod
if i == module_idx:
draw.rectangle(
[(0, y - 2), (sidebar_right - 1, y + CELL_H - 2)],
fill=SIDEBAR_SEL_BG,
)
draw.text((PADDING + BORDER, y), text, font=font, fill=SIDEBAR_SEL_FG)
else:
draw.text((PADDING + BORDER, y), text, font=font, fill=FG)
# Main content header + note card (box-drawing style, matches actual app)
header = "Notes (3 items)" + (" [ASCII]" if ascii_box else "")
draw.text((MAIN_X, content_top + CELL_H), header, font=font_bold, fill=FG)
card_x = MAIN_X
card_w = img.width - card_x - PADDING - BORDER
card_top = content_top + 2 * CELL_H
if card_w > 20:
# Box-drawing card: ┌───┐ / +---+ (Unicode vs ASCII fallback)
draw.rectangle([(card_x, card_top), (card_x + card_w, card_top + 5 * CELL_H)],
outline=FG, fill=(25, 25, 25))
draw.text((card_x + 8, card_top + 4), " Title: Grocery list", font=font_bold, fill=CARD_TITLE)
draw.text((card_x + 8, card_top + CELL_H + 4), "Milk, eggs, bread, coffee", font=font, fill=FG)
draw.text((card_x + 8, card_top + 4 * CELL_H + 4), " Note 1 of 3 (Up/Down) ", font=font, fill=STATUS_FG)
# Status bar
status_y = (ROWS - 1) * CELL_H + PADDING
draw.rectangle(
[(0, status_y), (img.width, img.height)],
fill=STATUS_BG,
)
draw.text((PADDING + BORDER, status_y), " :Notes=>View ", font=font, fill=STATUS_FG)
return img
def render_tasks_view():
"""Render Tasks module view."""
img = create_image(COLS, ROWS)
draw = ImageDraw.Draw(img)
font_path = find_mono_font()
font = ImageFont.truetype(font_path, 14) if font_path else ImageFont.load_default()
font_bold = ImageFont.truetype(font_path, 14) if font_path else font
# Title bar
title = " vibePDA | Tasks "
draw.rectangle([(0, 0), (img.width, CELL_H + PADDING)], fill=TITLE_BG)
draw.text((PADDING + BORDER, PADDING), title, font=font, fill=TITLE_FG)
# Menu bar
menu = " F1 Help | F2 New | F3 Edit | F4 Delete | F5 Search | F10 Quit "
draw.rectangle(
[(0, CELL_H + PADDING), (img.width, 2 * CELL_H + PADDING)],
fill=(40, 40, 40),
)
draw.text((PADDING + BORDER, CELL_H + PADDING), menu, font=font, fill=MENU_FG)
# Sidebar - Tasks selected
content_top = 2 * CELL_H + PADDING
sidebar_right = SIDEBAR_WIDTH * CELL_W + PADDING + BORDER
for i, mod in enumerate(MODULES):
y = content_top + (i + 1) * CELL_H
prefix = "> " if i == 1 else " "
text = prefix + mod
if i == 1:
draw.rectangle(
[(0, y - 2), (sidebar_right - 1, y + CELL_H - 2)],
fill=SIDEBAR_SEL_BG,
)
draw.text((PADDING + BORDER, y), text, font=font, fill=SIDEBAR_SEL_FG)
else:
draw.text((PADDING + BORDER, y), text, font=font, fill=FG)
# Main content header + task list (format: [x] id title)
draw.text((MAIN_X, content_top + CELL_H), "Tasks (4 items)", font=font_bold, fill=FG)
tasks = [
(" ", 1, "Buy groceries"),
("X", 2, "Finish report"),
(" ", 3, "Call dentist"),
(" ", 4, "Review PRs"),
]
for i, (mark, tid, title) in enumerate(tasks):
y = content_top + (i + 2) * CELL_H
line = f"[{mark}] {tid:3d} {title}"
draw.text((MAIN_X, y), line, font=font, fill=FG)
# Status bar
status_y = (ROWS - 1) * CELL_H + PADDING
draw.rectangle([(0, status_y), (img.width, img.height)], fill=STATUS_BG)
draw.text((PADDING + BORDER, status_y), " :Tasks=>View ", font=font, fill=STATUS_FG)
return img
def render_help_view():
"""Render Help overlay."""
img = create_image(COLS, ROWS)
draw = ImageDraw.Draw(img)
font_path = find_mono_font()
font = ImageFont.truetype(font_path, 14) if font_path else ImageFont.load_default()
# Dimmed background
draw.rectangle([(0, 0), (img.width, img.height)], fill=(20, 20, 20))
help_lines = [
"vibePDA - Terminal Personal Data Assistant",
"",
"NAVIGATION",
" Up/Down, j/k Move selection",
" Tab Switch between sidebar and list",
" Enter Edit selected item",
"",
"ACTIONS",
" F2 or N New item",
" F3 or E Edit selected",
" F5 or / Search/Filter items",
" F10 or q Quit",
"",
"Press any key to close",
]
content_top = 2 * CELL_H + PADDING
for i, line in enumerate(help_lines):
y = content_top + i * CELL_H
draw.text((PADDING + BORDER + 4, y), line, font=font, fill=FG)
return img
def render_search_view():
"""Render Search/Filter mode."""
img = create_image(COLS, ROWS)
draw = ImageDraw.Draw(img)
font_path = find_mono_font()
font = ImageFont.truetype(font_path, 14) if font_path else ImageFont.load_default()
font_bold = ImageFont.truetype(font_path, 14) if font_path else font
# Title bar
title = " vibePDA | Notes "
draw.rectangle([(0, 0), (img.width, CELL_H + PADDING)], fill=TITLE_BG)
draw.text((PADDING + BORDER, PADDING), title, font=font, fill=TITLE_FG)
# Menu bar
menu = " F1 Help | F2 New | F3 Edit | F4 Delete | F5 Search | F10 Quit "
draw.rectangle(
[(0, CELL_H + PADDING), (img.width, 2 * CELL_H + PADDING)],
fill=(40, 40, 40),
)
draw.text((PADDING + BORDER, CELL_H + PADDING), menu, font=font, fill=MENU_FG)
# Sidebar
content_top = 2 * CELL_H + PADDING
sidebar_right = SIDEBAR_WIDTH * CELL_W + PADDING + BORDER
for i, mod in enumerate(MODULES):
y = content_top + (i + 1) * CELL_H
prefix = "> " if i == 0 else " "
text = prefix + mod
if i == 0:
draw.rectangle(
[(0, y - 2), (sidebar_right - 1, y + CELL_H - 2)],
fill=SIDEBAR_SEL_BG,
)
draw.text((PADDING + BORDER, y), text, font=font, fill=SIDEBAR_SEL_FG)
else:
draw.text((PADDING + BORDER, y), text, font=font, fill=FG)
# Search prompt in status bar
status_y = (ROWS - 1) * CELL_H + PADDING
draw.rectangle([(0, status_y), (img.width, img.height)], fill=(60, 40, 0))
draw.text((PADDING + BORDER, status_y), " Search: grocery_ ", font=font, fill=(255, 255, 200))
# Filtered result (Notes with filter applied)
draw.text((MAIN_X, content_top + CELL_H), "Notes (1 item) [Filter: grocery]", font=font_bold, fill=FG)
draw.text((MAIN_X, content_top + 2 * CELL_H), "1 Grocery list", font=font, fill=CARD_TITLE)
draw.text((MAIN_X, content_top + 3 * CELL_H), "Milk, eggs, bread, coffee", font=font, fill=FG)
return img
def main():
print("Generating screenshots...")
OUT_DIR.mkdir(parents=True, exist_ok=True)
# Generate PNGs (Unicode + ASCII fallback variants for terminal compatibility)
screens = [
("notes.png", render_notes_view(0, ascii_box=False), "Notes module (Unicode)"),
("notes_ascii.png", render_notes_view(0, ascii_box=True), "Notes module (ASCII fallback)"),
("tasks.png", render_tasks_view(), "Tasks module"),
("help.png", render_help_view(), "Help overlay"),
("search.png", render_search_view(), "Search/Filter mode"),
]
for name, img, desc in screens:
path = OUT_DIR / name
img.save(path, "PNG")
print(f" Saved {path} ({desc})")
# Animated GIF - cycle through views
frames = []
for i in range(4):
frames.append(render_notes_view(0))
frames.append(render_tasks_view())
frames.append(render_search_view())
frames.append(render_help_view())
for i in range(3):
frames.append(render_notes_view(0))
# Resize for reasonable GIF size (2x scale for readability)
scale = 2
w, h = frames[0].size
frames_scaled = [f.resize((w * scale, h * scale), Image.NEAREST) for f in frames]
gif_path = OUT_DIR / "vibePDA-demo.gif"
frames_scaled[0].save(
gif_path,
save_all=True,
append_images=frames_scaled[1:],
duration=800,
loop=0,
)
print(f" Saved {gif_path} (animated demo)")
print("Done.")
if __name__ == "__main__":
main()