Merge pull request #15 from Ryooooooga/feature/fix-title-rendering

This commit is contained in:
Jesse Duffield 2021-10-18 09:00:56 +11:00 committed by GitHub
commit b2fc03c74a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

14
gui.go
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
}