mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-08-02 14:57:31 +03:00
rename cursor shape to mouse shape for OSC 22
This commit is contained in:
@ -71,41 +71,41 @@ typedef enum {
|
|||||||
} ghostty_input_mouse_momentum_e;
|
} ghostty_input_mouse_momentum_e;
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
GHOSTTY_CURSOR_SHAPE_DEFAULT,
|
GHOSTTY_MOUSE_SHAPE_DEFAULT,
|
||||||
GHOSTTY_CURSOR_SHAPE_CONTEXT_MENU,
|
GHOSTTY_MOUSE_SHAPE_CONTEXT_MENU,
|
||||||
GHOSTTY_CURSOR_SHAPE_HELP,
|
GHOSTTY_MOUSE_SHAPE_HELP,
|
||||||
GHOSTTY_CURSOR_SHAPE_POINTER,
|
GHOSTTY_MOUSE_SHAPE_POINTER,
|
||||||
GHOSTTY_CURSOR_SHAPE_PROGRESS,
|
GHOSTTY_MOUSE_SHAPE_PROGRESS,
|
||||||
GHOSTTY_CURSOR_SHAPE_WAIT,
|
GHOSTTY_MOUSE_SHAPE_WAIT,
|
||||||
GHOSTTY_CURSOR_SHAPE_CELL,
|
GHOSTTY_MOUSE_SHAPE_CELL,
|
||||||
GHOSTTY_CURSOR_SHAPE_CROSSHAIR,
|
GHOSTTY_MOUSE_SHAPE_CROSSHAIR,
|
||||||
GHOSTTY_CURSOR_SHAPE_TEXT,
|
GHOSTTY_MOUSE_SHAPE_TEXT,
|
||||||
GHOSTTY_CURSOR_SHAPE_VERTICAL_TEXT,
|
GHOSTTY_MOUSE_SHAPE_VERTICAL_TEXT,
|
||||||
GHOSTTY_CURSOR_SHAPE_ALIAS,
|
GHOSTTY_MOUSE_SHAPE_ALIAS,
|
||||||
GHOSTTY_CURSOR_SHAPE_COPY,
|
GHOSTTY_MOUSE_SHAPE_COPY,
|
||||||
GHOSTTY_CURSOR_SHAPE_MOVE,
|
GHOSTTY_MOUSE_SHAPE_MOVE,
|
||||||
GHOSTTY_CURSOR_SHAPE_NO_DROP,
|
GHOSTTY_MOUSE_SHAPE_NO_DROP,
|
||||||
GHOSTTY_CURSOR_SHAPE_NOT_ALLOWED,
|
GHOSTTY_MOUSE_SHAPE_NOT_ALLOWED,
|
||||||
GHOSTTY_CURSOR_SHAPE_GRAB,
|
GHOSTTY_MOUSE_SHAPE_GRAB,
|
||||||
GHOSTTY_CURSOR_SHAPE_GRABBING,
|
GHOSTTY_MOUSE_SHAPE_GRABBING,
|
||||||
GHOSTTY_CURSOR_SHAPE_ALL_SCROLL,
|
GHOSTTY_MOUSE_SHAPE_ALL_SCROLL,
|
||||||
GHOSTTY_CURSOR_SHAPE_COL_RESIZE,
|
GHOSTTY_MOUSE_SHAPE_COL_RESIZE,
|
||||||
GHOSTTY_CURSOR_SHAPE_ROW_RESIZE,
|
GHOSTTY_MOUSE_SHAPE_ROW_RESIZE,
|
||||||
GHOSTTY_CURSOR_SHAPE_N_RESIZE,
|
GHOSTTY_MOUSE_SHAPE_N_RESIZE,
|
||||||
GHOSTTY_CURSOR_SHAPE_E_RESIZE,
|
GHOSTTY_MOUSE_SHAPE_E_RESIZE,
|
||||||
GHOSTTY_CURSOR_SHAPE_S_RESIZE,
|
GHOSTTY_MOUSE_SHAPE_S_RESIZE,
|
||||||
GHOSTTY_CURSOR_SHAPE_W_RESIZE,
|
GHOSTTY_MOUSE_SHAPE_W_RESIZE,
|
||||||
GHOSTTY_CURSOR_SHAPE_NE_RESIZE,
|
GHOSTTY_MOUSE_SHAPE_NE_RESIZE,
|
||||||
GHOSTTY_CURSOR_SHAPE_NW_RESIZE,
|
GHOSTTY_MOUSE_SHAPE_NW_RESIZE,
|
||||||
GHOSTTY_CURSOR_SHAPE_SE_RESIZE,
|
GHOSTTY_MOUSE_SHAPE_SE_RESIZE,
|
||||||
GHOSTTY_CURSOR_SHAPE_SW_RESIZE,
|
GHOSTTY_MOUSE_SHAPE_SW_RESIZE,
|
||||||
GHOSTTY_CURSOR_SHAPE_EW_RESIZE,
|
GHOSTTY_MOUSE_SHAPE_EW_RESIZE,
|
||||||
GHOSTTY_CURSOR_SHAPE_NS_RESIZE,
|
GHOSTTY_MOUSE_SHAPE_NS_RESIZE,
|
||||||
GHOSTTY_CURSOR_SHAPE_NESW_RESIZE,
|
GHOSTTY_MOUSE_SHAPE_NESW_RESIZE,
|
||||||
GHOSTTY_CURSOR_SHAPE_NWSE_RESIZE,
|
GHOSTTY_MOUSE_SHAPE_NWSE_RESIZE,
|
||||||
GHOSTTY_CURSOR_SHAPE_ZOOM_IN,
|
GHOSTTY_MOUSE_SHAPE_ZOOM_IN,
|
||||||
GHOSTTY_CURSOR_SHAPE_ZOOM_OUT,
|
GHOSTTY_MOUSE_SHAPE_ZOOM_OUT,
|
||||||
} ghostty_cursor_shape_e;
|
} ghostty_mouse_shape_e;
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
GHOSTTY_NON_NATIVE_FULLSCREEN_FALSE,
|
GHOSTTY_NON_NATIVE_FULLSCREEN_FALSE,
|
||||||
@ -301,7 +301,7 @@ typedef struct {
|
|||||||
typedef void (*ghostty_runtime_wakeup_cb)(void *);
|
typedef void (*ghostty_runtime_wakeup_cb)(void *);
|
||||||
typedef const ghostty_config_t (*ghostty_runtime_reload_config_cb)(void *);
|
typedef const ghostty_config_t (*ghostty_runtime_reload_config_cb)(void *);
|
||||||
typedef void (*ghostty_runtime_set_title_cb)(void *, const char *);
|
typedef void (*ghostty_runtime_set_title_cb)(void *, const char *);
|
||||||
typedef void (*ghostty_runtime_set_cursor_shape_cb)(void *, ghostty_cursor_shape_e);
|
typedef void (*ghostty_runtime_set_mouse_shape_cb)(void *, ghostty_mouse_shape_e);
|
||||||
typedef const char* (*ghostty_runtime_read_clipboard_cb)(void *, ghostty_clipboard_e);
|
typedef const char* (*ghostty_runtime_read_clipboard_cb)(void *, ghostty_clipboard_e);
|
||||||
typedef void (*ghostty_runtime_write_clipboard_cb)(void *, const char *, ghostty_clipboard_e);
|
typedef void (*ghostty_runtime_write_clipboard_cb)(void *, const char *, ghostty_clipboard_e);
|
||||||
typedef void (*ghostty_runtime_new_split_cb)(void *, ghostty_split_direction_e, ghostty_surface_config_s);
|
typedef void (*ghostty_runtime_new_split_cb)(void *, ghostty_split_direction_e, ghostty_surface_config_s);
|
||||||
@ -319,7 +319,7 @@ typedef struct {
|
|||||||
ghostty_runtime_wakeup_cb wakeup_cb;
|
ghostty_runtime_wakeup_cb wakeup_cb;
|
||||||
ghostty_runtime_reload_config_cb reload_config_cb;
|
ghostty_runtime_reload_config_cb reload_config_cb;
|
||||||
ghostty_runtime_set_title_cb set_title_cb;
|
ghostty_runtime_set_title_cb set_title_cb;
|
||||||
ghostty_runtime_set_cursor_shape_cb set_cursor_shape_cb;
|
ghostty_runtime_set_mouse_shape_cb set_mouse_shape_cb;
|
||||||
ghostty_runtime_read_clipboard_cb read_clipboard_cb;
|
ghostty_runtime_read_clipboard_cb read_clipboard_cb;
|
||||||
ghostty_runtime_write_clipboard_cb write_clipboard_cb;
|
ghostty_runtime_write_clipboard_cb write_clipboard_cb;
|
||||||
ghostty_runtime_new_split_cb new_split_cb;
|
ghostty_runtime_new_split_cb new_split_cb;
|
||||||
|
@ -72,7 +72,7 @@ extension Ghostty {
|
|||||||
wakeup_cb: { userdata in AppState.wakeup(userdata) },
|
wakeup_cb: { userdata in AppState.wakeup(userdata) },
|
||||||
reload_config_cb: { userdata in AppState.reloadConfig(userdata) },
|
reload_config_cb: { userdata in AppState.reloadConfig(userdata) },
|
||||||
set_title_cb: { userdata, title in AppState.setTitle(userdata, title: title) },
|
set_title_cb: { userdata, title in AppState.setTitle(userdata, title: title) },
|
||||||
set_cursor_shape_cb: { userdata, shape in AppState.setCursorShape(userdata, shape: shape) },
|
set_mouse_shape_cb: { userdata, shape in AppState.setMouseShape(userdata, shape: shape) },
|
||||||
read_clipboard_cb: { userdata, loc in AppState.readClipboard(userdata, location: loc) },
|
read_clipboard_cb: { userdata, loc in AppState.readClipboard(userdata, location: loc) },
|
||||||
write_clipboard_cb: { userdata, str, loc in AppState.writeClipboard(userdata, string: str, location: loc) },
|
write_clipboard_cb: { userdata, str, loc in AppState.writeClipboard(userdata, string: str, location: loc) },
|
||||||
new_split_cb: { userdata, direction, surfaceConfig in AppState.newSplit(userdata, direction: direction, config: surfaceConfig) },
|
new_split_cb: { userdata, direction, surfaceConfig in AppState.newSplit(userdata, direction: direction, config: surfaceConfig) },
|
||||||
@ -334,7 +334,7 @@ extension Ghostty {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static func setCursorShape(_ userdata: UnsafeMutableRawPointer?, shape: ghostty_cursor_shape_e) {
|
static func setMouseShape(_ userdata: UnsafeMutableRawPointer?, shape: ghostty_mouse_shape_e) {
|
||||||
let surfaceView = Unmanaged<SurfaceView>.fromOpaque(userdata!).takeUnretainedValue()
|
let surfaceView = Unmanaged<SurfaceView>.fromOpaque(userdata!).takeUnretainedValue()
|
||||||
surfaceView.setCursorShape(shape)
|
surfaceView.setCursorShape(shape)
|
||||||
}
|
}
|
||||||
|
@ -267,51 +267,51 @@ extension Ghostty {
|
|||||||
ghostty_surface_set_size(surface, UInt32(scaledSize.width), UInt32(scaledSize.height))
|
ghostty_surface_set_size(surface, UInt32(scaledSize.width), UInt32(scaledSize.height))
|
||||||
}
|
}
|
||||||
|
|
||||||
func setCursorShape(_ shape: ghostty_cursor_shape_e) {
|
func setCursorShape(_ shape: ghostty_mouse_shape_e) {
|
||||||
switch (shape) {
|
switch (shape) {
|
||||||
case GHOSTTY_CURSOR_SHAPE_DEFAULT:
|
case GHOSTTY_MOUSE_SHAPE_DEFAULT:
|
||||||
cursor = .arrow
|
cursor = .arrow
|
||||||
|
|
||||||
case GHOSTTY_CURSOR_SHAPE_CONTEXT_MENU:
|
case GHOSTTY_MOUSE_SHAPE_CONTEXT_MENU:
|
||||||
cursor = .contextualMenu
|
cursor = .contextualMenu
|
||||||
|
|
||||||
case GHOSTTY_CURSOR_SHAPE_TEXT:
|
case GHOSTTY_MOUSE_SHAPE_TEXT:
|
||||||
cursor = .iBeam
|
cursor = .iBeam
|
||||||
|
|
||||||
case GHOSTTY_CURSOR_SHAPE_CROSSHAIR:
|
case GHOSTTY_MOUSE_SHAPE_CROSSHAIR:
|
||||||
cursor = .crosshair
|
cursor = .crosshair
|
||||||
|
|
||||||
case GHOSTTY_CURSOR_SHAPE_GRAB:
|
case GHOSTTY_MOUSE_SHAPE_GRAB:
|
||||||
cursor = .openHand
|
cursor = .openHand
|
||||||
|
|
||||||
case GHOSTTY_CURSOR_SHAPE_GRABBING:
|
case GHOSTTY_MOUSE_SHAPE_GRABBING:
|
||||||
cursor = .closedHand
|
cursor = .closedHand
|
||||||
|
|
||||||
case GHOSTTY_CURSOR_SHAPE_POINTER:
|
case GHOSTTY_MOUSE_SHAPE_POINTER:
|
||||||
cursor = .pointingHand
|
cursor = .pointingHand
|
||||||
|
|
||||||
case GHOSTTY_CURSOR_SHAPE_W_RESIZE:
|
case GHOSTTY_MOUSE_SHAPE_W_RESIZE:
|
||||||
cursor = .resizeLeft
|
cursor = .resizeLeft
|
||||||
|
|
||||||
case GHOSTTY_CURSOR_SHAPE_E_RESIZE:
|
case GHOSTTY_MOUSE_SHAPE_E_RESIZE:
|
||||||
cursor = .resizeRight
|
cursor = .resizeRight
|
||||||
|
|
||||||
case GHOSTTY_CURSOR_SHAPE_N_RESIZE:
|
case GHOSTTY_MOUSE_SHAPE_N_RESIZE:
|
||||||
cursor = .resizeUp
|
cursor = .resizeUp
|
||||||
|
|
||||||
case GHOSTTY_CURSOR_SHAPE_S_RESIZE:
|
case GHOSTTY_MOUSE_SHAPE_S_RESIZE:
|
||||||
cursor = .resizeDown
|
cursor = .resizeDown
|
||||||
|
|
||||||
case GHOSTTY_CURSOR_SHAPE_NS_RESIZE:
|
case GHOSTTY_MOUSE_SHAPE_NS_RESIZE:
|
||||||
cursor = .resizeUpDown
|
cursor = .resizeUpDown
|
||||||
|
|
||||||
case GHOSTTY_CURSOR_SHAPE_EW_RESIZE:
|
case GHOSTTY_MOUSE_SHAPE_EW_RESIZE:
|
||||||
cursor = .resizeLeftRight
|
cursor = .resizeLeftRight
|
||||||
|
|
||||||
case GHOSTTY_CURSOR_SHAPE_VERTICAL_TEXT:
|
case GHOSTTY_MOUSE_SHAPE_VERTICAL_TEXT:
|
||||||
cursor = .iBeamCursorForVerticalLayout
|
cursor = .iBeamCursorForVerticalLayout
|
||||||
|
|
||||||
case GHOSTTY_CURSOR_SHAPE_NOT_ALLOWED:
|
case GHOSTTY_MOUSE_SHAPE_NOT_ALLOWED:
|
||||||
cursor = .operationNotAllowed
|
cursor = .operationNotAllowed
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
@ -525,9 +525,9 @@ pub fn handleMessage(self: *Surface, msg: Message) !void {
|
|||||||
try self.rt_surface.setTitle(slice);
|
try self.rt_surface.setTitle(slice);
|
||||||
},
|
},
|
||||||
|
|
||||||
.set_cursor_shape => |shape| {
|
.set_mouse_shape => |shape| {
|
||||||
log.debug("changing cursor shape: {}", .{shape});
|
log.debug("changing mouse shape: {}", .{shape});
|
||||||
try self.rt_surface.setCursorShape(shape);
|
try self.rt_surface.setMouseShape(shape);
|
||||||
},
|
},
|
||||||
|
|
||||||
.cell_size => |size| try self.setCellSize(size),
|
.cell_size => |size| try self.setCellSize(size),
|
||||||
|
@ -50,7 +50,7 @@ pub const App = struct {
|
|||||||
set_title: *const fn (SurfaceUD, [*]const u8) callconv(.C) void,
|
set_title: *const fn (SurfaceUD, [*]const u8) callconv(.C) void,
|
||||||
|
|
||||||
/// Called to set the cursor shape.
|
/// Called to set the cursor shape.
|
||||||
set_cursor_shape: *const fn (SurfaceUD, terminal.CursorShape) callconv(.C) void,
|
set_mouse_shape: *const fn (SurfaceUD, terminal.MouseShape) callconv(.C) void,
|
||||||
|
|
||||||
/// Read the clipboard value. The return value must be preserved
|
/// Read the clipboard value. The return value must be preserved
|
||||||
/// by the host until the next call. If there is no valid clipboard
|
/// by the host until the next call. If there is no valid clipboard
|
||||||
@ -314,8 +314,8 @@ pub const Surface = struct {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn setCursorShape(self: *Surface, shape: terminal.CursorShape) !void {
|
pub fn setMouseShape(self: *Surface, shape: terminal.MouseShape) !void {
|
||||||
self.app.opts.set_cursor_shape(
|
self.app.opts.set_mouse_shape(
|
||||||
self.opts.userdata,
|
self.opts.userdata,
|
||||||
shape,
|
shape,
|
||||||
);
|
);
|
||||||
|
@ -357,7 +357,7 @@ pub const Surface = struct {
|
|||||||
errdefer self.* = undefined;
|
errdefer self.* = undefined;
|
||||||
|
|
||||||
// Initialize our cursor
|
// Initialize our cursor
|
||||||
try self.setCursorShape(.text);
|
try self.setMouseShape(.text);
|
||||||
|
|
||||||
// Add ourselves to the list of surfaces on the app.
|
// Add ourselves to the list of surfaces on the app.
|
||||||
try app.app.addSurface(self);
|
try app.app.addSurface(self);
|
||||||
@ -506,7 +506,7 @@ pub const Surface = struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Set the shape of the cursor.
|
/// Set the shape of the cursor.
|
||||||
pub fn setCursorShape(self: *Surface, shape: terminal.CursorShape) !void {
|
pub fn setMouseShape(self: *Surface, shape: terminal.MouseShape) !void {
|
||||||
if ((comptime builtin.target.isDarwin()) and
|
if ((comptime builtin.target.isDarwin()) and
|
||||||
!internal_os.macosVersionAtLeast(13, 0, 0))
|
!internal_os.macosVersionAtLeast(13, 0, 0))
|
||||||
{
|
{
|
||||||
|
@ -990,9 +990,9 @@ pub const Surface = struct {
|
|||||||
// ));
|
// ));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn setCursorShape(
|
pub fn setMouseShape(
|
||||||
self: *Surface,
|
self: *Surface,
|
||||||
shape: terminal.CursorShape,
|
shape: terminal.MouseShape,
|
||||||
) !void {
|
) !void {
|
||||||
const name: [:0]const u8 = switch (shape) {
|
const name: [:0]const u8 = switch (shape) {
|
||||||
.default => "default",
|
.default => "default",
|
||||||
|
@ -17,8 +17,8 @@ pub const Message = union(enum) {
|
|||||||
/// of any length
|
/// of any length
|
||||||
set_title: [256]u8,
|
set_title: [256]u8,
|
||||||
|
|
||||||
/// Set the cursor shape.
|
/// Set the mouse shape.
|
||||||
set_cursor_shape: terminal.CursorShape,
|
set_mouse_shape: terminal.MouseShape,
|
||||||
|
|
||||||
/// Change the cell size.
|
/// Change the cell size.
|
||||||
cell_size: renderer.CellSize,
|
cell_size: renderer.CellSize,
|
||||||
|
@ -15,7 +15,7 @@ pub const parse_table = @import("parse_table.zig");
|
|||||||
pub const Charset = charsets.Charset;
|
pub const Charset = charsets.Charset;
|
||||||
pub const CharsetSlot = charsets.Slots;
|
pub const CharsetSlot = charsets.Slots;
|
||||||
pub const CharsetActiveSlot = charsets.ActiveSlot;
|
pub const CharsetActiveSlot = charsets.ActiveSlot;
|
||||||
pub const CursorShape = @import("cursor_shape.zig").CursorShape;
|
pub const MouseShape = @import("mouse_shape.zig").MouseShape;
|
||||||
pub const Terminal = @import("Terminal.zig");
|
pub const Terminal = @import("Terminal.zig");
|
||||||
pub const Parser = @import("Parser.zig");
|
pub const Parser = @import("Parser.zig");
|
||||||
pub const Selection = @import("Selection.zig");
|
pub const Selection = @import("Selection.zig");
|
||||||
|
@ -5,7 +5,7 @@ const std = @import("std");
|
|||||||
/// can have a cross platform list.
|
/// can have a cross platform list.
|
||||||
//
|
//
|
||||||
// Must be kept in sync with ghostty_cursor_shape_e
|
// Must be kept in sync with ghostty_cursor_shape_e
|
||||||
pub const CursorShape = enum(c_int) {
|
pub const MouseShape = enum(c_int) {
|
||||||
default,
|
default,
|
||||||
context_menu,
|
context_menu,
|
||||||
help,
|
help,
|
||||||
@ -42,12 +42,12 @@ pub const CursorShape = enum(c_int) {
|
|||||||
zoom_out,
|
zoom_out,
|
||||||
|
|
||||||
/// Build cursor shape from string or null if its unknown.
|
/// Build cursor shape from string or null if its unknown.
|
||||||
pub fn fromString(v: []const u8) ?CursorShape {
|
pub fn fromString(v: []const u8) ?MouseShape {
|
||||||
return string_map.get(v);
|
return string_map.get(v);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const string_map = std.ComptimeStringMap(CursorShape, .{
|
const string_map = std.ComptimeStringMap(MouseShape, .{
|
||||||
// W3C
|
// W3C
|
||||||
.{ "default", .default },
|
.{ "default", .default },
|
||||||
.{ "context-menu", .context_menu },
|
.{ "context-menu", .context_menu },
|
||||||
@ -111,5 +111,5 @@ const string_map = std.ComptimeStringMap(CursorShape, .{
|
|||||||
|
|
||||||
test "cursor shape from string" {
|
test "cursor shape from string" {
|
||||||
const testing = std.testing;
|
const testing = std.testing;
|
||||||
try testing.expectEqual(CursorShape.default, CursorShape.fromString("default").?);
|
try testing.expectEqual(MouseShape.default, MouseShape.fromString("default").?);
|
||||||
}
|
}
|
@ -84,11 +84,11 @@ pub const Command = union(enum) {
|
|||||||
value: []const u8,
|
value: []const u8,
|
||||||
},
|
},
|
||||||
|
|
||||||
/// OSC 22. Set the cursor shape. There doesn't seem to be a standard
|
/// OSC 22. Set the mouse shape. There doesn't seem to be a standard
|
||||||
/// naming scheme for cursors but it looks like terminals such as Foot
|
/// naming scheme for cursors but it looks like terminals such as Foot
|
||||||
/// are moving towards using the W3C CSS cursor names. For OSC parsing,
|
/// are moving towards using the W3C CSS cursor names. For OSC parsing,
|
||||||
/// we just parse whatever string is given.
|
/// we just parse whatever string is given.
|
||||||
pointer_cursor: struct {
|
mouse_shape: struct {
|
||||||
value: []const u8,
|
value: []const u8,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
@ -248,10 +248,10 @@ pub const Parser = struct {
|
|||||||
|
|
||||||
.@"22" => switch (c) {
|
.@"22" => switch (c) {
|
||||||
';' => {
|
';' => {
|
||||||
self.command = .{ .pointer_cursor = undefined };
|
self.command = .{ .mouse_shape = undefined };
|
||||||
|
|
||||||
self.state = .string;
|
self.state = .string;
|
||||||
self.temp_state = .{ .str = &self.command.pointer_cursor.value };
|
self.temp_state = .{ .str = &self.command.mouse_shape.value };
|
||||||
self.buf_start = self.buf_idx;
|
self.buf_start = self.buf_idx;
|
||||||
},
|
},
|
||||||
else => self.state = .invalid,
|
else => self.state = .invalid,
|
||||||
@ -672,8 +672,8 @@ test "OSC: pointer cursor" {
|
|||||||
for (input) |ch| p.next(ch);
|
for (input) |ch| p.next(ch);
|
||||||
|
|
||||||
const cmd = p.end().?;
|
const cmd = p.end().?;
|
||||||
try testing.expect(cmd == .pointer_cursor);
|
try testing.expect(cmd == .mouse_shape);
|
||||||
try testing.expect(std.mem.eql(u8, "pointer", cmd.pointer_cursor.value));
|
try testing.expect(std.mem.eql(u8, "pointer", cmd.mouse_shape.value));
|
||||||
}
|
}
|
||||||
|
|
||||||
test "OSC: report pwd empty" {
|
test "OSC: report pwd empty" {
|
||||||
|
@ -9,7 +9,7 @@ const modes = @import("modes.zig");
|
|||||||
const osc = @import("osc.zig");
|
const osc = @import("osc.zig");
|
||||||
const sgr = @import("sgr.zig");
|
const sgr = @import("sgr.zig");
|
||||||
const trace = @import("tracy").trace;
|
const trace = @import("tracy").trace;
|
||||||
const CursorShape = @import("cursor_shape.zig").CursorShape;
|
const MouseShape = @import("mouse_shape.zig").MouseShape;
|
||||||
|
|
||||||
const log = std.log.scoped(.stream);
|
const log = std.log.scoped(.stream);
|
||||||
|
|
||||||
@ -850,14 +850,14 @@ pub fn Stream(comptime Handler: type) type {
|
|||||||
} else log.warn("unimplemented OSC callback: {}", .{cmd});
|
} else log.warn("unimplemented OSC callback: {}", .{cmd});
|
||||||
},
|
},
|
||||||
|
|
||||||
.pointer_cursor => |v| {
|
.mouse_shape => |v| {
|
||||||
if (@hasDecl(T, "setCursorShape")) {
|
if (@hasDecl(T, "setMouseShape")) {
|
||||||
const shape = CursorShape.fromString(v.value) orelse {
|
const shape = MouseShape.fromString(v.value) orelse {
|
||||||
log.warn("unknown cursor shape: {s}", .{v.value});
|
log.warn("unknown cursor shape: {s}", .{v.value});
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
|
|
||||||
try self.handler.setCursorShape(shape);
|
try self.handler.setMouseShape(shape);
|
||||||
} else log.warn("unimplemented OSC callback: {}", .{cmd});
|
} else log.warn("unimplemented OSC callback: {}", .{cmd});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -1682,12 +1682,12 @@ const StreamHandler = struct {
|
|||||||
}, .{ .forever = {} });
|
}, .{ .forever = {} });
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn setCursorShape(
|
pub fn setMouseShape(
|
||||||
self: *StreamHandler,
|
self: *StreamHandler,
|
||||||
shape: terminal.CursorShape,
|
shape: terminal.MouseShape,
|
||||||
) !void {
|
) !void {
|
||||||
_ = self.ev.surface_mailbox.push(.{
|
_ = self.ev.surface_mailbox.push(.{
|
||||||
.set_cursor_shape = shape,
|
.set_mouse_shape = shape,
|
||||||
}, .{ .forever = {} });
|
}, .{ .forever = {} });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user