summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJunegunn Choi <junegunn.c@gmail.com>2019-11-15 11:37:52 +0900
committerJunegunn Choi <junegunn.c@gmail.com>2019-11-15 11:39:51 +0900
commite24299239ee2b38ab93b7c57932c3ac765f596b3 (patch)
tree95725bb61ebe21acc82d82e715c342e27abba4a3
parentd2fa4701651a1228ab7aea67eb195fc446f4a2a0 (diff)
Add `--preview-window noborder` option to disable preview border
Close #1699
-rw-r--r--CHANGELOG.md2
-rw-r--r--man/man1/fzf.14
-rw-r--r--src/options.go8
-rw-r--r--src/terminal.go6
4 files changed, 16 insertions, 4 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 0a1a8a6d..b8eb3f5e 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -43,6 +43,8 @@ CHANGELOG
- `--info=default`
- `--info=inline` (same as old `--inline-info`)
- `--info=hidden`
+- Preview window border can be disabled by adding `noborder` to
+ `--preview-window`.
- When you transform the input with `--with-nth`, the trailing white spaces
are removed.
- `ctrl-\`, `ctrl-]`, `ctrl-^`, and `ctrl-/` can now be used with `--bind`
diff --git a/man/man1/fzf.1 b/man/man1/fzf.1
index f90a0571..877330cd 100644
--- a/man/man1/fzf.1
+++ b/man/man1/fzf.1
@@ -361,8 +361,8 @@ Preview window will be updated even when there is no match for the current
query if any of the placeholder expressions evaluates to a non-empty string.
.RE
.TP
-.BI "--preview-window=" "[POSITION][:SIZE[%]][:wrap][:hidden]"
-Determine the layout of the preview window. If the argument ends with
+.BI "--preview-window=" "[POSITION][:SIZE[%]][:noborder][:wrap][:hidden]"
+Determines the layout of the preview window. If the argument contains
\fB:hidden\fR, the preview window will be hidden by default until
\fBtoggle-preview\fR action is triggered. Long lines are truncated by default.
Line wrap can be enabled with \fB:wrap\fR flag.
diff --git a/src/options.go b/src/options.go
index fe0d06d3..26c67e8e 100644
--- a/src/options.go
+++ b/src/options.go
@@ -156,6 +156,7 @@ type previewOpts struct {
size sizeSpec
hidden bool
wrap bool
+ border bool
}
// Options stores the values of command-line options
@@ -248,7 +249,7 @@ func defaultOptions() *Options {
ToggleSort: false,
Expect: make(map[int]string),
Keymap: make(map[int][]action),
- Preview: previewOpts{"", posRight, sizeSpec{50, true}, false, false},
+ Preview: previewOpts{"", posRight, sizeSpec{50, true}, false, false, true},
PrintQuery: false,
ReadZero: false,
Printer: func(str string) { fmt.Println(str) },
@@ -937,6 +938,7 @@ func parsePreviewWindow(opts *previewOpts, input string) {
sizeRegex := regexp.MustCompile("^[0-9]+%?$")
for _, token := range tokens {
switch token {
+ case "":
case "hidden":
opts.hidden = true
case "wrap":
@@ -949,6 +951,10 @@ func parsePreviewWindow(opts *previewOpts, input string) {
opts.position = posLeft
case "right":
opts.position = posRight
+ case "border":
+ opts.border = true
+ case "noborder":
+ opts.border = false
default:
if sizeRegex.MatchString(token) {
opts.size = parseSize(token, 99, "window size")
diff --git a/src/terminal.go b/src/terminal.go
index 0b812ccc..13b932e5 100644
--- a/src/terminal.go
+++ b/src/terminal.go
@@ -624,7 +624,11 @@ func (t *Terminal) resizeWindows() {
noBorder := tui.MakeBorderStyle(tui.BorderNone, t.unicode)
if previewVisible {
createPreviewWindow := func(y int, x int, w int, h int) {
- t.pborder = t.tui.NewWindow(y, x, w, h, tui.MakeBorderStyle(tui.BorderAround, t.unicode))
+ previewBorder := noBorder
+ if t.preview.border {
+ previewBorder = tui.MakeBorderStyle(tui.BorderAround, t.unicode)
+ }
+ t.pborder = t.tui.NewWindow(y, x, w, h, previewBorder)
pwidth := w - 4
// ncurses auto-wraps the line when the cursor reaches the right-end of
// the window. To prevent unintended line-wraps, we use the width one