Update Tomo API

This commit is contained in:
2024-05-26 17:13:40 -04:00
parent 6ab689b5c1
commit 06d99b2790
17 changed files with 13 additions and 20 deletions

View File

@@ -3,7 +3,6 @@ package objects
import "image"
import "git.tebibyte.media/tomo/tomo"
import "git.tebibyte.media/tomo/tomo/text"
import "git.tebibyte.media/tomo/tomo/theme"
import "git.tebibyte.media/tomo/tomo/input"
import "git.tebibyte.media/tomo/tomo/event"
@@ -60,8 +59,8 @@ func (this *TextInput) handleKeyDown (key input.Key, numpad bool) {
sel := modifiers.Shift
changed := false
// TODO all this (except editing stuff) really should be moved into the
// backend
// TODO all dot control (movement, selection, etc) should be done in the
// backend. (editing should be done here, though)
switch {
case key == input.KeyEnter:
@@ -105,6 +104,14 @@ func (this *TextInput) handleKeyDown (key input.Key, numpad bool) {
}
}
// Type types a character at the current dot position.
func (this *TextInput) Type (char rune) {
dot := this.Dot()
this.text, dot = text.Type(this.text, dot, rune(char))
this.Select(dot)
this.SetText(string(this.text))
}
func (this *TextInput) handleScroll (x, y float64) {
this.ScrollTo(this.ContentBounds().Min.Add(image.Pt(int(x), int(y))))
}