add file selector text area
This commit is contained in:
parent
d6acfe235b
commit
ebbdb99f37
@ -145,7 +145,19 @@ func main() {
|
|||||||
)
|
)
|
||||||
|
|
||||||
// import pop-up
|
// import pop-up
|
||||||
popup := ui.NewBox("import", []string{"⏎ submit", "(esc)close"}, nil, ui.StyleActive, false)
|
wd, _ := os.Getwd()
|
||||||
|
fileSelector := ui.NewEditableTextLine(wd)
|
||||||
|
fileSelector.ResetCursor(false)
|
||||||
|
fileSelector.SetStyle(ui.StyleActive.Underline(true))
|
||||||
|
popup := ui.NewBox(
|
||||||
|
"import csv file",
|
||||||
|
[]string{"⏎ submit", "(esc)close"},
|
||||||
|
ui.Contents{
|
||||||
|
{Container: fileSelector, Offsets: ui.Offsets{Top: 2, Left: 2}},
|
||||||
|
},
|
||||||
|
ui.StyleActive,
|
||||||
|
false,
|
||||||
|
)
|
||||||
popup.SetVisible(false)
|
popup.SetVisible(false)
|
||||||
|
|
||||||
// init
|
// init
|
||||||
@ -192,8 +204,20 @@ func main() {
|
|||||||
}
|
}
|
||||||
} else if curr == IN_IMPORT {
|
} else if curr == IN_IMPORT {
|
||||||
if v.Key() == tcell.KeyEsc {
|
if v.Key() == tcell.KeyEsc {
|
||||||
|
fileSelector.SetText(wd)
|
||||||
|
fileSelector.ResetCursor(false)
|
||||||
screen.PostEvent(NewEventCloseImport())
|
screen.PostEvent(NewEventCloseImport())
|
||||||
}
|
}
|
||||||
|
if v.Key() == tcell.KeyBackspace || v.Key() == tcell.KeyBackspace2 {
|
||||||
|
fileSelector.DeleteAtCursor()
|
||||||
|
} else if v.Key() == tcell.KeyRight {
|
||||||
|
fileSelector.MoveCursor(1)
|
||||||
|
|
||||||
|
} else if v.Key() == tcell.KeyLeft {
|
||||||
|
fileSelector.MoveCursor(-1)
|
||||||
|
} else if v.Rune() != 0 {
|
||||||
|
fileSelector.InsertAtCursor(v.Rune())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
case *tcell.EventResize: // screen redraw
|
case *tcell.EventResize: // screen redraw
|
||||||
w, h := screen.Size()
|
w, h := screen.Size()
|
||||||
@ -214,7 +238,7 @@ func main() {
|
|||||||
state.Set("ui_state", IN_IMPORT)
|
state.Set("ui_state", IN_IMPORT)
|
||||||
menu.SetStyle(ui.StyleInactive)
|
menu.SetStyle(ui.StyleInactive)
|
||||||
popup.SetVisible(true)
|
popup.SetVisible(true)
|
||||||
popup.SetSize(6, 3, 10, 80)
|
popup.SetSize(6, 3, 5, 80)
|
||||||
case *EventCloseImport:
|
case *EventCloseImport:
|
||||||
state.Set("ui_state", IN_MENU)
|
state.Set("ui_state", IN_MENU)
|
||||||
menu.SetStyle(ui.StyleActive)
|
menu.SetStyle(ui.StyleActive)
|
||||||
@ -229,7 +253,6 @@ func main() {
|
|||||||
default:
|
default:
|
||||||
}
|
}
|
||||||
// repaint
|
// repaint
|
||||||
screen.Clear()
|
|
||||||
container.Draw(screen)
|
container.Draw(screen)
|
||||||
popup.Draw(screen)
|
popup.Draw(screen)
|
||||||
screen.Show()
|
screen.Show()
|
||||||
|
Loading…
Reference in New Issue
Block a user