mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-01 07:35:40 +00:00
dc6fedc163
The Queue interface was changed from
type Queue interface {
Events(k Key) []Event
}
to the more complex single-step protocol
type Queue interface {
Next(k Key) (Event, bool)
}
to cater for a particular use case: Editor's SubmitEvent. When a
SubmitEvent is passed to a caller of Editor.Next, the Editor state,
in particular the current text, must not have changed by edits
later in the command stream. For example, pressing the keys <E>,
<Enter>, <E> should result in a SubmitEvent where the Editor has
a single 'e' in Text(), not two.
However, there is no reason to push the more complex Queue to every user.
Rather, store remaining input events inside Editor and process them as
Editor.Event (or Layout) is called.
Finally, revert the Queue interface to the simpler Events method.
Signed-off-by: Elias Naur <mail@eliasnaur.com>
21 lines
450 B
Go
21 lines
450 B
Go
// SPDX-License-Identifier: Unlicense OR MIT
|
|
|
|
package ui
|
|
|
|
// Queue maps an event handler key to the events
|
|
// available to the handler.
|
|
type Queue interface {
|
|
// Events returns the available events for a
|
|
// Key.
|
|
Events(k Key) []Event
|
|
}
|
|
|
|
// Key is the stable identifier for an event handler.
|
|
// For a handler h, the key is typically &h.
|
|
type Key interface{}
|
|
|
|
// Event is the marker interface for events.
|
|
type Event interface {
|
|
ImplementsEvent()
|
|
}
|