summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMitchell Hashimoto <mitchell.hashimoto@gmail.com>2023-09-09 13:02:53 -0700
committerGitHub <noreply@github.com>2023-09-09 13:02:53 -0700
commit7fd8dde933e408358a79f2179772d686ddd6893e (patch)
treea4b5422856c6dfd5d462e082353a6fce09a3b952 /src
parentce18b63f936fee52551653928155833714a6fc1b (diff)
parentf31bde48fc556e41b712e69862e74ed56ce73347 (diff)
Merge pull request #420 from mitchellh/macos-prev-next-tab
macos: add prev/next tab custom binding support
Diffstat (limited to 'src')
-rw-r--r--src/apprt/embedded.zig34
1 files changed, 32 insertions, 2 deletions
diff --git a/src/apprt/embedded.zig b/src/apprt/embedded.zig
index 7d246c940..650bee842 100644
--- a/src/apprt/embedded.zig
+++ b/src/apprt/embedded.zig
@@ -76,12 +76,19 @@ pub const App = struct {
toggle_split_zoom: ?*const fn (SurfaceUD) callconv(.C) void = null,
/// Goto tab
- goto_tab: ?*const fn (SurfaceUD, usize) callconv(.C) void = null,
+ goto_tab: ?*const fn (SurfaceUD, GotoTab) callconv(.C) void = null,
/// Toggle fullscreen for current window.
toggle_fullscreen: ?*const fn (SurfaceUD, configpkg.NonNativeFullscreen) callconv(.C) void = null,
};
+ /// Special values for the goto_tab callback.
+ const GotoTab = enum(i32) {
+ previous = -1,
+ next = -2,
+ _,
+ };
+
core_app: *CoreApp,
config: *const Config,
opts: Options,
@@ -637,7 +644,30 @@ pub const Surface = struct {
return;
};
- func(self.opts.userdata, n);
+ const idx = std.math.cast(i32, n) orelse {
+ log.warn("cannot cast tab index to i32 n={}", .{n});
+ return;
+ };
+
+ func(self.opts.userdata, @enumFromInt(idx));
+ }
+
+ pub fn gotoPreviousTab(self: *Surface) void {
+ const func = self.app.opts.goto_tab orelse {
+ log.info("runtime embedder does not goto_tab", .{});
+ return;
+ };
+
+ func(self.opts.userdata, .previous);
+ }
+
+ pub fn gotoNextTab(self: *Surface) void {
+ const func = self.app.opts.goto_tab orelse {
+ log.info("runtime embedder does not goto_tab", .{});
+ return;
+ };
+
+ func(self.opts.userdata, .next);
}
pub fn toggleFullscreen(self: *Surface, nonNativeFullscreen: configpkg.NonNativeFullscreen) void {