diff --git a/pkg/tools/cb/cb.go b/pkg/tools/cb/cb.go index d8139da..dbb7f1e 100644 --- a/pkg/tools/cb/cb.go +++ b/pkg/tools/cb/cb.go @@ -32,6 +32,21 @@ var ( clipSize fyne.Size ) +var ( + clipStyle = widget.RichTextStyle{ + ColorName: theme.ColorNamePlaceHolder, + Inline: false, + SizeName: theme.SizeNameCaptionText, + TextStyle: fyne.TextStyle{Monospace: true}, + } + selectedClipStyle = widget.RichTextStyle{ + ColorName: theme.ColorNameForeground, + Inline: false, + SizeName: theme.SizeNameCaptionText, + TextStyle: fyne.TextStyle{Monospace: true}, + } +) + func init() { var err error @@ -129,8 +144,23 @@ func Show() { if results[selection] == "" { selection = 0 } - list.Objects = make([]fyne.CanvasObject, 0, histViewCount) - populateList(results, list, copyAndClose, selection) + + for i, v := range list.Objects { + border := v.(*fyne.Container) + clipContainer := border.Objects[0].(*fyneh.FixedContainer) + label := clipContainer.Content.(*widget.RichText) + textSegment := label.Segments[0].(*widget.TextSegment) + + style := clipStyle + if i == selection { + style = selectedClipStyle + } + + if textSegment.Style != style { + textSegment.Style = style + label.Refresh() + } + } } bag["updateSelection"] = updateSelection @@ -211,21 +241,6 @@ func Show() { w.SetFixedSize(true) } -var ( - clipStyle = widget.RichTextStyle{ - ColorName: theme.ColorNamePlaceHolder, - Inline: false, - SizeName: theme.SizeNameCaptionText, - TextStyle: fyne.TextStyle{Monospace: true}, - } - selectedClipStyle = widget.RichTextStyle{ - ColorName: theme.ColorNameForeground, - Inline: false, - SizeName: theme.SizeNameCaptionText, - TextStyle: fyne.TextStyle{Monospace: true}, - } -) - func populateList(history []string, list *fyne.Container, copyAndClose func(i int) bool, selection int) { newLabel := func(t string, style widget.RichTextStyle) *widget.RichText { w := widget.NewRichText(&widget.TextSegment{