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
@@ -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
|
||||
}
|
||||
Reference in new issue
Block a user