summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJunegunn Choi <junegunn.c@gmail.com>2015-07-23 21:05:33 +0900
committerJunegunn Choi <junegunn.c@gmail.com>2015-07-23 21:05:33 +0900
commitfdbf3d3fec4121a52a77330bba383c4878547b2a (patch)
treef4c1447c194027ffd718612d64e0e5f5ef404fe1
parentf9136cffe6d9a57003f3db39a07546b43df134cb (diff)
Replace eof action with cancel (#289)
-rw-r--r--CHANGELOG.md5
-rw-r--r--man/man1/fzf.12
-rw-r--r--src/options.go4
-rw-r--r--src/terminal.go8
-rw-r--r--test/test_go.rb14
5 files changed, 19 insertions, 14 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 3c6ab2cf..3f411708 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -9,8 +9,9 @@ CHANGELOG
- Added options for sticky header
- `--header-file`
- `--header-lines`
-- Added `eof` action which closes the finder only when the input is empty
- - e.g. `export FZF_DEFAULT_OPTS="--bind esc:eof"`
+- Added `cancel` action which clears the input or closes the finder when the
+ input is already empty
+ - e.g. `export FZF_DEFAULT_OPTS="--bind esc:cancel"`
- Added `delete-char/eof` action to differentiate `CTRL-D` and `DEL`
### Minor improvements/fixes
diff --git a/man/man1/fzf.1 b/man/man1/fzf.1
index 17aac59f..0c6b375e 100644
--- a/man/man1/fzf.1
+++ b/man/man1/fzf.1
@@ -188,13 +188,13 @@ e.g. \fBfzf --bind=ctrl-j:accept,ctrl-k:kill-line\fR
\fBbackward-kill-word\fR \fIalt-bs\fR
\fBbackward-word\fR \fIalt-b shift-left\fR
\fBbeginning-of-line\fR \fIctrl-a home\fR
+ \fBcancel\fR
\fBclear-screen\fR \fIctrl-l\fR
\fBdelete-char\fR \fIdel\fR
\fBdelete-char/eof\fR \fIctrl-d\fR
\fBdeselect-all\fR
\fBdown\fR \fIctrl-j ctrl-n down\fR
\fBend-of-line\fR \fIctrl-e end\fR
- \fBeof\fR
\fBexecute(...)\fR (see below for the details)
\fBforward-char\fR \fIctrl-f right\fR
\fBforward-word\fR \fIalt-f shift-right\fR
diff --git a/src/options.go b/src/options.go
index bb6da9ec..5ab511dd 100644
--- a/src/options.go
+++ b/src/options.go
@@ -501,8 +501,8 @@ func parseKeymap(keymap map[int]actionType, execmap map[int]string, toggleSort b
keymap[key] = actDeleteCharEof
case "end-of-line":
keymap[key] = actEndOfLine
- case "eof":
- keymap[key] = actEof
+ case "cancel":
+ keymap[key] = actCancel
case "forward-char":
keymap[key] = actForwardChar
case "forward-word":
diff --git a/src/terminal.go b/src/terminal.go
index cbc19ba6..18b37d5a 100644
--- a/src/terminal.go
+++ b/src/terminal.go
@@ -100,11 +100,11 @@ const (
actBackwardChar
actBackwardDeleteChar
actBackwardWord
+ actCancel
actClearScreen
actDeleteChar
actDeleteCharEof
actEndOfLine
- actEof
actForwardChar
actForwardWord
actKillLine
@@ -817,9 +817,13 @@ func (t *Terminal) Loop() {
}
case actEndOfLine:
t.cx = len(t.input)
- case actEof:
+ case actCancel:
if len(t.input) == 0 {
req(reqQuit)
+ } else {
+ t.yanked = t.input
+ t.input = []rune{}
+ t.cx = 0
}
case actForwardChar:
if t.cx < len(t.input) {
diff --git a/test/test_go.rb b/test/test_go.rb
index 4f247edd..ad2150e0 100644
--- a/test/test_go.rb
+++ b/test/test_go.rb
@@ -718,14 +718,14 @@ class TestGoFZF < TestBase
end
end
- def test_eof
- tmux.send_keys "seq 100 | #{fzf "--bind 2:eof"}", :Enter
- tmux.until { |lines| lines[-2].include?('100/100') }
+ def test_canel
+ tmux.send_keys "seq 10 | #{fzf "--bind 2:cancel"}", :Enter
+ tmux.until { |lines| lines[-2].include?('10/10') }
tmux.send_keys '123'
- tmux.until do |lines|
- lines[-1] == '> 13' && lines[-2].include?('1/100')
- end
- tmux.send_keys :BSpace, :BSpace
+ tmux.until { |lines| lines[-1] == '> 3' && lines[-2].include?('1/10') }
+ tmux.send_keys 'C-y', 'C-y'
+ tmux.until { |lines| lines[-1] == '> 311' }
+ tmux.send_keys 2
tmux.until { |lines| lines[-1] == '>' }
tmux.send_keys 2
tmux.prepare