mirror of
https://github.com/ghostty-org/ghostty.git
synced 2026-04-19 05:50:27 +00:00
core: add input binding to control terminal inspector
This commit is contained in:
@@ -2278,6 +2278,12 @@ pub fn performBindingAction(self: *Surface, action: input.Binding.Action) !bool
|
||||
} else log.warn("runtime doesn't implement toggleFullscreen", .{});
|
||||
},
|
||||
|
||||
.inspector => |mode| {
|
||||
if (@hasDecl(apprt.Surface, "controlInspector")) {
|
||||
self.rt_surface.controlInspector(mode);
|
||||
} else log.warn("runtime doesn't implement controlInspector", .{});
|
||||
},
|
||||
|
||||
.close_surface => self.close(),
|
||||
|
||||
.close_window => try self.app.closeSurface(self),
|
||||
|
||||
@@ -73,6 +73,9 @@ pub const App = struct {
|
||||
/// New window with options.
|
||||
new_window: ?*const fn (SurfaceUD, apprt.Surface.Options) callconv(.C) void = null,
|
||||
|
||||
/// Control the inspector visibility
|
||||
control_inspector: ?*const fn (SurfaceUD, input.InspectorMode) callconv(.C) void = null,
|
||||
|
||||
/// Close the current surface given by this function.
|
||||
close_surface: ?*const fn (SurfaceUD, bool) callconv(.C) void = null,
|
||||
|
||||
@@ -326,6 +329,15 @@ pub const Surface = struct {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn controlInspector(self: *const Surface, mode: input.InspectorMode) void {
|
||||
const func = self.app.opts.control_inspector orelse {
|
||||
log.info("runtime embedder does not support the terminal inspector", .{});
|
||||
return;
|
||||
};
|
||||
|
||||
func(self.opts.userdata, mode);
|
||||
}
|
||||
|
||||
pub fn newSplit(self: *const Surface, direction: input.SplitDirection) !void {
|
||||
const func = self.app.opts.new_split orelse {
|
||||
log.info("runtime embedder does not support splits", .{});
|
||||
|
||||
@@ -8,6 +8,7 @@ pub const keycodes = @import("input/keycodes.zig");
|
||||
pub const kitty = @import("input/kitty.zig");
|
||||
pub const Binding = @import("input/Binding.zig");
|
||||
pub const KeyEncoder = @import("input/KeyEncoder.zig");
|
||||
pub const InspectorMode = Binding.Action.InspectorMode;
|
||||
pub const SplitDirection = Binding.Action.SplitDirection;
|
||||
pub const SplitFocusDirection = Binding.Action.SplitFocusDirection;
|
||||
|
||||
|
||||
@@ -176,6 +176,10 @@ pub const Action = union(enum) {
|
||||
/// zoom/unzoom the current split.
|
||||
toggle_split_zoom: void,
|
||||
|
||||
/// Show, hide, or toggle the terminal inspector for the currently
|
||||
/// focused terminal.
|
||||
inspector: InspectorMode,
|
||||
|
||||
/// Reload the configuration. The exact meaning depends on the app runtime
|
||||
/// in use but this usually involves re-reading the configuration file
|
||||
/// and applying any changes. Note that not all changes can be applied at
|
||||
@@ -220,6 +224,13 @@ pub const Action = union(enum) {
|
||||
right,
|
||||
};
|
||||
|
||||
// Extern because it is used in the embedded runtime ABI.
|
||||
pub const InspectorMode = enum(c_int) {
|
||||
toggle,
|
||||
show,
|
||||
hide,
|
||||
};
|
||||
|
||||
/// Parse an action in the format of "key=value" where key is the
|
||||
/// action name and value is the action parameter. The parameter
|
||||
/// is optional depending on the action.
|
||||
|
||||
Reference in New Issue
Block a user