Add Mumble message review shortcuts
This commit is contained in:
1 parent
d5f8a392cf
commit
64440fbb78
18 files changed
+484
-30
No files matched your search
@@ -237,7 +237,7 @@ func DefaultCommandBindings(layout KeyboardLayout) CommandBindings {
|
||||
{Symbol: leftKeySymbol, Modifiers: controlModifier, CthulhuModifier: true}: ObjectPreviousSibling,
|
||||
{Symbol: rightKeySymbol, Modifiers: controlModifier, CthulhuModifier: true}: ObjectNextSibling,
|
||||
}
|
||||
for index := 0; index < 9; index++ {
|
||||
for index := 0; index < 12; index++ {
|
||||
bindings[CommandChord{Symbol: 0xffbe + uint32(index), CthulhuModifier: true}] = MessageCommand(index, false)
|
||||
bindings[CommandChord{Symbol: 0xffbe + uint32(index), Modifiers: 1, CthulhuModifier: true}] = MessageCommand(index, true)
|
||||
}
|
||||
|
||||
@@ -4,19 +4,22 @@
|
||||
|
||||
package input
|
||||
|
||||
import "strings"
|
||||
import (
|
||||
"strconv"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// Message commands are independent of the physical key. Configured bindings,
|
||||
// learn mode and both keyboard layouts use the same numbered requests.
|
||||
func MessageCommand(index int, copyMessage bool) Command {
|
||||
if index < 0 || index >= 9 {
|
||||
if index < 0 || index >= 12 {
|
||||
return ""
|
||||
}
|
||||
action := "review"
|
||||
if copyMessage {
|
||||
action = "copy"
|
||||
}
|
||||
return Command(action + "-chat-message-" + string(rune('1'+index)))
|
||||
return Command(action + "-chat-message-" + strconv.Itoa(index+1))
|
||||
}
|
||||
|
||||
func MessageCommandIndex(command Command) (index int, copyMessage, ok bool) {
|
||||
@@ -25,8 +28,9 @@ func MessageCommandIndex(command Command) (index int, copyMessage, ok bool) {
|
||||
number, found = strings.CutPrefix(string(command), "copy-chat-message-")
|
||||
copyMessage = true
|
||||
}
|
||||
if !found || len(number) != 1 || number[0] < '1' || number[0] > '9' {
|
||||
value, err := strconv.Atoi(number)
|
||||
if !found || err != nil || value < 1 || value > 12 || strconv.Itoa(value) != number {
|
||||
return 0, false, false
|
||||
}
|
||||
return int(number[0] - '1'), copyMessage, true
|
||||
return value - 1, copyMessage, true
|
||||
}
|
||||
@@ -16,7 +16,7 @@ func TestMessagingBindingsAndExplicitAssignments(t *testing.T) {
|
||||
if bindings[CommandChord{Symbol: 'h', CthulhuModifier: true}] != ToggleLearnMode {
|
||||
t.Fatal("learn mode shortcut changed")
|
||||
}
|
||||
for index := 0; index < 9; index++ {
|
||||
for index := 0; index < 12; index++ {
|
||||
for _, copyMessage := range []bool{false, true} {
|
||||
modifiers := uint16(0)
|
||||
if copyMessage {
|
||||
@@ -45,7 +45,7 @@ func TestMessagingBindingsAndExplicitAssignments(t *testing.T) {
|
||||
}
|
||||
}
|
||||
}
|
||||
for _, command := range []Command{"review-chat-message-0", "review-chat-message-10", "copy-chat-message-01", ToggleLearnMode} {
|
||||
for _, command := range []Command{"review-chat-message-0", "review-chat-message-13", "copy-chat-message-01", "review-chat-message-+1", "review-chat-message- 1", ToggleLearnMode} {
|
||||
if _, _, ok := MessageCommandIndex(command); ok {
|
||||
t.Fatalf("accepted %q", command)
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user