m/fzf
1
0
mirror of https://github.com/junegunn/fzf.git synced 2025-11-15 14:53:47 -05:00

Add support for negative --height

fzf --height=-1

Close #3487
This commit is contained in:
Junegunn Choi
2023-12-21 18:41:01 +09:00
parent 87fc1c84b8
commit d7b61ede07
5 changed files with 44 additions and 9 deletions

View File

@@ -57,6 +57,8 @@ const usage = `usage: fzf [options]
Layout
--height=[~]HEIGHT[%] Display fzf window below the cursor with the given
height instead of using fullscreen.
A negative value is calcalated as the terminal height
minus the given value.
If prefixed with '~', fzf will determine the height
according to the input size.
--min-height=HEIGHT Minimum height when --height is given in percent
@@ -157,6 +159,7 @@ type heightSpec struct {
size float64
percent bool
auto bool
inverse bool
}
type sizeSpec struct {
@@ -1386,6 +1389,13 @@ func parseHeight(str string) heightSpec {
heightSpec.auto = true
str = str[1:]
}
if strings.HasPrefix(str, "-") {
if heightSpec.auto {
errorExit("negative(-) height is not compatible with adaptive(~) height")
}
heightSpec.inverse = true
str = str[1:]
}
size := parseSize(str, 100, "height")
heightSpec.size = size.size