diff options
author | Junegunn Choi <junegunn.c@gmail.com> | 2016-05-13 00:51:15 +0900 |
---|---|---|
committer | Junegunn Choi <junegunn.c@gmail.com> | 2016-05-13 00:51:15 +0900 |
commit | 9078688baf9ee82c5cbe222b825a247dffe2814e (patch) | |
tree | a6ea3dc462fb63bc2510c8403cdce70e7ad49577 | |
parent | 9bd8b1d25f7ea255fa104729e81e43453f439612 (diff) |
Add print-query action for --bind
Close #571
-rw-r--r-- | src/options.go | 2 | ||||
-rw-r--r-- | src/terminal.go | 8 | ||||
-rw-r--r-- | test/test_go.rb | 7 |
3 files changed, 17 insertions, 0 deletions
diff --git a/src/options.go b/src/options.go index 4d5ac2d8..ea7d717c 100644 --- a/src/options.go +++ b/src/options.go @@ -531,6 +531,8 @@ func parseKeymap(keymap map[int]actionType, execmap map[int]string, str string) keymap[key] = actAbort case "accept": keymap[key] = actAccept + case "print-query": + keymap[key] = actPrintQuery case "backward-char": keymap[key] = actBackwardChar case "backward-delete-char": diff --git a/src/terminal.go b/src/terminal.go index cd9ca934..771cad78 100644 --- a/src/terminal.go +++ b/src/terminal.go @@ -91,6 +91,7 @@ const ( reqRefresh reqRedraw reqClose + reqPrintQuery reqQuit ) @@ -132,6 +133,7 @@ const ( actUp actPageUp actPageDown + actPrintQuery actToggleSort actPreviousHistory actNextHistory @@ -819,6 +821,10 @@ func (t *Terminal) Loop() { exit(exitOk) } exit(exitNoMatch) + case reqPrintQuery: + C.Close() + fmt.Println(string(t.input)) + exit(exitOk) case reqQuit: C.Close() exit(exitInterrupt) @@ -906,6 +912,8 @@ func (t *Terminal) Loop() { if t.cx > 0 { t.cx-- } + case actPrintQuery: + req(reqPrintQuery) case actAbort: req(reqQuit) case actDeleteChar: diff --git a/test/test_go.rb b/test/test_go.rb index 81f77c93..02bf08d2 100644 --- a/test/test_go.rb +++ b/test/test_go.rb @@ -771,6 +771,13 @@ class TestGoFZF < TestBase assert_equal %w[4 5 6 9], readonce.split($/) end + def test_bind_print_query + tmux.send_keys "seq 1 1000 | #{fzf '-m --bind=ctrl-j:print-query'}", :Enter + tmux.until { |lines| lines[-2].end_with? '/1000' } + tmux.send_keys 'print-my-query', 'C-j' + assert_equal %w[print-my-query], readonce.split($/) + end + def test_long_line data = '.' * 256 * 1024 File.open(tempname, 'w') do |f| |