Add --min-height option for percent --height
This commit is contained in:
parent
78a3f81972
commit
340af463cd
@ -138,6 +138,10 @@ Label characters for \fBjump\fR and \fBjump-accept\fR
|
|||||||
Display fzf window below the cursor with the given height instead of using
|
Display fzf window below the cursor with the given height instead of using
|
||||||
fullscreen.
|
fullscreen.
|
||||||
.TP
|
.TP
|
||||||
|
.BI "--min-height=" "HEIGHT"
|
||||||
|
Minimum height when \fB--height\fR is given in percent (default: 10).
|
||||||
|
Ignored when \fB--height\fR is not specified.
|
||||||
|
.TP
|
||||||
.B "--reverse"
|
.B "--reverse"
|
||||||
Reverse orientation
|
Reverse orientation
|
||||||
.TP
|
.TP
|
||||||
|
@ -50,6 +50,8 @@ const usage = `usage: fzf [options]
|
|||||||
Layout
|
Layout
|
||||||
--height=HEIGHT[%] Display fzf window below the cursor with the given
|
--height=HEIGHT[%] Display fzf window below the cursor with the given
|
||||||
height instead of using fullscreen
|
height instead of using fullscreen
|
||||||
|
--min-height=HEIGHT Minimum height when --height is given in percent
|
||||||
|
(default: 10)
|
||||||
--reverse Reverse orientation
|
--reverse Reverse orientation
|
||||||
--margin=MARGIN Screen margin (TRBL / TB,RL / T,RL,B / T,R,B,L)
|
--margin=MARGIN Screen margin (TRBL / TB,RL / T,RL,B / T,R,B,L)
|
||||||
--inline-info Display finder info inline with the query
|
--inline-info Display finder info inline with the query
|
||||||
@ -153,6 +155,7 @@ type Options struct {
|
|||||||
Black bool
|
Black bool
|
||||||
Bold bool
|
Bold bool
|
||||||
Height sizeSpec
|
Height sizeSpec
|
||||||
|
MinHeight int
|
||||||
Reverse bool
|
Reverse bool
|
||||||
Cycle bool
|
Cycle bool
|
||||||
Hscroll bool
|
Hscroll bool
|
||||||
@ -200,6 +203,7 @@ func defaultOptions() *Options {
|
|||||||
Theme: tui.EmptyTheme(),
|
Theme: tui.EmptyTheme(),
|
||||||
Black: false,
|
Black: false,
|
||||||
Bold: true,
|
Bold: true,
|
||||||
|
MinHeight: 10,
|
||||||
Reverse: false,
|
Reverse: false,
|
||||||
Cycle: false,
|
Cycle: false,
|
||||||
Hscroll: true,
|
Hscroll: true,
|
||||||
@ -1023,7 +1027,9 @@ func parseOptions(opts *Options, allArgs []string) {
|
|||||||
parsePreviewWindow(&opts.Preview,
|
parsePreviewWindow(&opts.Preview,
|
||||||
nextString(allArgs, &i, "preview window layout required: [up|down|left|right][:SIZE[%]][:wrap][:hidden]"))
|
nextString(allArgs, &i, "preview window layout required: [up|down|left|right][:SIZE[%]][:wrap][:hidden]"))
|
||||||
case "--height":
|
case "--height":
|
||||||
opts.Height = parseHeight(nextString(allArgs, &i, "height required: [HEIGHT[%]]"))
|
opts.Height = parseHeight(nextString(allArgs, &i, "height required: HEIGHT[%]"))
|
||||||
|
case "--min-height":
|
||||||
|
opts.MinHeight = nextInt(allArgs, &i, "height required: HEIGHT")
|
||||||
case "--no-height":
|
case "--no-height":
|
||||||
opts.Height = sizeSpec{}
|
opts.Height = sizeSpec{}
|
||||||
case "--no-margin":
|
case "--no-margin":
|
||||||
@ -1054,6 +1060,8 @@ func parseOptions(opts *Options, allArgs []string) {
|
|||||||
opts.Sort = 1 // Don't care
|
opts.Sort = 1 // Don't care
|
||||||
} else if match, value := optString(arg, "--height="); match {
|
} else if match, value := optString(arg, "--height="); match {
|
||||||
opts.Height = parseHeight(value)
|
opts.Height = parseHeight(value)
|
||||||
|
} else if match, value := optString(arg, "--min-height="); match {
|
||||||
|
opts.MinHeight = atoi(value)
|
||||||
} else if match, value := optString(arg, "--toggle-sort="); match {
|
} else if match, value := optString(arg, "--toggle-sort="); match {
|
||||||
parseToggleSort(opts.Keymap, value)
|
parseToggleSort(opts.Keymap, value)
|
||||||
} else if match, value := optString(arg, "--expect="); match {
|
} else if match, value := optString(arg, "--expect="); match {
|
||||||
|
@ -275,14 +275,15 @@ func NewTerminal(opts *Options, eventBox *util.EventBox) *Terminal {
|
|||||||
maxHeightFunc := func(termHeight int) int {
|
maxHeightFunc := func(termHeight int) int {
|
||||||
var maxHeight int
|
var maxHeight int
|
||||||
if opts.Height.percent {
|
if opts.Height.percent {
|
||||||
maxHeight = int(opts.Height.size * float64(termHeight) / 100.0)
|
maxHeight = util.Min(termHeight,
|
||||||
|
util.Max(int(opts.Height.size*float64(termHeight)/100.0), opts.MinHeight))
|
||||||
} else {
|
} else {
|
||||||
maxHeight = util.Min(int(opts.Height.size), termHeight)
|
maxHeight = util.Min(termHeight, int(opts.Height.size))
|
||||||
}
|
}
|
||||||
if opts.InlineInfo {
|
if opts.InlineInfo {
|
||||||
return util.Max(maxHeight, 3)
|
return util.Max(maxHeight, minHeight-1)
|
||||||
}
|
}
|
||||||
return util.Max(maxHeight, 4)
|
return util.Max(maxHeight, minHeight)
|
||||||
}
|
}
|
||||||
renderer = tui.NewLightRenderer(opts.Theme, opts.Black, opts.Mouse, opts.Tabstop, maxHeightFunc)
|
renderer = tui.NewLightRenderer(opts.Theme, opts.Black, opts.Mouse, opts.Tabstop, maxHeightFunc)
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user