import (
"bytes"
+ "strings"
"github.com/zyedidia/micro/internal/display"
"github.com/zyedidia/micro/internal/info"
*info.InfoBuf
}
-func NewInfoPane(ib *info.InfoBuf, w display.BWindow) *InfoPane {
+func NewInfoPane(ib *info.InfoBuf, w display.BWindow, tab *Tab) *InfoPane {
ip := new(InfoPane)
ip.InfoBuf = ib
- ip.BufPane = NewBufPane(ib.Buffer, w)
+ ip.BufPane = NewBufPane(ib.Buffer, w, tab)
return ip
}
func NewInfoBar() *InfoPane {
ib := info.NewBuffer()
w := display.NewInfoWindow(ib)
- return NewInfoPane(ib, w)
+ return NewInfoPane(ib, w, nil)
}
func (h *InfoPane) Close() {
}
}
+// DoKeyEvent executes a key event for the command bar, doing any overridden actions
func (h *InfoPane) DoKeyEvent(e KeyEvent) bool {
done := false
if action, ok := BufKeyBindings[e]; ok {
}
}
for s, a := range InfoOverrides {
- if s == estr {
+ // TODO this is a hack and really we should have support
+ // for having binding overrides for different buffers
+ if strings.HasPrefix(estr, s) {
done = true
a(h)
break
"HalfPageDown",
"ToggleHelp",
"ToggleKeyMenu",
+ "ToggleDiffGutter",
"ToggleRuler",
"JumpLine",
"ClearStatus",
"SkipMultiCursor",
}
-// InfoOverrides is the list of actions which have been overriden
+// InfoOverrides is the list of actions which have been overridden
// by the infohandler
var InfoOverrides = map[string]InfoKeyAction{
"CursorUp": (*InfoPane).CursorUp,
"CursorDown": (*InfoPane).CursorDown,
"InsertNewline": (*InfoPane).InsertNewline,
- "InsertTab": (*InfoPane).InsertTab,
- "OutdentLine": (*InfoPane).CycleBack,
+ "Autocomplete": (*InfoPane).Autocomplete,
"Escape": (*InfoPane).Escape,
"Quit": (*InfoPane).Quit,
"QuitAll": (*InfoPane).QuitAll,
}
+// CursorUp cycles history up
func (h *InfoPane) CursorUp() {
h.UpHistory(h.History[h.PromptType])
}
+
+// CursorDown cycles history down
func (h *InfoPane) CursorDown() {
h.DownHistory(h.History[h.PromptType])
}
-func (h *InfoPane) InsertTab() {
+
+// Autocomplete begins autocompletion
+func (h *InfoPane) Autocomplete() {
b := h.Buf
if b.HasSuggestions {
b.CycleAutocomplete(true)
}
}
}
-func (h *InfoPane) CycleBack() {
- if h.Buf.HasSuggestions {
- h.Buf.CycleAutocomplete(false)
- }
-}
+
+// InsertNewline completes the prompt
func (h *InfoPane) InsertNewline() {
if !h.HasYN {
h.DonePrompt(false)
}
}
+
+// Quit cancels the prompt
func (h *InfoPane) Quit() {
h.DonePrompt(true)
}
+
+// QuitAll cancels the prompt
func (h *InfoPane) QuitAll() {
h.DonePrompt(true)
}
+
+// Escape cancels the prompt
func (h *InfoPane) Escape() {
h.DonePrompt(true)
}