1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-07-05 00:59:19 +02:00

better title rendering

This commit is contained in:
Jesse Duffield
2021-10-18 09:21:33 +11:00
parent a05f22efa2
commit 71fdc5c038
4 changed files with 13 additions and 7 deletions

View File

@ -15,6 +15,7 @@ import (
"github.com/gdamore/tcell/v2"
"github.com/go-errors/errors"
"github.com/mattn/go-runewidth"
)
// OutputMode represents an output mode, which determines how colors
@ -921,8 +922,8 @@ func (g *Gui) drawTitle(v *View, fgColor, bgColor Attribute) error {
str := strings.Join(tabs, separator)
x := v.x0 + 2
for i, ch := range str {
x := v.x0 + i + 2
if x < 0 {
continue
} else if x > v.x1-2 || x >= g.maxX {
@ -948,6 +949,7 @@ func (g *Gui) drawTitle(v *View, fgColor, bgColor Attribute) error {
if err := g.SetRune(x, v.y0, ch, currentFgColor, currentBgColor); err != nil {
return err
}
x += runewidth.RuneWidth(ch)
}
return nil
}
@ -962,14 +964,15 @@ func (g *Gui) drawSubtitle(v *View, fgColor, bgColor Attribute) error {
if start < v.x0 {
return nil
}
for i, ch := range v.Subtitle {
x := start + i
x := start
for _, ch := range v.Subtitle {
if x >= v.x1 {
break
}
if err := g.SetRune(x, v.y0, ch, fgColor, bgColor); err != nil {
return err
}
x += runewidth.RuneWidth(ch)
}
return nil
}
@ -990,14 +993,15 @@ func (g *Gui) drawListFooter(v *View, fgColor, bgColor Attribute) error {
if start < v.x0 {
return nil
}
for i, ch := range message {
x := start + i
x := start
for _, ch := range message {
if x >= v.x1 {
break
}
if err := g.SetRune(x, v.y1, ch, fgColor, bgColor); err != nil {
return err
}
x += runewidth.RuneWidth(ch)
}
return nil
}