mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-04 08:55:35 +00:00
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:
+7
-2
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user