xC + frontends: merge M-! into M-a + reversed M-A

Both WeeChat and irssi merge these two by prioritising highlights
when you press M-a.
This commit is contained in:
p
2026-08-09 14:58:11 +02:00
parent 6ba94ba664
commit 2d1df86a46
11 changed files with 180 additions and 129 deletions
+22 -12
View File
@@ -1210,7 +1210,7 @@ class WindowDelegate: NSObject, NSWindowDelegate {
refreshBufferList()
}
// Buffer indexes rotated to start after the current buffer.
// Buffers rotated to start after the current buffer.
func rotatedBuffers() -> Array<Buffer> {
guard let i = relayBuffers.firstIndex(
where: { $0.bufferName == relayBufferCurrent }) else {
@@ -1239,22 +1239,32 @@ class WindowDelegate: NSObject, NSWindowDelegate {
}
}
@objc func actionGotoHighlight() {
for b in rotatedBuffers() {
func gotoActivity(backwards: Bool) {
var candidates = rotatedBuffers()
candidates.popLast()
if backwards {
candidates.reverse()
}
for b in candidates {
if b.highlighted {
bufferActivate(name: b.bufferName)
return
}
}
for b in candidates {
if b.newMessages != 0 {
bufferActivate(name: b.bufferName)
return
}
}
}
@objc func actionGotoActivity() {
for b in rotatedBuffers() {
if b.newMessages != 0 {
bufferActivate(name: b.bufferName)
return
}
}
gotoActivity(backwards: false)
}
@objc func actionGotoBacktivity() {
gotoActivity(backwards: true)
}
@objc func actionToggleUnimportant() {
@@ -1314,12 +1324,12 @@ pushAccelerator("Switch buffer",
// TODO(p): Remove .command, and ignore these with the right Option key.
bufferMenu.addItem(NSMenuItem.separator())
pushAccelerator("Go to highlight",
#selector(WindowDelegate.actionGotoHighlight),
"!", [.command, .option])
pushAccelerator("Go to activity",
#selector(WindowDelegate.actionGotoActivity),
"a", [.command, .option])
pushAccelerator("Go to activity backwards",
#selector(WindowDelegate.actionGotoBacktivity),
"a", [.shift, .command, .option])
bufferMenu.addItem(NSMenuItem.separator())
pushAccelerator("Toggle unimportant",