macos: support cursor style

This commit is contained in:
Mitchell Hashimoto
2023-09-14 10:40:40 -07:00
parent 31a61613e9
commit 3356146bb4
5 changed files with 237 additions and 107 deletions

View File

@@ -11,6 +11,7 @@ const Allocator = std.mem.Allocator;
const objc = @import("objc");
const apprt = @import("../apprt.zig");
const input = @import("../input.zig");
const terminal = @import("../terminal/main.zig");
const CoreApp = @import("../App.zig");
const CoreSurface = @import("../Surface.zig");
const configpkg = @import("../config.zig");
@@ -48,6 +49,9 @@ pub const App = struct {
/// Called to set the title of the window.
set_title: *const fn (SurfaceUD, [*]const u8) callconv(.C) void,
/// Called to set the cursor shape.
set_cursor_shape: *const fn (SurfaceUD, terminal.CursorShape) callconv(.C) void,
/// Read the clipboard value. The return value must be preserved
/// by the host until the next call. If there is no valid clipboard
/// value then this should return null.
@@ -310,6 +314,13 @@ pub const Surface = struct {
);
}
pub fn setCursorShape(self: *Surface, shape: terminal.CursorShape) !void {
self.app.opts.set_cursor_shape(
self.opts.userdata,
shape,
);
}
pub fn supportsClipboard(
self: *const Surface,
clipboard_type: apprt.Clipboard,

View File

@@ -3,6 +3,8 @@ const std = @import("std");
/// The possible cursor shapes. Not all app runtimes support these shapes.
/// The shapes are always based on the W3C supported cursor styles so we
/// can have a cross platform list.
//
// Must be kept in sync with ghostty_cursor_shape_e
pub const CursorShape = enum(c_int) {
default,
context_menu,