diff --git a/style.go b/style.go index 366bbc4..81a1c2d 100644 --- a/style.go +++ b/style.go @@ -4,7 +4,7 @@ import . "github.com/charmbracelet/lipgloss" //nolint:revive var ( keyword = NewStyle(). - Foreground(AdaptiveColor{Light: "#04B575", Dark: "#04B575"}). + Foreground(Color("#04B575")). Render paragraph = NewStyle(). diff --git a/ui/pager.go b/ui/pager.go index f93fd0b..95f6025 100644 --- a/ui/pager.go +++ b/ui/pager.go @@ -32,7 +32,7 @@ var ( Foreground(cream). Background(green). Padding(0, 1). - Render("Set Memo") + SetString("Set Memo") statusBarNoteFg = lipgloss.AdaptiveColor{Light: "#656565", Dark: "#7D7D7D"} statusBarBg = lipgloss.AdaptiveColor{Light: "#E6E6E6", Dark: "#242424"} @@ -168,7 +168,7 @@ func (m *pagerModel) setSize(w, h int) { m.viewport.Width = w m.viewport.Height = h - statusBarHeight m.textInput.Width = w - - ansi.PrintableRuneWidth(noteHeading) - + ansi.PrintableRuneWidth(noteHeading.String()) - ansi.PrintableRuneWidth(m.textInput.Prompt) - 1 if m.showHelp { diff --git a/ui/stash.go b/ui/stash.go index b258ca6..c61ac32 100644 --- a/ui/stash.go +++ b/ui/stash.go @@ -34,9 +34,9 @@ var ( ) var ( - dividerDot = darkGrayFg(" • ") - dividerBar = darkGrayFg(" │ ") - offlineHeaderNote = darkGrayFg("(Offline)") + dividerDot = darkGrayFg.SetString(" • ") + dividerBar = darkGrayFg.SetString(" │ ") + offlineHeaderNote = darkGrayFg.SetString("(Offline)") logoStyle = lipgloss.NewStyle(). Foreground(lipgloss.Color("#ECFD65")). @@ -98,28 +98,7 @@ type section struct { } // map sections to their associated types. -var sections = map[sectionKey]section{ - localSection: { - key: localSection, - docTypes: NewDocTypeSet(LocalDoc), - paginator: newStashPaginator(), - }, - stashedSection: { - key: stashedSection, - docTypes: NewDocTypeSet(StashedDoc, ConvertedDoc), - paginator: newStashPaginator(), - }, - newsSection: { - key: newsSection, - docTypes: NewDocTypeSet(NewsDoc), - paginator: newStashPaginator(), - }, - filterSection: { - key: filterSection, - docTypes: DocTypeSet{}, - paginator: newStashPaginator(), - }, -} +var sections = map[sectionKey]section{} // filterState is the current filtering state in the file listing. type filterState int @@ -155,6 +134,31 @@ type statusMessage struct { message string } +func initSections() { + sections = map[sectionKey]section{ + localSection: { + key: localSection, + docTypes: NewDocTypeSet(LocalDoc), + paginator: newStashPaginator(), + }, + stashedSection: { + key: stashedSection, + docTypes: NewDocTypeSet(StashedDoc, ConvertedDoc), + paginator: newStashPaginator(), + }, + newsSection: { + key: newsSection, + docTypes: NewDocTypeSet(NewsDoc), + paginator: newStashPaginator(), + }, + filterSection: { + key: filterSection, + docTypes: DocTypeSet{}, + paginator: newStashPaginator(), + }, + } +} + // String returns a styled version of the status message appropriate for the // given context. func (s statusMessage) String() string { @@ -563,7 +567,7 @@ func newStashPaginator() paginator.Model { p := paginator.New() p.Type = paginator.Dots p.ActiveDot = brightGrayFg("•") - p.InactiveDot = darkGrayFg("•") + p.InactiveDot = darkGrayFg.Render("•") return p } @@ -1255,13 +1259,13 @@ func (m stashModel) headerView() string { sections[i] = grayFg(sections[i]) } - return strings.Join(sections, dividerDot) + return strings.Join(sections, dividerDot.String()) } if m.loadingDone() && len(m.markdowns) == 0 { var maybeOffline string if m.common.authStatus == authFailed { - maybeOffline = " " + offlineHeaderNote + maybeOffline = " " + offlineHeaderNote.String() } if m.stashedOnly() { @@ -1302,9 +1306,9 @@ func (m stashModel) headerView() string { sections = append(sections, s) } - s := strings.Join(sections, dividerBar) + s := strings.Join(sections, dividerBar.String()) if m.common.authStatus == authFailed { - s += dividerDot + offlineHeaderNote + s += dividerDot.String() + offlineHeaderNote.String() } return s diff --git a/ui/stashhelp.go b/ui/stashhelp.go index 6c0b88d..2b30c2e 100644 --- a/ui/stashhelp.go +++ b/ui/stashhelp.go @@ -231,7 +231,7 @@ func (m stashModel) miniHelpView(entries ...string) string { next = fmt.Sprintf("%s %s", k, v) if i < len(entries)-2 { - next += dividerDot + next += dividerDot.String() } // Only this (and the following) help text items if we have the diff --git a/ui/styles.go b/ui/styles.go index a539c58..e5a6c83 100644 --- a/ui/styles.go +++ b/ui/styles.go @@ -41,7 +41,7 @@ var ( grayFg = NewStyle().Foreground(gray).Render midGrayFg = NewStyle().Foreground(midGray).Render - darkGrayFg = NewStyle().Foreground(darkGray).Render + darkGrayFg = NewStyle().Foreground(darkGray) greenFg = NewStyle().Foreground(green).Render semiDimGreenFg = NewStyle().Foreground(semiDimGreen).Render diff --git a/ui/ui.go b/ui/ui.go index bc0ef88..df7e37f 100644 --- a/ui/ui.go +++ b/ui/ui.go @@ -199,6 +199,8 @@ func (m *model) unloadDocument() []tea.Cmd { } func newModel(cfg Config) tea.Model { + initSections() + if cfg.GlamourStyle == "auto" { if te.HasDarkBackground() { cfg.GlamourStyle = "dark"