mirror of
https://github.com/Llewellynvdm/fzf.git
synced 2025-02-15 02:01:46 +00:00
parent
b9ca1fe830
commit
31bbaad06e
@ -24,6 +24,8 @@ CHANGELOG
|
|||||||
# Right-aligned (negative integer)
|
# Right-aligned (negative integer)
|
||||||
fzf --height=10 --border-label="╢ $label ╟" --border=bottom --border-label-pos=-3 --color=label:italic:black
|
fzf --height=10 --border-label="╢ $label ╟" --border=bottom --border-label-pos=-3 --color=label:italic:black
|
||||||
```
|
```
|
||||||
|
- Also added `--preview-label` and `--preview-label-pos` for the border of the
|
||||||
|
preview window
|
||||||
- Info panel (counter) will be followed by a horizontal separator by default
|
- Info panel (counter) will be followed by a horizontal separator by default
|
||||||
- The color of the separator can be customized via `--color=separator:...`
|
- The color of the separator can be customized via `--color=separator:...`
|
||||||
- Separator can be disabled by adding `:nosep` to `--info`
|
- Separator can be disabled by adding `:nosep` to `--info`
|
||||||
|
@ -96,6 +96,8 @@ const usage = `usage: fzf [options]
|
|||||||
[,border-BORDER_OPT]
|
[,border-BORDER_OPT]
|
||||||
[,+SCROLL[OFFSETS][/DENOM]][,~HEADER_LINES]
|
[,+SCROLL[OFFSETS][/DENOM]][,~HEADER_LINES]
|
||||||
[,default][,<SIZE_THRESHOLD(ALTERNATIVE_LAYOUT)]
|
[,default][,<SIZE_THRESHOLD(ALTERNATIVE_LAYOUT)]
|
||||||
|
--preview-label=LABEL
|
||||||
|
--preview-label-pos=COL
|
||||||
|
|
||||||
Scripting
|
Scripting
|
||||||
-q, --query=STR Start the finder with the given query
|
-q, --query=STR Start the finder with the given query
|
||||||
@ -275,6 +277,8 @@ type Options struct {
|
|||||||
BorderShape tui.BorderShape
|
BorderShape tui.BorderShape
|
||||||
Label string
|
Label string
|
||||||
LabelPos int
|
LabelPos int
|
||||||
|
PLabel string
|
||||||
|
PLabelPos int
|
||||||
Unicode bool
|
Unicode bool
|
||||||
Tabstop int
|
Tabstop int
|
||||||
ClearOnExit bool
|
ClearOnExit bool
|
||||||
@ -343,6 +347,8 @@ func defaultOptions() *Options {
|
|||||||
Tabstop: 8,
|
Tabstop: 8,
|
||||||
Label: "",
|
Label: "",
|
||||||
LabelPos: 0,
|
LabelPos: 0,
|
||||||
|
PLabel: "",
|
||||||
|
PLabelPos: 0,
|
||||||
ClearOnExit: true,
|
ClearOnExit: true,
|
||||||
Version: false}
|
Version: false}
|
||||||
}
|
}
|
||||||
@ -1593,6 +1599,11 @@ func parseOptions(opts *Options, allArgs []string) {
|
|||||||
case "--border-label-pos":
|
case "--border-label-pos":
|
||||||
pos := nextString(allArgs, &i, "label position required (positive or negative integer or 'center')")
|
pos := nextString(allArgs, &i, "label position required (positive or negative integer or 'center')")
|
||||||
opts.LabelPos = parseLabelPosition(pos)
|
opts.LabelPos = parseLabelPosition(pos)
|
||||||
|
case "--preview-label":
|
||||||
|
opts.PLabel = nextString(allArgs, &i, "preview label required")
|
||||||
|
case "--preview-label-pos":
|
||||||
|
pos := nextString(allArgs, &i, "preview label position required (positive or negative integer or 'center')")
|
||||||
|
opts.PLabelPos = parseLabelPosition(pos)
|
||||||
case "--no-unicode":
|
case "--no-unicode":
|
||||||
opts.Unicode = false
|
opts.Unicode = false
|
||||||
case "--unicode":
|
case "--unicode":
|
||||||
@ -1632,6 +1643,10 @@ func parseOptions(opts *Options, allArgs []string) {
|
|||||||
opts.Label = value
|
opts.Label = value
|
||||||
} else if match, value := optString(arg, "--border-label-pos="); match {
|
} else if match, value := optString(arg, "--border-label-pos="); match {
|
||||||
opts.LabelPos = parseLabelPosition(value)
|
opts.LabelPos = parseLabelPosition(value)
|
||||||
|
} else if match, value := optString(arg, "--preview-label="); match {
|
||||||
|
opts.PLabel = value
|
||||||
|
} else if match, value := optString(arg, "--preview-label-pos="); match {
|
||||||
|
opts.PLabelPos = parseLabelPosition(value)
|
||||||
} else if match, value := optString(arg, "--prompt="); match {
|
} else if match, value := optString(arg, "--prompt="); match {
|
||||||
opts.Prompt = value
|
opts.Prompt = value
|
||||||
} else if match, value := optString(arg, "--pointer="); match {
|
} else if match, value := optString(arg, "--pointer="); match {
|
||||||
|
@ -117,6 +117,9 @@ type Terminal struct {
|
|||||||
borderLabel func()
|
borderLabel func()
|
||||||
borderLabelLen int
|
borderLabelLen int
|
||||||
borderLabelPos int
|
borderLabelPos int
|
||||||
|
previewLabel func()
|
||||||
|
previewLabelLen int
|
||||||
|
previewLabelPos int
|
||||||
pointer string
|
pointer string
|
||||||
pointerLen int
|
pointerLen int
|
||||||
pointerEmpty string
|
pointerEmpty string
|
||||||
@ -549,6 +552,8 @@ func NewTerminal(opts *Options, eventBox *util.EventBox) *Terminal {
|
|||||||
borderShape: opts.BorderShape,
|
borderShape: opts.BorderShape,
|
||||||
borderLabel: nil,
|
borderLabel: nil,
|
||||||
borderLabelPos: opts.LabelPos,
|
borderLabelPos: opts.LabelPos,
|
||||||
|
previewLabel: nil,
|
||||||
|
previewLabelPos: opts.PLabelPos,
|
||||||
cleanExit: opts.ClearOnExit,
|
cleanExit: opts.ClearOnExit,
|
||||||
paused: opts.Phony,
|
paused: opts.Phony,
|
||||||
strong: strongAttr,
|
strong: strongAttr,
|
||||||
@ -595,6 +600,9 @@ func NewTerminal(opts *Options, eventBox *util.EventBox) *Terminal {
|
|||||||
if len(opts.Label) > 0 {
|
if len(opts.Label) > 0 {
|
||||||
t.borderLabel, t.borderLabelLen = t.parseBorderLabel(opts.Label)
|
t.borderLabel, t.borderLabelLen = t.parseBorderLabel(opts.Label)
|
||||||
}
|
}
|
||||||
|
if len(opts.PLabel) > 0 {
|
||||||
|
t.previewLabel, t.previewLabelLen = t.parseBorderLabel(opts.PLabel)
|
||||||
|
}
|
||||||
|
|
||||||
return &t
|
return &t
|
||||||
}
|
}
|
||||||
@ -938,27 +946,6 @@ func (t *Terminal) resizeWindows() {
|
|||||||
false, tui.MakeBorderStyle(t.borderShape, t.unicode))
|
false, tui.MakeBorderStyle(t.borderShape, t.unicode))
|
||||||
}
|
}
|
||||||
|
|
||||||
// Print border label
|
|
||||||
if t.border != nil && t.borderLabel != nil {
|
|
||||||
switch t.borderShape {
|
|
||||||
case tui.BorderHorizontal, tui.BorderTop, tui.BorderBottom, tui.BorderRounded, tui.BorderSharp:
|
|
||||||
var col int
|
|
||||||
if t.borderLabelPos == 0 {
|
|
||||||
col = util.Max(0, (t.border.Width()-t.borderLabelLen)/2)
|
|
||||||
} else if t.borderLabelPos < 0 {
|
|
||||||
col = util.Max(0, t.border.Width()+t.borderLabelPos+1-t.borderLabelLen)
|
|
||||||
} else {
|
|
||||||
col = util.Min(t.borderLabelPos-1, t.border.Width()-t.borderLabelLen)
|
|
||||||
}
|
|
||||||
row := 0
|
|
||||||
if t.borderShape == tui.BorderBottom {
|
|
||||||
row = t.border.Height() - 1
|
|
||||||
}
|
|
||||||
t.border.Move(row, col)
|
|
||||||
t.borderLabel()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Add padding to margin
|
// Add padding to margin
|
||||||
for idx, val := range paddingInt {
|
for idx, val := range paddingInt {
|
||||||
marginInt[idx] += val
|
marginInt[idx] += val
|
||||||
@ -1063,6 +1050,34 @@ func (t *Terminal) resizeWindows() {
|
|||||||
width,
|
width,
|
||||||
height, false, noBorder)
|
height, false, noBorder)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Print border label
|
||||||
|
printLabel := func(window tui.Window, render func(), pos int, length int, borderShape tui.BorderShape) {
|
||||||
|
if window == nil || render == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
switch borderShape {
|
||||||
|
case tui.BorderHorizontal, tui.BorderTop, tui.BorderBottom, tui.BorderRounded, tui.BorderSharp:
|
||||||
|
var col int
|
||||||
|
if pos == 0 {
|
||||||
|
col = util.Max(0, (window.Width()-length)/2)
|
||||||
|
} else if pos < 0 {
|
||||||
|
col = util.Max(0, window.Width()+pos+1-length)
|
||||||
|
} else {
|
||||||
|
col = util.Min(pos-1, window.Width()-length)
|
||||||
|
}
|
||||||
|
row := 0
|
||||||
|
if borderShape == tui.BorderBottom {
|
||||||
|
row = window.Height() - 1
|
||||||
|
}
|
||||||
|
window.Move(row, col)
|
||||||
|
render()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
printLabel(t.border, t.borderLabel, t.borderLabelPos, t.borderLabelLen, t.borderShape)
|
||||||
|
printLabel(t.pborder, t.previewLabel, t.previewLabelPos, t.previewLabelLen, t.previewOpts.border)
|
||||||
|
|
||||||
for i := 0; i < t.window.Height(); i++ {
|
for i := 0; i < t.window.Height(); i++ {
|
||||||
t.window.MoveAndClear(i, 0)
|
t.window.MoveAndClear(i, 0)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user