package cview
import (
"code.rocketnine.space/tslocum/cbind"
"github.com/gdamore/tcell/v2"
)
type Key struct {
Cancel []string
Select []string
Select2 []string
MoveUp []string
MoveUp2 []string
MoveDown []string
MoveDown2 []string
MoveLeft []string
MoveLeft2 []string
MoveRight []string
MoveRight2 []string
MoveFirst []string
MoveFirst2 []string
MoveLast []string
MoveLast2 []string
MovePreviousField []string
MoveNextField []string
MovePreviousPage []string
MoveNextPage []string
ShowContextMenu []string
}
var Keys = Key {
Cancel : []string {"Escape" },
Select : []string {"Enter" , "Ctrl+J" },
Select2 : []string {"Space" },
MoveUp : []string {"Up" },
MoveUp2 : []string {"k" },
MoveDown : []string {"Down" },
MoveDown2 : []string {"j" },
MoveLeft : []string {"Left" },
MoveLeft2 : []string {"h" },
MoveRight : []string {"Right" },
MoveRight2 : []string {"l" },
MoveFirst : []string {"Home" , "Ctrl+A" },
MoveFirst2 : []string {"g" },
MoveLast : []string {"End" , "Ctrl+E" },
MoveLast2 : []string {"G" },
MovePreviousField : []string {"Backtab" },
MoveNextField : []string {"Tab" },
MovePreviousPage : []string {"PageUp" , "Ctrl+B" },
MoveNextPage : []string {"PageDown" , "Ctrl+F" },
ShowContextMenu : []string {"Alt+Enter" },
}
func HitShortcut (event *tcell .EventKey , keybindings ...[]string ) bool {
enc , err := cbind .Encode (event .Modifiers (), event .Key (), event .Rune ())
if err != nil {
return false
}
for _ , binds := range keybindings {
for _ , key := range binds {
if key == enc {
return true
}
}
}
return false
}
The pages are generated with Golds v0.8.2 . (GOOS=linux GOARCH=amd64)
Golds is a Go 101 project developed by Tapir Liu .
PR and bug reports are welcome and can be submitted to the issue list .
Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds .