Skip to content

Commit

Permalink
Revert "Merge branch 'johan/ui-colors-from-chroma'"
Browse files Browse the repository at this point in the history
This reverts commit ed49174, reversing
changes made to 12f316f.

Before this goes in, we should first auto detect bright vs dark terminal
background and default to different themes in those two cases: #67
  • Loading branch information
walles committed Dec 28, 2023
1 parent 7940474 commit e80c604
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 103 deletions.
43 changes: 2 additions & 41 deletions m/styling.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,42 +55,6 @@ func twinStyleFromChroma(chromaStyle *chroma.Style, chromaFormatter *chroma.Form
return &cells[0].Style
}

func backgroundStyleFromChroma(chromaStyle chroma.Style) twin.Style {
backgroundEntry := chromaStyle.Get(chroma.Background)

backgroundColor := twin.ColorDefault
if backgroundEntry.Background.IsSet() {
backgroundColor = twin.NewColor24Bit(
backgroundEntry.Background.Red(),
backgroundEntry.Background.Green(),
backgroundEntry.Background.Blue())
}

foregroundColor := twin.ColorDefault
if backgroundEntry.Colour.IsSet() {
foregroundColor = twin.NewColor24Bit(
backgroundEntry.Colour.Red(),
backgroundEntry.Colour.Green(),
backgroundEntry.Colour.Blue())
}

returnMe := twin.StyleDefault.
WithBackground(backgroundColor).
WithForeground(foregroundColor)

if backgroundEntry.Bold == chroma.Yes {
returnMe = returnMe.WithAttr(twin.AttrBold)
}
if backgroundEntry.Italic == chroma.Yes {
returnMe = returnMe.WithAttr(twin.AttrItalic)
}
if backgroundEntry.Underline == chroma.Yes {
returnMe = returnMe.WithAttr(twin.AttrUnderline)
}

return returnMe
}

// consumeLessTermcapEnvs parses LESS_TERMCAP_xx environment variables and
// adapts the moar output accordingly.
func consumeLessTermcapEnvs(chromaStyle *chroma.Style, chromaFormatter *chroma.Formatter) {
Expand Down Expand Up @@ -124,11 +88,8 @@ func styleUi(chromaStyle *chroma.Style, chromaFormatter *chroma.Formatter, statu
if standoutStyle != nil {
statusbarStyle = *standoutStyle
} else if statusbarOption == STATUSBAR_STYLE_INVERSE {
if chromaStyle != nil {
statusbarStyle = backgroundStyleFromChroma(*chromaStyle).WithAttr(twin.AttrReverse)
} else {
statusbarStyle = twin.StyleDefault.WithAttr(twin.AttrReverse)
}
// FIXME: Get this from the Chroma style
statusbarStyle = twin.StyleDefault.WithAttr(twin.AttrReverse)
} else if statusbarOption == STATUSBAR_STYLE_PLAIN {
plain := twinStyleFromChroma(chromaStyle, chromaFormatter, chroma.None)
if plain != nil {
Expand Down
54 changes: 0 additions & 54 deletions m/styling_test.go

This file was deleted.

8 changes: 0 additions & 8 deletions twin/styles.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,14 +117,6 @@ func (attr AttrMask) has(attrs AttrMask) bool {
return attr&attrs != 0
}

func (style Style) Background() Color {
return style.bg
}

func (style Style) Foreground() Color {
return style.fg
}

func (style Style) WithBackground(color Color) Style {
return Style{
fg: style.fg,
Expand Down

0 comments on commit e80c604

Please sign in to comment.