You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Set default terminal fg/bg from Emacs theme colors
The terminal hardcoded default colors to rgb(204,204,204) on black,
ignoring the active Emacs theme. Add ghostel--set-default-colors
(Zig) to set the terminal's default fg/bg from hex strings, and call
it from ghostel--apply-palette using the Emacs default face. This
makes terminals respect the current theme at creation and on theme
change.
env.bindFunction("ghostel--mouse-event", 6, 6, &fnMouseEvent, "Send a mouse event to the terminal.\n\n(ghostel--mouse-event TERM ACTION BUTTON ROW COL MODS)");
43
43
env.bindFunction("ghostel--focus-event", 2, 2, &fnFocusEvent, "Send a focus event to the terminal.\n\n(ghostel--focus-event TERM GAINED)");
44
44
env.bindFunction("ghostel--set-palette", 2, 2, &fnSetPalette, "Set the ANSI color palette.\n\n(ghostel--set-palette TERM COLORS-STRING)");
45
+
env.bindFunction("ghostel--set-default-colors", 3, 3, &fnSetDefaultColors, "Set default foreground and background colors.\n\n(ghostel--set-default-colors TERM FG-HEX BG-HEX)");
45
46
env.bindFunction("ghostel--mode-enabled", 2, 2, &fnModeEnabled, "Return t if terminal DEC private MODE is enabled.\n\n(ghostel--mode-enabled TERM MODE)");
46
47
env.bindFunction("ghostel--debug-state", 1, 1, &fnDebugState, "Return debug info about terminal/render state.\n\n(ghostel--debug-state TERM)");
47
48
env.bindFunction("ghostel--debug-feed", 2, 2, &fnDebugFeed, "Feed STR to terminal and return first row + cursor.\n\n(ghostel--debug-feed TERM STR)");
@@ -559,6 +560,55 @@ fn hexDigit(ch: u8) ?u8 {
559
560
returnnull;
560
561
}
561
562
563
+
/// Parse a "#RRGGBB" hex color string into a ColorRgb.
564
+
fnparseHexColor(s: []constu8) ?gt.ColorRgb {
565
+
if (s.len<7ors[0] !='#') returnnull;
566
+
constr=parseHexByte(s[1], s[2]) orelsereturnnull;
567
+
constg=parseHexByte(s[3], s[4]) orelsereturnnull;
568
+
constb=parseHexByte(s[5], s[6]) orelsereturnnull;
569
+
return .{ .r=r, .g=g, .b=b };
570
+
}
571
+
572
+
/// (ghostel--set-default-colors TERM FG-HEX BG-HEX)
573
+
/// Set the terminal's default foreground and background colors from "#RRGGBB" strings.
0 commit comments