parent
b40ebdcb33
commit
f1f28018a6
104
ui.go
104
ui.go
@ -22,6 +22,32 @@ import (
|
||||
const gEscapeCode = 27
|
||||
|
||||
var gKeyVal = map[tcell.Key]string{
|
||||
tcell.KeyEnter: "<enter>",
|
||||
tcell.KeyBackspace: "<backspace>",
|
||||
tcell.KeyTab: "<tab>",
|
||||
tcell.KeyBacktab: "<backtab>",
|
||||
tcell.KeyEsc: "<esc>",
|
||||
tcell.KeyBackspace2: "<backspace2>",
|
||||
tcell.KeyDelete: "<delete>",
|
||||
tcell.KeyInsert: "<insert>",
|
||||
tcell.KeyUp: "<up>",
|
||||
tcell.KeyDown: "<down>",
|
||||
tcell.KeyLeft: "<left>",
|
||||
tcell.KeyRight: "<right>",
|
||||
tcell.KeyHome: "<home>",
|
||||
tcell.KeyEnd: "<end>",
|
||||
tcell.KeyUpLeft: "<upleft>",
|
||||
tcell.KeyUpRight: "<upright>",
|
||||
tcell.KeyDownLeft: "<downleft>",
|
||||
tcell.KeyDownRight: "<downright>",
|
||||
tcell.KeyCenter: "<center>",
|
||||
tcell.KeyPgDn: "<pgdn>",
|
||||
tcell.KeyPgUp: "<pgup>",
|
||||
tcell.KeyClear: "<clear>",
|
||||
tcell.KeyExit: "<exit>",
|
||||
tcell.KeyCancel: "<cancel>",
|
||||
tcell.KeyPause: "<pause>",
|
||||
tcell.KeyPrint: "<print>",
|
||||
tcell.KeyF1: "<f-1>",
|
||||
tcell.KeyF2: "<f-2>",
|
||||
tcell.KeyF3: "<f-3>",
|
||||
@ -34,17 +60,58 @@ var gKeyVal = map[tcell.Key]string{
|
||||
tcell.KeyF10: "<f-10>",
|
||||
tcell.KeyF11: "<f-11>",
|
||||
tcell.KeyF12: "<f-12>",
|
||||
tcell.KeyInsert: "<insert>",
|
||||
tcell.KeyDelete: "<delete>",
|
||||
tcell.KeyHome: "<home>",
|
||||
tcell.KeyEnd: "<end>",
|
||||
tcell.KeyPgUp: "<pgup>",
|
||||
tcell.KeyPgDn: "<pgdn>",
|
||||
tcell.KeyUp: "<up>",
|
||||
tcell.KeyDown: "<down>",
|
||||
tcell.KeyLeft: "<left>",
|
||||
tcell.KeyRight: "<right>",
|
||||
tcell.KeyCtrlSpace: "<c-space>",
|
||||
tcell.KeyF13: "<f-13>",
|
||||
tcell.KeyF14: "<f-14>",
|
||||
tcell.KeyF15: "<f-15>",
|
||||
tcell.KeyF16: "<f-16>",
|
||||
tcell.KeyF17: "<f-17>",
|
||||
tcell.KeyF18: "<f-18>",
|
||||
tcell.KeyF19: "<f-19>",
|
||||
tcell.KeyF20: "<f-20>",
|
||||
tcell.KeyF21: "<f-21>",
|
||||
tcell.KeyF22: "<f-22>",
|
||||
tcell.KeyF23: "<f-23>",
|
||||
tcell.KeyF24: "<f-24>",
|
||||
tcell.KeyF25: "<f-25>",
|
||||
tcell.KeyF26: "<f-26>",
|
||||
tcell.KeyF27: "<f-27>",
|
||||
tcell.KeyF28: "<f-28>",
|
||||
tcell.KeyF29: "<f-29>",
|
||||
tcell.KeyF30: "<f-30>",
|
||||
tcell.KeyF31: "<f-31>",
|
||||
tcell.KeyF32: "<f-32>",
|
||||
tcell.KeyF33: "<f-33>",
|
||||
tcell.KeyF34: "<f-34>",
|
||||
tcell.KeyF35: "<f-35>",
|
||||
tcell.KeyF36: "<f-36>",
|
||||
tcell.KeyF37: "<f-37>",
|
||||
tcell.KeyF38: "<f-38>",
|
||||
tcell.KeyF39: "<f-39>",
|
||||
tcell.KeyF40: "<f-40>",
|
||||
tcell.KeyF41: "<f-41>",
|
||||
tcell.KeyF42: "<f-42>",
|
||||
tcell.KeyF43: "<f-43>",
|
||||
tcell.KeyF44: "<f-44>",
|
||||
tcell.KeyF45: "<f-45>",
|
||||
tcell.KeyF46: "<f-46>",
|
||||
tcell.KeyF47: "<f-47>",
|
||||
tcell.KeyF48: "<f-48>",
|
||||
tcell.KeyF49: "<f-49>",
|
||||
tcell.KeyF50: "<f-50>",
|
||||
tcell.KeyF51: "<f-51>",
|
||||
tcell.KeyF52: "<f-52>",
|
||||
tcell.KeyF53: "<f-53>",
|
||||
tcell.KeyF54: "<f-54>",
|
||||
tcell.KeyF55: "<f-55>",
|
||||
tcell.KeyF56: "<f-56>",
|
||||
tcell.KeyF57: "<f-57>",
|
||||
tcell.KeyF58: "<f-58>",
|
||||
tcell.KeyF59: "<f-59>",
|
||||
tcell.KeyF60: "<f-60>",
|
||||
tcell.KeyF61: "<f-61>",
|
||||
tcell.KeyF62: "<f-62>",
|
||||
tcell.KeyF63: "<f-63>",
|
||||
tcell.KeyF64: "<f-64>",
|
||||
tcell.KeyCtrlA: "<c-a>",
|
||||
tcell.KeyCtrlB: "<c-b>",
|
||||
tcell.KeyCtrlC: "<c-c>",
|
||||
@ -52,12 +119,9 @@ var gKeyVal = map[tcell.Key]string{
|
||||
tcell.KeyCtrlE: "<c-e>",
|
||||
tcell.KeyCtrlF: "<c-f>",
|
||||
tcell.KeyCtrlG: "<c-g>",
|
||||
tcell.KeyBackspace: "<bs>",
|
||||
tcell.KeyTab: "<tab>",
|
||||
tcell.KeyCtrlJ: "<c-j>",
|
||||
tcell.KeyCtrlK: "<c-k>",
|
||||
tcell.KeyCtrlL: "<c-l>",
|
||||
tcell.KeyEnter: "<enter>",
|
||||
tcell.KeyCtrlN: "<c-n>",
|
||||
tcell.KeyCtrlO: "<c-o>",
|
||||
tcell.KeyCtrlP: "<c-p>",
|
||||
@ -71,13 +135,11 @@ var gKeyVal = map[tcell.Key]string{
|
||||
tcell.KeyCtrlX: "<c-x>",
|
||||
tcell.KeyCtrlY: "<c-y>",
|
||||
tcell.KeyCtrlZ: "<c-z>",
|
||||
tcell.KeyEsc: "<esc>",
|
||||
tcell.KeyCtrlBackslash: "<c-\\>",
|
||||
tcell.KeyCtrlSpace: "<c-space>",
|
||||
tcell.KeyCtrlUnderscore: "<c-_>",
|
||||
tcell.KeyCtrlRightSq: "<c-]>",
|
||||
// TODO: compatability only, they are discouraged
|
||||
tcell.KeyCtrlCarat: "<c-6>",
|
||||
tcell.KeyCtrlUnderscore: "<c-/>",
|
||||
tcell.KeyBackspace2: "<bs2>",
|
||||
tcell.KeyCtrlBackslash: "<c-\\>",
|
||||
tcell.KeyCtrlCarat: "<c-^>",
|
||||
}
|
||||
|
||||
var gValKey map[string]tcell.Key
|
||||
@ -822,6 +884,8 @@ func (ui *ui) pollEvent() tcell.Event {
|
||||
ch = '<'
|
||||
case val == "<gt>":
|
||||
ch = '>'
|
||||
case val == "<space>":
|
||||
ch = ' '
|
||||
case reAltKey.MatchString(val):
|
||||
match := reAltKey.FindStringSubmatch(val)[1]
|
||||
ch, _ = utf8.DecodeRuneInString(match)
|
||||
|
Loading…
Reference in New Issue
Block a user