mirror of
https://github.com/junegunn/fzf.git
synced 2025-07-31 20:22:01 -07:00
Provide an option to reverse items only (#1267)
This commit is contained in:
committed by
Junegunn Choi
parent
2c26f02f5c
commit
daa1958f86
@@ -53,7 +53,7 @@ const usage = `usage: fzf [options]
|
||||
height instead of using fullscreen
|
||||
--min-height=HEIGHT Minimum height when --height is given in percent
|
||||
(default: 10)
|
||||
--reverse Reverse orientation
|
||||
--layout=LAYOUT Choose layout: [default|reverse|reverse-list]
|
||||
--border Draw border above and below the finder
|
||||
--margin=MARGIN Screen margin (TRBL / TB,RL / T,RL,B / T,R,B,L)
|
||||
--inline-info Display finder info inline with the query
|
||||
@@ -90,7 +90,8 @@ const usage = `usage: fzf [options]
|
||||
|
||||
Environment variables
|
||||
FZF_DEFAULT_COMMAND Default command to use when input is tty
|
||||
FZF_DEFAULT_OPTS Default options (e.g. '--reverse --inline-info')
|
||||
FZF_DEFAULT_OPTS Default options
|
||||
(e.g. '--layout=reverse --inline-info')
|
||||
|
||||
`
|
||||
|
||||
@@ -132,6 +133,14 @@ const (
|
||||
posRight
|
||||
)
|
||||
|
||||
type layoutType int
|
||||
|
||||
const (
|
||||
layoutDefault layoutType = iota
|
||||
layoutReverse
|
||||
layoutReverseList
|
||||
)
|
||||
|
||||
type previewOpts struct {
|
||||
command string
|
||||
position windowPosition
|
||||
@@ -161,7 +170,7 @@ type Options struct {
|
||||
Bold bool
|
||||
Height sizeSpec
|
||||
MinHeight int
|
||||
Reverse bool
|
||||
Layout layoutType
|
||||
Cycle bool
|
||||
Hscroll bool
|
||||
HscrollOff int
|
||||
@@ -211,7 +220,7 @@ func defaultOptions() *Options {
|
||||
Black: false,
|
||||
Bold: true,
|
||||
MinHeight: 10,
|
||||
Reverse: false,
|
||||
Layout: layoutDefault,
|
||||
Cycle: false,
|
||||
Hscroll: true,
|
||||
HscrollOff: 10,
|
||||
@@ -857,6 +866,20 @@ func parseHeight(str string) sizeSpec {
|
||||
return size
|
||||
}
|
||||
|
||||
func parseLayout(str string) layoutType {
|
||||
switch str {
|
||||
case "default":
|
||||
return layoutDefault
|
||||
case "reverse":
|
||||
return layoutReverse
|
||||
case "reverse-list":
|
||||
return layoutReverseList
|
||||
default:
|
||||
errorExit("invalid layout (expected: default / reverse / reverse-list)")
|
||||
}
|
||||
return layoutDefault
|
||||
}
|
||||
|
||||
func parsePreviewWindow(opts *previewOpts, input string) {
|
||||
// Default
|
||||
opts.position = posRight
|
||||
@@ -1037,10 +1060,13 @@ func parseOptions(opts *Options, allArgs []string) {
|
||||
opts.Bold = true
|
||||
case "--no-bold":
|
||||
opts.Bold = false
|
||||
case "--layout":
|
||||
opts.Layout = parseLayout(
|
||||
nextString(allArgs, &i, "layout required (default / reverse / reverse-list)"))
|
||||
case "--reverse":
|
||||
opts.Reverse = true
|
||||
opts.Layout = layoutReverse
|
||||
case "--no-reverse":
|
||||
opts.Reverse = false
|
||||
opts.Layout = layoutDefault
|
||||
case "--cycle":
|
||||
opts.Cycle = true
|
||||
case "--no-cycle":
|
||||
@@ -1156,6 +1182,8 @@ func parseOptions(opts *Options, allArgs []string) {
|
||||
opts.Height = parseHeight(value)
|
||||
} else if match, value := optString(arg, "--min-height="); match {
|
||||
opts.MinHeight = atoi(value)
|
||||
} else if match, value := optString(arg, "--layout="); match {
|
||||
opts.Layout = parseLayout(value)
|
||||
} else if match, value := optString(arg, "--toggle-sort="); match {
|
||||
parseToggleSort(opts.Keymap, value)
|
||||
} else if match, value := optString(arg, "--expect="); match {
|
||||
|
Reference in New Issue
Block a user