mirror of
https://github.com/walles/moar.git
synced 2024-08-17 07:50:35 +03:00
Attempt to set status bar color from theme
Fails due to: https://github.com/alecthomas/chroma/issues/867
This commit is contained in:
parent
64e9d4db5e
commit
b5299f6fbc
23
m/pager.go
23
m/pager.go
@ -482,9 +482,20 @@ func (p *Pager) initStyle() {
|
|||||||
p.numberStyle = parsedTokens[0].Style
|
p.numberStyle = parsedTokens[0].Style
|
||||||
}
|
}
|
||||||
|
|
||||||
statusBarStyleAnsi := toAnsiSgr(chroma.None, *p.ChromaStyle, *p.ChromaFormatter) + "X"
|
statusBarStyleAnsi := toAnsiSgr(chroma.Background, *p.ChromaStyle, *p.ChromaFormatter) + "X"
|
||||||
if statusBarStyleAnsi == "X" {
|
if statusBarStyleAnsi == "X" {
|
||||||
p.statusBarStyle = twin.StyleDefault
|
p.statusBarStyle = twin.StyleDefault
|
||||||
|
|
||||||
|
switch p.StatusBarStyleOption {
|
||||||
|
case STATUSBAR_STYLE_INVERSE:
|
||||||
|
p.statusBarStyle = p.statusBarStyle.WithAttr(twin.AttrReverse)
|
||||||
|
case STATUSBAR_STYLE_PLAIN:
|
||||||
|
// This case intentionally left blank
|
||||||
|
case STATUSBAR_STYLE_BOLD:
|
||||||
|
p.statusBarStyle = p.statusBarStyle.WithAttr(twin.AttrBold)
|
||||||
|
default:
|
||||||
|
panic(fmt.Sprint("Unknown status bar style option: ", p.StatusBarStyleOption))
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
// Turn statusBarStyleAnsi into a twin.Style
|
// Turn statusBarStyleAnsi into a twin.Style
|
||||||
statusBarStyleAsLine := NewLine(statusBarStyleAnsi)
|
statusBarStyleAsLine := NewLine(statusBarStyleAnsi)
|
||||||
@ -494,16 +505,6 @@ func (p *Pager) initStyle() {
|
|||||||
}
|
}
|
||||||
p.statusBarStyle = parsedTokens[0].Style
|
p.statusBarStyle = parsedTokens[0].Style
|
||||||
}
|
}
|
||||||
switch p.StatusBarStyleOption {
|
|
||||||
case STATUSBAR_STYLE_INVERSE:
|
|
||||||
p.statusBarStyle = p.statusBarStyle.WithAttr(twin.AttrReverse)
|
|
||||||
case STATUSBAR_STYLE_PLAIN:
|
|
||||||
// This case intentionally left blank
|
|
||||||
case STATUSBAR_STYLE_BOLD:
|
|
||||||
p.statusBarStyle = p.statusBarStyle.WithAttr(twin.AttrBold)
|
|
||||||
default:
|
|
||||||
panic(fmt.Sprint("Unknown status bar style option: ", p.StatusBarStyleOption))
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// StartPaging brings up the pager on screen
|
// StartPaging brings up the pager on screen
|
||||||
|
@ -590,6 +590,8 @@ func TestInitStyle(t *testing.T) {
|
|||||||
}
|
}
|
||||||
testMe.initStyle()
|
testMe.initStyle()
|
||||||
assert.Equal(t, testMe.linePrefix, "\x1b[38;2;235;219;178m")
|
assert.Equal(t, testMe.linePrefix, "\x1b[38;2;235;219;178m")
|
||||||
|
assert.Equal(t, testMe.statusBarStyle,
|
||||||
|
twin.StyleDefault.Foreground(twin.NewColorHex(0xebdbb2)).Background(twin.NewColorHex(0x282828)))
|
||||||
}
|
}
|
||||||
|
|
||||||
func benchmarkSearch(b *testing.B, highlighted bool) {
|
func benchmarkSearch(b *testing.B, highlighted bool) {
|
||||||
|
Loading…
Reference in New Issue
Block a user