Browse Source

Change default colors (fields and buttons are now green)

textarea
Trevor Slocum 1 year ago
parent
commit
d11681497c
  1. 2
      CHANGELOG
  2. 12
      README.md
  3. 6
      demos/presentation/table.go
  4. 2
      demos/presentation/treeview.go
  5. 10
      form.go
  6. 4
      go.mod
  7. 8
      go.sum
  8. 2
      inputfield.go
  9. 4
      styles.go

2
CHANGELOG

@ -4,7 +4,7 @@ v1.5.6 (WIP) @@ -4,7 +4,7 @@ v1.5.6 (WIP)
- Draw additional accents when rendering a list divider
- Update List, Table and TreeView to not handle Tab or Backtab
- Allow specifying TabbedPanels switcher height
- Change default colors (focused buttons and fields are now blue)
- Change default colors (fields and buttons are now green)
- When resetting color with "-" tag, set background color to primitive
background color, rather than the terminal background color

12
README.md

@ -53,13 +53,13 @@ import ( @@ -53,13 +53,13 @@ import (
func main() {
app := cview.NewApplication()
tv := cview.NewTextView()
tv.SetBorder(true)
tv.SetTitle("Hello, world!")
tv.SetText("Lorem ipsum dolor sit amet")
box := cview.NewTextView()
box.SetBorder(true)
box.SetTitle("Hello, world!")
box.SetText("Lorem ipsum dolor sit amet")
app.SetRoot(box, true)
app.SetRoot(tv, true)
if err := app.Run(); err != nil {
panic(err)
}

6
demos/presentation/table.go

@ -253,11 +253,11 @@ func Table(nextSlide func()) (title string, content cview.Primitive) { @@ -253,11 +253,11 @@ func Table(nextSlide func()) (title string, content cview.Primitive) {
table.SetFixed(1, 1)
for row, line := range strings.Split(tableData, "\n") {
for column, cell := range strings.Split(line, "|") {
color := tcell.ColorWhite.TrueColor()
color := cview.Styles.PrimaryTextColor
if row == 0 {
color = tcell.ColorYellow.TrueColor()
color = cview.Styles.SecondaryTextColor
} else if column == 0 {
color = tcell.ColorDarkCyan.TrueColor()
color = cview.Styles.TertiaryTextColor
}
align := cview.AlignLeft
if row == 0 {

2
demos/presentation/treeview.go

@ -131,7 +131,7 @@ func TreeView(nextSlide func()) (title string, content cview.Primitive) { @@ -131,7 +131,7 @@ func TreeView(nextSlide func()) (title string, content cview.Primitive) {
node.SetExpanded(target == rootNode)
node.SetReference(target)
if target.expand {
node.SetColor(tcell.ColorGreen.TrueColor())
node.SetColor(tcell.ColorLimeGreen.TrueColor())
} else if target.selected != nil {
node.SetColor(tcell.ColorRed.TrueColor())
}

10
form.go

@ -151,14 +151,14 @@ func NewForm() *Form { @@ -151,14 +151,14 @@ func NewForm() *Form {
Box: box,
itemPadding: 1,
labelColor: Styles.SecondaryTextColor,
fieldBackgroundColor: Styles.PrimaryTextColor,
fieldBackgroundColor: Styles.MoreContrastBackgroundColor,
fieldBackgroundColorFocused: Styles.ContrastBackgroundColor,
fieldTextColor: Styles.ContrastPrimaryTextColor,
fieldTextColorFocused: Styles.PrimaryTextColor,
buttonBackgroundColor: Styles.PrimaryTextColor,
fieldTextColor: Styles.InverseTextColor,
fieldTextColorFocused: Styles.InverseTextColor,
buttonBackgroundColor: Styles.MoreContrastBackgroundColor,
buttonBackgroundColorFocused: Styles.ContrastBackgroundColor,
buttonTextColor: Styles.InverseTextColor,
buttonTextColorFocused: Styles.PrimaryTextColor,
buttonTextColorFocused: Styles.InverseTextColor,
labelColorFocused: ColorUnset,
}

4
go.mod

@ -4,11 +4,11 @@ go 1.12 @@ -4,11 +4,11 @@ go 1.12
require (
code.rocketnine.space/tslocum/cbind v0.1.5
github.com/gdamore/tcell/v2 v2.3.3
github.com/gdamore/tcell/v2 v2.3.8
github.com/lucasb-eyer/go-colorful v1.2.0
github.com/mattn/go-runewidth v0.0.13
github.com/rivo/uniseg v0.2.0
golang.org/x/sys v0.0.0-20210525143221-35b2ab0089ea // indirect
golang.org/x/sys v0.0.0-20210603125802-9665404d3644 // indirect
golang.org/x/term v0.0.0-20210503060354-a79de5458b56 // indirect
golang.org/x/text v0.3.6 // indirect
)

8
go.sum

@ -3,8 +3,8 @@ code.rocketnine.space/tslocum/cbind v0.1.5/go.mod h1:LtfqJTzM7qhg88nAvNhx+VnTjZ0 @@ -3,8 +3,8 @@ code.rocketnine.space/tslocum/cbind v0.1.5/go.mod h1:LtfqJTzM7qhg88nAvNhx+VnTjZ0
github.com/gdamore/encoding v1.0.0 h1:+7OoQ1Bc6eTm5niUzBa0Ctsh6JbMW6Ra+YNuAtDBdko=
github.com/gdamore/encoding v1.0.0/go.mod h1:alR0ol34c49FCSBLjhosxzcPHQbf2trDkoo5dl+VrEg=
github.com/gdamore/tcell/v2 v2.2.0/go.mod h1:cTTuF84Dlj/RqmaCIV5p4w8uG1zWdk0SF6oBpwHp4fU=
github.com/gdamore/tcell/v2 v2.3.3 h1:RKoI6OcqYrr/Do8yHZklecdGzDTJH9ACKdfECbRdw3M=
github.com/gdamore/tcell/v2 v2.3.3/go.mod h1:cTTuF84Dlj/RqmaCIV5p4w8uG1zWdk0SF6oBpwHp4fU=
github.com/gdamore/tcell/v2 v2.3.8 h1:kU+TwS6JQ7Xao4kJkhnxkOB1fdNiIThfHKXqezvV3rM=
github.com/gdamore/tcell/v2 v2.3.8/go.mod h1:cTTuF84Dlj/RqmaCIV5p4w8uG1zWdk0SF6oBpwHp4fU=
github.com/lucasb-eyer/go-colorful v1.0.3/go.mod h1:R4dSotOR9KMtayYi1e77YzuveK+i7ruzyGqttikkLy0=
github.com/lucasb-eyer/go-colorful v1.2.0 h1:1nnpGOrhyZZuNyfu1QjKiUICQ74+3FNCN69Aj6K7nkY=
github.com/lucasb-eyer/go-colorful v1.2.0/go.mod h1:R4dSotOR9KMtayYi1e77YzuveK+i7ruzyGqttikkLy0=
@ -16,8 +16,8 @@ github.com/rivo/uniseg v0.2.0 h1:S1pD9weZBuJdFmowNwbpi7BJ8TNftyUImj/0WQi72jY= @@ -16,8 +16,8 @@ github.com/rivo/uniseg v0.2.0 h1:S1pD9weZBuJdFmowNwbpi7BJ8TNftyUImj/0WQi72jY=
github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210309040221-94ec62e08169/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210525143221-35b2ab0089ea h1:+WiDlPBBaO+h9vPNZi8uJ3k4BkKQB7Iow3aqwHVA5hI=
golang.org/x/sys v0.0.0-20210525143221-35b2ab0089ea/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20210603125802-9665404d3644 h1:CA1DEQ4NdKphKeL70tvsWNdT5oFh1lOjihRcEDROi0I=
golang.org/x/sys v0.0.0-20210603125802-9665404d3644/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.0.0-20201210144234-2321bbc49cbf/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210220032956-6a3ed077a48d/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210503060354-a79de5458b56 h1:b8jxX3zqjpqb2LklXPzKSGJhzyxCOZSz8ncv8Nv+y7w=

2
inputfield.go

@ -147,7 +147,7 @@ func NewInputField() *InputField { @@ -147,7 +147,7 @@ func NewInputField() *InputField {
fieldBackgroundColor: Styles.PrimaryTextColor,
fieldBackgroundColorFocused: Styles.ContrastBackgroundColor,
fieldTextColor: Styles.ContrastPrimaryTextColor,
fieldTextColorFocused: Styles.PrimaryTextColor,
fieldTextColorFocused: Styles.ContrastPrimaryTextColor,
placeholderTextColor: Styles.ContrastSecondaryTextColor,
autocompleteListTextColor: Styles.PrimitiveBackgroundColor,
autocompleteListBackgroundColor: Styles.MoreContrastBackgroundColor,

4
styles.go

@ -53,13 +53,13 @@ var Styles = Theme{ @@ -53,13 +53,13 @@ var Styles = Theme{
PrimaryTextColor: tcell.ColorWhite.TrueColor(),
SecondaryTextColor: tcell.ColorYellow.TrueColor(),
TertiaryTextColor: tcell.ColorGreen.TrueColor(),
TertiaryTextColor: tcell.ColorLimeGreen.TrueColor(),
InverseTextColor: tcell.ColorBlack.TrueColor(),
ContrastPrimaryTextColor: tcell.ColorBlack.TrueColor(),
ContrastSecondaryTextColor: tcell.ColorLightSlateGray.TrueColor(),
PrimitiveBackgroundColor: tcell.ColorBlack.TrueColor(),
ContrastBackgroundColor: tcell.ColorBlue.TrueColor(),
ContrastBackgroundColor: tcell.ColorLimeGreen.TrueColor(),
MoreContrastBackgroundColor: tcell.ColorGreen.TrueColor(),
CheckBoxCheckedRune: 'X',

Loading…
Cancel
Save