mirror of
https://github.com/charmbracelet/glow
synced 2024-11-10 06:04:18 +00:00
Style detailed help view and re-style mini help view
This commit is contained in:
parent
92d7696c76
commit
d21802dbc6
3 changed files with 35 additions and 23 deletions
39
ui/stash.go
39
ui/stash.go
|
@ -29,10 +29,9 @@ const (
|
|||
)
|
||||
|
||||
var (
|
||||
stashHelpItemStyle styleFunc = newFgStyle(common.NewColorPair("#5C5C5C", "#9B9B9B"))
|
||||
stashTextInputPromptStyle styleFunc = newFgStyle(common.YellowGreen)
|
||||
dividerDot string = te.String(" • ").Foreground(common.NewColorPair("#3C3C3C", "#DDDADA").Color()).String()
|
||||
offlineHeaderNote string = te.String("(Offline)").Foreground(common.NewColorPair("#3C3C3C", "#DDDADA").Color()).String()
|
||||
dividerDot string = darkGrayFg(" • ")
|
||||
offlineHeaderNote string = darkGrayFg("(Offline)")
|
||||
)
|
||||
|
||||
// MSG
|
||||
|
@ -403,7 +402,8 @@ func newStashModel(general *general) stashModel {
|
|||
|
||||
p := paginator.NewModel()
|
||||
p.Type = paginator.Dots
|
||||
p.InactiveDot = common.Subtle("•")
|
||||
p.ActiveDot = brightGrayFg("•")
|
||||
p.InactiveDot = darkGrayFg("•")
|
||||
|
||||
ni := textinput.NewModel()
|
||||
ni.Prompt = stashTextInputPromptStyle("Memo: ")
|
||||
|
@ -1181,13 +1181,13 @@ func (m stashModel) helpView() (string, int) {
|
|||
}
|
||||
|
||||
if m.showFullHelp {
|
||||
if m.filterState != filtering {
|
||||
if m.filterState != filtering && m.selectionState == selectionIdle {
|
||||
appHelp = append(appHelp, "?", "close help")
|
||||
}
|
||||
s = m.fullHelpView(navHelp, filterHelp, selectionHelp, sectionHelp, appHelp)
|
||||
} else {
|
||||
if m.filterState != filtering {
|
||||
appHelp = append(appHelp, "?", "help")
|
||||
if m.filterState != filtering && m.selectionState == selectionIdle {
|
||||
appHelp = append(appHelp, "?", "more")
|
||||
}
|
||||
s = m.miniHelpView(concatStringSlices(
|
||||
filterHelp,
|
||||
|
@ -1221,17 +1221,20 @@ func (m stashModel) miniHelpView(entries ...string) string {
|
|||
)
|
||||
|
||||
for i := 0; i < len(entries); i = i + 2 {
|
||||
next = fmt.Sprintf("%s: %s", entries[i], entries[i+1])
|
||||
k := entries[i]
|
||||
v := entries[i+1]
|
||||
|
||||
// If we need this more often we'll formalize something rather than
|
||||
// use an if clause/switch here.
|
||||
switch entries[i+1] {
|
||||
case "stash":
|
||||
next = greenFg(next)
|
||||
switch k {
|
||||
case "s":
|
||||
k = greenFg(k)
|
||||
v = dimGreenFg(v)
|
||||
default:
|
||||
next = stashHelpItemStyle(next)
|
||||
k = grayFg(k)
|
||||
v = midGrayFg(v)
|
||||
}
|
||||
|
||||
next = fmt.Sprintf("%s %s", k, v)
|
||||
|
||||
if i < len(entries)-2 {
|
||||
next += dividerDot
|
||||
}
|
||||
|
@ -1323,6 +1326,14 @@ func buildHelpTextColumn(keys, vals []string, colHeight int) (rows []string) {
|
|||
if i < len(vals) {
|
||||
v = vals[i]
|
||||
}
|
||||
switch k {
|
||||
case "s":
|
||||
k = greenFg(k)
|
||||
v = dimGreenFg(v)
|
||||
default:
|
||||
k = grayFg(k)
|
||||
v = midGrayFg(v)
|
||||
}
|
||||
b.WriteString(k)
|
||||
b.WriteString(strings.Repeat(" ", keyWidth-ansi.PrintableRuneWidth(k))) // pad keys
|
||||
b.WriteString(" ") // gap
|
||||
|
|
|
@ -94,24 +94,24 @@ func stashItemView(b *strings.Builder, m stashModel, index int, md *markdown) {
|
|||
} else if isFiltering && m.filterInput.Value() == "" {
|
||||
icon = dimGreenFg(icon)
|
||||
if title == noMemoTitle {
|
||||
title = dimWarmGrayFg(title)
|
||||
title = dimBrightGrayFg(title)
|
||||
} else {
|
||||
title = dimNormalFg(title)
|
||||
}
|
||||
gutter = " "
|
||||
date = dimWarmGrayFg(date)
|
||||
date = dimBrightGrayFg(date)
|
||||
|
||||
} else {
|
||||
|
||||
icon = greenFg(icon)
|
||||
if title == noMemoTitle {
|
||||
title = warmGrayFg(title)
|
||||
title = brightGrayFg(title)
|
||||
} else {
|
||||
s := termenv.Style{}.Foreground(common.NewColorPair("#dddddd", "#1a1a1a").Color())
|
||||
title = styleFilteredText(title, m.filterInput.Value(), s, s.Underline())
|
||||
}
|
||||
gutter = " "
|
||||
date = warmGrayFg(date)
|
||||
date = brightGrayFg(date)
|
||||
}
|
||||
|
||||
}
|
||||
|
|
11
ui/styles.go
11
ui/styles.go
|
@ -15,14 +15,15 @@ var (
|
|||
normalFg = newFgStyle(common.NewColorPair("#dddddd", "#1a1a1a"))
|
||||
dimNormalFg = newFgStyle(common.NewColorPair("#777777", "#A49FA5"))
|
||||
|
||||
warmGrayFg = newFgStyle(common.NewColorPair("#979797", "#847A85"))
|
||||
dimWarmGrayFg = newFgStyle(common.NewColorPair("#4D4D4D", "#C2B8C2"))
|
||||
brightGrayFg = newFgStyle(common.NewColorPair("#979797", "#847A85"))
|
||||
dimBrightGrayFg = newFgStyle(common.NewColorPair("#4D4D4D", "#C2B8C2"))
|
||||
|
||||
grayFg = newFgStyle(common.NewColorPair("#626262", "#000"))
|
||||
dimGrayFg = newFgStyle(common.NewColorPair("#3F3F3F", "#000"))
|
||||
grayFg = newFgStyle(common.NewColorPair("#626262", "#909090"))
|
||||
midGrayFg = newFgStyle(common.NewColorPair("#434343", "#BCBCBC"))
|
||||
darkGrayFg = newFgStyle(common.NewColorPair("#3C3C3C", "#DDDADA"))
|
||||
|
||||
greenFg = newFgStyle(common.NewColorPair("#04B575", "#04B575"))
|
||||
dimGreenFg = newFgStyle(common.NewColorPair("#0B5137", "#82E1BF"))
|
||||
dimGreenFg = newFgStyle(common.NewColorPair("#0B5137", "#72D2B0"))
|
||||
|
||||
fuchsiaFg = newFgStyle(common.Fuschia)
|
||||
dimFuchsiaFg = newFgStyle(common.NewColorPair("#99519E", "#F1A8FF"))
|
||||
|
|
Loading…
Reference in a new issue