コード例 #1
0
ファイル: compat.go プロジェクト: jmptrader/tcell
func makeEvent(tev tcell.Event) Event {
	switch tev := tev.(type) {
	case *tcell.EventInterrupt:
		return Event{Type: EventInterrupt}
	case *tcell.EventResize:
		w, h := tev.Size()
		return Event{Type: EventResize, Width: w, Height: h}
	case *tcell.EventKey:
		k := tev.Key()
		ch := rune(0)
		if k == tcell.KeyRune {
			ch = tev.Rune()
			if ch == ' ' {
				k = tcell.Key(' ')
			}
		}
		mod := tev.Modifiers()
		return Event{
			Type: EventKey,
			Key:  Key(k),
			Ch:   ch,
			Mod:  Modifier(mod),
		}
	default:
		return Event{Type: EventNone}
	}
}
コード例 #2
0
ファイル: compat.go プロジェクト: jmptrader/tcell
	KeyCtrlV      = Key(tcell.KeyCtrlV)
	KeyCtrlW      = Key(tcell.KeyCtrlW)
	KeyCtrlX      = Key(tcell.KeyCtrlX)
	KeyCtrlY      = Key(tcell.KeyCtrlY)
	KeyCtrlZ      = Key(tcell.KeyCtrlZ)
	KeyBackspace  = Key(tcell.KeyBackspace)
	KeyBackspace2 = Key(tcell.KeyBackspace2)
	KeyTab        = Key(tcell.KeyTab)
	KeyEnter      = Key(tcell.KeyEnter)
	KeyEsc        = Key(tcell.KeyEscape)
	KeyPgdn       = Key(tcell.KeyPgDn)
	KeyPgup       = Key(tcell.KeyPgUp)
	MouseLeft     = Key(tcell.KeyF63) // arbitrary assignments
	MouseRight    = Key(tcell.KeyF62)
	MouseMiddle   = Key(tcell.KeyF61)
	KeySpace      = Key(tcell.Key(' '))
)

// Modifiers.
const (
	ModAlt = Modifier(tcell.ModAlt)
)

func makeEvent(tev tcell.Event) Event {
	switch tev := tev.(type) {
	case *tcell.EventInterrupt:
		return Event{Type: EventInterrupt}
	case *tcell.EventResize:
		w, h := tev.Size()
		return Event{Type: EventResize, Width: w, Height: h}
	case *tcell.EventKey: