Migrate components to ilovetui

Signed-off-by: Hadi <112569860+anotherhadi@users.noreply.github.com>
This commit is contained in:
Hadi
2026-05-26 16:38:09 +02:00
parent c7523e69e7
commit 9ac6040629
20 changed files with 54 additions and 154 deletions
+1 -1
View File
@@ -8,7 +8,7 @@ require (
charm.land/glamour/v2 v2.0.0 charm.land/glamour/v2 v2.0.0
charm.land/lipgloss/v2 v2.0.3 charm.land/lipgloss/v2 v2.0.3
github.com/andybalholm/brotli v1.0.4 github.com/andybalholm/brotli v1.0.4
github.com/anotherhadi/ilovetui v0.1.4 github.com/anotherhadi/ilovetui v0.1.6
github.com/charmbracelet/x/ansi v0.11.7 github.com/charmbracelet/x/ansi v0.11.7
github.com/klauspost/compress v1.17.8 github.com/klauspost/compress v1.17.8
github.com/lqqyt2423/go-mitmproxy v1.8.11 github.com/lqqyt2423/go-mitmproxy v1.8.11
+2 -2
View File
@@ -16,8 +16,8 @@ github.com/alecthomas/repr v0.5.2 h1:SU73FTI9D1P5UNtvseffFSGmdNci/O6RsqzeXJtP0Qs
github.com/alecthomas/repr v0.5.2/go.mod h1:Fr0507jx4eOXV7AlPV6AVZLYrLIuIeSOWtW57eE/O/4= github.com/alecthomas/repr v0.5.2/go.mod h1:Fr0507jx4eOXV7AlPV6AVZLYrLIuIeSOWtW57eE/O/4=
github.com/andybalholm/brotli v1.0.4 h1:V7DdXeJtZscaqfNuAdSRuRFzuiKlHSC/Zh3zl9qY3JY= github.com/andybalholm/brotli v1.0.4 h1:V7DdXeJtZscaqfNuAdSRuRFzuiKlHSC/Zh3zl9qY3JY=
github.com/andybalholm/brotli v1.0.4/go.mod h1:fO7iG3H7G2nSZ7m0zPUDn85XEX2GTukHGRSepvi9Eig= github.com/andybalholm/brotli v1.0.4/go.mod h1:fO7iG3H7G2nSZ7m0zPUDn85XEX2GTukHGRSepvi9Eig=
github.com/anotherhadi/ilovetui v0.1.4 h1:2sLAm3rJxg7/NrrTyH+Tk+kbIq+SvkBvrI7OvffvDcw= github.com/anotherhadi/ilovetui v0.1.6 h1:NKg+T1DpV08Q4r+iowFrXF+0bTd6Y2f4OFpFwhsfsyY=
github.com/anotherhadi/ilovetui v0.1.4/go.mod h1:ZjSCOM/wev1wAz235/Z/54h/6mRu6WkNhRaXxUhe2hw= github.com/anotherhadi/ilovetui v0.1.6/go.mod h1:HVai6u5NGKSMOpmioYpwrN0lSxQjc7HtISUc5hTwvOw=
github.com/atotto/clipboard v0.1.4 h1:EH0zSVneZPSuFR11BlR9YppQTVDbh5+16AmcJi4g1z4= github.com/atotto/clipboard v0.1.4 h1:EH0zSVneZPSuFR11BlR9YppQTVDbh5+16AmcJi4g1z4=
github.com/atotto/clipboard v0.1.4/go.mod h1:ZY9tmq7sm5xIbd9bOK4onWV4S6X0u6GY7Vn0Yu86PYI= github.com/atotto/clipboard v0.1.4/go.mod h1:ZY9tmq7sm5xIbd9bOK4onWV4S6X0u6GY7Vn0Yu86PYI=
github.com/aymanbagabas/go-udiff v0.4.1 h1:OEIrQ8maEeDBXQDoGCbbTTXYJMYRCRO1fnodZ12Gv5o= github.com/aymanbagabas/go-udiff v0.4.1 h1:OEIrQ8maEeDBXQDoGCbbTTXYJMYRCRO1fnodZ12Gv5o=
-71
View File
@@ -1,71 +1,10 @@
package style package style
import ( import (
"strings"
"charm.land/bubbles/v2/paginator"
"charm.land/bubbles/v2/textarea"
"charm.land/bubbles/v2/viewport"
"charm.land/lipgloss/v2" "charm.land/lipgloss/v2"
ilovetui "github.com/anotherhadi/ilovetui" ilovetui "github.com/anotherhadi/ilovetui"
) )
func NewViewport() viewport.Model {
vp := viewport.New()
vp.MouseWheelEnabled = false
return vp
}
func ViewportView(vp *viewport.Model) string {
v := vp.View()
if vp.AtBottom() {
return v
}
lines := strings.Split(v, "\n")
if len(lines) == 0 {
return v
}
arrow := lipgloss.NewStyle().Foreground(ilovetui.S.Subtle).Render("↓")
arrowW := lipgloss.Width(arrow)
inner := vp.Width() - 2*arrowW
if inner < 0 {
inner = 0
}
lines[len(lines)-1] = arrow + strings.Repeat(" ", inner) + arrow
return strings.Join(lines, "\n")
}
func NewPaginator() paginator.Model {
p := paginator.New()
p.Type = paginator.Dots
p.ActiveDot = S.PagerDotActive
p.InactiveDot = S.PagerDotInactive
return p
}
func NewTextarea(showLineNumbers bool) textarea.Model {
ta := textarea.New()
ta.Prompt = ""
ta.ShowLineNumbers = showLineNumbers
ta.CharLimit = 0
ta.EndOfBufferCharacter = '~'
ts := ta.Styles()
ts.Focused.Base = lipgloss.NewStyle()
ts.Blurred.Base = lipgloss.NewStyle()
ts.Focused.Text = lipgloss.NewStyle().Foreground(ilovetui.S.Text)
ts.Focused.CursorLine = lipgloss.NewStyle().Background(ilovetui.S.Selection).Foreground(ilovetui.S.Text)
ts.Focused.CursorLineNumber = lipgloss.NewStyle().Background(ilovetui.S.Selection).Foreground(ilovetui.S.Primary).Bold(true)
ts.Focused.LineNumber = lipgloss.NewStyle().Foreground(ilovetui.S.Subtle)
ts.Focused.Placeholder = lipgloss.NewStyle().Foreground(ilovetui.S.Subtle)
ts.Focused.EndOfBuffer = lipgloss.NewStyle().Foreground(ilovetui.S.SubtleBg)
ts.Blurred.Text = lipgloss.NewStyle().Foreground(ilovetui.S.Muted)
ts.Blurred.LineNumber = lipgloss.NewStyle().Foreground(ilovetui.S.SubtleBg)
ts.Blurred.Placeholder = lipgloss.NewStyle().Foreground(ilovetui.S.Subtle)
ts.Blurred.EndOfBuffer = lipgloss.NewStyle().Foreground(ilovetui.S.SubtleBg)
ta.SetStyles(ts)
return ta
}
func SeverityStyle(sev string) lipgloss.Style { func SeverityStyle(sev string) lipgloss.Style {
base := lipgloss.NewStyle().Bold(true) base := lipgloss.NewStyle().Bold(true)
switch sev { switch sev {
@@ -95,13 +34,3 @@ func StatusStyle(code, width int) lipgloss.Style {
return base.Foreground(ilovetui.S.Success) return base.Foreground(ilovetui.S.Success)
} }
} }
// SplitH splits totalHeight into top and bottom sections, accounting for the
// status bar height.
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
}
-19
View File
@@ -1,7 +1,6 @@
package style package style
import ( import (
"charm.land/bubbles/v2/help"
"charm.land/lipgloss/v2" "charm.land/lipgloss/v2"
ilovetui "github.com/anotherhadi/ilovetui" ilovetui "github.com/anotherhadi/ilovetui"
) )
@@ -9,9 +8,6 @@ import (
type Styles struct { type Styles struct {
PanelEditing lipgloss.Style PanelEditing lipgloss.Style
PagerDotActive string
PagerDotInactive string
methodGet lipgloss.Style methodGet lipgloss.Style
methodPost lipgloss.Style methodPost lipgloss.Style
methodPutPatch lipgloss.Style methodPutPatch lipgloss.Style
@@ -28,9 +24,6 @@ func Init() {
Border(lipgloss.RoundedBorder()). Border(lipgloss.RoundedBorder()).
BorderForeground(ilovetui.S.Base0E), BorderForeground(ilovetui.S.Base0E),
PagerDotActive: lipgloss.NewStyle().Foreground(ilovetui.S.Primary).SetString("•").String(),
PagerDotInactive: lipgloss.NewStyle().Foreground(ilovetui.S.Subtle).SetString("•").String(),
methodGet: methodBase.Foreground(ilovetui.S.Success), methodGet: methodBase.Foreground(ilovetui.S.Success),
methodPost: methodBase.Foreground(ilovetui.S.Warning), methodPost: methodBase.Foreground(ilovetui.S.Warning),
methodPutPatch: methodBase.Foreground(ilovetui.S.Primary), methodPutPatch: methodBase.Foreground(ilovetui.S.Primary),
@@ -39,18 +32,6 @@ func Init() {
} }
} }
func NewHelp() help.Model {
h := help.New()
h.Styles.ShortKey = lipgloss.NewStyle().Foreground(ilovetui.S.Primary)
h.Styles.ShortDesc = lipgloss.NewStyle().Foreground(ilovetui.S.Muted)
h.Styles.ShortSeparator = lipgloss.NewStyle().Foreground(ilovetui.S.Subtle)
h.Styles.FullKey = lipgloss.NewStyle().Foreground(ilovetui.S.Primary)
h.Styles.FullDesc = lipgloss.NewStyle().Foreground(ilovetui.S.Muted)
h.Styles.FullSeparator = lipgloss.NewStyle().Foreground(ilovetui.S.Subtle)
h.Styles.Ellipsis = lipgloss.NewStyle().Foreground(ilovetui.S.Subtle)
return h
}
func (s *Styles) Method(method string) lipgloss.Style { func (s *Styles) Method(method string) lipgloss.Style {
switch method { switch method {
case "GET": case "GET":
+3 -3
View File
@@ -212,9 +212,9 @@ type Model struct {
func New() Model { func New() Model {
return Model{ return Model{
leftViewport: style.NewViewport(), leftViewport: ilovetui.NewViewport(),
rightViewport: style.NewViewport(), rightViewport: ilovetui.NewViewport(),
help: style.NewHelp(), help: ilovetui.NewHelp(),
} }
} }
+2 -2
View File
@@ -57,8 +57,8 @@ func (m *Model) renderPanels(panelH int) string {
rightBorder = ilovetui.S.PanelFocused rightBorder = ilovetui.S.PanelFocused
} }
left := ilovetui.RenderWithTitle(leftBorder, leftTitle, style.ViewportView(&m.leftViewport), leftW, panelH) left := ilovetui.RenderWithTitle(leftBorder, leftTitle, ilovetui.ViewportView(&m.leftViewport), leftW, panelH)
right := ilovetui.RenderWithTitle(rightBorder, rightTitle, style.ViewportView(&m.rightViewport), rightW, panelH) right := ilovetui.RenderWithTitle(rightBorder, rightTitle, ilovetui.ViewportView(&m.rightViewport), rightW, panelH)
return lipgloss.JoinHorizontal(lipgloss.Top, left, right) return lipgloss.JoinHorizontal(lipgloss.Top, left, right)
} }
+1 -2
View File
@@ -16,7 +16,6 @@ import (
"charm.land/lipgloss/v2" "charm.land/lipgloss/v2"
ilovetui "github.com/anotherhadi/ilovetui" ilovetui "github.com/anotherhadi/ilovetui"
"github.com/anotherhadi/spilltea/internal/keys" "github.com/anotherhadi/spilltea/internal/keys"
"github.com/anotherhadi/spilltea/internal/style"
) )
func readDoc(name string) string { func readDoc(name string) string {
@@ -64,7 +63,7 @@ func New() Model {
return Model{ return Model{
viewport: viewport.New(), viewport: viewport.New(),
help: style.NewHelp(), help: ilovetui.NewHelp(),
searchInput: ti, searchInput: ti,
} }
} }
+5 -6
View File
@@ -14,7 +14,6 @@ import (
ilovetui "github.com/anotherhadi/ilovetui" ilovetui "github.com/anotherhadi/ilovetui"
"github.com/anotherhadi/spilltea/internal/db" "github.com/anotherhadi/spilltea/internal/db"
"github.com/anotherhadi/spilltea/internal/keys" "github.com/anotherhadi/spilltea/internal/keys"
"github.com/anotherhadi/spilltea/internal/style"
"github.com/anotherhadi/spilltea/internal/util" "github.com/anotherhadi/spilltea/internal/util"
) )
@@ -39,10 +38,10 @@ type Model struct {
func New() Model { func New() Model {
return Model{ return Model{
listViewport: style.NewViewport(), listViewport: ilovetui.NewViewport(),
bodyViewport: style.NewViewport(), bodyViewport: ilovetui.NewViewport(),
pager: style.NewPaginator(), pager: ilovetui.NewPaginator(),
help: style.NewHelp(), help: ilovetui.NewHelp(),
} }
} }
@@ -76,7 +75,7 @@ func (m *Model) recalcSizes() {
m.help.SetWidth(m.width - 2) m.help.SetWidth(m.width - 2)
inner := m.width - 2 inner := m.width - 2
listH, bodyH := style.SplitH(m.height, m.renderStatusBar(), 0.35) listH, bodyH := ilovetui.SplitH(m.height, m.renderStatusBar(), 0.35)
listVH := ilovetui.ContentHeight(listH) - 1 // -1 for the pager dots row listVH := ilovetui.ContentHeight(listH) - 1 // -1 for the pager dots row
if listVH < 0 { if listVH < 0 {
+2 -2
View File
@@ -17,7 +17,7 @@ func (m Model) View() tea.View {
return tea.NewView("Loading...") return tea.NewView("Loading...")
} }
listH, bodyH := style.SplitH(m.height, m.renderStatusBar(), 0.35) listH, bodyH := ilovetui.SplitH(m.height, m.renderStatusBar(), 0.35)
content := lipgloss.JoinVertical(lipgloss.Left, content := lipgloss.JoinVertical(lipgloss.Left,
m.renderListPanel(m.width, listH), m.renderListPanel(m.width, listH),
@@ -44,7 +44,7 @@ func (m *Model) renderBodyPanel(h int) string {
if len(m.findings) > 0 { if len(m.findings) > 0 {
title = m.findings[m.cursor].Title title = m.findings[m.cursor].Title
} }
return ilovetui.RenderWithTitle(ilovetui.S.Panel, title, style.ViewportView(&m.bodyViewport), m.width, h) return ilovetui.RenderWithTitle(ilovetui.S.Panel, title, ilovetui.ViewportView(&m.bodyViewport), m.width, h)
} }
func (m *Model) renderList() string { func (m *Model) renderList() string {
+5 -6
View File
@@ -10,7 +10,6 @@ import (
ilovetui "github.com/anotherhadi/ilovetui" ilovetui "github.com/anotherhadi/ilovetui"
"github.com/anotherhadi/spilltea/internal/db" "github.com/anotherhadi/spilltea/internal/db"
"github.com/anotherhadi/spilltea/internal/keys" "github.com/anotherhadi/spilltea/internal/keys"
"github.com/anotherhadi/spilltea/internal/style"
"github.com/anotherhadi/spilltea/internal/util" "github.com/anotherhadi/spilltea/internal/util"
) )
@@ -45,10 +44,10 @@ func New() Model {
ti := textinput.New() ti := textinput.New()
ti.Prompt = "" ti.Prompt = ""
return Model{ return Model{
listViewport: style.NewViewport(), listViewport: ilovetui.NewViewport(),
bodyViewport: style.NewViewport(), bodyViewport: ilovetui.NewViewport(),
pager: style.NewPaginator(), pager: ilovetui.NewPaginator(),
help: style.NewHelp(), help: ilovetui.NewHelp(),
searchInput: ti, searchInput: ti,
} }
} }
@@ -125,7 +124,7 @@ func (m *Model) recalcSizes() {
// 2 (padding) + 2 (prefix char + space) // 2 (padding) + 2 (prefix char + space)
m.searchInput.SetWidth(m.width - 4) m.searchInput.SetWidth(m.width - 4)
listH, bodyH := style.SplitH(m.height, m.renderStatusBar(), 0.35) listH, bodyH := ilovetui.SplitH(m.height, m.renderStatusBar(), 0.35)
inner := m.width - 2 inner := m.width - 2
if inner < 0 { if inner < 0 {
+2 -2
View File
@@ -18,7 +18,7 @@ func (m Model) View() tea.View {
return tea.NewView("Loading...") return tea.NewView("Loading...")
} }
listH, bodyH := style.SplitH(m.height, m.renderStatusBar(), 0.35) listH, bodyH := ilovetui.SplitH(m.height, m.renderStatusBar(), 0.35)
content := lipgloss.JoinVertical(lipgloss.Left, content := lipgloss.JoinVertical(lipgloss.Left,
m.renderListPanel(m.width, listH), m.renderListPanel(m.width, listH),
@@ -45,7 +45,7 @@ func (m *Model) renderBodyPanel(h int) string {
if m.focusedPanel == panelResponse { if m.focusedPanel == panelResponse {
title = icons.I.Response + "Response" title = icons.I.Response + "Response"
} }
return ilovetui.RenderWithTitle(ilovetui.S.Panel, title, style.ViewportView(&m.bodyViewport), m.width, h) return ilovetui.RenderWithTitle(ilovetui.S.Panel, title, ilovetui.ViewportView(&m.bodyViewport), m.width, h)
} }
func (m *Model) renderStatusBar() string { func (m *Model) renderStatusBar() string {
+1 -1
View File
@@ -158,7 +158,7 @@ func (m *Model) listHalfWidths() (leftW, rightW int) {
func (m *Model) recalcSizes() { func (m *Model) recalcSizes() {
m.help.SetWidth(m.width - 2) m.help.SetWidth(m.width - 2)
listH, bodyH := style.SplitH(m.height, m.renderStatusBar(), 0.35) listH, bodyH := ilovetui.SplitH(m.height, m.renderStatusBar(), 0.35)
bodyInner := m.width - 2 bodyInner := m.width - 2
if bodyInner < 0 { if bodyInner < 0 {
-4
View File
@@ -1,15 +1,11 @@
package intercept package intercept
import ( import (
"charm.land/bubbles/v2/help"
"charm.land/bubbles/v2/key" "charm.land/bubbles/v2/key"
"github.com/anotherhadi/spilltea/internal/icons" "github.com/anotherhadi/spilltea/internal/icons"
"github.com/anotherhadi/spilltea/internal/keys" "github.com/anotherhadi/spilltea/internal/keys"
"github.com/anotherhadi/spilltea/internal/style"
) )
func newHelp() help.Model { return style.NewHelp() }
type interceptKeyMap struct{ width int } type interceptKeyMap struct{ width int }
func iconBinding(b key.Binding, icon string) key.Binding { func iconBinding(b key.Binding, icon string) key.Binding {
+8 -8
View File
@@ -6,9 +6,9 @@ import (
"charm.land/bubbles/v2/textarea" "charm.land/bubbles/v2/textarea"
"charm.land/bubbles/v2/viewport" "charm.land/bubbles/v2/viewport"
tea "charm.land/bubbletea/v2" tea "charm.land/bubbletea/v2"
ilovetui "github.com/anotherhadi/ilovetui"
"github.com/anotherhadi/spilltea/internal/config" "github.com/anotherhadi/spilltea/internal/config"
"github.com/anotherhadi/spilltea/internal/intercept" "github.com/anotherhadi/spilltea/internal/intercept"
"github.com/anotherhadi/spilltea/internal/style"
) )
type panel int type panel int
@@ -48,14 +48,14 @@ type Model struct {
func New(broker *intercept.Broker) Model { func New(broker *intercept.Broker) Model {
cfg := config.Global cfg := config.Global
ta := style.NewTextarea(false) ta := ilovetui.NewTextarea(false)
ta.Blur() ta.Blur()
lv := style.NewViewport() lv := ilovetui.NewViewport()
rv := style.NewViewport() rv := ilovetui.NewViewport()
bv := style.NewViewport() bv := ilovetui.NewViewport()
p := style.NewPaginator() p := ilovetui.NewPaginator()
rp := style.NewPaginator() rp := ilovetui.NewPaginator()
broker.SetCaptureResponse(cfg.Intercept.DefaultCaptureResponse) broker.SetCaptureResponse(cfg.Intercept.DefaultCaptureResponse)
@@ -69,7 +69,7 @@ func New(broker *intercept.Broker) Model {
textarea: ta, textarea: ta,
pager: p, pager: p,
responsePager: rp, responsePager: rp,
help: newHelp(), help: ilovetui.NewHelp(),
pendingEdits: make(map[*intercept.PendingRequest]string), pendingEdits: make(map[*intercept.PendingRequest]string),
pendingResponseEdits: make(map[*intercept.PendingResponse]string), pendingResponseEdits: make(map[*intercept.PendingResponse]string),
} }
+2 -2
View File
@@ -17,7 +17,7 @@ func (m Model) View() tea.View {
return tea.NewView("Loading...") return tea.NewView("Loading...")
} }
listH, bodyH := style.SplitH(m.height, m.renderStatusBar(), 0.35) listH, bodyH := ilovetui.SplitH(m.height, m.renderStatusBar(), 0.35)
var listRow string var listRow string
if m.captureResponse { if m.captureResponse {
@@ -82,7 +82,7 @@ func (m *Model) renderBodyPanel(h int) string {
if m.editing { if m.editing {
body = m.textarea.View() body = m.textarea.View()
} else { } else {
body = style.ViewportView(&m.bodyViewport) body = ilovetui.ViewportView(&m.bodyViewport)
} }
border := ilovetui.S.Panel border := ilovetui.S.Panel
+6 -7
View File
@@ -13,7 +13,6 @@ import (
ilovetui "github.com/anotherhadi/ilovetui" ilovetui "github.com/anotherhadi/ilovetui"
"github.com/anotherhadi/spilltea/internal/keys" "github.com/anotherhadi/spilltea/internal/keys"
"github.com/anotherhadi/spilltea/internal/plugins" "github.com/anotherhadi/spilltea/internal/plugins"
"github.com/anotherhadi/spilltea/internal/style"
) )
type Model struct { type Model struct {
@@ -37,7 +36,7 @@ type Model struct {
} }
func New(mgr *plugins.Manager) Model { func New(mgr *plugins.Manager) Model {
ta := style.NewTextarea(true) ta := ilovetui.NewTextarea(true)
ta.Placeholder = "plugin configuration..." ta.Placeholder = "plugin configuration..."
ta.Blur() ta.Blur()
@@ -46,12 +45,12 @@ func New(mgr *plugins.Manager) Model {
return Model{ return Model{
manager: mgr, manager: mgr,
listViewport: style.NewViewport(), listViewport: ilovetui.NewViewport(),
detailViewport: style.NewViewport(), detailViewport: ilovetui.NewViewport(),
textarea: ta, textarea: ta,
filterInput: fi, filterInput: fi,
pager: style.NewPaginator(), pager: ilovetui.NewPaginator(),
help: style.NewHelp(), help: ilovetui.NewHelp(),
} }
} }
@@ -71,7 +70,7 @@ func (m *Model) recalcSizes() {
} }
m.help.SetWidth(m.width - 2) m.help.SetWidth(m.width - 2)
listH, detailH := style.SplitH(m.height, m.renderStatusBar(), 0.4) listH, detailH := ilovetui.SplitH(m.height, m.renderStatusBar(), 0.4)
inner := m.width - 2 inner := m.width - 2
if inner < 0 { if inner < 0 {
+2 -3
View File
@@ -10,7 +10,6 @@ import (
ilovetui "github.com/anotherhadi/ilovetui" ilovetui "github.com/anotherhadi/ilovetui"
"github.com/anotherhadi/spilltea/internal/icons" "github.com/anotherhadi/spilltea/internal/icons"
"github.com/anotherhadi/spilltea/internal/keys" "github.com/anotherhadi/spilltea/internal/keys"
"github.com/anotherhadi/spilltea/internal/style"
"github.com/anotherhadi/spilltea/internal/util" "github.com/anotherhadi/spilltea/internal/util"
) )
@@ -19,7 +18,7 @@ func (m Model) View() tea.View {
return tea.NewView(lipgloss.Place(m.width, m.height, lipgloss.Center, lipgloss.Center, ilovetui.S.Faint.Render(util.CenterLines("(._.)~*.'", "no plugins loaded")))) return tea.NewView(lipgloss.Place(m.width, m.height, lipgloss.Center, lipgloss.Center, ilovetui.S.Faint.Render(util.CenterLines("(._.)~*.'", "no plugins loaded"))))
} }
listH, detailH := style.SplitH(m.height, m.renderStatusBar(), 0.4) listH, detailH := ilovetui.SplitH(m.height, m.renderStatusBar(), 0.4)
content := lipgloss.JoinVertical(lipgloss.Left, content := lipgloss.JoinVertical(lipgloss.Left,
m.renderListPanel(m.width, listH), m.renderListPanel(m.width, listH),
@@ -71,7 +70,7 @@ func (m *Model) renderDetailPanel(h int) string {
ilovetui.S.Faint.Render(filepath.Base(info.FilePath)), ilovetui.S.Faint.Render(filepath.Base(info.FilePath)),
) )
parts := []string{header, style.ViewportView(&m.detailViewport)} parts := []string{header, ilovetui.ViewportView(&m.detailViewport)}
if m.hasConfig() { if m.hasConfig() {
var configLabel string var configLabel string
+7 -8
View File
@@ -12,7 +12,6 @@ import (
ilovetui "github.com/anotherhadi/ilovetui" ilovetui "github.com/anotherhadi/ilovetui"
"github.com/anotherhadi/spilltea/internal/db" "github.com/anotherhadi/spilltea/internal/db"
"github.com/anotherhadi/spilltea/internal/keys" "github.com/anotherhadi/spilltea/internal/keys"
"github.com/anotherhadi/spilltea/internal/style"
) )
type SendToReplayMsg struct { type SendToReplayMsg struct {
@@ -62,15 +61,15 @@ type Model struct {
} }
func New() Model { func New() Model {
ta := style.NewTextarea(false) ta := ilovetui.NewTextarea(false)
ta.Blur() ta.Blur()
return Model{ return Model{
listViewport: style.NewViewport(), listViewport: ilovetui.NewViewport(),
requestViewport: style.NewViewport(), requestViewport: ilovetui.NewViewport(),
responseViewport: style.NewViewport(), responseViewport: ilovetui.NewViewport(),
textarea: ta, textarea: ta,
pager: style.NewPaginator(), pager: ilovetui.NewPaginator(),
help: style.NewHelp(), help: ilovetui.NewHelp(),
} }
} }
@@ -150,7 +149,7 @@ func (m *Model) SetSize(w, h int) {
func (m *Model) recalcSizes() { func (m *Model) recalcSizes() {
m.help.SetWidth(m.width - 2) m.help.SetWidth(m.width - 2)
listH, bodyH := style.SplitH(m.height, m.renderStatusBar(), 0.35) listH, bodyH := ilovetui.SplitH(m.height, m.renderStatusBar(), 0.35)
listInner := m.width - 2 listInner := m.width - 2
if listInner < 0 { if listInner < 0 {
+3 -3
View File
@@ -17,7 +17,7 @@ func (m Model) View() tea.View {
return tea.NewView("Loading...") return tea.NewView("Loading...")
} }
listH, bodyH := style.SplitH(m.height, m.renderStatusBar(), 0.35) listH, bodyH := ilovetui.SplitH(m.height, m.renderStatusBar(), 0.35)
leftW, rightW := m.bodyHalfWidths() leftW, rightW := m.bodyHalfWidths()
bodyRow := lipgloss.JoinHorizontal(lipgloss.Top, bodyRow := lipgloss.JoinHorizontal(lipgloss.Top,
@@ -56,7 +56,7 @@ func (m *Model) renderRequestPanel(w, h int) string {
body = m.textarea.View() body = m.textarea.View()
border = ilovetui.S.PanelFocused border = ilovetui.S.PanelFocused
} else { } else {
body = style.ViewportView(&m.requestViewport) body = ilovetui.ViewportView(&m.requestViewport)
if m.focusedPanel == panelRequest { if m.focusedPanel == panelRequest {
border = ilovetui.S.PanelFocused border = ilovetui.S.PanelFocused
} }
@@ -69,7 +69,7 @@ func (m *Model) renderResponsePanel(w, h int) string {
if !m.editing && m.focusedPanel == panelResponse { if !m.editing && m.focusedPanel == panelResponse {
border = ilovetui.S.PanelFocused border = ilovetui.S.PanelFocused
} }
return ilovetui.RenderWithTitle(border, icons.I.Response+"Response", style.ViewportView(&m.responseViewport), w, h) return ilovetui.RenderWithTitle(border, icons.I.Response+"Response", ilovetui.ViewportView(&m.responseViewport), w, h)
} }
func (m *Model) renderStatusBar() string { func (m *Model) renderStatusBar() string {
+2 -2
View File
@@ -26,8 +26,8 @@ schema = 3
hash = 'sha256-gAnPRdGP4yna4hiRIEDyBtDOVJqd7RU27wlPu96Rdf8=' hash = 'sha256-gAnPRdGP4yna4hiRIEDyBtDOVJqd7RU27wlPu96Rdf8='
[mod.'github.com/anotherhadi/ilovetui'] [mod.'github.com/anotherhadi/ilovetui']
version = 'v0.1.4' version = 'v0.1.6'
hash = 'sha256-WOwCI4gqNnQvnQG2Miadx+St02IiImAX3B7ne7DdblA=' hash = 'sha256-7E+7UFks5vM3XWCvX2joFmHGcW7qqnoox6ZPFglaLO4='
[mod.'github.com/atotto/clipboard'] [mod.'github.com/atotto/clipboard']
version = 'v0.1.4' version = 'v0.1.4'