summaryrefslogtreecommitdiff
path: root/src/result.go
diff options
context:
space:
mode:
authorJunegunn Choi <junegunn.c@gmail.com>2025-06-24 22:50:02 +0900
committerJunegunn Choi <junegunn.c@gmail.com>2025-06-25 02:12:10 +0900
commit4811e52af3ed7f89e82baa908f9a8a25fb593361 (patch)
treeda7d88eadf9a0e8044b4748dd790cd599117b663 /src/result.go
parent8d81730ec2855d3d32a171f8b675430ffb4c4d59 (diff)
downloadfzf-4811e52af3ed7f89e82baa908f9a8a25fb593361.tar.gz
Support full-line background color in the list section
Close #4432
Diffstat (limited to 'src/result.go')
-rw-r--r--src/result.go27
1 files changed, 23 insertions, 4 deletions
diff --git a/src/result.go b/src/result.go
index 3c63e2e4..3dfd58cc 100644
--- a/src/result.go
+++ b/src/result.go
@@ -19,6 +19,10 @@ type colorOffset struct {
url *url
}
+func (co colorOffset) IsFullBgMarker(at int32) bool {
+ return at == co.offset[0] && at == co.offset[1] && co.color.Attr()&tui.FullBg > 0
+}
+
type Result struct {
item *Item
points [4]uint16
@@ -149,12 +153,20 @@ func (result *Result) colorOffsets(matchOffsets []Offset, nthOffsets []Offset, t
color bool
match bool
nth bool
+ fbg tui.Color
}
- cols := make([]cellInfo, maxCol)
+ cols := make([]cellInfo, maxCol+1)
+ for idx := range cols {
+ cols[idx].fbg = -1
+ }
for colorIndex, ansi := range itemColors {
- for i := ansi.offset[0]; i < ansi.offset[1]; i++ {
- cols[i] = cellInfo{colorIndex, true, false, false}
+ if ansi.offset[0] == ansi.offset[1] && ansi.color.attr&tui.FullBg > 0 {
+ cols[ansi.offset[0]].fbg = ansi.color.lbg
+ } else {
+ for i := ansi.offset[0]; i < ansi.offset[1]; i++ {
+ cols[i] = cellInfo{colorIndex, true, false, false, cols[i].fbg}
+ }
}
}
@@ -176,7 +188,7 @@ func (result *Result) colorOffsets(matchOffsets []Offset, nthOffsets []Offset, t
// ------------ ---- -- ----
// ++++++++ ++++++++++
// --++++++++-- --++++++++++---
- var curr cellInfo = cellInfo{0, false, false, false}
+ curr := cellInfo{0, false, false, false, -1}
start := 0
ansiToColorPair := func(ansi ansiOffset, base tui.ColorPair) tui.ColorPair {
if !theme.Colored {
@@ -194,6 +206,13 @@ func (result *Result) colorOffsets(matchOffsets []Offset, nthOffsets []Offset, t
}
var colors []colorOffset
add := func(idx int) {
+ if curr.fbg >= 0 {
+ colors = append(colors, colorOffset{
+ offset: [2]int32{int32(start), int32(start)},
+ color: tui.NewColorPair(-1, curr.fbg, tui.FullBg),
+ match: false,
+ url: nil})
+ }
if (curr.color || curr.nth || curr.match) && idx > start {
if curr.match {
var color tui.ColorPair