// Copyright (c) 2026 Storm Dragon // Authors: Storm Dragon, Angus Kola // SPDX-License-Identifier: GPL-3.0-or-later package input 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 >= 12 { return "" } action := "review" if copyMessage { action = "copy" } return Command(action + "-chat-message-" + strconv.Itoa(index+1)) } func MessageCommandIndex(command Command) (index int, copyMessage, ok bool) { number, found := strings.CutPrefix(string(command), "review-chat-message-") if !found { number, found = strings.CutPrefix(string(command), "copy-chat-message-") copyMessage = true } value, err := strconv.Atoi(number) if !found || err != nil || value < 1 || value > 12 || strconv.Itoa(value) != number { return 0, false, false } return value - 1, copyMessage, true }