257 lines
5.9 KiB
Go
257 lines
5.9 KiB
Go
// Copyright 2017-2025 WIT.COM Inc. All rights reserved.
|
|
// Use of this source code is governed by the GPL 3.0
|
|
|
|
package main
|
|
|
|
// simple colors for light and dark
|
|
|
|
import (
|
|
"github.com/awesome-gocui/gocui"
|
|
)
|
|
|
|
// DONE ON ENABLE() WIDGET
|
|
// restores the last saved color and makes it active
|
|
func (tk *guiWidget) restoreEnableColor() {
|
|
if tk.color == nil {
|
|
tk.color = new(colorT)
|
|
}
|
|
tk.color.frame = tk.colorLast.frame
|
|
tk.color.fg = tk.colorLast.fg
|
|
tk.color.bg = tk.colorLast.bg
|
|
tk.color.selFg = tk.colorLast.selFg
|
|
tk.color.selBg = tk.colorLast.selBg
|
|
|
|
tk.activateColor()
|
|
}
|
|
|
|
// DONE ON DISABLE() WIDGET
|
|
// makes the button look disabled
|
|
func (tk *guiWidget) setColorDisable() {
|
|
if tk.color == nil {
|
|
tk.color = new(colorT)
|
|
}
|
|
// save the current color
|
|
tk.color.frame = superLightGrey
|
|
tk.color.fg = gocui.ColorBlack
|
|
tk.color.bg = superLightGrey
|
|
tk.color.selFg = superLightGrey
|
|
tk.color.selBg = superLightGrey
|
|
tk.activateColor()
|
|
}
|
|
|
|
// sets the current gocui highlight colors
|
|
func (tk *guiWidget) activateColor() {
|
|
if tk.v == nil {
|
|
return
|
|
}
|
|
tk.v.FrameColor = tk.color.frame
|
|
tk.v.FgColor = tk.color.fg
|
|
tk.v.BgColor = tk.color.bg
|
|
tk.v.SelFgColor = tk.color.selFg
|
|
tk.v.SelBgColor = tk.color.selBg
|
|
}
|
|
|
|
// saves the color and makes it active
|
|
func (tk *guiWidget) updateColor() {
|
|
if tk.v == nil {
|
|
return
|
|
}
|
|
tk.colorLast.frame = tk.color.frame
|
|
tk.colorLast.fg = tk.color.fg
|
|
tk.colorLast.bg = tk.color.bg
|
|
tk.colorLast.selFg = tk.color.selFg
|
|
tk.colorLast.selBg = tk.color.selBg
|
|
|
|
tk.activateColor()
|
|
}
|
|
|
|
// Below are all the colors. TODO: move to protobuf and save in a config file
|
|
|
|
func (tk *guiWidget) setColorWindowFrame() {
|
|
if tk.color == nil {
|
|
tk.color = new(colorT)
|
|
}
|
|
if me.dark { // use a dark color palette
|
|
tk.color.frame = gocui.AttrNone
|
|
tk.color.fg = gocui.ColorBlack
|
|
tk.color.bg = gocui.ColorBlack
|
|
tk.color.selFg = gocui.AttrNone
|
|
tk.color.selBg = gocui.AttrNone
|
|
} else {
|
|
tk.color.frame = gocui.AttrNone
|
|
tk.color.fg = gocui.AttrNone
|
|
tk.color.bg = gocui.AttrNone
|
|
tk.color.selFg = gocui.AttrNone
|
|
tk.color.selBg = gocui.AttrNone
|
|
}
|
|
|
|
tk.updateColor()
|
|
}
|
|
|
|
// weird. lots of color problems for me on debian sid using the traditional Andy Herzfield 'gnome'
|
|
func (tk *guiWidget) setColorWindowTitleActive() {
|
|
if tk.color == nil {
|
|
tk.color = new(colorT)
|
|
}
|
|
if me.dark { // use a dark color palette
|
|
tk.color.frame = gocui.AttrNone
|
|
tk.color.fg = gocui.ColorBlue
|
|
tk.color.bg = gocui.AttrNone
|
|
tk.color.selFg = gocui.ColorWhite
|
|
tk.color.selBg = gocui.ColorBlue
|
|
} else {
|
|
tk.color.frame = gocui.ColorWhite
|
|
tk.color.fg = gocui.ColorWhite
|
|
tk.color.bg = gocui.ColorBlue
|
|
tk.color.selFg = gocui.ColorWhite
|
|
tk.color.selBg = gocui.ColorBlue
|
|
}
|
|
|
|
tk.updateColor()
|
|
}
|
|
|
|
func (tk *guiWidget) setColorWindowTitle() {
|
|
if tk.color == nil {
|
|
tk.color = new(colorT)
|
|
}
|
|
if me.dark { // use a dark color palette
|
|
tk.color.frame = gocui.AttrNone
|
|
tk.color.fg = gocui.ColorBlue
|
|
tk.color.bg = gocui.AttrNone
|
|
tk.color.selFg = gocui.ColorWhite
|
|
tk.color.selBg = gocui.ColorBlue
|
|
} else {
|
|
tk.color.frame = gocui.ColorWhite
|
|
tk.color.fg = gocui.ColorBlue
|
|
tk.color.bg = gocui.AttrNone
|
|
tk.color.selFg = gocui.ColorWhite
|
|
tk.color.selBg = gocui.ColorBlue
|
|
}
|
|
|
|
tk.updateColor()
|
|
}
|
|
|
|
func (tk *guiWidget) setColorBG() {
|
|
if tk.color == nil {
|
|
tk.color = new(colorT)
|
|
}
|
|
if me.dark {
|
|
tk.color.frame = gocui.AttrNone
|
|
tk.color.fg = gocui.ColorBlack
|
|
tk.color.bg = gocui.ColorBlack
|
|
tk.color.selFg = gocui.AttrNone
|
|
tk.color.selBg = gocui.AttrNone
|
|
} else {
|
|
tk.color.frame = gocui.ColorWhite
|
|
tk.color.fg = gocui.ColorWhite
|
|
tk.color.bg = gocui.AttrNone
|
|
tk.color.selFg = gocui.AttrNone
|
|
tk.color.selBg = gocui.AttrNone
|
|
}
|
|
|
|
tk.updateColor()
|
|
}
|
|
|
|
func (tk *guiWidget) setColorLabel() {
|
|
if tk.color == nil {
|
|
tk.color = new(colorT)
|
|
}
|
|
if me.dark {
|
|
tk.color.frame = gocui.AttrNone
|
|
tk.color.fg = gocui.ColorWhite
|
|
tk.color.bg = gocui.ColorBlack
|
|
tk.color.selFg = gocui.ColorWhite
|
|
tk.color.selBg = gocui.AttrNone
|
|
} else {
|
|
tk.color.frame = gocui.AttrNone
|
|
tk.color.fg = gocui.ColorBlack
|
|
tk.color.bg = gocui.AttrNone
|
|
tk.color.selFg = gocui.AttrNone
|
|
tk.color.selBg = gocui.ColorWhite
|
|
}
|
|
|
|
tk.updateColor()
|
|
}
|
|
|
|
func (tk *guiWidget) setColorButtonDense() {
|
|
if tk.color == nil {
|
|
tk.color = new(colorT)
|
|
}
|
|
if me.dark {
|
|
tk.color.frame = gocui.AttrNone
|
|
tk.color.fg = gocui.ColorBlue
|
|
tk.color.bg = gocui.ColorBlack
|
|
tk.color.selFg = gocui.ColorWhite
|
|
tk.color.selBg = gocui.ColorBlue
|
|
} else {
|
|
tk.color.frame = gocui.AttrNone
|
|
tk.color.fg = gocui.ColorWhite
|
|
tk.color.bg = gocui.ColorBlue
|
|
tk.color.selFg = gocui.ColorBlue
|
|
tk.color.selBg = gocui.AttrNone
|
|
}
|
|
|
|
tk.updateColor()
|
|
}
|
|
|
|
func (tk *guiWidget) setColorButton() {
|
|
if tk.color == nil {
|
|
tk.color = new(colorT)
|
|
}
|
|
if me.dark {
|
|
tk.color.frame = gocui.ColorBlack
|
|
tk.color.fg = gocui.ColorBlue
|
|
tk.color.bg = gocui.ColorBlack
|
|
tk.color.selFg = gocui.ColorWhite
|
|
tk.color.selBg = gocui.ColorBlue
|
|
} else {
|
|
tk.color.frame = gocui.ColorBlue
|
|
tk.color.fg = gocui.AttrNone
|
|
tk.color.bg = gocui.AttrNone
|
|
tk.color.selFg = gocui.ColorWhite
|
|
tk.color.selBg = gocui.ColorBlue
|
|
}
|
|
|
|
tk.updateColor()
|
|
}
|
|
|
|
func (tk *guiWidget) setColorInput() {
|
|
if tk.color == nil {
|
|
tk.color = new(colorT)
|
|
}
|
|
if me.dark {
|
|
tk.color.frame = gocui.ColorYellow
|
|
tk.color.fg = gocui.AttrNone
|
|
tk.color.bg = gocui.AttrNone
|
|
tk.color.selFg = gocui.ColorYellow
|
|
tk.color.selBg = gocui.ColorBlack
|
|
} else {
|
|
tk.color.frame = gocui.ColorYellow
|
|
tk.color.fg = gocui.AttrNone
|
|
tk.color.bg = gocui.AttrNone
|
|
tk.color.selFg = gocui.ColorYellow
|
|
tk.color.selBg = gocui.ColorBlack
|
|
}
|
|
tk.updateColor()
|
|
}
|
|
|
|
func (tk *guiWidget) setColorModal() {
|
|
if tk.color == nil {
|
|
tk.color = new(colorT)
|
|
}
|
|
if me.dark {
|
|
tk.color.frame = gocui.ColorRed
|
|
tk.color.fg = gocui.ColorRed
|
|
tk.color.bg = gocui.ColorBlack
|
|
tk.color.selFg = gocui.ColorBlack
|
|
tk.color.selBg = gocui.AttrNone
|
|
} else {
|
|
tk.color.frame = gocui.ColorRed
|
|
tk.color.fg = gocui.AttrNone
|
|
tk.color.bg = gocui.AttrNone
|
|
tk.color.selFg = gocui.AttrNone
|
|
tk.color.selBg = gocui.ColorWhite
|
|
}
|
|
tk.updateColor()
|
|
}
|