Infobar history

This commit is contained in:
Zachary Yedidia
2019-01-03 17:07:28 -05:00
parent 6fdf275b8a
commit e29cae4f7f
6 changed files with 100 additions and 63 deletions

View File

@@ -35,6 +35,15 @@ func (h *InfoHandler) HandleEvent(event tcell.Event) {
done := h.DoKeyEvent(ke)
if !done && e.Key() == tcell.KeyRune {
h.DoRuneInsert(e.Rune())
done = true
}
if done && h.HasPrompt {
resp := strings.TrimSpace(string(h.LineBytes(0)))
hist := h.History[h.PromptType]
hist[h.HistoryNum] = resp
if h.EventCallback != nil {
h.EventCallback(resp)
}
}
case *tcell.EventMouse:
h.BufHandler.HandleEvent(event)
@@ -61,19 +70,9 @@ func (h *InfoHandler) DoKeyEvent(e KeyEvent) bool {
done = action(h.BufHandler)
}
}
if done && h.EventCallback != nil {
h.EventCallback(strings.TrimSpace(string(h.LineBytes(0))))
}
return done
}
func (h *InfoHandler) DoRuneInsert(r rune) {
h.BufHandler.DoRuneInsert(r)
if h.EventCallback != nil {
h.EventCallback(strings.TrimSpace(string(h.LineBytes(0))))
}
}
// InfoNones is a list of actions that should have no effect when executed
// by an infohandler
var InfoNones = []string{
@@ -136,10 +135,10 @@ var InfoOverrides = map[string]InfoKeyAction{
}
func (h *InfoHandler) CursorUp() {
// TODO: history
h.UpHistory(h.History[h.PromptType])
}
func (h *InfoHandler) CursorDown() {
// TODO: history
h.DownHistory(h.History[h.PromptType])
}
func (h *InfoHandler) InsertTab() {
// TODO: autocomplete