mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-03 16:35:36 +00:00
ui: change Queue to return all events at once
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>
This commit is contained in:
+3
-3
@@ -5,9 +5,9 @@ package ui
|
||||
// Queue maps an event handler key to the events
|
||||
// available to the handler.
|
||||
type Queue interface {
|
||||
// Next returns the next available event, or
|
||||
// false if none are available.
|
||||
Next(k Key) (Event, bool)
|
||||
// Events returns the available events for a
|
||||
// Key.
|
||||
Events(k Key) []Event
|
||||
}
|
||||
|
||||
// Key is the stable identifier for an event handler.
|
||||
|
||||
Reference in New Issue
Block a user