mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-25 13:16:11 +03:00
terminal: handle set application keypad mode (both ESC and modes)
This commit is contained in:
@ -1114,6 +1114,7 @@ pub fn keyCallback(
|
|||||||
// We'll need to know these values here on.
|
// We'll need to know these values here on.
|
||||||
self.renderer_state.mutex.lock();
|
self.renderer_state.mutex.lock();
|
||||||
const cursor_key_application = self.io.terminal.modes.cursor_keys;
|
const cursor_key_application = self.io.terminal.modes.cursor_keys;
|
||||||
|
const keypad_key_application = self.io.terminal.modes.keypad_keys;
|
||||||
self.renderer_state.mutex.unlock();
|
self.renderer_state.mutex.unlock();
|
||||||
|
|
||||||
// Check if we're processing a function key.
|
// Check if we're processing a function key.
|
||||||
@ -1126,7 +1127,8 @@ pub fn keyCallback(
|
|||||||
|
|
||||||
switch (entry.keypad) {
|
switch (entry.keypad) {
|
||||||
.any => {},
|
.any => {},
|
||||||
else => {}, // TODO
|
.normal => if (keypad_key_application) continue,
|
||||||
|
.application => if (!keypad_key_application) continue,
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (entry.modify_other_keys) {
|
switch (entry.modify_other_keys) {
|
||||||
|
@ -90,6 +90,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
|
||||||
|
|
||||||
focus_event: bool = false, // 1004
|
focus_event: bool = false, // 1004
|
||||||
mouse_alternate_scroll: bool = true, // 1007
|
mouse_alternate_scroll: bool = true, // 1007
|
||||||
|
@ -88,6 +88,9 @@ pub const Mode = enum(u16) {
|
|||||||
/// mode ?3 is set or unset.
|
/// mode ?3 is set or unset.
|
||||||
enable_mode_3 = 40,
|
enable_mode_3 = 40,
|
||||||
|
|
||||||
|
/// DECNKM. Sets application keypad mode if enabled.
|
||||||
|
keypad_keys = 66,
|
||||||
|
|
||||||
/// "Normal" mouse events: click/release, scroll
|
/// "Normal" mouse events: click/release, scroll
|
||||||
mouse_event_normal = 1000,
|
mouse_event_normal = 1000,
|
||||||
|
|
||||||
|
@ -765,6 +765,16 @@ pub fn Stream(comptime Handler: type) type {
|
|||||||
},
|
},
|
||||||
} else log.warn("unimplemented invokeCharset: {}", .{action}),
|
} else log.warn("unimplemented invokeCharset: {}", .{action}),
|
||||||
|
|
||||||
|
// Set application keypad mode
|
||||||
|
'=' => if (@hasDecl(T, "setMode")) {
|
||||||
|
try self.handler.setMode(.keypad_keys, true);
|
||||||
|
} else log.warn("unimplemented setMode: {}", .{action}),
|
||||||
|
|
||||||
|
// Reset application keypad mode
|
||||||
|
'>' => if (@hasDecl(T, "setMode")) {
|
||||||
|
try self.handler.setMode(.keypad_keys, false);
|
||||||
|
} else log.warn("unimplemented setMode: {}", .{action}),
|
||||||
|
|
||||||
else => if (@hasDecl(T, "escUnimplemented"))
|
else => if (@hasDecl(T, "escUnimplemented"))
|
||||||
try self.handler.escUnimplemented(action)
|
try self.handler.escUnimplemented(action)
|
||||||
else
|
else
|
||||||
|
@ -1193,6 +1193,10 @@ const StreamHandler = struct {
|
|||||||
self.terminal.modes.cursor_keys = enabled;
|
self.terminal.modes.cursor_keys = enabled;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
.keypad_keys => {
|
||||||
|
self.terminal.modes.keypad_keys = enabled;
|
||||||
|
},
|
||||||
|
|
||||||
.insert => {
|
.insert => {
|
||||||
self.terminal.modes.insert = enabled;
|
self.terminal.modes.insert = enabled;
|
||||||
},
|
},
|
||||||
|
Reference in New Issue
Block a user