2 Commits

Author SHA1 Message Date
Hadi f3a1877832 edit flake
Signed-off-by: Hadi <112569860+anotherhadi@users.noreply.github.com>
2026-05-26 17:55:09 +02:00
Hadi 499d61bddf add paginator & spilth
Signed-off-by: Hadi <112569860+anotherhadi@users.noreply.github.com>
2026-05-26 16:35:09 +02:00
3 changed files with 28 additions and 1 deletions
+20
View File
@@ -4,6 +4,7 @@ import (
"strings" "strings"
"charm.land/bubbles/v2/help" "charm.land/bubbles/v2/help"
"charm.land/bubbles/v2/paginator"
"charm.land/bubbles/v2/textarea" "charm.land/bubbles/v2/textarea"
"charm.land/bubbles/v2/viewport" "charm.land/bubbles/v2/viewport"
"charm.land/lipgloss/v2" "charm.land/lipgloss/v2"
@@ -47,6 +48,25 @@ func NewTextarea(showLineNumbers bool) textarea.Model {
return ta return ta
} }
// NewPaginator returns a dot-style paginator.Model styled with the active theme.
func NewPaginator() paginator.Model {
p := paginator.New()
p.Type = paginator.Dots
p.ActiveDot = S.PagerDotActive
p.InactiveDot = S.PagerDotInactive
return p
}
// SplitH splits totalHeight into top and bottom sections, accounting for the
// height of statusBar (measured by newline count).
func SplitH(totalHeight int, statusBar string, ratio float64) (top, bottom int) {
statusH := strings.Count(statusBar, "\n") + 1
available := totalHeight - statusH
top = int(float64(available) * ratio)
bottom = available - top
return
}
// NewViewport returns a viewport.Model with mouse wheel disabled. // NewViewport returns a viewport.Model with mouse wheel disabled.
func NewViewport() viewport.Model { func NewViewport() viewport.Model {
vp := viewport.New() vp := viewport.New()
+1 -1
View File
@@ -1,5 +1,5 @@
{ {
description = ""; description = "A minimal Go library that provides a shared Base16color theme for terminal UIs built with bubbletea and lipgloss.";
inputs = { inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
+7
View File
@@ -47,6 +47,10 @@ type Styles struct {
// Pre-built panel styles (rounded border) // Pre-built panel styles (rounded border)
Panel lipgloss.Style Panel lipgloss.Style
PanelFocused lipgloss.Style PanelFocused lipgloss.Style
// Pre-rendered pager dot strings
PagerDotActive string
PagerDotInactive string
} }
func newStyles(c colorsYAML) Styles { func newStyles(c colorsYAML) Styles {
@@ -102,5 +106,8 @@ func newStyles(c colorsYAML) Styles {
PanelFocused: lipgloss.NewStyle(). PanelFocused: lipgloss.NewStyle().
Border(lipgloss.RoundedBorder()). Border(lipgloss.RoundedBorder()).
BorderForeground(b0D), BorderForeground(b0D),
PagerDotActive: lipgloss.NewStyle().Foreground(b0D).SetString("•").String(),
PagerDotInactive: lipgloss.NewStyle().Foreground(b03).SetString("•").String(),
} }
} }