Compare commits

...

2 Commits

Author SHA1 Message Date
55215dedc2 Select all in textBox uses the length of the rune slice 2024-09-12 01:15:17 -04:00
eb98d143db Fix textBox 2024-09-12 01:15:01 -04:00

View File

@ -392,6 +392,8 @@ func (this *textBox) runeUnderMouse () int {
return this.drawer.AtPosition(fixPt(position))
}
// TODO the keynav here should make better use of input key chords.
func (this *textBox) handleKeyDown (key input.Key, numberPad bool) bool {
if this.box.handleKeyDown(key, numberPad) { return true }
if !this.selectable { return false }
@ -399,8 +401,8 @@ func (this *textBox) handleKeyDown (key input.Key, numberPad bool) bool {
// because fuck you thats why!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
modifiers := this.Window().Modifiers()
dot := this.Dot()
sel := modifiers.Shift
word := modifiers.Control
sel := modifiers.Shift()
word := modifiers.Control()
moveVertically := func (delta fixed.Int26_6) {
currentDot := 0
@ -438,7 +440,7 @@ func (this *textBox) handleKeyDown (key input.Key, numberPad bool) bool {
}
switch {
case key == input.KeyHome || (modifiers.Alt && key == input.KeyLeft):
case key == input.KeyHome || (modifiers.Alt() && key == input.KeyLeft):
if word {
dot.End = 0
} else {
@ -447,7 +449,7 @@ func (this *textBox) handleKeyDown (key input.Key, numberPad bool) bool {
if !sel { dot.Start = dot.End }
this.userSelect(dot)
return true
case key == input.KeyEnd || (modifiers.Alt && key == input.KeyRight):
case key == input.KeyEnd || (modifiers.Alt() && key == input.KeyRight):
if word {
dot.End = len(this.runes)
} else {
@ -476,9 +478,9 @@ func (this *textBox) handleKeyDown (key input.Key, numberPad bool) bool {
case key == input.KeyDown:
moveVertically(fixed.I(1))
return true
case key == input.Key('a') && modifiers.Control:
case key == input.Key('a') && modifiers.Control():
dot.Start = 0
dot.End = len(this.text) // FIXME
dot.End = len(this.runes)
this.userSelect(dot)
return true
default:
@ -492,9 +494,9 @@ func (this *textBox) handleKeyUp (key input.Key, numberPad bool) bool {
modifiers := this.Window().Modifiers()
switch {
case key == input.KeyHome || (modifiers.Alt && key == input.KeyLeft):
case key == input.KeyHome || (modifiers.Alt() && key == input.KeyLeft):
return true
case key == input.KeyEnd || (modifiers.Alt && key == input.KeyRight):
case key == input.KeyEnd || (modifiers.Alt() && key == input.KeyRight):
return true
case key == input.KeyUp:
return true
@ -504,7 +506,7 @@ func (this *textBox) handleKeyUp (key input.Key, numberPad bool) bool {
return true
case key == input.KeyRight:
return true
case key == input.Key('a') && modifiers.Control:
case key == input.Key('a') && modifiers.Control():
return true
default:
return false