Chore: colorschemes to their own file
This commit is contained in:
63
colors.go
Normal file
63
colors.go
Normal file
@@ -0,0 +1,63 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/gdamore/tcell/v2"
|
||||
"github.com/rivo/tview"
|
||||
)
|
||||
|
||||
var (
|
||||
colorschemes = map[string]tview.Theme{
|
||||
"default": tview.Theme{
|
||||
PrimitiveBackgroundColor: tcell.ColorDefault,
|
||||
ContrastBackgroundColor: tcell.ColorGray,
|
||||
MoreContrastBackgroundColor: tcell.ColorSteelBlue,
|
||||
BorderColor: tcell.ColorGray,
|
||||
TitleColor: tcell.ColorRed,
|
||||
GraphicsColor: tcell.ColorBlue,
|
||||
PrimaryTextColor: tcell.ColorLightGray,
|
||||
SecondaryTextColor: tcell.ColorYellow,
|
||||
TertiaryTextColor: tcell.ColorOrange,
|
||||
InverseTextColor: tcell.ColorPurple,
|
||||
ContrastSecondaryTextColor: tcell.ColorLime,
|
||||
},
|
||||
"gruvbox": tview.Theme{
|
||||
PrimitiveBackgroundColor: tcell.NewHexColor(0x282828), // Background: #282828 (dark gray)
|
||||
ContrastBackgroundColor: tcell.ColorDarkGoldenrod, // Selected option: warm yellow (#b57614)
|
||||
MoreContrastBackgroundColor: tcell.ColorDarkSlateGray, // Non-selected options: dark grayish-blue (#32302f)
|
||||
BorderColor: tcell.ColorLightGray, // Light gray (#a89984)
|
||||
TitleColor: tcell.ColorRed, // Red (#fb4934)
|
||||
GraphicsColor: tcell.ColorDarkCyan, // Cyan (#689d6a)
|
||||
PrimaryTextColor: tcell.ColorLightGray, // Light gray (#d5c4a1)
|
||||
SecondaryTextColor: tcell.ColorYellow, // Yellow (#fabd2f)
|
||||
TertiaryTextColor: tcell.ColorOrange, // Orange (#fe8019)
|
||||
InverseTextColor: tcell.ColorWhite, // White (#f9f5d7) for selected text
|
||||
ContrastSecondaryTextColor: tcell.ColorLightGreen, // Light green (#b8bb26)
|
||||
},
|
||||
"solarized": tview.Theme{
|
||||
PrimitiveBackgroundColor: tcell.NewHexColor(0x002b36), // Background: #002b36 (base03)
|
||||
ContrastBackgroundColor: tcell.ColorDarkCyan, // Selected option: cyan (#2aa198)
|
||||
MoreContrastBackgroundColor: tcell.ColorDarkSlateGray, // Non-selected options: dark blue (#073642)
|
||||
BorderColor: tcell.ColorLightBlue, // Light blue (#839496)
|
||||
TitleColor: tcell.ColorRed, // Red (#dc322f)
|
||||
GraphicsColor: tcell.ColorBlue, // Blue (#268bd2)
|
||||
PrimaryTextColor: tcell.ColorWhite, // White (#fdf6e3)
|
||||
SecondaryTextColor: tcell.ColorYellow, // Yellow (#b58900)
|
||||
TertiaryTextColor: tcell.ColorOrange, // Orange (#cb4b16)
|
||||
InverseTextColor: tcell.ColorWhite, // White (#eee8d5) for selected text
|
||||
ContrastSecondaryTextColor: tcell.ColorLightCyan, // Light cyan (#93a1a1)
|
||||
},
|
||||
"dracula": tview.Theme{
|
||||
PrimitiveBackgroundColor: tcell.NewHexColor(0x282a36), // Background: #282a36
|
||||
ContrastBackgroundColor: tcell.ColorDarkMagenta, // Selected option: magenta (#bd93f9)
|
||||
MoreContrastBackgroundColor: tcell.ColorDarkGray, // Non-selected options: dark gray (#44475a)
|
||||
BorderColor: tcell.ColorLightGray, // Light gray (#f8f8f2)
|
||||
TitleColor: tcell.ColorRed, // Red (#ff5555)
|
||||
GraphicsColor: tcell.ColorDarkCyan, // Cyan (#8be9fd)
|
||||
PrimaryTextColor: tcell.ColorWhite, // White (#f8f8f2)
|
||||
SecondaryTextColor: tcell.ColorYellow, // Yellow (#f1fa8c)
|
||||
TertiaryTextColor: tcell.ColorOrange, // Orange (#ffb86c)
|
||||
InverseTextColor: tcell.ColorWhite, // White (#f8f8f2) for selected text
|
||||
ContrastSecondaryTextColor: tcell.ColorLightGreen, // Light green (#50fa7b)
|
||||
},
|
||||
}
|
||||
)
|
||||
@@ -433,7 +433,7 @@ func updateFlexLayout() {
|
||||
flex.AddItem(textView, 0, 40, false)
|
||||
flex.AddItem(textArea, 0, 10, false)
|
||||
if positionVisible {
|
||||
flex.AddItem(statusLineWidget, 0, 4, false)
|
||||
flex.AddItem(statusLineWidget, 0, 2, false)
|
||||
}
|
||||
// Keep focus on currently focused widget
|
||||
focused := app.GetFocus()
|
||||
|
||||
63
tui.go
63
tui.go
@@ -10,14 +10,11 @@ import (
|
||||
"path"
|
||||
"strconv"
|
||||
"strings"
|
||||
"sync"
|
||||
|
||||
"github.com/gdamore/tcell/v2"
|
||||
"github.com/rivo/tview"
|
||||
)
|
||||
|
||||
var _ = sync.RWMutex{}
|
||||
|
||||
var (
|
||||
app *tview.Application
|
||||
pages *tview.Pages
|
||||
@@ -120,66 +117,11 @@ var (
|
||||
|
||||
Press <Enter> or 'x' to return
|
||||
`
|
||||
colorschemes = map[string]tview.Theme{
|
||||
"default": tview.Theme{
|
||||
PrimitiveBackgroundColor: tcell.ColorDefault,
|
||||
ContrastBackgroundColor: tcell.ColorGray,
|
||||
MoreContrastBackgroundColor: tcell.ColorSteelBlue,
|
||||
BorderColor: tcell.ColorGray,
|
||||
TitleColor: tcell.ColorRed,
|
||||
GraphicsColor: tcell.ColorBlue,
|
||||
PrimaryTextColor: tcell.ColorLightGray,
|
||||
SecondaryTextColor: tcell.ColorYellow,
|
||||
TertiaryTextColor: tcell.ColorOrange,
|
||||
InverseTextColor: tcell.ColorPurple,
|
||||
ContrastSecondaryTextColor: tcell.ColorLime,
|
||||
},
|
||||
"gruvbox": tview.Theme{
|
||||
PrimitiveBackgroundColor: tcell.NewHexColor(0x282828), // Background: #282828 (dark gray)
|
||||
ContrastBackgroundColor: tcell.ColorDarkGoldenrod, // Selected option: warm yellow (#b57614)
|
||||
MoreContrastBackgroundColor: tcell.ColorDarkSlateGray, // Non-selected options: dark grayish-blue (#32302f)
|
||||
BorderColor: tcell.ColorLightGray, // Light gray (#a89984)
|
||||
TitleColor: tcell.ColorRed, // Red (#fb4934)
|
||||
GraphicsColor: tcell.ColorDarkCyan, // Cyan (#689d6a)
|
||||
PrimaryTextColor: tcell.ColorLightGray, // Light gray (#d5c4a1)
|
||||
SecondaryTextColor: tcell.ColorYellow, // Yellow (#fabd2f)
|
||||
TertiaryTextColor: tcell.ColorOrange, // Orange (#fe8019)
|
||||
InverseTextColor: tcell.ColorWhite, // White (#f9f5d7) for selected text
|
||||
ContrastSecondaryTextColor: tcell.ColorLightGreen, // Light green (#b8bb26)
|
||||
},
|
||||
"solarized": tview.Theme{
|
||||
PrimitiveBackgroundColor: tcell.NewHexColor(0x002b36), // Background: #002b36 (base03)
|
||||
ContrastBackgroundColor: tcell.ColorDarkCyan, // Selected option: cyan (#2aa198)
|
||||
MoreContrastBackgroundColor: tcell.ColorDarkSlateGray, // Non-selected options: dark blue (#073642)
|
||||
BorderColor: tcell.ColorLightBlue, // Light blue (#839496)
|
||||
TitleColor: tcell.ColorRed, // Red (#dc322f)
|
||||
GraphicsColor: tcell.ColorBlue, // Blue (#268bd2)
|
||||
PrimaryTextColor: tcell.ColorWhite, // White (#fdf6e3)
|
||||
SecondaryTextColor: tcell.ColorYellow, // Yellow (#b58900)
|
||||
TertiaryTextColor: tcell.ColorOrange, // Orange (#cb4b16)
|
||||
InverseTextColor: tcell.ColorWhite, // White (#eee8d5) for selected text
|
||||
ContrastSecondaryTextColor: tcell.ColorLightCyan, // Light cyan (#93a1a1)
|
||||
},
|
||||
"dracula": tview.Theme{
|
||||
PrimitiveBackgroundColor: tcell.NewHexColor(0x282a36), // Background: #282a36
|
||||
ContrastBackgroundColor: tcell.ColorDarkMagenta, // Selected option: magenta (#bd93f9)
|
||||
MoreContrastBackgroundColor: tcell.ColorDarkGray, // Non-selected options: dark gray (#44475a)
|
||||
BorderColor: tcell.ColorLightGray, // Light gray (#f8f8f2)
|
||||
TitleColor: tcell.ColorRed, // Red (#ff5555)
|
||||
GraphicsColor: tcell.ColorDarkCyan, // Cyan (#8be9fd)
|
||||
PrimaryTextColor: tcell.ColorWhite, // White (#f8f8f2)
|
||||
SecondaryTextColor: tcell.ColorYellow, // Yellow (#f1fa8c)
|
||||
TertiaryTextColor: tcell.ColorOrange, // Orange (#ffb86c)
|
||||
InverseTextColor: tcell.ColorWhite, // White (#f8f8f2) for selected text
|
||||
ContrastSecondaryTextColor: tcell.ColorLightGreen, // Light green (#50fa7b)
|
||||
},
|
||||
}
|
||||
)
|
||||
|
||||
func init() {
|
||||
// Start background goroutine to update model color cache
|
||||
startModelColorUpdater()
|
||||
|
||||
tview.Styles = colorschemes["default"]
|
||||
app = tview.NewApplication()
|
||||
pages = tview.NewPages()
|
||||
@@ -290,6 +232,11 @@ func init() {
|
||||
statusLineWidget = tview.NewTextView().
|
||||
SetDynamicColors(true).
|
||||
SetTextAlign(tview.AlignCenter)
|
||||
// // vertical text center alignment
|
||||
// statusLineWidget.SetDrawFunc(func(screen tcell.Screen, x, y, w, h int) (int, int, int, int) {
|
||||
// y += h / 2
|
||||
// return x, y, w, h
|
||||
// })
|
||||
// Initially set up flex without search bar
|
||||
flex = tview.NewFlex().SetDirection(tview.FlexRow).
|
||||
AddItem(textView, 0, 40, false).
|
||||
|
||||
Reference in New Issue
Block a user