]> git.lizzy.rs Git - micro.git/blob - internal/action/events.go
Merge
[micro.git] / internal / action / events.go
1 package action
2
3 import (
4         "github.com/zyedidia/tcell"
5 )
6
7 type Event interface{}
8
9 // RawEvent is simply an escape code
10 // We allow users to directly bind escape codes
11 // to get around some of a limitations of terminals
12 type RawEvent struct {
13         esc string
14 }
15
16 // KeyEvent is a key event containing a key code,
17 // some possible modifiers (alt, ctrl, etc...) and
18 // a rune if it was simply a character press
19 // Note: to be compatible with tcell events,
20 // for ctrl keys r=code
21 type KeyEvent struct {
22         code tcell.Key
23         mod  tcell.ModMask
24         r    rune
25 }
26
27 // MouseEvent is a mouse event with a mouse button and
28 // any possible key modifiers
29 type MouseEvent struct {
30         btn tcell.ButtonMask
31         mod tcell.ModMask
32 }
33
34 type KeyAction func(Handler) bool
35 type MouseAction func(Handler, tcell.EventMouse) bool
36
37 // A Handler will take a tcell event and execute it
38 // appropriately
39 type Handler interface {
40         HandleEvent(tcell.Event)
41         HandleCommand(string)
42 }