]> git.lizzy.rs Git - micro.git/blobdiff - internal/action/infopane.go
better top
[micro.git] / internal / action / infopane.go
index 1ab7c2812acb6263e74b76a1f076745abbf95e79..2fc5b3ce71c0770fdeb6438f1cfffbfd1dc9f805 100644 (file)
@@ -2,6 +2,7 @@ package action
 
 import (
        "bytes"
+       "strings"
 
        "github.com/zyedidia/micro/internal/display"
        "github.com/zyedidia/micro/internal/info"
@@ -16,10 +17,10 @@ type InfoPane struct {
        *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
 }
@@ -27,7 +28,7 @@ func NewInfoPane(ib *info.InfoBuf, w display.BWindow) *InfoPane {
 func NewInfoBar() *InfoPane {
        ib := info.NewBuffer()
        w := display.NewInfoWindow(ib)
-       return NewInfoPane(ib, w)
+       return NewInfoPane(ib, w, nil)
 }
 
 func (h *InfoPane) Close() {
@@ -72,6 +73,7 @@ func (h *InfoPane) HandleEvent(event tcell.Event) {
        }
 }
 
+// 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 {
@@ -82,7 +84,9 @@ func (h *InfoPane) DoKeyEvent(e KeyEvent) bool {
                        }
                }
                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
@@ -119,6 +123,7 @@ var InfoNones = []string{
        "HalfPageDown",
        "ToggleHelp",
        "ToggleKeyMenu",
+       "ToggleDiffGutter",
        "ToggleRuler",
        "JumpLine",
        "ClearStatus",
@@ -144,26 +149,30 @@ var InfoNones = []string{
        "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)
@@ -187,22 +196,25 @@ func (h *InfoPane) InsertTab() {
                }
        }
 }
-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)
 }