m/fzf
1
0
mirror of https://github.com/junegunn/fzf.git synced 2025-11-15 06:43: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

@@ -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)
}
return int(opts.Height.size)
if opts.Height.inverse {
size = float64(termHeight) - 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()