summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJunegunn Choi <junegunn.c@gmail.com>2017-05-22 17:07:05 +0900
committerJunegunn Choi <junegunn.c@gmail.com>2017-05-22 17:07:05 +0900
commite1e33397700573da6d6b4fbaff9ac71f10fa36ed (patch)
tree33295b058db8c7cbd8cc2aea1bd7ae7fd73a1fa0 /src
parent3a5086796d797f6e4402e9cd73e13687facfcb7f (diff)
Implement bindable "change" event and "top" action
# Move cursor to the top result whenever the query string is changed fzf --bind change:top Close #925
Diffstat (limited to 'src')
-rw-r--r--src/options.go4
-rw-r--r--src/terminal.go9
-rw-r--r--src/tui/tui.go2
3 files changed, 15 insertions, 0 deletions
diff --git a/src/options.go b/src/options.go
index 8dd58f08..e9e2f28e 100644
--- a/src/options.go
+++ b/src/options.go
@@ -400,6 +400,8 @@ func parseKeyChords(str string, message string) map[int]string {
chord = tui.BSpace
case "ctrl-space":
chord = tui.CtrlSpace
+ case "change":
+ chord = tui.Change
case "alt-enter", "alt-return":
chord = tui.CtrlAltM
case "alt-space":
@@ -714,6 +716,8 @@ func parseKeymap(keymap map[int][]action, str string) {
appendAction(actDown)
case "up":
appendAction(actUp)
+ case "top":
+ appendAction(actTop)
case "page-up":
appendAction(actPageUp)
case "page-down":
diff --git a/src/terminal.go b/src/terminal.go
index 5aab6cd0..3d9ef6c0 100644
--- a/src/terminal.go
+++ b/src/terminal.go
@@ -213,6 +213,7 @@ const (
actExecuteSilent
actExecuteMulti // Deprecated
actSigStop
+ actTop
)
func toActions(types ...actionType) []action {
@@ -1609,6 +1610,9 @@ func (t *Terminal) Loop() {
req(reqClose)
case actClearScreen:
req(reqRedraw)
+ case actTop:
+ t.vset(0)
+ req(reqList)
case actUnixLineDiscard:
if t.cx > 0 {
t.yanked = copySlice(t.input[:t.cx])
@@ -1749,6 +1753,11 @@ func (t *Terminal) Loop() {
}
t.truncateQuery()
changed = string(previousInput) != string(t.input)
+ if onChanges, prs := t.keymap[tui.Change]; changed && prs {
+ if !doActions(onChanges, tui.Change) {
+ continue
+ }
+ }
} else {
if mapkey == tui.Rune {
if idx := strings.IndexRune(t.jumpLabels, event.Char); idx >= 0 && idx < t.maxItems() && idx < t.merger.Length() {
diff --git a/src/tui/tui.go b/src/tui/tui.go
index c638b35a..1ba8ca79 100644
--- a/src/tui/tui.go
+++ b/src/tui/tui.go
@@ -75,6 +75,8 @@ const (
F11
F12
+ Change
+
AltSpace
AltSlash
AltBS