53 lines
974 B
Go
53 lines
974 B
Go
package models
|
|
|
|
import (
|
|
"strings"
|
|
|
|
"github.com/charmbracelet/bubbles/viewport"
|
|
tea "github.com/charmbracelet/bubbletea"
|
|
"github.com/charmbracelet/lipgloss"
|
|
)
|
|
|
|
var viewportStyle = lipgloss.NewStyle().
|
|
BorderStyle(lipgloss.NormalBorder()).
|
|
MarginLeft(1)
|
|
|
|
type statusPaneModel struct {
|
|
viewport viewport.Model
|
|
|
|
width int
|
|
heightOffset int
|
|
height int
|
|
}
|
|
|
|
func newStatusPaneModel() statusPaneModel {
|
|
return statusPaneModel{}
|
|
}
|
|
|
|
func (m statusPaneModel) Init() tea.Cmd {
|
|
return nil
|
|
}
|
|
|
|
func (m statusPaneModel) Update(msg tea.Msg) (statusPaneModel, tea.Cmd) {
|
|
switch msg := msg.(type) {
|
|
case tea.WindowSizeMsg:
|
|
m.width = msg.Width
|
|
m.height = msg.Height - m.heightOffset - 4
|
|
m.viewport = viewport.New(msg.Width, m.height)
|
|
}
|
|
return m, nil
|
|
}
|
|
|
|
func (m statusPaneModel) View() string {
|
|
body := strings.Builder{}
|
|
|
|
body.WriteString(
|
|
viewportStyle.
|
|
Width(m.width - 2).
|
|
Height(m.height).
|
|
Render(m.viewport.View()),
|
|
)
|
|
|
|
return body.String()
|
|
}
|