Started working on colorschemes

This commit is contained in:
Caleb Bassi 2018-02-20 23:56:37 -08:00
parent 8cc70da406
commit eb68133613
6 changed files with 77 additions and 17 deletions

View File

@ -61,7 +61,7 @@ Alternatively, if you're on Arch Linux you can install the `gotop` package from
## Colorschemes
A different Colorscheme can be set with the `-c` flag followed its name. You can find them in the `colorschemes` folder.
Feel free to add a new one. You can use 256 colors, bold, underline, and reverse. More info [here](https://godoc.org/github.com/nsf/termbox-go#Attribute) and [here](https://godoc.org/github.com/nsf/termbox-go#OutputMode) under 'Output256'.
Feel free to add a new one. You can use 256 colors, bold, underline, and reverse. You can see the template and get more info [here]() and see the default colorscheme as an example [here]().
## TODO

30
colorschemes/default.go Normal file
View File

@ -0,0 +1,30 @@
package colorschemes
var DefaultCS = Colorscheme{
Name: "Default",
Author: "Caleb Bassi",
Bg: -1,
Border{
Labels: 0,
Line: 0,
},
CPU{
Lines: []int{0, 0, 0, 0},
},
Mem{
Main: 0,
Swap: 0,
},
Proc{
Cursor: 5,
},
Sparkline{
Graph: 10,
},
}

View File

View File

46
colorschemes/template.go Normal file
View File

@ -0,0 +1,46 @@
package colorschemes
/*
the standard 256 terminal colors are supported
-1 = clear
You can combine a color with Bold, Underline, or Reverse by using bitwise OR ('|').
For example, to get Bold red Labels, you would do 'Labels: 2 | Bold'
*/
// Ignore this
const (
Bold int = 1 << (iota + 9)
Underline
Reverse
)
type Colorscheme struct {
Name string
Author string
Bg int
Border struct {
Labels int
Line int
}
CPU struct {
Lines []int
}
Mem struct {
Main int
Swap int
}
Proc struct {
Cursor int
}
Sparkline struct {
Graph int
}
}

View File

@ -30,19 +30,3 @@ type ColorScheme struct {
LineGraph Attribute
TableCursor Attribute
}
// 0 <= r,g,b <= 5
func ColorRGB(r, g, b int) Attribute {
within := func(n int) int {
if n < 0 {
return 0
}
if n > 5 {
return 5
}
return n
}
r, b, g = within(r), within(b), within(g)
return Attribute(0x0f + 36*r + 6*g + b)
}