summaryrefslogtreecommitdiffstats
path: root/src/terminal.go
diff options
context:
space:
mode:
Diffstat (limited to 'src/terminal.go')
-rw-r--r--src/terminal.go17
1 files changed, 12 insertions, 5 deletions
diff --git a/src/terminal.go b/src/terminal.go
index 62e80431..b09c47dd 100644
--- a/src/terminal.go
+++ b/src/terminal.go
@@ -147,6 +147,7 @@ type labelPrinter func(tui.Window, int)
type Terminal struct {
initDelay time.Duration
infoStyle infoStyle
+ infoSep string
separator labelPrinter
separatorLen int
spinner []string
@@ -579,6 +580,7 @@ func NewTerminal(opts *Options, eventBox *util.EventBox) *Terminal {
t := Terminal{
initDelay: delay,
infoStyle: opts.InfoStyle,
+ infoSep: opts.InfoSep,
separator: nil,
spinner: makeSpinner(opts.Unicode),
queryLen: [2]int{0, 0},
@@ -1393,16 +1395,21 @@ func (t *Terminal) printInfo() {
pos = 2
case infoInline:
pos = t.promptLen + t.queryLen[0] + t.queryLen[1] + 1
- if pos+len(" < ") > t.window.Width() {
- return
+ str := t.infoSep
+ maxWidth := t.window.Width() - pos
+ width := runewidth.StringWidth(str)
+ if width > maxWidth {
+ trimmed, _ := t.trimRight([]rune(str), maxWidth)
+ str = string(trimmed)
+ width = maxWidth
}
t.move(line, pos, t.separatorLen == 0)
if t.reading {
- t.window.CPrint(tui.ColSpinner, " < ")
+ t.window.CPrint(tui.ColSpinner, str)
} else {
- t.window.CPrint(tui.ColPrompt, " < ")
+ t.window.CPrint(tui.ColPrompt, str)
}
- pos += len(" < ")
+ pos += width
case infoHidden:
return
}