Commit 2b2446d
feat: add dynamic theme changes (#3)
* feat: add dynamic theme changes
Enable runtime theme changes via `terminal.options.theme = newTheme`
without restarting the terminal. All existing content re-renders
instantly with the new colors.
- Add `ghostty_terminal_set_colors` WASM export that updates terminal
colors and forces a full redraw
- Wire up `handleOptionChange('theme')` to merge partial themes,
update the renderer, and sync WASM terminal colors
- Support partial theme updates that accumulate (e.g. setting only
background preserves all other colors)
- Cells with ANSI palette/default colors re-resolve; explicit RGB
cells remain unchanged
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* refactor: address code review suggestions from PR #3
- Add struct layout comment in ghostty.ts to document GhosttyTerminalConfig field offsets and warn about Zig/TS drift
- Expose renderer.theme as a public getter on CanvasRenderer to eliminate @ts-ignore in Dynamic Theme Changes tests
- Remove trailing whitespace in renderStateUpdate section of ghostty-wasm-api.patch
* refactor: eliminate duplication in theme config building
- Extract buildThemePalette() helper in terminal.ts; used by both buildWasmConfig() and buildThemeColorsConfig()
- Extract writeConfigToPtr() helper in ghostty.ts; used by constructor and setColors()
- Remove double initialization of currentTheme (class field default was immediately overwritten in constructor)
- setTheme() now accepts Required<ITheme> and assigns directly, removing redundant spread against DEFAULT_THEME
* fix: correct terminal.zig hunk line count in patch
The @@ -0,0 +1,1168 @@ header was off by 5 — actual content is 1163 lines.
Rebuilt ghostty-vt.wasm against updated submodule.
---------
Co-authored-by: Brian Egan <brian.egan@verygood.ventures>
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>1 parent 1386570 commit 2b2446d
7 files changed
Lines changed: 507 additions & 103 deletions
Binary file not shown.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
288 | 288 | | |
289 | 289 | | |
290 | 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 | | - | |
| 291 | + | |
317 | 292 | | |
318 | 293 | | |
319 | | - | |
320 | 294 | | |
321 | 295 | | |
322 | 296 | | |
| |||
364 | 338 | | |
365 | 339 | | |
366 | 340 | | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
367 | 387 | | |
368 | 388 | | |
369 | 389 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
98 | 98 | | |
99 | 99 | | |
100 | 100 | | |
101 | | - | |
| 101 | + | |
| 102 | + | |
102 | 103 | | |
103 | 104 | | |
104 | 105 | | |
| |||
138 | 139 | | |
139 | 140 | | |
140 | 141 | | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
141 | 147 | | |
142 | 148 | | |
143 | 149 | | |
| |||
151 | 157 | | |
152 | 158 | | |
153 | 159 | | |
154 | | - | |
| 160 | + | |
155 | 161 | | |
156 | 162 | | |
157 | 163 | | |
158 | 164 | | |
159 | | - | |
160 | | - | |
161 | | - | |
162 | | - | |
163 | | - | |
164 | | - | |
165 | | - | |
166 | | - | |
167 | | - | |
168 | | - | |
169 | | - | |
170 | | - | |
171 | | - | |
172 | | - | |
173 | | - | |
174 | | - | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
175 | 181 | | |
176 | 182 | | |
177 | 183 | | |
| |||
253 | 259 | | |
254 | 260 | | |
255 | 261 | | |
256 | | - | |
| 262 | + | |
257 | 263 | | |
258 | 264 | | |
259 | 265 | | |
| |||
523 | 529 | | |
524 | 530 | | |
525 | 531 | | |
526 | | - | |
| 532 | + | |
527 | 533 | | |
528 | 534 | | |
529 | 535 | | |
| |||
559 | 565 | | |
560 | 566 | | |
561 | 567 | | |
562 | | - | |
| 568 | + | |
563 | 569 | | |
564 | 570 | | |
565 | 571 | | |
| |||
612 | 618 | | |
613 | 619 | | |
614 | 620 | | |
615 | | - | |
| 621 | + | |
616 | 622 | | |
617 | 623 | | |
618 | 624 | | |
| |||
720 | 726 | | |
721 | 727 | | |
722 | 728 | | |
723 | | - | |
| 729 | + | |
724 | 730 | | |
725 | 731 | | |
726 | 732 | | |
| |||
734 | 740 | | |
735 | 741 | | |
736 | 742 | | |
737 | | - | |
| 743 | + | |
738 | 744 | | |
739 | 745 | | |
740 | 746 | | |
| |||
786 | 792 | | |
787 | 793 | | |
788 | 794 | | |
789 | | - | |
790 | | - | |
| 795 | + | |
| 796 | + | |
791 | 797 | | |
792 | 798 | | |
793 | 799 | | |
794 | | - | |
795 | | - | |
796 | | - | |
797 | | - | |
798 | | - | |
799 | | - | |
800 | | - | |
801 | | - | |
802 | | - | |
803 | | - | |
804 | | - | |
805 | | - | |
806 | | - | |
807 | | - | |
808 | | - | |
809 | | - | |
| 800 | + | |
| 801 | + | |
| 802 | + | |
| 803 | + | |
| 804 | + | |
| 805 | + | |
| 806 | + | |
| 807 | + | |
| 808 | + | |
| 809 | + | |
| 810 | + | |
| 811 | + | |
| 812 | + | |
| 813 | + | |
| 814 | + | |
| 815 | + | |
810 | 816 | | |
811 | 817 | | |
812 | 818 | | |
| |||
873 | 879 | | |
874 | 880 | | |
875 | 881 | | |
876 | | - | |
| 882 | + | |
877 | 883 | | |
878 | 884 | | |
879 | 885 | | |
| |||
988 | 994 | | |
989 | 995 | | |
990 | 996 | | |
991 | | - | |
| 997 | + | |
992 | 998 | | |
993 | 999 | | |
994 | 1000 | | |
| |||
0 commit comments