Merge branch 'ghostty-org:main' into adjust-line

This commit is contained in:
Justin Su
2024-07-21 17:52:46 -04:00
committed by GitHub
3 changed files with 30 additions and 5 deletions

View File

@@ -118,7 +118,8 @@ class TerminalController: NSWindowController, NSWindowDelegate,
/// Update the accessory view of each tab according to the keyboard /// Update the accessory view of each tab according to the keyboard
/// shortcut that activates it (if any). This is called when the key window /// shortcut that activates it (if any). This is called when the key window
/// changes and when a window is closed. /// changes, when a window is closed, and when tabs are reordered
/// with the mouse.
func relabelTabs() { func relabelTabs() {
// Reset this to false. It'll be set back to true later. // Reset this to false. It'll be set back to true later.
tabListenForFrame = false tabListenForFrame = false
@@ -129,11 +130,19 @@ class TerminalController: NSWindowController, NSWindowDelegate,
// otherwise the accessory view doesn't matter. // otherwise the accessory view doesn't matter.
tabListenForFrame = windows.count > 1 tabListenForFrame = windows.count > 1
for (index, window) in windows.enumerated().prefix(9) { for (tab, window) in zip(1..., windows) {
let action = "goto_tab:\(index + 1)" // We need to clear any windows beyond this because they have had
// a keyEquivalent set previously.
guard tab <= 9 else {
window.keyEquivalent = ""
continue
}
let action = "goto_tab:\(tab)"
if let equiv = ghostty.config.keyEquivalent(for: action) { if let equiv = ghostty.config.keyEquivalent(for: action) {
window.keyEquivalent = "\(equiv)" window.keyEquivalent = "\(equiv)"
} else {
window.keyEquivalent = ""
} }
} }
} }

View File

@@ -23,6 +23,13 @@ pub const Slant = enum(c_uint) {
oblique = c.FC_SLANT_OBLIQUE, oblique = c.FC_SLANT_OBLIQUE,
}; };
pub const Spacing = enum(c_uint) {
proportional = c.FC_PROPORTIONAL,
dual = c.FC_DUAL,
mono = c.FC_MONO,
charcell = c.FC_CHARCELL,
};
pub const Property = enum { pub const Property = enum {
family, family,
style, style,

View File

@@ -139,6 +139,15 @@ pub const Descriptor = struct {
false, false,
)); ));
// For fontconfig, we always add monospace in the pattern. Since
// fontconfig sorts by closeness to the pattern, this doesn't fully
// exclude non-monospace but helps prefer it.
assert(pat.add(
.spacing,
.{ .integer = @intFromEnum(fontconfig.Spacing.mono) },
false,
));
return pat; return pat;
} }
@@ -277,7 +286,7 @@ pub const Fontconfig = struct {
if (res.result != .match) return error.FontConfigFailed; if (res.result != .match) return error.FontConfigFailed;
errdefer res.fs.destroy(); errdefer res.fs.destroy();
return DiscoverIterator{ return .{
.config = self.fc_config, .config = self.fc_config,
.pattern = pat, .pattern = pat,
.set = res.fs, .set = res.fs,