diff options
author | Junegunn Choi <junegunn.c@gmail.com> | 2023-12-21 18:41:01 +0900 |
---|---|---|
committer | Junegunn Choi <junegunn.c@gmail.com> | 2023-12-21 18:42:23 +0900 |
commit | d7b61ede07ab20ba106191968f12aaf600b6ede4 (patch) | |
tree | f86613d7e0ef3ec06aa44890d81bd5ab991e6b67 /src/terminal.go | |
parent | 87fc1c84b8700e694ec341b36ac3ce29a7a30e6b (diff) |
Add support for negative --height
fzf --height=-1
Close #3487
Diffstat (limited to 'src/terminal.go')
-rw-r--r-- | src/terminal.go | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/src/terminal.go b/src/terminal.go index 4a4498bb..394be4fc 100644 --- a/src/terminal.go +++ b/src/terminal.go @@ -594,10 +594,17 @@ func makeSpinner(unicode bool) []string { } func evaluateHeight(opts *Options, termHeight int) int { + size := opts.Height.size if opts.Height.percent { - return util.Max(int(opts.Height.size*float64(termHeight)/100.0), opts.MinHeight) + if opts.Height.inverse { + size = 100 - size + } + return util.Max(int(size*float64(termHeight)/100.0), opts.MinHeight) + } + if opts.Height.inverse { + size = float64(termHeight) - size } - return int(opts.Height.size) + return int(size) } // NewTerminal returns new Terminal object @@ -819,7 +826,7 @@ func (t *Terminal) extraLines() int { return extra } -func (t *Terminal) MaxFitAndPad(opts *Options) (int, int) { +func (t *Terminal) MaxFitAndPad() (int, int) { _, screenHeight, marginInt, paddingInt := t.adjustMarginAndPadding() padHeight := marginInt[0] + marginInt[2] + paddingInt[0] + paddingInt[2] fit := screenHeight - padHeight - t.extraLines() |