[#1223] lens/tui: Add rich text support for multipage view component

Signed-off-by: Aleksey Savchuk <a.savchuk@yadro.com>
This commit is contained in:
Aleksey Savchuk 2024-07-29 00:39:51 +03:00
parent cd282edfd5
commit 8682762ef1
No known key found for this signature in database

View file

@ -141,22 +141,14 @@ func (v *MultipageView) draw(screen tcell.Screen) {
}
v.DrawForSubclass(screen, v)
deltaY := 0
for index := v.firstItemIndex; index < v.lastItemIndex; index++ {
deltaX := 0
for i, char := range v.items[index].Text {
if i == width {
break
}
if index == v.selectedItemIndex {
screen.SetContent(x+deltaX, y+deltaY, char, nil, v.selectedTextStyle)
} else {
screen.SetContent(x+deltaX, y+deltaY, char, nil, v.mainTextStyle)
}
deltaX++
text := v.items[index].Text
if index == v.selectedItemIndex {
text = fmt.Sprintf("[:white]%s[:black]", text)
}
deltaY++
tview.Print(screen, text, x, y, width, tview.AlignLeft, tcell.ColorWhite)
y++
}
v.SetTitle(title)
}