mirror of
https://github.com/ghostty-org/ghostty.git
synced 2026-07-27 19:16:27 +00:00
apprt/embedded: add API for reporting color scheme
This commit is contained in:
@@ -2803,7 +2803,7 @@ fn dragLeftClickBefore(
|
||||
|
||||
/// Call to notify Ghostty that the color scheme for the terminal has
|
||||
/// changed.
|
||||
pub fn colorSchemeCallback(self: *Surface, scheme: apprt.ColorScheme) void {
|
||||
pub fn colorSchemeCallback(self: *Surface, scheme: apprt.ColorScheme) !void {
|
||||
self.color_scheme = scheme;
|
||||
}
|
||||
|
||||
|
||||
@@ -689,6 +689,13 @@ pub const Surface = struct {
|
||||
};
|
||||
}
|
||||
|
||||
pub fn colorSchemeCallback(self: *Surface, scheme: apprt.ColorScheme) void {
|
||||
self.core_surface.colorSchemeCallback(scheme) catch |err| {
|
||||
log.err("error setting color scheme err={}", .{err});
|
||||
return;
|
||||
};
|
||||
}
|
||||
|
||||
pub fn mouseButtonCallback(
|
||||
self: *Surface,
|
||||
action: input.MouseButtonState,
|
||||
@@ -1516,6 +1523,19 @@ pub const CAPI = struct {
|
||||
surface.updateSize(w, h);
|
||||
}
|
||||
|
||||
/// Update the color scheme of the surface.
|
||||
export fn ghostty_surface_set_color_scheme(surface: *Surface, scheme_raw: c_int) void {
|
||||
const scheme = std.meta.intToEnum(apprt.ColorScheme, scheme_raw) catch {
|
||||
log.warn(
|
||||
"invalid color scheme to ghostty_surface_set_color_scheme value={}",
|
||||
.{scheme_raw},
|
||||
);
|
||||
return;
|
||||
};
|
||||
|
||||
surface.colorSchemeCallback(scheme);
|
||||
}
|
||||
|
||||
/// Update the content scale of the surface.
|
||||
export fn ghostty_surface_set_content_scale(surface: *Surface, x: f64, y: f64) void {
|
||||
surface.updateContentScale(x, y);
|
||||
|
||||
Reference in New Issue
Block a user