github.com/daidehu6831/wails/v2@v2.2.0/pkg/menu/keys/stringify.go (about) 1 package keys 2 3 import ( 4 "github.com/leaanthony/slicer" 5 "strings" 6 ) 7 8 var modifierStringMap = map[string]map[Modifier]string{ 9 "windows": { 10 CmdOrCtrlKey: "Ctrl", 11 ControlKey: "Ctrl", 12 OptionOrAltKey: "Alt", 13 ShiftKey: "Shift", 14 //SuperKey: "Win", 15 }, 16 "darwin": { 17 CmdOrCtrlKey: "Cmd", 18 ControlKey: "Ctrl", 19 OptionOrAltKey: "Option", 20 ShiftKey: "Shift", 21 //SuperKey: "Cmd", 22 }, 23 "linux": { 24 CmdOrCtrlKey: "Ctrl", 25 ControlKey: "Ctrl", 26 OptionOrAltKey: "Alt", 27 ShiftKey: "Shift", 28 //SuperKey: "Super", 29 }, 30 } 31 32 func Stringify(accelerator *Accelerator, platform string) string { 33 result := slicer.String() 34 for _, modifier := range accelerator.Modifiers { 35 result.Add(modifierStringMap[platform][modifier]) 36 } 37 result.Deduplicate() 38 result.Add(strings.ToUpper(accelerator.Key)) 39 return result.Join("+") 40 }