add a simple status bar

This commit is contained in:
2026-01-04 03:00:24 +00:00
parent 3ecc365a9b
commit 500d9bc8e8
2 changed files with 23 additions and 10 deletions
+1
View File
@@ -7,6 +7,7 @@ const (
dividerWidth = 1 dividerWidth = 1
dragHitArea = 2 // +/- chars around divider dragHitArea = 2 // +/- chars around divider
fsTreeStartOffset = 1 fsTreeStartOffset = 1
statusBarHeight = 3
) )
// calculateLayout computes the widths for the file tree and note view // calculateLayout computes the widths for the file tree and note view
+22 -10
View File
@@ -43,6 +43,7 @@ type model struct {
noteView *NoteView noteView *NoteView
isDragging bool isDragging bool
isHoveringDivider bool isHoveringDivider bool
contentHeight int
} }
func NewModel(rootPath string) *model { func NewModel(rootPath string) *model {
@@ -80,8 +81,8 @@ func (m *model) loadTreeCmd(path string) tea.Cmd {
func (m *model) layout(width, height int) { func (m *model) layout(width, height int) {
m.terminalWidth = width m.terminalWidth = width
m.terminalHeight = height m.terminalHeight = height
m.fsTreeWidth, m.noteViewWidth = calculateLayout(width, m.fsTreeWidth) m.fsTreeWidth, m.noteViewWidth = calculateLayout(width, m.fsTreeWidth)
m.contentHeight = max(0, height-statusBarHeight)
} }
func (m *model) Init() tea.Cmd { func (m *model) Init() tea.Cmd {
@@ -99,13 +100,13 @@ func (m *model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
if m.tree != nil { if m.tree != nil {
_, cmd := m.tree.Update(tea.WindowSizeMsg{ _, cmd := m.tree.Update(tea.WindowSizeMsg{
Width: m.fsTreeWidth, Width: m.fsTreeWidth,
Height: m.terminalHeight, Height: m.contentHeight,
}) })
cmds = append(cmds, cmd) cmds = append(cmds, cmd)
} }
_, cmd := m.noteView.Update(tea.WindowSizeMsg{ _, cmd := m.noteView.Update(tea.WindowSizeMsg{
Width: m.noteViewWidth, Width: m.noteViewWidth,
Height: m.terminalHeight, Height: m.contentHeight,
}) })
cmds = append(cmds, cmd) cmds = append(cmds, cmd)
return m, tea.Batch(cmds...) return m, tea.Batch(cmds...)
@@ -114,7 +115,7 @@ func (m *model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
m.tree = msg.tree m.tree = msg.tree
m.loading = false m.loading = false
_, cmd := m.tree.Update(tea.WindowSizeMsg{ _, cmd := m.tree.Update(tea.WindowSizeMsg{
Height: m.terminalHeight, Height: m.contentHeight,
Width: m.fsTreeWidth, Width: m.fsTreeWidth,
}) })
return m, cmd return m, cmd
@@ -165,13 +166,13 @@ func (m *model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
if m.tree != nil { if m.tree != nil {
_, cmd := m.tree.Update(tea.WindowSizeMsg{ _, cmd := m.tree.Update(tea.WindowSizeMsg{
Width: m.fsTreeWidth, Width: m.fsTreeWidth,
Height: m.terminalHeight, Height: m.contentHeight,
}) })
cmds = append(cmds, cmd) cmds = append(cmds, cmd)
} }
_, cmd := m.noteView.Update(tea.WindowSizeMsg{ _, cmd := m.noteView.Update(tea.WindowSizeMsg{
Width: m.noteViewWidth, Width: m.noteViewWidth,
Height: m.terminalHeight, Height: m.contentHeight,
}) })
cmds = append(cmds, cmd) cmds = append(cmds, cmd)
return m, tea.Batch(cmds...) return m, tea.Batch(cmds...)
@@ -203,7 +204,7 @@ func (m model) View() string {
tree := m.tree.View() tree := m.tree.View()
tree = lipgloss.NewStyle(). tree = lipgloss.NewStyle().
Height(m.terminalHeight). Height(m.contentHeight).
Width(m.fsTreeWidth). Width(m.fsTreeWidth).
Align(lipgloss.Left). Align(lipgloss.Left).
PaddingTop(fsTreeStartOffset). PaddingTop(fsTreeStartOffset).
@@ -218,7 +219,7 @@ func (m model) View() string {
} }
// Repeat the character vertically to fill height // Repeat the character vertically to fill height
dividerLines := make([]string, m.terminalHeight) dividerLines := make([]string, m.contentHeight)
for i := range dividerLines { for i := range dividerLines {
dividerLines[i] = dividerChar dividerLines[i] = dividerChar
} }
@@ -226,7 +227,7 @@ func (m model) View() string {
// Ensure divider has the correct height style applied (though JoinVertical does most of it) // Ensure divider has the correct height style applied (though JoinVertical does most of it)
divider = lipgloss.NewStyle(). divider = lipgloss.NewStyle().
Height(m.terminalHeight). Height(m.contentHeight).
Render(divider) Render(divider)
notes := m.noteView.View() notes := m.noteView.View()
@@ -237,7 +238,18 @@ func (m model) View() string {
divider, divider,
notes, notes,
) )
return full
statusBar := lipgloss.NewStyle().
Width(m.terminalWidth - 2). // Subtract borders
Height(1).
Border(lipgloss.NormalBorder()).
Render("") // Placeholder text to ensure it's visible, can be empty string
return lipgloss.JoinVertical(
lipgloss.Left,
full,
statusBar,
)
} }
// =================== bubbletea ui fns =================== // =================== bubbletea ui fns ===================