mirror of
https://github.com/junegunn/fzf.git
synced 2025-07-31 20:22:01 -07:00
Compare commits
13 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
248320fa55 | ||
|
d4e26707c7 | ||
|
99ea1056ac | ||
|
7bcf4effa5 | ||
|
e1df876b61 | ||
|
28ffb9638d | ||
|
1c20255504 | ||
|
1fd884b34f | ||
|
701687faab | ||
|
bbc3055feb | ||
|
95c69083c7 | ||
|
57a37b5832 | ||
|
d29ae1c462 |
6
.gitmodules
vendored
Normal file
6
.gitmodules
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
[submodule "src/vendor/github.com/junegunn/go-shellwords"]
|
||||
path = src/vendor/github.com/junegunn/go-shellwords
|
||||
url = https://github.com/junegunn/go-shellwords.git
|
||||
[submodule "src/vendor/github.com/junegunn/go-runewidth"]
|
||||
path = src/vendor/github.com/junegunn/go-runewidth
|
||||
url = https://github.com/junegunn/go-runewidth.git
|
@@ -1,6 +1,11 @@
|
||||
CHANGELOG
|
||||
=========
|
||||
|
||||
0.11.1
|
||||
------
|
||||
|
||||
- Added `--tabstop=SPACES` option
|
||||
|
||||
0.11.0
|
||||
------
|
||||
|
||||
|
11
README.md
11
README.md
@@ -261,6 +261,17 @@ export FZF_COMPLETION_TRIGGER='~~'
|
||||
export FZF_COMPLETION_OPTS='+c -x'
|
||||
```
|
||||
|
||||
#### Supported commands
|
||||
|
||||
On bash, fuzzy completion is enabled only for a predefined set of commands
|
||||
(`complete | grep _fzf` to see the list). But you can enable it for other
|
||||
commands as well like follows.
|
||||
|
||||
```sh
|
||||
# There are also _fzf_path_completion and _fzf_dir_completion
|
||||
complete -F _fzf_file_completion -o default -o bashdefault doge
|
||||
```
|
||||
|
||||
Usage as Vim plugin
|
||||
-------------------
|
||||
|
||||
|
4
fzf
4
fzf
@@ -370,7 +370,7 @@ class FZF
|
||||
+i Case-sensitive match
|
||||
-n, --nth=N[,..] Comma-separated list of field index expressions
|
||||
for limiting search scope. Each can be a non-zero
|
||||
integer or a range expression ([BEGIN]..[END])
|
||||
integer or a range expression ([BEGIN]..[END]).
|
||||
--with-nth=N[,..] Transform the item using index expressions for search
|
||||
-d, --delimiter=STR Field delimiter regex for --nth (default: AWK-style)
|
||||
|
||||
@@ -396,7 +396,7 @@ class FZF
|
||||
|
||||
Environment variables
|
||||
FZF_DEFAULT_COMMAND Default command to use when input is tty
|
||||
FZF_DEFAULT_OPTS Defaults options. (e.g. "-x -m --sort 10000")] + $/ + $/
|
||||
FZF_DEFAULT_OPTS Default options (e.g. "-x -m --sort 10000")] + $/ + $/
|
||||
exit x
|
||||
end
|
||||
|
||||
|
19
install
19
install
@@ -2,25 +2,28 @@
|
||||
|
||||
set -u
|
||||
|
||||
[[ "$@" =~ --pre ]] && version=0.11.0 pre=1 ||
|
||||
version=0.11.0 pre=0
|
||||
[[ "$@" =~ --pre ]] && version=0.11.1 pre=1 ||
|
||||
version=0.11.1 pre=0
|
||||
|
||||
auto_completion=
|
||||
key_bindings=
|
||||
update_config=1
|
||||
binary_arch=
|
||||
|
||||
help() {
|
||||
cat << EOF
|
||||
usage: $0 [OPTIONS]
|
||||
|
||||
--help Show this message
|
||||
--bin Download fzf binary only
|
||||
--bin Download fzf binary only; Do not generate ~/.fzf.{bash,zsh}
|
||||
--all Download fzf binary and update configuration files
|
||||
to enable key bindings and fuzzy completion
|
||||
--[no-]key-bindings Enable/disable key bindings (CTRL-T, CTRL-R, ALT-C)
|
||||
--[no-]completion Enable/disable fuzzy completion (bash & zsh)
|
||||
--[no-]update-rc Whether or not to update shell configuration files
|
||||
|
||||
--32 Download 32-bit binary
|
||||
--64 Download 64-bit binary
|
||||
EOF
|
||||
}
|
||||
|
||||
@@ -41,6 +44,8 @@ for opt in $@; do
|
||||
--no-completion) auto_completion=0 ;;
|
||||
--update-rc) update_config=1 ;;
|
||||
--no-update-rc) update_config=0 ;;
|
||||
--32) binary_arch=386 ;;
|
||||
--64) binary_arch=amd64 ;;
|
||||
--bin) ;;
|
||||
*)
|
||||
echo "unknown option: $opt"
|
||||
@@ -143,10 +148,10 @@ archi=$(uname -sm)
|
||||
binary_available=1
|
||||
binary_error=""
|
||||
case "$archi" in
|
||||
Darwin\ x86_64) download fzf-$version-darwin_amd64 ;;
|
||||
Darwin\ i*86) download fzf-$version-darwin_386 ;;
|
||||
Linux\ x86_64) download fzf-$version-linux_amd64 ;;
|
||||
Linux\ i*86) download fzf-$version-linux_386 ;;
|
||||
Darwin\ x86_64) download fzf-$version-darwin_${binary_arch:-amd64} ;;
|
||||
Darwin\ i*86) download fzf-$version-darwin_${binary_arch:-386} ;;
|
||||
Linux\ x86_64) download fzf-$version-linux_${binary_arch:-amd64} ;;
|
||||
Linux\ i*86) download fzf-$version-linux_${binary_arch:-386} ;;
|
||||
*) binary_available=0 binary_error=1 ;;
|
||||
esac
|
||||
|
||||
|
@@ -21,7 +21,7 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
..
|
||||
.TH fzf 1 "Nov 2015" "fzf 0.11.0" "fzf - a command-line fuzzy finder"
|
||||
.TH fzf 1 "Dec 2015" "fzf 0.11.1" "fzf - a command-line fuzzy finder"
|
||||
|
||||
.SH NAME
|
||||
fzf - a command-line fuzzy finder
|
||||
@@ -157,6 +157,9 @@ e.g. \fBfzf --margin 10%\fR
|
||||
\fBfzf --margin 1,5%\fR
|
||||
.RE
|
||||
.TP
|
||||
.BI "--tabstop=" SPACES
|
||||
Number of spaces for a tab character (default: 8)
|
||||
.TP
|
||||
.B "--cycle"
|
||||
Enable cyclic scroll
|
||||
.TP
|
||||
|
@@ -241,9 +241,9 @@ complete -o default -F _fzf_opts_completion fzf
|
||||
d_cmds="cd pushd rmdir"
|
||||
f_cmds="
|
||||
awk cat diff diff3
|
||||
emacs ex file ftp g++ gcc gvim head hg java
|
||||
emacs emacsclient ex file ftp g++ gcc gvim head hg java
|
||||
javac ld less more mvim nvim patch perl python ruby
|
||||
sed sftp sort source tail tee uniq vi view vim wc"
|
||||
sed sftp sort source tail tee uniq vi view vim wc xdg-open"
|
||||
a_cmds="
|
||||
basename bunzip2 bzip2 chmod chown curl cp dirname du
|
||||
find git grep gunzip gzip hg jar
|
||||
|
@@ -21,7 +21,7 @@ __fzf_generic_path_completion() {
|
||||
tail=$6
|
||||
[ ${FZF_TMUX:-1} -eq 1 ] && fzf="fzf-tmux -d ${FZF_TMUX_HEIGHT:-40%}" || fzf="fzf"
|
||||
|
||||
if ! setopt | grep nonomatch > /dev/null; then
|
||||
if ! setopt | \grep nonomatch > /dev/null; then
|
||||
nnm=1
|
||||
setopt nonomatch
|
||||
fi
|
||||
@@ -116,11 +116,8 @@ _fzf_complete_unalias() {
|
||||
}
|
||||
|
||||
fzf-completion() {
|
||||
local tokens cmd prefix trigger tail fzf matches lbuf d_cmds sws
|
||||
if setopt | grep shwordsplit > /dev/null; then
|
||||
sws=1
|
||||
unsetopt shwordsplit
|
||||
fi
|
||||
local tokens cmd prefix trigger tail fzf matches lbuf d_cmds
|
||||
setopt localoptions noshwordsplit
|
||||
|
||||
# http://zsh.sourceforge.net/FAQ/zshfaq03.html
|
||||
# http://zsh.sourceforge.net/Doc/Release/Expansion.html#Parameter-Expansion-Flags
|
||||
@@ -163,12 +160,10 @@ fzf-completion() {
|
||||
else
|
||||
eval "zle ${fzf_default_completion:-expand-or-complete}"
|
||||
fi
|
||||
[ -n "$sws" ] && setopt shwordsplit
|
||||
}
|
||||
|
||||
[ -z "$fzf_default_completion" ] &&
|
||||
fzf_default_completion=$(bindkey '^I' | grep -v undefined-key | awk '{print $2}')
|
||||
fzf_default_completion=$(bindkey '^I' | \grep -v undefined-key | awk '{print $2}')
|
||||
|
||||
zle -N fzf-completion
|
||||
bindkey '^I' fzf-completion
|
||||
|
||||
|
44
src/Dockerfile.android
Normal file
44
src/Dockerfile.android
Normal file
@@ -0,0 +1,44 @@
|
||||
FROM ubuntu:14.04
|
||||
MAINTAINER Junegunn Choi <junegunn.c@gmail.com>
|
||||
|
||||
# apt-get
|
||||
RUN apt-get update && apt-get -y upgrade && \
|
||||
apt-get install -y --force-yes git curl build-essential
|
||||
|
||||
# Install Go 1.4
|
||||
RUN cd / && curl \
|
||||
https://storage.googleapis.com/golang/go1.4.2.linux-amd64.tar.gz | \
|
||||
tar -xz && mv go go1.4 && \
|
||||
sed -i 's@#define PTHREAD_KEYS_MAX 128@@' /go1.4/src/runtime/cgo/gcc_android_arm.c
|
||||
|
||||
ENV GOPATH /go
|
||||
ENV GOROOT /go1.4
|
||||
ENV PATH /go1.4/bin:$PATH
|
||||
|
||||
RUN cd / && \
|
||||
curl -O http://dl.google.com/android/ndk/android-ndk-r10e-linux-x86_64.bin && \
|
||||
chmod 755 /android-ndk* && /android-ndk-r10e-linux-x86_64.bin && \
|
||||
mv android-ndk-r10e /android-ndk
|
||||
|
||||
RUN cd /android-ndk && bash ./build/tools/make-standalone-toolchain.sh --platform=android-21 --install-dir=/ndk --arch=arm
|
||||
|
||||
ENV NDK_CC /ndk/bin/arm-linux-androideabi-gcc
|
||||
|
||||
RUN cd $GOROOT/src && \
|
||||
CC_FOR_TARGET=$NDK_CC GOOS=android GOARCH=arm GOARM=7 ./make.bash
|
||||
|
||||
RUN cd / && curl \
|
||||
http://ftp.gnu.org/gnu/ncurses/ncurses-5.9.tar.gz | \
|
||||
tar -xz && cd /ncurses-5.9 && \
|
||||
./configure CC=$NDK_CC CFLAGS="-fPIE -march=armv7-a -mfpu=neon -mhard-float -Wl,--no-warn-mismatch" LDFLAGS="-march=armv7-a -Wl,--no-warn-mismatch" --host=arm-linux --enable-overwrite --enable-const --without-cxx-binding --without-shared --without-debug --enable-widec --enable-ext-colors --enable-ext-mouse --enable-pc-files --with-pkg-config-libdir=$PKG_CONFIG_LIBDIR --without-manpages --without-ada --disable-shared --without-tests --prefix=/ndk/sysroot/usr --with-default-terminfo-dirs=/usr/share/terminfo --with-terminfo-dirs=/usr/share/terminfo ac_cv_header_locale_h=n ac_cv_func_getpwent=no ac_cv_func_getpwnam=no ac_cv_func_getpwuid=no && \
|
||||
sed -i 's@#define HAVE_LOCALE_H 1@/* #undef HAVE_LOCALE_H */@' include/ncurses_cfg.h && \
|
||||
make && \
|
||||
sed -i '0,/echo.*/{s/echo.*/exit 0/}' misc/run_tic.sh && \
|
||||
make install && \
|
||||
mv /ndk/sysroot/usr/lib/libncursesw.a /ndk/sysroot/usr/lib/libncurses.a
|
||||
|
||||
# Volume
|
||||
VOLUME /go
|
||||
|
||||
# Default CMD
|
||||
CMD cd /go/src/github.com/junegunn/fzf/src && /bin/bash
|
@@ -11,9 +11,16 @@ RUN cd / && curl \
|
||||
https://storage.googleapis.com/golang/go1.4.2.linux-amd64.tar.gz | \
|
||||
tar -xz && mv go go1.4
|
||||
|
||||
# Install Go 1.5
|
||||
RUN cd / && curl \
|
||||
https://storage.googleapis.com/golang/go1.5.1.linux-amd64.tar.gz | \
|
||||
tar -xz && mv go go1.5
|
||||
|
||||
ENV GO15VENDOREXPERIMENT 1
|
||||
ENV GOROOT_BOOTSTRAP /go1.4
|
||||
ENV GOROOT /go1.5
|
||||
ENV GOPATH /go
|
||||
ENV GOROOT /go1.4
|
||||
ENV PATH /go1.4/bin:$PATH
|
||||
ENV PATH /go1.5/bin:$PATH
|
||||
|
||||
# For i386 build
|
||||
RUN cd $GOROOT/src && GOARCH=386 ./make.bash
|
||||
|
41
src/Makefile
41
src/Makefile
@@ -2,12 +2,14 @@ ifndef GOPATH
|
||||
$(error GOPATH is undefined)
|
||||
endif
|
||||
|
||||
ifndef GOOS
|
||||
UNAME_S := $(shell uname -s)
|
||||
ifeq ($(UNAME_S),Darwin)
|
||||
GOOS := darwin
|
||||
else ifeq ($(UNAME_S),Linux)
|
||||
GOOS := linux
|
||||
endif
|
||||
endif
|
||||
|
||||
ifneq ($(shell uname -m),x86_64)
|
||||
$(error "Build on $(UNAME_M) is not supported, yet.")
|
||||
@@ -16,11 +18,13 @@ endif
|
||||
SOURCES := $(wildcard *.go */*.go)
|
||||
BINDIR := ../bin
|
||||
|
||||
BINARY32 := fzf-$(GOOS)_386
|
||||
BINARY64 := fzf-$(GOOS)_amd64
|
||||
VERSION = $(shell fzf/$(BINARY64) --version)
|
||||
RELEASE32 = fzf-$(VERSION)-$(GOOS)_386
|
||||
RELEASE64 = fzf-$(VERSION)-$(GOOS)_amd64
|
||||
BINARY32 := fzf-$(GOOS)_386
|
||||
BINARY64 := fzf-$(GOOS)_amd64
|
||||
BINARYARM7 := fzf-$(GOOS)_arm7
|
||||
VERSION := $(shell awk -F= '/version =/ {print $$2}' constants.go | tr -d "\" ")
|
||||
RELEASE32 = fzf-$(VERSION)-$(GOOS)_386
|
||||
RELEASE64 = fzf-$(VERSION)-$(GOOS)_amd64
|
||||
RELEASEARM7 = fzf-$(VERSION)-$(GOOS)_arm7
|
||||
|
||||
all: release
|
||||
|
||||
@@ -31,9 +35,14 @@ release: build
|
||||
|
||||
build: test fzf/$(BINARY32) fzf/$(BINARY64)
|
||||
|
||||
android-build:
|
||||
cd fzf && GOARCH=arm GOARM=7 CGO_ENABLED=1 go build -a -ldflags="-extldflags=-pie" -o $(BINARYARM7)
|
||||
cd fzf && cp $(BINARYARM7) $(RELEASEARM7) && tar -czf $(RELEASEARM7).tgz $(RELEASEARM7) && \
|
||||
rm -f $(RELEASEARM7)
|
||||
|
||||
test:
|
||||
go get
|
||||
go test -v ./...
|
||||
GO15VENDOREXPERIMENT=1 go get
|
||||
GO15VENDOREXPERIMENT=1 SHELL=/bin/sh go test -v ./...
|
||||
|
||||
install: $(BINDIR)/fzf
|
||||
|
||||
@@ -44,10 +53,10 @@ clean:
|
||||
cd fzf && rm -f fzf-*
|
||||
|
||||
fzf/$(BINARY32): $(SOURCES)
|
||||
cd fzf && GOARCH=386 CGO_ENABLED=1 go build -a -o $(BINARY32)
|
||||
cd fzf && GO15VENDOREXPERIMENT=1 GOARCH=386 CGO_ENABLED=1 go build -a -o $(BINARY32)
|
||||
|
||||
fzf/$(BINARY64): $(SOURCES)
|
||||
cd fzf && go build -a -tags "$(TAGS)" -o $(BINARY64)
|
||||
cd fzf && GO15VENDOREXPERIMENT=1 go build -a -tags "$(TAGS)" -o $(BINARY64)
|
||||
|
||||
$(BINDIR)/fzf: fzf/$(BINARY64) | $(BINDIR)
|
||||
cp -f fzf/$(BINARY64) $(BINDIR)
|
||||
@@ -65,6 +74,9 @@ docker-ubuntu:
|
||||
docker-centos:
|
||||
docker build -t junegunn/centos-sandbox - < Dockerfile.centos
|
||||
|
||||
docker-android:
|
||||
docker build -t junegunn/android-sandbox - < Dockerfile.android
|
||||
|
||||
arch: docker-arch
|
||||
docker run -i -t -v $(GOPATH):/go junegunn/$@-sandbox \
|
||||
sh -c 'cd /go/src/github.com/junegunn/fzf/src; /bin/bash'
|
||||
@@ -81,5 +93,14 @@ linux: docker-centos
|
||||
docker run -i -t -v $(GOPATH):/go junegunn/centos-sandbox \
|
||||
/bin/bash -ci 'cd /go/src/github.com/junegunn/fzf/src; make TAGS=static'
|
||||
|
||||
ubuntu-android: docker-android
|
||||
docker run -i -t -v $(GOPATH):/go junegunn/$@-sandbox \
|
||||
sh -c 'cd /go/src/github.com/junegunn/fzf/src; /bin/bash'
|
||||
|
||||
android: docker-android
|
||||
docker run -i -t -v $(GOPATH):/go junegunn/android-sandbox \
|
||||
/bin/bash -ci 'cd /go/src/github.com/junegunn/fzf/src; GOOS=android make android-build'
|
||||
|
||||
.PHONY: all build release test install uninstall clean docker \
|
||||
linux arch ubuntu centos docker-arch docker-ubuntu docker-centos
|
||||
linux arch ubuntu centos docker-arch docker-ubuntu docker-centos \
|
||||
android-build docker-android ubuntu-android android
|
||||
|
@@ -8,7 +8,7 @@ import (
|
||||
|
||||
const (
|
||||
// Current version
|
||||
version = "0.11.0"
|
||||
version = "0.11.1"
|
||||
|
||||
// Core
|
||||
coordinatorDelayMax time.Duration = 100 * time.Millisecond
|
||||
|
@@ -5,6 +5,12 @@ package curses
|
||||
#include <locale.h>
|
||||
#cgo !static LDFLAGS: -lncurses
|
||||
#cgo static LDFLAGS: -l:libncursesw.a -l:libtinfo.a -l:libgpm.a -ldl
|
||||
#cgo android static LDFLAGS: -l:libncurses.a -fPIE -march=armv7-a -mfpu=neon -mhard-float -Wl,--no-warn-mismatch
|
||||
|
||||
SCREEN *c_newterm () {
|
||||
return newterm(NULL, stderr, stdin);
|
||||
}
|
||||
|
||||
*/
|
||||
import "C"
|
||||
|
||||
@@ -260,7 +266,7 @@ func Init(theme *ColorTheme, black bool, mouse bool) {
|
||||
}
|
||||
|
||||
C.setlocale(C.LC_ALL, C.CString(""))
|
||||
_screen = C.newterm(nil, C.stderr, C.stdin)
|
||||
_screen = C.c_newterm()
|
||||
if _screen == nil {
|
||||
fmt.Println("Invalid $TERM: " + os.Getenv("TERM"))
|
||||
os.Exit(2)
|
||||
|
@@ -22,7 +22,7 @@ const usage = `usage: fzf [options]
|
||||
+i Case-sensitive match
|
||||
-n, --nth=N[,..] Comma-separated list of field index expressions
|
||||
for limiting search scope. Each can be a non-zero
|
||||
integer or a range expression ([BEGIN]..[END])
|
||||
integer or a range expression ([BEGIN]..[END]).
|
||||
--with-nth=N[,..] Transform item using index expressions within finder
|
||||
-d, --delimiter=STR Field delimiter regex for --nth (default: AWK-style)
|
||||
+s, --no-sort Do not sort the result
|
||||
@@ -38,6 +38,7 @@ const usage = `usage: fzf [options]
|
||||
--black Use black background
|
||||
--reverse Reverse orientation
|
||||
--margin=MARGIN Screen margin (TRBL / TB,RL / T,RL,B / T,R,B,L)
|
||||
--tabstop=SPACES Number of spaces for a tab character (default: 8)
|
||||
--cycle Enable cyclic scroll
|
||||
--no-hscroll Disable horizontal scroll
|
||||
--inline-info Display finder info inline with the query
|
||||
@@ -59,7 +60,7 @@ const usage = `usage: fzf [options]
|
||||
|
||||
Environment variables
|
||||
FZF_DEFAULT_COMMAND Default command to use when input is tty
|
||||
FZF_DEFAULT_OPTS Defaults options. (e.g. '--reverse --inline-info')
|
||||
FZF_DEFAULT_OPTS Default options (e.g. '--reverse --inline-info')
|
||||
|
||||
`
|
||||
|
||||
@@ -123,6 +124,7 @@ type Options struct {
|
||||
Header []string
|
||||
HeaderLines int
|
||||
Margin [4]string
|
||||
Tabstop int
|
||||
Version bool
|
||||
}
|
||||
|
||||
@@ -169,6 +171,7 @@ func defaultOptions() *Options {
|
||||
Header: make([]string, 0),
|
||||
HeaderLines: 0,
|
||||
Margin: defaultMargin(),
|
||||
Tabstop: 8,
|
||||
Version: false}
|
||||
}
|
||||
|
||||
@@ -822,6 +825,8 @@ func parseOptions(opts *Options, allArgs []string) {
|
||||
case "--margin":
|
||||
opts.Margin = parseMargin(
|
||||
nextString(allArgs, &i, "margin required (TRBL / TB,RL / T,RL,B / T,R,B,L)"))
|
||||
case "--tabstop":
|
||||
opts.Tabstop = nextInt(allArgs, &i, "tab stop required")
|
||||
case "--version":
|
||||
opts.Version = true
|
||||
default:
|
||||
@@ -861,6 +866,8 @@ func parseOptions(opts *Options, allArgs []string) {
|
||||
opts.HeaderLines = atoi(value)
|
||||
} else if match, value := optString(arg, "--margin="); match {
|
||||
opts.Margin = parseMargin(value)
|
||||
} else if match, value := optString(arg, "--tabstop="); match {
|
||||
opts.Tabstop = atoi(value)
|
||||
} else {
|
||||
errorExit("unknown option: " + arg)
|
||||
}
|
||||
@@ -871,6 +878,10 @@ func parseOptions(opts *Options, allArgs []string) {
|
||||
errorExit("header lines must be a non-negative integer")
|
||||
}
|
||||
|
||||
if opts.Tabstop < 1 {
|
||||
errorExit("tab stop must be a positive integer")
|
||||
}
|
||||
|
||||
// Change default actions for CTRL-N / CTRL-P when --history is used
|
||||
if opts.History != nil {
|
||||
if _, prs := keymap[curses.CtrlP]; !prs {
|
||||
|
@@ -80,6 +80,7 @@ func (a byTimeOrder) Less(i, j int) bool {
|
||||
|
||||
var _spinner = []string{`-`, `\`, `|`, `/`, `-`, `\`, `|`, `/`}
|
||||
var _runeWidths = make(map[rune]int)
|
||||
var _tabStop int
|
||||
|
||||
const (
|
||||
reqPrompt util.EventType = iota
|
||||
@@ -194,6 +195,7 @@ func NewTerminal(opts *Options, eventBox *util.EventBox) *Terminal {
|
||||
} else {
|
||||
header = reverseStringArray(opts.Header)
|
||||
}
|
||||
_tabStop = opts.Tabstop
|
||||
return &Terminal{
|
||||
inlineInfo: opts.InlineInfo,
|
||||
prompt: opts.Prompt,
|
||||
@@ -324,7 +326,7 @@ func (t *Terminal) sortSelected() []selectedItem {
|
||||
|
||||
func runeWidth(r rune, prefixWidth int) int {
|
||||
if r == '\t' {
|
||||
return 8 - prefixWidth%8
|
||||
return _tabStop - prefixWidth%_tabStop
|
||||
} else if w, found := _runeWidths[r]; found {
|
||||
return w
|
||||
} else {
|
||||
|
1
src/vendor/github.com/junegunn/go-runewidth
generated
vendored
Submodule
1
src/vendor/github.com/junegunn/go-runewidth
generated
vendored
Submodule
Submodule src/vendor/github.com/junegunn/go-runewidth added at 63c378b851
1
src/vendor/github.com/junegunn/go-shellwords
generated
vendored
Submodule
1
src/vendor/github.com/junegunn/go-shellwords
generated
vendored
Submodule
Submodule src/vendor/github.com/junegunn/go-shellwords added at 35d512af75
@@ -6,6 +6,7 @@ require 'fileutils'
|
||||
|
||||
DEFAULT_TIMEOUT = 20
|
||||
|
||||
FILE = File.expand_path(__FILE__)
|
||||
base = File.expand_path('../../', __FILE__)
|
||||
Dir.chdir base
|
||||
FZF = "FZF_DEFAULT_OPTS= FZF_DEFAULT_COMMAND= #{base}/bin/fzf"
|
||||
@@ -803,8 +804,8 @@ class TestGoFZF < TestBase
|
||||
end
|
||||
|
||||
def test_header
|
||||
tmux.send_keys "seq 100 | #{fzf "--header \\\"\\$(head -5 #{__FILE__})\\\""}", :Enter
|
||||
header = File.readlines(__FILE__).take(5).map(&:strip)
|
||||
tmux.send_keys "seq 100 | #{fzf "--header \\\"\\$(head -5 #{FILE})\\\""}", :Enter
|
||||
header = File.readlines(FILE).take(5).map(&:strip)
|
||||
tmux.until do |lines|
|
||||
lines[-2].include?('100/100') &&
|
||||
lines[-7..-3].map(&:strip) == header
|
||||
@@ -812,8 +813,8 @@ class TestGoFZF < TestBase
|
||||
end
|
||||
|
||||
def test_header_reverse
|
||||
tmux.send_keys "seq 100 | #{fzf "--header=\\\"\\$(head -5 #{__FILE__})\\\" --reverse"}", :Enter
|
||||
header = File.readlines(__FILE__).take(5).map(&:strip)
|
||||
tmux.send_keys "seq 100 | #{fzf "--header=\\\"\\$(head -5 #{FILE})\\\" --reverse"}", :Enter
|
||||
header = File.readlines(FILE).take(5).map(&:strip)
|
||||
tmux.until do |lines|
|
||||
lines[1].include?('100/100') &&
|
||||
lines[2..6].map(&:strip) == header
|
||||
@@ -821,8 +822,8 @@ class TestGoFZF < TestBase
|
||||
end
|
||||
|
||||
def test_header_and_header_lines
|
||||
tmux.send_keys "seq 100 | #{fzf "--header-lines 10 --header \\\"\\$(head -5 #{__FILE__})\\\""}", :Enter
|
||||
header = File.readlines(__FILE__).take(5).map(&:strip)
|
||||
tmux.send_keys "seq 100 | #{fzf "--header-lines 10 --header \\\"\\$(head -5 #{FILE})\\\""}", :Enter
|
||||
header = File.readlines(FILE).take(5).map(&:strip)
|
||||
tmux.until do |lines|
|
||||
lines[-2].include?('90/90') &&
|
||||
lines[-7...-2].map(&:strip) == header &&
|
||||
@@ -831,8 +832,8 @@ class TestGoFZF < TestBase
|
||||
end
|
||||
|
||||
def test_header_and_header_lines_reverse
|
||||
tmux.send_keys "seq 100 | #{fzf "--reverse --header-lines 10 --header \\\"\\$(head -5 #{__FILE__})\\\""}", :Enter
|
||||
header = File.readlines(__FILE__).take(5).map(&:strip)
|
||||
tmux.send_keys "seq 100 | #{fzf "--reverse --header-lines 10 --header \\\"\\$(head -5 #{FILE})\\\""}", :Enter
|
||||
header = File.readlines(FILE).take(5).map(&:strip)
|
||||
tmux.until do |lines|
|
||||
lines[1].include?('90/90') &&
|
||||
lines[2...7].map(&:strip) == header &&
|
||||
@@ -865,6 +866,26 @@ class TestGoFZF < TestBase
|
||||
tmux.send_keys :Enter
|
||||
end
|
||||
|
||||
def test_tabstop
|
||||
writelines tempname, ["f\too\tba\tr\tbaz\tbarfooq\tux"]
|
||||
{
|
||||
1 => '> f oo ba r baz barfooq ux',
|
||||
2 => '> f oo ba r baz barfooq ux',
|
||||
3 => '> f oo ba r baz barfooq ux',
|
||||
4 => '> f oo ba r baz barfooq ux',
|
||||
5 => '> f oo ba r baz barfooq ux',
|
||||
6 => '> f oo ba r baz barfooq ux',
|
||||
7 => '> f oo ba r baz barfooq ux',
|
||||
8 => '> f oo ba r baz barfooq ux',
|
||||
9 => '> f oo ba r baz barfooq ux',
|
||||
}.each do |ts, exp|
|
||||
tmux.prepare
|
||||
tmux.send_keys %[cat #{tempname} | fzf --tabstop=#{ts}], :Enter
|
||||
tmux.until { |lines| lines[-3] == exp }
|
||||
tmux.send_keys :Enter
|
||||
end
|
||||
end
|
||||
|
||||
def test_with_nth
|
||||
writelines tempname, ['hello world ', 'byebye']
|
||||
assert_equal 'hello world ', `cat #{tempname} | #{FZF} -f"^he hehe" -x -n 2.. --with-nth 2,1,1`.chomp
|
||||
|
Reference in New Issue
Block a user