ghostty icon indicating copy to clipboard operation
ghostty copied to clipboard

custom shader: add color scheme information to uniforms

Open benodiwal opened this issue 2 months ago • 4 comments

Add new shader uniforms to provide access to terminal color scheme:

  • iPalette[256]: 256-color ANSI palette array
  • iBackgroundColor: terminal background color
  • iForegroundColor: terminal foreground color
  • iCursorColor: pure cursor color (without opacity)

The new iCursorColor uniform provides the unmodified cursor color from the colorscheme, while existing iCurrentCursorColor retains the opacity-modified version. This enables shader authors to create sophisticated theme-aware effects and replace cursors entirely.

Color uniforms are populated per-frame when terminal colors change, including dynamic updates via OSC sequences. All uniforms use normalized float values (0.0-1.0) with RGB components.

The tests in this PR were written primarily by Claude Code.

Fixes #9417

benodiwal avatar Nov 09 '25 02:11 benodiwal

Is this PR AI-assisted? It's okay if it is, we just ask that you disclose that fact if so. (See CONTRIBUTING.md.)

qwerasd205 avatar Nov 09 '25 16:11 qwerasd205

Tests are written by agent. Let me disclose this in description. Thanks for pointing out.

benodiwal avatar Nov 09 '25 18:11 benodiwal

Should we really be trying to update the palette every single frame for this? Maybe this would be better to do on a config reload or an OSC sequence? I suppose bg_color is updated every frame so maybe this isn't actually such a big deal.

Still seems kind of wasteful. Maybe some way of marking the colors as dirty would be a better approach

ClearAspect avatar Nov 13 '25 05:11 ClearAspect

#9656

ClearAspect avatar Nov 20 '25 21:11 ClearAspect