From c5f561793e62424386f27aef6c4a86ee29b4828b Mon Sep 17 00:00:00 2001 From: Chris Marshall Date: Thu, 27 Oct 2016 12:51:33 -0400 Subject: [PATCH] Define key mapping maps for lookup on key presses --- handlers/event.go | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/handlers/event.go b/handlers/event.go index 77f7ed4..44bdf19 100644 --- a/handlers/event.go +++ b/handlers/event.go @@ -15,6 +15,39 @@ func RegisterEventHandlers(ctx *context.AppContext) { termui.Handle("/sys/wnd/resize", resizeHandler(ctx)) } +var keyMapping = map[termbox.Key]string{ + termbox.KeyPgup: "pg-up", + termbox.KeyCtrlB: "ctrl-b", + termbox.KeyCtrlU: "ctrl-u", + termbox.KeyPgdn: "pg-dn", + termbox.KeyCtrlF: "ctrl-f", + termbox.KeyCtrlD: "ctrl-d", + termbox.KeyEsc: "esc", + termbox.KeyEnter: "enter", + termbox.KeyBackspace: "backspace", + termbox.KeyBackspace2: "backspace", + termbox.KeyDelete: "del", + termbox.KeyArrowRight: "right", + termbox.KeyArrowLeft: "left", +} + +var actionMap = map[string]func(*context.AppContext){ + "backspace": actionBackSpace, + "delete": actionDelete, + "cursor-right": actionMoveCursorRight, + "cursor-left": actionMoveCursorLeft, + "send": actionSend, + "quit": actionQuit, + "insert": actionInsertMode, + "normal": actionCommandMode, + "channel-up": actionMoveCursorUpChannels, + "channel-down": actionMoveCursorDownChannels, + "channel-top": actionMoveCursorTopChannels, + "channel-bottom": actionMoveCursorBottomChannels, + "chat-up": actionScrollUpChat, + "chat-down": actionScrollDownChat, +} + func anyKeyHandler(ctx *context.AppContext) { go func() { for {