summaryrefslogtreecommitdiff
path: root/config.go
diff options
context:
space:
mode:
authordelthas <delthas@dille.cc>2022-08-15 15:57:06 +0200
committerdelthas <delthas@dille.cc>2022-08-15 15:57:06 +0200
commitf23dd3273dd29a32c7c759aab0fb34a3784bd5d0 (patch)
tree55bb578a8420a1ec8422ad54f709b973cc5744c4 /config.go
parentAdd a project description (diff)
Revert to using base colors by default, making extended configurable
In a previous commit, the color scheme for displaying nicks was changed to use more colors (30 rather than 14), using extended colors from the 256 colors set. The issue with this is that most terminal emulators customize the colors of the first 16 colors to make them more readable (eg, a terminal emulator with a light theme will make colors darker, and one with a dark theme will make colors lighter). So the 14 colors used before were usually not the default color codes from the original xterm/X11 spec, but specific colors chosen by the terminal emulator to be particularly readable. In a way, changing the behavior to use colors from the 256 colors set, which is usually not overriden, made them much less readable. Which is why we need a configuration option for this. I conversatively chose to make the default color scheme the previous one, with only the base 16 colors. The 256 colors scheme can be enable by adding to the configuration file: colors { nicks extended }
Diffstat (limited to 'config.go')
-rw-r--r--config.go17
1 files changed, 17 insertions, 0 deletions
diff --git a/config.go b/config.go
index 2450e75..9ee6d09 100644
--- a/config.go
+++ b/config.go
@@ -9,6 +9,8 @@ import (
"strconv"
"strings"
+ "git.sr.ht/~taiite/senpai/ui"
+
"github.com/gdamore/tcell/v2"
"git.sr.ht/~emersion/go-scfg"
@@ -47,6 +49,7 @@ func parseColor(s string, c *tcell.Color) error {
type ConfigColors struct {
Prompt tcell.Color
Unread tcell.Color
+ Nicks ui.ColorScheme
}
type Config struct {
@@ -107,6 +110,7 @@ func Defaults() (cfg Config, err error) {
Colors: ConfigColors{
Prompt: tcell.ColorDefault,
Unread: tcell.ColorDefault,
+ Nicks: ui.ColorSchemeBase,
},
Debug: false,
}
@@ -301,6 +305,19 @@ func unmarshal(filename string, cfg *Config) (err error) {
return err
}
+ switch child.Name {
+ case "nicks":
+ switch colorStr {
+ case "base":
+ cfg.Colors.Nicks = ui.ColorSchemeBase
+ case "extended":
+ cfg.Colors.Nicks = ui.ColorSchemeExtended
+ default:
+ return fmt.Errorf("unknown nick color scheme %q", colorStr)
+ }
+ continue
+ }
+
var color tcell.Color
if err = parseColor(colorStr, &color); err != nil {
return err