mirror of
https://github.com/junegunn/fzf.git
synced 2025-12-08 13:44:50 +08:00
@@ -565,7 +565,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.noExtraLine() {
|
||||
effectiveMinHeight--
|
||||
}
|
||||
effectiveMinHeight += borderLines(opts.BorderShape)
|
||||
@@ -845,7 +845,7 @@ func (t *Terminal) parsePrompt(prompt string) (func(), int) {
|
||||
}
|
||||
|
||||
func (t *Terminal) noInfoLine() bool {
|
||||
return t.infoStyle != infoDefault
|
||||
return t.infoStyle.noExtraLine()
|
||||
}
|
||||
|
||||
func getScrollbar(total int, height int, offset int) (int, int) {
|
||||
@@ -1479,6 +1479,8 @@ func (t *Terminal) printInfo() {
|
||||
printSpinner()
|
||||
t.move(line+1, 2, false)
|
||||
pos = 2
|
||||
case infoRight:
|
||||
t.move(line+1, 0, false)
|
||||
case infoInlineRight:
|
||||
pos = t.promptLen + t.queryLen[0] + t.queryLen[1] + 1
|
||||
t.move(line, pos, true)
|
||||
@@ -1529,6 +1531,37 @@ func (t *Terminal) printInfo() {
|
||||
if t.failed != nil && t.count == 0 {
|
||||
output = fmt.Sprintf("[Command failed: %s]", *t.failed)
|
||||
}
|
||||
|
||||
printSeparator := func(fillLength int, pad bool) {
|
||||
// --------_
|
||||
if t.separatorLen > 0 {
|
||||
t.separator(t.window, fillLength)
|
||||
t.window.Print(" ")
|
||||
} else if pad {
|
||||
t.window.Print(strings.Repeat(" ", fillLength+1))
|
||||
}
|
||||
}
|
||||
if t.infoStyle == infoRight {
|
||||
maxWidth := t.window.Width()
|
||||
if t.reading {
|
||||
// Need space for spinner and a margin column
|
||||
maxWidth -= 2
|
||||
}
|
||||
output = t.trimMessage(output, maxWidth)
|
||||
fillLength := t.window.Width() - len(output) - 2
|
||||
if t.reading {
|
||||
if fillLength >= 2 {
|
||||
printSeparator(fillLength-2, true)
|
||||
}
|
||||
printSpinner()
|
||||
t.window.Print(" ")
|
||||
} else if fillLength >= 0 {
|
||||
printSeparator(fillLength, true)
|
||||
}
|
||||
t.window.CPrint(tui.ColInfo, output)
|
||||
return
|
||||
}
|
||||
|
||||
if t.infoStyle == infoInlineRight {
|
||||
pos = util.Max(pos, t.window.Width()-util.StringWidth(output)-3)
|
||||
if pos >= t.window.Width() {
|
||||
@@ -1539,14 +1572,14 @@ func (t *Terminal) printInfo() {
|
||||
t.window.Print(" ")
|
||||
pos += 2
|
||||
}
|
||||
|
||||
maxWidth := t.window.Width() - pos
|
||||
output = t.trimMessage(output, maxWidth)
|
||||
t.window.CPrint(tui.ColInfo, output)
|
||||
|
||||
fillLength := maxWidth - len(output) - 2
|
||||
if t.separatorLen > 0 && fillLength > 0 {
|
||||
if fillLength > 0 {
|
||||
t.window.CPrint(tui.ColSeparator, " ")
|
||||
t.separator(t.window, fillLength)
|
||||
printSeparator(fillLength, false)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user