package app import ( "path/filepath" "strings" "glint/internal/theme" "github.com/charmbracelet/lipgloss" ) // headerText is the name shown in the editor's filename bar: the file's // basename without its extension, or "Untitled" for a buffer with no path. A // frontmatter "title" deliberately does not override it — edit mode shows what // is on disk. Unsaved changes append a bullet. func (a *App) headerText() string { name := "Untitled" if a.path != "" { base := filepath.Base(a.path) name = strings.TrimSuffix(base, filepath.Ext(base)) } if a.editor.Dirty { name += " •" } return name } // showHeader reports whether the filename bar belongs on screen: in the editor // and the overlays that keep it visible beneath them. The picker has its own // layout, help replaces the body, and preview draws its own title bar. func (a *App) showHeader() bool { switch a.mode { case ModeEditor, ModeFind, ModeGotoLine, ModeSpell: return true } return false } // headerBar renders the filename as one content-column-wide row: a bold filled // block in the heading color for a named file, muted plain text for an unnamed // buffer so "unsaved and unnamed" reads at a glance. Returns "" when the header // does not belong on screen. func (a *App) headerBar() string { if !a.showHeader() { return "" } w := a.contentWidth() if w < 3 { return "" } label := truncate(" "+a.headerText()+" ", w) if a.path == "" { return lipgloss.NewStyle(). Foreground(a.theme.Muted). Background(a.theme.Background). Width(w). Render(label) } return lipgloss.NewStyle(). Bold(true). Foreground(lipgloss.Color(theme.LegibleText(string(a.theme.Heading)))). Background(a.theme.Heading). Width(w). Render(label) }