summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/options.go49
-rw-r--r--src/terminal.go17
-rw-r--r--src/tui/tui.go9
3 files changed, 54 insertions, 21 deletions
diff --git a/src/options.go b/src/options.go
index 80ca3e11..36fd2055 100644
--- a/src/options.go
+++ b/src/options.go
@@ -69,7 +69,7 @@ const usage = `usage: fzf [options]
NEGATIVE_INTEGER: columns from right] (default: 0)
--margin=MARGIN Screen margin (TRBL | TB,RL | T,RL,B | T,R,B,L)
--padding=PADDING Padding inside border (TRBL | TB,RL | T,RL,B | T,R,B,L)
- --info=STYLE Finder info style [default|inline|hidden]
+ --info=STYLE Finder info style [default|inline|hidden[:nosep]]
--prompt=STR Input prompt (default: '> ')
--pointer=STR Pointer to the current line (default: '>')
--marker=STR Multi-select marker (default: '>')
@@ -169,10 +169,14 @@ const (
layoutReverseList
)
-type infoStyle int
+type infoLayout int
+type infoStyle struct {
+ layout infoLayout
+ separator bool
+}
const (
- infoDefault infoStyle = iota
+ infoDefault infoLayout = iota
infoInline
infoHidden
)
@@ -310,7 +314,7 @@ func defaultOptions() *Options {
HscrollOff: 10,
ScrollOff: 0,
FileWord: false,
- InfoStyle: infoDefault,
+ InfoStyle: infoStyle{layout: infoDefault, separator: true},
JumpLabels: defaultJumpLabels,
Prompt: "> ",
Pointer: ">",
@@ -813,6 +817,8 @@ func parseTheme(defaultTheme *tui.ColorTheme, str string) *tui.ColorTheme {
mergeAttr(&theme.CurrentMatch)
case "border":
mergeAttr(&theme.Border)
+ case "separator":
+ mergeAttr(&theme.Separator)
case "label":
mergeAttr(&theme.BorderLabel)
case "prompt":
@@ -1214,17 +1220,26 @@ func parseLayout(str string) layoutType {
}
func parseInfoStyle(str string) infoStyle {
- switch str {
- case "default":
- return infoDefault
- case "inline":
- return infoInline
- case "hidden":
- return infoHidden
- default:
- errorExit("invalid info style (expected: default / inline / hidden)")
+ layout := infoDefault
+ separator := true
+
+ for _, token := range regexp.MustCompile("[,:]").Split(strings.ToLower(str), -1) {
+ switch token {
+ case "default":
+ layout = infoDefault
+ case "inline":
+ layout = infoInline
+ case "hidden":
+ layout = infoHidden
+ case "nosep":
+ separator = false
+ case "sep":
+ separator = true
+ default:
+ errorExit("invalid info style (expected: default|inline|hidden[:nosep])")
+ }
}
- return infoDefault
+ return infoStyle{layout: layout, separator: separator}
}
func parsePreviewWindow(opts *previewOpts, input string) {
@@ -1486,11 +1501,11 @@ func parseOptions(opts *Options, allArgs []string) {
opts.InfoStyle = parseInfoStyle(
nextString(allArgs, &i, "info style required"))
case "--no-info":
- opts.InfoStyle = infoHidden
+ opts.InfoStyle.layout = infoHidden
case "--inline-info":
- opts.InfoStyle = infoInline
+ opts.InfoStyle.layout = infoInline
case "--no-inline-info":
- opts.InfoStyle = infoDefault
+ opts.InfoStyle.layout = infoDefault
case "--jump-labels":
opts.JumpLabels = nextString(allArgs, &i, "label characters required")
validateJumpLabels = true
diff --git a/src/terminal.go b/src/terminal.go
index c28b5335..ca50de42 100644
--- a/src/terminal.go
+++ b/src/terminal.go
@@ -495,7 +495,7 @@ func NewTerminal(opts *Options, eventBox *util.EventBox) *Terminal {
if previewBox != nil && opts.Preview.aboveOrBelow() {
effectiveMinHeight += 1 + borderLines(opts.Preview.border)
}
- if opts.InfoStyle != infoDefault {
+ if opts.InfoStyle.layout != infoDefault {
effectiveMinHeight--
}
effectiveMinHeight += borderLines(opts.BorderShape)
@@ -677,7 +677,7 @@ func (t *Terminal) parsePrompt(prompt string) (func(), int) {
}
func (t *Terminal) noInfoLine() bool {
- return t.infoStyle != infoDefault
+ return t.infoStyle.layout != infoDefault
}
// Input returns current query string
@@ -1153,7 +1153,7 @@ func (t *Terminal) trimMessage(message string, maxWidth int) string {
func (t *Terminal) printInfo() {
pos := 0
line := t.promptLine()
- switch t.infoStyle {
+ switch t.infoStyle.layout {
case infoDefault:
t.move(line+1, 0, true)
if t.reading {
@@ -1202,8 +1202,17 @@ func (t *Terminal) printInfo() {
if t.failed != nil && t.count == 0 {
output = fmt.Sprintf("[Command failed: %s]", *t.failed)
}
- output = t.trimMessage(output, t.window.Width()-pos)
+ maxWidth := t.window.Width() - pos
+ output = t.trimMessage(output, maxWidth)
t.window.CPrint(tui.ColInfo, output)
+
+ if t.infoStyle.separator && len(output) < maxWidth-2 {
+ bar := "─"
+ if !t.unicode {
+ bar = "-"
+ }
+ t.window.CPrint(tui.ColSeparator, " "+strings.Repeat(bar, maxWidth-len(output)-2))
+ }
}
func (t *Terminal) printHeader() {
diff --git a/src/tui/tui.go b/src/tui/tui.go
index 1a9c748a..793d410a 100644
--- a/src/tui/tui.go
+++ b/src/tui/tui.go
@@ -267,6 +267,7 @@ type ColorTheme struct {
Cursor ColorAttr
Selected ColorAttr
Header ColorAttr
+ Separator ColorAttr
Border ColorAttr
BorderLabel ColorAttr
}
@@ -439,6 +440,7 @@ var (
ColSpinner ColorPair
ColInfo ColorPair
ColHeader ColorPair
+ ColSeparator ColorPair
ColBorder ColorPair
ColPreview ColorPair
ColPreviewBorder ColorPair
@@ -465,6 +467,7 @@ func EmptyTheme() *ColorTheme {
Cursor: ColorAttr{colUndefined, AttrUndefined},
Selected: ColorAttr{colUndefined, AttrUndefined},
Header: ColorAttr{colUndefined, AttrUndefined},
+ Separator: ColorAttr{colUndefined, AttrUndefined},
Border: ColorAttr{colUndefined, AttrUndefined},
BorderLabel: ColorAttr{colUndefined, AttrUndefined},
}
@@ -490,6 +493,7 @@ func NoColorTheme() *ColorTheme {
Cursor: ColorAttr{colDefault, AttrRegular},
Selected: ColorAttr{colDefault, AttrRegular},
Header: ColorAttr{colDefault, AttrRegular},
+ Separator: ColorAttr{colDefault, AttrRegular},
Border: ColorAttr{colDefault, AttrRegular},
BorderLabel: ColorAttr{colDefault, AttrRegular},
}
@@ -520,6 +524,7 @@ func init() {
Cursor: ColorAttr{colRed, AttrUndefined},
Selected: ColorAttr{colMagenta, AttrUndefined},
Header: ColorAttr{colCyan, AttrUndefined},
+ Separator: ColorAttr{colBlack, AttrUndefined},
Border: ColorAttr{colBlack, AttrUndefined},
BorderLabel: ColorAttr{colWhite, AttrUndefined},
}
@@ -542,6 +547,7 @@ func init() {
Cursor: ColorAttr{161, AttrUndefined},
Selected: ColorAttr{168, AttrUndefined},
Header: ColorAttr{109, AttrUndefined},
+ Separator: ColorAttr{59, AttrUndefined},
Border: ColorAttr{59, AttrUndefined},
BorderLabel: ColorAttr{145, AttrUndefined},
}
@@ -564,6 +570,7 @@ func init() {
Cursor: ColorAttr{161, AttrUndefined},
Selected: ColorAttr{168, AttrUndefined},
Header: ColorAttr{31, AttrUndefined},
+ Separator: ColorAttr{145, AttrUndefined},
Border: ColorAttr{145, AttrUndefined},
BorderLabel: ColorAttr{59, AttrUndefined},
}
@@ -601,6 +608,7 @@ func initTheme(theme *ColorTheme, baseTheme *ColorTheme, forceBlack bool) {
theme.Cursor = o(baseTheme.Cursor, theme.Cursor)
theme.Selected = o(baseTheme.Selected, theme.Selected)
theme.Header = o(baseTheme.Header, theme.Header)
+ theme.Separator = o(baseTheme.Separator, theme.Separator)
theme.Border = o(baseTheme.Border, theme.Border)
theme.BorderLabel = o(baseTheme.BorderLabel, theme.BorderLabel)
@@ -634,6 +642,7 @@ func initPalette(theme *ColorTheme) {
ColSpinner = pair(theme.Spinner, theme.Bg)
ColInfo = pair(theme.Info, theme.Bg)
ColHeader = pair(theme.Header, theme.Bg)
+ ColSeparator = pair(theme.Separator, theme.Bg)
ColBorder = pair(theme.Border, theme.Bg)
ColBorderLabel = pair(theme.BorderLabel, theme.Bg)
ColPreview = pair(theme.PreviewFg, theme.PreviewBg)