mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-09-05 19:08:17 +00:00
config: bind both physical digit plus unicode digit for goto_tab
Fixes #8478 The comments explain this.
This commit is contained in:
@@ -439,8 +439,7 @@ class TerminalController: BaseTerminalController, TabGroupCloseCoordinator.Contr
|
||||
continue
|
||||
}
|
||||
|
||||
let action = "goto_tab:\(tab)"
|
||||
if let equiv = ghostty.config.keyboardShortcut(for: action) {
|
||||
if let equiv = ghostty.config.keyboardShortcut(for: "goto_tab:\(tab)") {
|
||||
window.keyEquivalent = "\(equiv)"
|
||||
} else {
|
||||
window.keyEquivalent = ""
|
||||
|
@@ -1264,7 +1264,7 @@ extension Ghostty {
|
||||
|
||||
var key_ev = event.ghosttyKeyEvent(action, translationMods: translationEvent?.modifierFlags)
|
||||
key_ev.composing = composing
|
||||
|
||||
|
||||
// For text, we only encode UTF8 if we don't have a single control
|
||||
// character. Control characters are encoded by Ghostty itself.
|
||||
// Without this, `ctrl+enter` does the wrong thing.
|
||||
|
@@ -5785,15 +5785,24 @@ pub const Keybinds = struct {
|
||||
else
|
||||
.{ .alt = true };
|
||||
|
||||
// Cmd+N for goto tab N
|
||||
// Cmd/Alt+N for goto tab N
|
||||
const start: u21 = '1';
|
||||
const end: u21 = '8';
|
||||
var i: u21 = start;
|
||||
while (i <= end) : (i += 1) {
|
||||
comptime var i: u21 = start;
|
||||
inline while (i <= end) : (i += 1) {
|
||||
// We register BOTH the physical `digit_N` key and the unicode
|
||||
// `N` key. This allows most keyboard layouts to work with
|
||||
// this shortcut. Namely, AZERTY doesn't produce unicode `N`
|
||||
// for their digit keys (they're on shifted keys on the same
|
||||
// physical keys).
|
||||
|
||||
try self.set.putFlags(
|
||||
alloc,
|
||||
.{
|
||||
.key = .{ .unicode = i },
|
||||
.key = .{ .physical = @field(
|
||||
inputpkg.Key,
|
||||
std.fmt.comptimePrint("digit_{u}", .{i}),
|
||||
) },
|
||||
.mods = mods,
|
||||
},
|
||||
.{ .goto_tab = (i - start) + 1 },
|
||||
@@ -5806,6 +5815,22 @@ pub const Keybinds = struct {
|
||||
.performable = !builtin.target.os.tag.isDarwin(),
|
||||
},
|
||||
);
|
||||
|
||||
// Important: this must be the LAST binding set so that the
|
||||
// libghostty trigger API returns this one for the action,
|
||||
// so that things like the macOS tab bar key equivalent label
|
||||
// work properly.
|
||||
try self.set.putFlags(
|
||||
alloc,
|
||||
.{
|
||||
.key = .{ .unicode = i },
|
||||
.mods = mods,
|
||||
},
|
||||
.{ .goto_tab = (i - start) + 1 },
|
||||
.{
|
||||
.performable = !builtin.target.os.tag.isDarwin(),
|
||||
},
|
||||
);
|
||||
}
|
||||
try self.set.putFlags(
|
||||
alloc,
|
||||
|
Reference in New Issue
Block a user