ui/input: support single stepping through events

Change input.Events interface to return one event at a time until
the queue is empty.

Change text.Editor and gestures to match.

Re-add Editor.Submit while we're here; we don't want to enable
submit mode always.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
Elias Naur
2019-06-21 16:30:20 +02:00
parent 893b7f3c9f
commit b981ccf9ed
4 changed files with 28 additions and 9 deletions
+7 -2
View File
@@ -25,6 +25,7 @@ type Editor struct {
Face Face
Alignment Alignment
SingleLine bool
Submit bool
oldCfg ui.Config
blinkStart time.Time
@@ -103,7 +104,11 @@ func (e *Editor) Next() (EditorEvent, bool) {
}
}
stop := (sdist > 0 && soff >= smax) || (sdist < 0 && soff <= smin)
for _, ke := range e.Inputs.For(e) {
for {
ke, ok := e.Inputs.Next(e)
if !ok {
break
}
e.blinkStart = e.Config.Now
switch ke := ke.(type) {
case key.Focus:
@@ -112,7 +117,7 @@ func (e *Editor) Next() (EditorEvent, bool) {
if !e.focused {
break
}
if ke.Name == key.NameReturn || ke.Name == key.NameEnter {
if e.Submit && (ke.Name == key.NameReturn || ke.Name == key.NameEnter) {
if !ke.Modifiers.Contain(key.ModShift) {
return Submit{}, true
}