mirror of
https://github.com/anotherhadi/ilovetui.git
synced 2026-06-26 00:42:33 +02:00
Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| f3a1877832 | |||
| 499d61bddf |
@@ -4,6 +4,7 @@ import (
|
||||
"strings"
|
||||
|
||||
"charm.land/bubbles/v2/help"
|
||||
"charm.land/bubbles/v2/paginator"
|
||||
"charm.land/bubbles/v2/textarea"
|
||||
"charm.land/bubbles/v2/viewport"
|
||||
"charm.land/lipgloss/v2"
|
||||
@@ -47,6 +48,25 @@ func NewTextarea(showLineNumbers bool) textarea.Model {
|
||||
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.
|
||||
func NewViewport() viewport.Model {
|
||||
vp := viewport.New()
|
||||
|
||||
@@ -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 = {
|
||||
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
||||
|
||||
@@ -47,6 +47,10 @@ type Styles struct {
|
||||
// Pre-built panel styles (rounded border)
|
||||
Panel lipgloss.Style
|
||||
PanelFocused lipgloss.Style
|
||||
|
||||
// Pre-rendered pager dot strings
|
||||
PagerDotActive string
|
||||
PagerDotInactive string
|
||||
}
|
||||
|
||||
func newStyles(c colorsYAML) Styles {
|
||||
@@ -102,5 +106,8 @@ func newStyles(c colorsYAML) Styles {
|
||||
PanelFocused: lipgloss.NewStyle().
|
||||
Border(lipgloss.RoundedBorder()).
|
||||
BorderForeground(b0D),
|
||||
|
||||
PagerDotActive: lipgloss.NewStyle().Foreground(b0D).SetString("•").String(),
|
||||
PagerDotInactive: lipgloss.NewStyle().Foreground(b03).SetString("•").String(),
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user