Skip to content

Commit ce5274b

Browse files
authored
Merge pull request #54 from jesseduffield/InactiveViewSelBgColor
Add view properties HighlightInactive and InactiveViewSelBgColor
2 parents 05e1204 + e3264e1 commit ce5274b

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

view.go

+14-1
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,11 @@ type View struct {
8181
// foreground colors of the selected line, when it is highlighted.
8282
SelBgColor, SelFgColor Attribute
8383

84+
// InactiveViewSelBgColor is used to configure the background color of the
85+
// selected line, when it is highlighted but the view doesn't have the
86+
// focus.
87+
InactiveViewSelBgColor Attribute
88+
8489
// If Editable is true, keystrokes will be added to the view's internal
8590
// buffer at the cursor position.
8691
Editable bool
@@ -96,6 +101,9 @@ type View struct {
96101
// If Highlight is true, Sel{Bg,Fg}Colors will be used
97102
// for the line under the cursor position.
98103
Highlight bool
104+
// If HighlightInactive is true, InavtiveViewSel{Bg,Fg}Colors will be used
105+
// instead of Sel{Bg,Fg}Colors for highlighting selected lines.
106+
HighlightInactive bool
99107

100108
// If Frame is true, a border will be drawn around the view.
101109
Frame bool
@@ -404,6 +412,7 @@ func newView(name string, x0, y0, x1, y1 int, mode OutputMode) *View {
404412

405413
v.FgColor, v.BgColor = ColorDefault, ColorDefault
406414
v.SelFgColor, v.SelBgColor = ColorDefault, ColorDefault
415+
v.InactiveViewSelBgColor = ColorDefault
407416
v.TitleColor, v.FrameColor = ColorDefault, ColorDefault
408417
return v
409418
}
@@ -506,7 +515,11 @@ func (v *View) setRune(x, y int, ch rune, fgColor, bgColor Attribute) error {
506515
fgColor += 8
507516
}
508517
fgColor = fgColor | AttrBold
509-
bgColor = bgColor | v.SelBgColor
518+
if v.HighlightInactive {
519+
bgColor = bgColor | v.InactiveViewSelBgColor
520+
} else {
521+
bgColor = bgColor | v.SelBgColor
522+
}
510523
}
511524
}
512525

0 commit comments

Comments
 (0)