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:
+22
-12
@@ -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",
|
||||
|
||||
Reference in New Issue
Block a user