add go modules

This commit is contained in:
anton.gurov
2019-10-17 19:57:20 +03:00
parent 83dc2f9007
commit ed22f7a37e
24 changed files with 380 additions and 1520 deletions

34
ui/keyinput.go Normal file
View File

@ -0,0 +1,34 @@
package ui
import (
"lab.zaar.be/thefish/alchemyst-go/util"
blt "lab.zaar.be/thefish/bearlibterminal"
)
var modifiers = []int{blt.TK_SHIFT, blt.TK_ALT, blt.TK_CONTROL}
func ReadKey(ctx util.ClientCtx) (string, int) {
if !blt.HasInput() {
return "", blt.TK_NONE
}
var key = blt.Read()
var pressed = ""
var isModifier, _ = util.InArray(key, modifiers)
if !isModifier {
pressed = Scancodemap[key]
if blt.Check(blt.TK_SHIFT) != 0 {
pressed = "Shift+" + pressed
}
if blt.Check(blt.TK_ALT) != 0 {
pressed = "Alt+" + pressed
}
if blt.Check(blt.TK_CONTROL) != 0 {
pressed = "Ctrl+" + pressed
}
ctx.Logger().Debug().Msg(pressed)
}
return pressed, key
}