// Copyright (c) 2026 Storm Dragon // Authors: Storm Dragon, Angus Kola // SPDX-License-Identifier: GPL-3.0-or-later package input import "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 { return "" } action := "review" if copyMessage { action = "copy" } return Command(action + "-chat-message-" + string(rune('1'+index))) } 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 } if !found || len(number) != 1 || number[0] < '1' || number[0] > '9' { return 0, false, false } return int(number[0] - '1'), copyMessage, true }