Fix textBox

This commit is contained in:
Sasha Koshka 2024-09-12 01:14:54 -04:00
parent 42deb40c2d
commit eb98d143db

View File

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