diff --git a/internal/config/config.toml b/internal/config/config.toml index 41d196a..e9ac182 100644 --- a/internal/config/config.toml +++ b/internal/config/config.toml @@ -169,7 +169,7 @@ down = "ctrl+n" top = "home" bottom = "end" -# style = { foreground = "", background = "", attributes = "" or [""] } +# style = { foreground = "", background = "", attributes = "" or ["",""], underline = "", underline_color = "" } [theme.title] alignment = "left" # `"left"`, `"center"`, or `"right"`. normal_style = { attributes = "dim" } @@ -208,7 +208,7 @@ thumb_style = {} reply_indicator = ">" forwarded_indicator = "<" -mention_style = { foreground = "blue" } +mention_style = { foreground = "blue", attributes = "bold" } emoji_style = { foreground = "green" } url_style = { foreground = "blue" } attachment_style = { foreground = "yellow" } diff --git a/internal/config/theme.go b/internal/config/theme.go index 8e215e7..9bea7a2 100644 --- a/internal/config/theme.go +++ b/internal/config/theme.go @@ -44,45 +44,65 @@ func (sw *StyleWrapper) UnmarshalTOML(v any) error { for key, val := range m { switch key { case "foreground": - s, ok := val.(string) - if !ok { - continue + if s, ok := val.(string); ok { + sw.Style = sw.Foreground(tcell.GetColor(s)) } - - color := tcell.GetColor(s) - sw.Style = sw.Foreground(color) case "background": - s, ok := val.(string) - if !ok { - continue + if s, ok := val.(string); ok { + sw.Style = sw.Background(tcell.GetColor(s)) } - - color := tcell.GetColor(s) - sw.Style = sw.Background(color) case "attributes": - var attrs tcell.AttrMask switch val := val.(type) { case string: - attrs |= stringToAttrMask(val) + sw.parseAttr(val) case []any: for _, attr := range val { - s, ok := attr.(string) - if !ok { - continue + if s, ok := attr.(string); ok { + sw.parseAttr(s) } - - attrs |= stringToAttrMask(s) } } - - sw.Style = sw.Attributes(attrs) + case "underline": + if s, ok := val.(string); ok { + switch s { + case "": sw.Style = sw.Underline(tcell.UnderlineStyleNone) + case "solid": sw.Style = sw.Underline(tcell.UnderlineStyleSolid) + case "double": sw.Style = sw.Underline(tcell.UnderlineStyleDouble) + case "curly": sw.Style = sw.Underline(tcell.UnderlineStyleCurly) + case "dotted": sw.Style = sw.Underline(tcell.UnderlineStyleDotted) + case "dashed": sw.Style = sw.Underline(tcell.UnderlineStyleDashed) + } + } + case "underline_color": + if s, ok := val.(string); ok { + sw.Style = sw.Underline(tcell.GetColor(s)) + } } } return nil } +func (sw *StyleWrapper) parseAttr(s string) { + switch s { + case "underline": + sw.Style = sw.Underline(true) + case "bold": + sw.Style = sw.Bold(true) + case "blink": + sw.Style = sw.Blink(true) + case "reverse": + sw.Style = sw.Reverse(true) + case "dim": + sw.Style = sw.Dim(true) + case "italic": + sw.Style = sw.Italic(true) + case "strikethrough": + sw.Style = sw.StrikeThrough(true) + } +} + type BorderSetWrapper struct{ tview.BorderSet } func (bw *BorderSetWrapper) UnmarshalTOML(val any) error { @@ -227,22 +247,3 @@ type ( Help HelpTheme `toml:"help"` } ) - -func stringToAttrMask(s string) tcell.AttrMask { - switch s { - case "bold": - return tcell.AttrBold - case "blink": - return tcell.AttrBlink - case "reverse": - return tcell.AttrReverse - case "dim": - return tcell.AttrDim - case "italic": - return tcell.AttrItalic - case "strikethrough": - return tcell.AttrStrikeThrough - default: - return tcell.AttrNone - } -}