ui: add package input for merged input

To avoid passing a queue type for each kind of input (pointer, key),
introduce package input for mapping a handler key to all input events.

Future input sources can be added without changes to programs, and
as an added bonus, event ordering is preserved across input sources.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
Elias Naur
2019-06-07 21:41:09 +02:00
parent 28dd25736f
commit a35118d522
10 changed files with 172 additions and 130 deletions
+6 -14
View File
@@ -16,14 +16,6 @@ type OpHideInput struct{}
type Key interface{}
type Events interface {
For(k Key) []Event
}
type Event interface {
isKeyEvent()
}
type Focus struct {
Focus bool
}
@@ -93,9 +85,9 @@ func (h OpHideInput) Add(o *ui.Ops) {
o.Write(data)
}
func (Edit) ImplementsEvent() {}
func (Chord) ImplementsEvent() {}
func (Focus) ImplementsEvent() {}
func (Edit) isKeyEvent() {}
func (Chord) isKeyEvent() {}
func (Focus) isKeyEvent() {}
func (Edit) ImplementsEvent() {}
func (Chord) ImplementsEvent() {}
func (Focus) ImplementsEvent() {}
func (Edit) ImplementsInputEvent() {}
func (Chord) ImplementsInputEvent() {}
func (Focus) ImplementsInputEvent() {}