more verbose --list-keys output with modifiers
This commit is contained in:
parent
a0049f668b
commit
a580b0944b
1 changed files with 30 additions and 5 deletions
39
dotool.go
39
dotool.go
|
@ -151,17 +151,42 @@ func (c Chord) KeyUp(kb uinput.Keyboard) {
|
||||||
log(kb.KeyUp(c.Key))
|
log(kb.KeyUp(c.Key))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *Chord) String() string {
|
||||||
|
var sb strings.Builder
|
||||||
|
if c.Super {
|
||||||
|
sb.WriteString("super+")
|
||||||
|
}
|
||||||
|
if c.AltGr {
|
||||||
|
sb.WriteString("altgr+")
|
||||||
|
}
|
||||||
|
if c.Ctrl {
|
||||||
|
sb.WriteString("ctrl+")
|
||||||
|
}
|
||||||
|
if c.Alt {
|
||||||
|
sb.WriteString("alt+")
|
||||||
|
}
|
||||||
|
if c.Shift {
|
||||||
|
sb.WriteString("shift+")
|
||||||
|
}
|
||||||
|
sb.WriteString("k:")
|
||||||
|
sb.WriteString(strconv.Itoa(c.Key))
|
||||||
|
return sb.String()
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
func listKeys(keymap *xkb.Keymap, keys map[string]Chord) {
|
func listKeys(keymap *xkb.Keymap, keys map[string]Chord) {
|
||||||
|
var margin int
|
||||||
|
for code := 1; code < 256; code++ {
|
||||||
|
for name := range keys {
|
||||||
|
if len(name) > margin {
|
||||||
|
margin = len(name)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
for code := 1; code < 256; code++ {
|
for code := 1; code < 256; code++ {
|
||||||
for name, chord := range keys {
|
for name, chord := range keys {
|
||||||
if chord.Key == code && (chord == Chord{Key: code}) {
|
if chord.Key == code {
|
||||||
fmt.Println(name, code)
|
fmt.Printf("%-*s %s\n", margin, name, chord.String())
|
||||||
}
|
|
||||||
}
|
|
||||||
for name, chord := range keys {
|
|
||||||
if chord.Key == code && (chord != Chord{Key: code}) {
|
|
||||||
fmt.Println(name, code)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue