mirror of
https://github.com/jroimartin/gocui.git
synced 2025-04-24 13:48:51 +08:00
Add *Gui.Highlight to enable/disable current view's custom color
This commit is contained in:
parent
c0ae071931
commit
a7019c8547
@ -100,6 +100,7 @@ func main() {
|
||||
}
|
||||
defer g.Close()
|
||||
|
||||
g.Highlight = true
|
||||
g.SelFgColor = gocui.ColorGreen
|
||||
g.SetLayout(layout)
|
||||
|
||||
|
@ -28,6 +28,7 @@ func main() {
|
||||
defer g.Close()
|
||||
|
||||
g.SetLayout(layout)
|
||||
g.Highlight = true
|
||||
g.SelFgColor = gocui.ColorRed
|
||||
|
||||
if err := initKeybindings(g); err != nil {
|
||||
|
7
gui.go
7
gui.go
@ -45,6 +45,9 @@ type Gui struct {
|
||||
// colors of the current view.
|
||||
SelBgColor, SelFgColor Attribute
|
||||
|
||||
// If Highlight is true, Sel{Bg,Fg}Colors will be used for the current view.
|
||||
Highlight bool
|
||||
|
||||
// If Cursor is true then the cursor is enabled.
|
||||
Cursor bool
|
||||
|
||||
@ -383,7 +386,7 @@ func (g *Gui) flush() error {
|
||||
for _, v := range g.views {
|
||||
if v.Frame {
|
||||
var fgColor, bgColor Attribute
|
||||
if v == g.currentView {
|
||||
if g.Highlight && v == g.currentView {
|
||||
fgColor = g.SelFgColor
|
||||
bgColor = g.SelBgColor
|
||||
} else {
|
||||
@ -539,7 +542,7 @@ func (g *Gui) drawIntersections() error {
|
||||
}
|
||||
|
||||
var fgColor, bgColor Attribute
|
||||
if v == g.currentView {
|
||||
if g.Highlight && v == g.currentView {
|
||||
fgColor = g.SelFgColor
|
||||
bgColor = g.SelBgColor
|
||||
} else {
|
||||
|
Loading…
x
Reference in New Issue
Block a user