mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-22 19:56:08 +03:00
parse and respect mode 1036
This commit is contained in:
@ -1006,7 +1006,9 @@ pub fn charCallback(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Critical area
|
// Critical area
|
||||||
{
|
const critical: struct {
|
||||||
|
alt_esc_prefix: bool,
|
||||||
|
} = critical: {
|
||||||
self.renderer_state.mutex.lock();
|
self.renderer_state.mutex.lock();
|
||||||
defer self.renderer_state.mutex.unlock();
|
defer self.renderer_state.mutex.unlock();
|
||||||
|
|
||||||
@ -1019,17 +1021,31 @@ pub fn charCallback(
|
|||||||
// We want to scroll to the bottom
|
// We want to scroll to the bottom
|
||||||
// TODO: detect if we're at the bottom to avoid the render call here.
|
// TODO: detect if we're at the bottom to avoid the render call here.
|
||||||
try self.io.terminal.scrollViewport(.{ .bottom = {} });
|
try self.io.terminal.scrollViewport(.{ .bottom = {} });
|
||||||
}
|
|
||||||
|
break :critical .{
|
||||||
|
.alt_esc_prefix = self.io.terminal.modes.alt_esc_prefix,
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
var data: termio.Message.WriteReq.Small.Array = undefined;
|
var data: termio.Message.WriteReq.Small.Array = undefined;
|
||||||
|
|
||||||
// Prefix our data with ESC if we have alt pressed.
|
// Prefix our data with ESC if we have alt pressed.
|
||||||
var i: u8 = 0;
|
var i: u8 = 0;
|
||||||
if (mods.alt) alt: {
|
if (mods.alt) alt: {
|
||||||
|
// If the terminal explicitly disabled this feature using mode 1036,
|
||||||
|
// then we don't send the prefix.
|
||||||
|
if (!critical.alt_esc_prefix) {
|
||||||
|
log.debug("alt_esc_prefix disabled with mode, not sending esc prefix", .{});
|
||||||
|
break :alt;
|
||||||
|
}
|
||||||
|
|
||||||
// On macOS, we have to opt-in to using alt because option
|
// On macOS, we have to opt-in to using alt because option
|
||||||
// by default is a unicode character sequence.
|
// by default is a unicode character sequence.
|
||||||
if (comptime builtin.target.isDarwin()) {
|
if (comptime builtin.target.isDarwin()) {
|
||||||
if (!self.config.macos_option_as_alt) break :alt;
|
if (!self.config.macos_option_as_alt) {
|
||||||
|
log.debug("macos_option_as_alt disabled, not sending esc prefix", .{});
|
||||||
|
break :alt;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
data[i] = 0x1b;
|
data[i] = 0x1b;
|
||||||
|
@ -611,16 +611,12 @@ pub const Surface = struct {
|
|||||||
glfw_action: glfw.Action,
|
glfw_action: glfw.Action,
|
||||||
glfw_mods: glfw.Mods,
|
glfw_mods: glfw.Mods,
|
||||||
) void {
|
) void {
|
||||||
|
const tracy = trace(@src());
|
||||||
|
defer tracy.end();
|
||||||
_ = scancode;
|
_ = scancode;
|
||||||
|
|
||||||
const core_win = window.getUserPointer(CoreSurface) orelse return;
|
const core_win = window.getUserPointer(CoreSurface) orelse return;
|
||||||
|
|
||||||
// Reset our consumption state
|
|
||||||
core_win.rt_surface.key_consumed = false;
|
|
||||||
|
|
||||||
const tracy = trace(@src());
|
|
||||||
defer tracy.end();
|
|
||||||
|
|
||||||
// Convert our glfw types into our input types
|
// Convert our glfw types into our input types
|
||||||
const mods: input.Mods = @bitCast(glfw_mods);
|
const mods: input.Mods = @bitCast(glfw_mods);
|
||||||
const action: input.Action = switch (glfw_action) {
|
const action: input.Action = switch (glfw_action) {
|
||||||
@ -756,6 +752,7 @@ pub const Surface = struct {
|
|||||||
|
|
||||||
// TODO: we need to do mapped keybindings
|
// TODO: we need to do mapped keybindings
|
||||||
|
|
||||||
|
core_win.rt_surface.key_mods = mods;
|
||||||
core_win.rt_surface.key_consumed = core_win.keyCallback(
|
core_win.rt_surface.key_consumed = core_win.keyCallback(
|
||||||
action,
|
action,
|
||||||
key,
|
key,
|
||||||
|
@ -91,6 +91,7 @@ modes: packed struct {
|
|||||||
deccolm: bool = false, // 3,
|
deccolm: bool = false, // 3,
|
||||||
deccolm_supported: bool = false, // 40
|
deccolm_supported: bool = false, // 40
|
||||||
keypad_keys: bool = false, // 66
|
keypad_keys: bool = false, // 66
|
||||||
|
alt_esc_prefix: bool = true, // 1036
|
||||||
|
|
||||||
focus_event: bool = false, // 1004
|
focus_event: bool = false, // 1004
|
||||||
mouse_alternate_scroll: bool = true, // 1007
|
mouse_alternate_scroll: bool = true, // 1007
|
||||||
|
@ -121,6 +121,9 @@ pub const Mode = enum(u16) {
|
|||||||
/// Report mouse position in the SGR format as pixels, instead of cells.
|
/// Report mouse position in the SGR format as pixels, instead of cells.
|
||||||
mouse_format_sgr_pixels = 1016,
|
mouse_format_sgr_pixels = 1016,
|
||||||
|
|
||||||
|
/// The alt key sends esc as a prefix before any character. On by default.
|
||||||
|
alt_esc_prefix = 1036,
|
||||||
|
|
||||||
/// Alternate screen mode with save cursor and clear on enter.
|
/// Alternate screen mode with save cursor and clear on enter.
|
||||||
alt_screen_save_cursor_clear_enter = 1049,
|
alt_screen_save_cursor_clear_enter = 1049,
|
||||||
|
|
||||||
|
@ -1274,8 +1274,8 @@ const StreamHandler = struct {
|
|||||||
.mouse_format_sgr_pixels => self.terminal.modes.mouse_format = if (enabled) .sgr_pixels else .x10,
|
.mouse_format_sgr_pixels => self.terminal.modes.mouse_format = if (enabled) .sgr_pixels else .x10,
|
||||||
|
|
||||||
.mouse_alternate_scroll => self.terminal.modes.mouse_alternate_scroll = enabled,
|
.mouse_alternate_scroll => self.terminal.modes.mouse_alternate_scroll = enabled,
|
||||||
|
|
||||||
.focus_event => self.terminal.modes.focus_event = enabled,
|
.focus_event => self.terminal.modes.focus_event = enabled,
|
||||||
|
.alt_esc_prefix => self.terminal.modes.alt_esc_prefix = enabled,
|
||||||
|
|
||||||
else => if (enabled) log.warn("unimplemented mode: {}", .{mode}),
|
else => if (enabled) log.warn("unimplemented mode: {}", .{mode}),
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user