diff options
| author | Junegunn Choi <junegunn.c@gmail.com> | 2017-01-10 01:04:36 +0900 |
|---|---|---|
| committer | Junegunn Choi <junegunn.c@gmail.com> | 2017-01-10 01:04:36 +0900 |
| commit | 340af463cd9c52c0a3a7ea5688035bba1cd29f6a (patch) | |
| tree | 870eccd5ac33d6c8dc5c298c1f58e2c6c51cf3df /src | |
| parent | 78a3f81972312d13d50e5b24dcabaa40284566b5 (diff) | |
| download | fzf-340af463cd9c52c0a3a7ea5688035bba1cd29f6a.tar.gz | |
Add --min-height option for percent --height
Diffstat (limited to 'src')
| -rw-r--r-- | src/options.go | 10 | ||||
| -rw-r--r-- | src/terminal.go | 9 |
2 files changed, 14 insertions, 5 deletions
diff --git a/src/options.go b/src/options.go index f34ee84c..cbb0155c 100644 --- a/src/options.go +++ b/src/options.go @@ -50,6 +50,8 @@ const usage = `usage: fzf [options] Layout --height=HEIGHT[%] Display fzf window below the cursor with the given height instead of using fullscreen + --min-height=HEIGHT Minimum height when --height is given in percent + (default: 10) --reverse Reverse orientation --margin=MARGIN Screen margin (TRBL / TB,RL / T,RL,B / T,R,B,L) --inline-info Display finder info inline with the query @@ -153,6 +155,7 @@ type Options struct { Black bool Bold bool Height sizeSpec + MinHeight int Reverse bool Cycle bool Hscroll bool @@ -200,6 +203,7 @@ func defaultOptions() *Options { Theme: tui.EmptyTheme(), Black: false, Bold: true, + MinHeight: 10, Reverse: false, Cycle: false, Hscroll: true, @@ -1023,7 +1027,9 @@ func parseOptions(opts *Options, allArgs []string) { parsePreviewWindow(&opts.Preview, nextString(allArgs, &i, "preview window layout required: [up|down|left|right][:SIZE[%]][:wrap][:hidden]")) 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": opts.Height = sizeSpec{} case "--no-margin": @@ -1054,6 +1060,8 @@ func parseOptions(opts *Options, allArgs []string) { opts.Sort = 1 // Don't care } else if match, value := optString(arg, "--height="); match { 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 { parseToggleSort(opts.Keymap, value) } else if match, value := optString(arg, "--expect="); match { diff --git a/src/terminal.go b/src/terminal.go index c6533276..ce63adf1 100644 --- a/src/terminal.go +++ b/src/terminal.go @@ -275,14 +275,15 @@ func NewTerminal(opts *Options, eventBox *util.EventBox) *Terminal { maxHeightFunc := func(termHeight int) int { var maxHeight int 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 { - maxHeight = util.Min(int(opts.Height.size), termHeight) + maxHeight = util.Min(termHeight, int(opts.Height.size)) } 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) } else { |
