From 8682762ef104cc60fb9b0eabd598f55b2734e7bb Mon Sep 17 00:00:00 2001 From: Aleksey Savchuk Date: Mon, 29 Jul 2024 00:39:51 +0300 Subject: [PATCH] [#1223] lens/tui: Add rich text support for multipage view component Signed-off-by: Aleksey Savchuk --- .../internal/tuiutil/multipage-view.go | 20 ++++++------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/cmd/frostfs-lens/internal/tuiutil/multipage-view.go b/cmd/frostfs-lens/internal/tuiutil/multipage-view.go index 99a9d2a85..15620fe3e 100644 --- a/cmd/frostfs-lens/internal/tuiutil/multipage-view.go +++ b/cmd/frostfs-lens/internal/tuiutil/multipage-view.go @@ -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) }