Added temporary command x-replace
This runs a search and replace over the entire model. This is just temporary at the moment in order to get something working. Also added hitting backspace on an empty entrybox to cancel it.
This commit is contained in:
parent
04aeff6b52
commit
6e6e586f1d
5 changed files with 71 additions and 20 deletions
|
|
@ -4,7 +4,7 @@ package ui
|
|||
|
||||
import (
|
||||
"unicode"
|
||||
)
|
||||
)
|
||||
|
||||
// A text component. This simply renders a text string.
|
||||
type TextView struct {
|
||||
|
|
@ -124,6 +124,8 @@ func (te *TextEntry) KeyPressed(key rune, mod int) {
|
|||
if mod&ModKeyAlt != 0 {
|
||||
te.backspaceWhile(unicode.IsSpace)
|
||||
te.backspaceWhile(func(r rune) bool { return !unicode.IsSpace(r) })
|
||||
} else if te.cursorOffset == 0 {
|
||||
te.cancelAndExit()
|
||||
} else {
|
||||
te.backspace()
|
||||
}
|
||||
|
|
@ -136,14 +138,18 @@ func (te *TextEntry) KeyPressed(key rune, mod int) {
|
|||
te.OnEntry(te.value)
|
||||
}
|
||||
} else if key == KeyCtrlC {
|
||||
if te.OnCancel != nil {
|
||||
te.OnCancel()
|
||||
}
|
||||
te.cancelAndExit()
|
||||
}
|
||||
|
||||
//panic(fmt.Sprintf("Entered key: '%x', mod: '%x'", key, mod))
|
||||
}
|
||||
|
||||
func (te *TextEntry) cancelAndExit() {
|
||||
if te.OnCancel != nil {
|
||||
te.OnCancel()
|
||||
}
|
||||
}
|
||||
|
||||
// Backspace
|
||||
func (te *TextEntry) backspace() {
|
||||
te.removeCharAtPos(te.cursorOffset - 1)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue