]> git.lizzy.rs Git - micro.git/commitdiff
Add cycleautocompleteback action
authorZachary Yedidia <zyedidia@gmail.com>
Sat, 4 Jan 2020 20:51:15 +0000 (15:51 -0500)
committerZachary Yedidia <zyedidia@gmail.com>
Sat, 4 Jan 2020 20:51:15 +0000 (15:51 -0500)
internal/action/actions.go
internal/action/bindings.go
internal/action/bufpane.go
internal/action/infopane.go

index 67e5dbd5b81c07baa44d3a36a46b399da14664d9..a85f7bbb8c2213c70a1e1e2da651c1c3cd2526b9 100644 (file)
@@ -1,6 +1,7 @@
 package action
 
 import (
+       "log"
        "regexp"
        "runtime"
        "strings"
@@ -611,6 +612,21 @@ func (h *BufPane) Autocomplete() bool {
        return b.Autocomplete(buffer.BufferComplete)
 }
 
+// CycleAutocompleteBack cycles back in the autocomplete suggestion list
+func (h *BufPane) CycleAutocompleteBack() bool {
+       if h.Cursor.HasSelection() {
+               return false
+       }
+       log.Println(h.Buf.HasSuggestions)
+
+       if h.Buf.HasSuggestions {
+               h.Buf.CycleAutocomplete(false)
+               log.Println("TRUE")
+               return true
+       }
+       return false
+}
+
 // InsertTab inserts a tab or spaces
 func (h *BufPane) InsertTab() bool {
        b := h.Buf
index 5d469c76499149dcd145b45aa6054fdd19ba5631..8984c043b17802f37d6570f907cd52125d7ecd16 100644 (file)
@@ -422,7 +422,7 @@ func DefaultBindings() map[string]string {
                "Alt-CtrlH":      "DeleteWordLeft",
                "Alt-Backspace":  "DeleteWordLeft",
                "Tab":            "Autocomplete|IndentSelection|InsertTab",
-               "Backtab":        "OutdentSelection|OutdentLine",
+               "Backtab":        "CycleAutocompleteBack|OutdentSelection|OutdentLine",
                "CtrlO":          "OpenFile",
                "CtrlS":          "Save",
                "CtrlF":          "Find",
index f3a734daf848165c410cd3e3280d5acbe2b2701f..fdd8a5b41bd90c14cf568554752d7ffeece40d8d 100644 (file)
@@ -355,7 +355,7 @@ func (h *BufPane) DoKeyEvent(e Event) bool {
 }
 
 func (h *BufPane) execAction(action func(*BufPane) bool, name string, cursor int) bool {
-       if name != "Autocomplete" {
+       if name != "Autocomplete" && name != "CycleAutocompleteBack" {
                h.Buf.HasSuggestions = false
        }
 
@@ -523,6 +523,7 @@ var BufKeyActions = map[string]BufKeyAction{
        "IndentSelection":        (*BufPane).IndentSelection,
        "OutdentSelection":       (*BufPane).OutdentSelection,
        "Autocomplete":           (*BufPane).Autocomplete,
+       "CycleAutocompleteBack":  (*BufPane).CycleAutocompleteBack,
        "OutdentLine":            (*BufPane).OutdentLine,
        "Paste":                  (*BufPane).Paste,
        "PastePrimary":           (*BufPane).PastePrimary,
index 00dde63350ef86c692688f30076610103c7fa290..acff35972efba4d60651e2f807fcdf98731bedc2 100644 (file)
@@ -154,7 +154,6 @@ var InfoOverrides = map[string]InfoKeyAction{
        "CursorDown":    (*InfoPane).CursorDown,
        "InsertNewline": (*InfoPane).InsertNewline,
        "Autocomplete":  (*InfoPane).Autocomplete,
-       "OutdentLine":   (*InfoPane).CycleBack,
        "Escape":        (*InfoPane).Escape,
        "Quit":          (*InfoPane).Quit,
        "QuitAll":       (*InfoPane).QuitAll,
@@ -196,13 +195,6 @@ func (h *InfoPane) Autocomplete() {
        }
 }
 
-// CycleBack cycles back in the autocomplete suggestion list
-func (h *InfoPane) CycleBack() {
-       if h.Buf.HasSuggestions {
-               h.Buf.CycleAutocomplete(false)
-       }
-}
-
 // InsertNewline completes the prompt
 func (h *InfoPane) InsertNewline() {
        if !h.HasYN {