io/input,io/key: [API] replace SelectionOp with command

Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
Elias Naur
2023-10-09 17:04:22 -05:00
parent 627e028d3c
commit 813d836641
5 changed files with 29 additions and 54 deletions
+16 -6
View File
@@ -42,6 +42,7 @@ type keyHandler struct {
order int
dirOrder int
filter key.Set
trans f32.Affine2D
}
type dirFocusEntry struct {
@@ -290,19 +291,28 @@ func (q *keyQueue) handlerFor(tag event.Tag, area int, bounds image.Rectangle) *
return h
}
func (q *keyQueue) inputOp(op key.InputOp, area int, bounds image.Rectangle) {
func (q *keyQueue) inputOp(op key.InputOp, t f32.Affine2D, area int, bounds image.Rectangle) {
h := q.handlerFor(op.Tag, area, bounds)
h.visible = true
h.hint = op.Hint
h.filter = op.Keys
h.trans = t
}
func (q *keyQueue) selectionOp(t f32.Affine2D, op key.SelectionOp) {
if op.Tag == q.focus {
q.content.Selection.Range = op.Range
q.content.Selection.Caret = op.Caret
q.content.Selection.Transform = t
func (q *keyQueue) setSelection(req key.SelectionCmd) {
if req.Tag != q.focus {
return
}
q.content.Selection.Range = req.Range
q.content.Selection.Caret = req.Caret
}
func (q *keyQueue) editorState() EditorState {
s := q.content
if f := q.focus; f != nil {
s.Selection.Transform = q.handlers[f].trans
}
return s
}
func (q *keyQueue) snippetOp(op key.SnippetOp) {