Have actually implemented useful commands for reading/writing CSV files

This commit is contained in:
Leon Mika 2018-09-01 11:27:34 +10:00
parent 33847a78c1
commit ae833d5db8
9 changed files with 252 additions and 55 deletions

View file

@ -87,6 +87,7 @@ const (
KeyBackspace = KeyCtrlH
KeyBackspace2 = KeyCtrl8
KeyEnter = KeyCtrlM
KeyEsc = KeyCtrl3
)
// The type of events supported by the driver
@ -116,7 +117,6 @@ type Event struct {
// The terminal driver interface.
type Driver interface {
// Initializes the driver. Returns an error if there was an error
Init() error

View file

@ -2,7 +2,9 @@
package ui
import "unicode"
import (
"unicode"
)
// A text component. This simply renders a text string.
type TextView struct {
@ -58,6 +60,9 @@ type TextEntry struct {
// Called when the user presses Enter
OnEntry func(val string)
// Called when the user presses Esc or CtrlC
OnCancel func()
}
func (te *TextEntry) Remeasure(w, h int) (int, int) {
@ -127,11 +132,16 @@ func (te *TextEntry) KeyPressed(key rune, mod int) {
} else if key == KeyDelete {
te.removeCharAtPos(te.cursorOffset)
} else if key == KeyEnter {
//panic("Entered text: '" + te.value + "'")
if te.OnEntry != nil {
te.OnEntry(te.value)
}
} else if key == KeyCtrlC {
if te.OnCancel != nil {
te.OnCancel()
}
}
//panic(fmt.Sprintf("Entered key: '%x', mod: '%x'", key, mod))
}
// Backspace