YN callbacks and better multi cursor

This commit is contained in:
Zachary Yedidia
2019-01-04 21:48:19 -05:00
parent e101dcd55a
commit 35d111bf73
5 changed files with 86 additions and 36 deletions

View File

@@ -34,10 +34,18 @@ func (h *InfoHandler) HandleEvent(event tcell.Event) {
done := h.DoKeyEvent(ke)
if !done && e.Key() == tcell.KeyRune {
h.DoRuneInsert(e.Rune())
done = true
if e.Rune() == 'y' && h.HasYN {
h.YNResp = true
h.DonePrompt(false)
} else if e.Rune() == 'n' && h.HasYN {
h.YNResp = false
h.DonePrompt(false)
} else if !h.HasYN {
h.DoRuneInsert(e.Rune())
done = true
}
}
if done && h.HasPrompt {
if done && h.HasPrompt && !h.HasYN {
resp := strings.TrimSpace(string(h.LineBytes(0)))
hist := h.History[h.PromptType]
hist[h.HistoryNum] = resp
@@ -144,7 +152,9 @@ func (h *InfoHandler) InsertTab() {
// TODO: autocomplete
}
func (h *InfoHandler) InsertNewline() {
h.DonePrompt(false)
if !h.HasYN {
h.DonePrompt(false)
}
}
func (h *InfoHandler) Quit() {
h.DonePrompt(true)