mirror of
https://github.com/anotherhadi/spilltea.git
synced 2026-07-06 12:42:32 +02:00
Migrate components to ilovetui
Signed-off-by: Hadi <112569860+anotherhadi@users.noreply.github.com>
This commit is contained in:
@@ -8,7 +8,7 @@ require (
|
||||
charm.land/glamour/v2 v2.0.0
|
||||
charm.land/lipgloss/v2 v2.0.3
|
||||
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/klauspost/compress v1.17.8
|
||||
github.com/lqqyt2423/go-mitmproxy v1.8.11
|
||||
|
||||
@@ -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/andybalholm/brotli v1.0.4 h1:V7DdXeJtZscaqfNuAdSRuRFzuiKlHSC/Zh3zl9qY3JY=
|
||||
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.4/go.mod h1:ZjSCOM/wev1wAz235/Z/54h/6mRu6WkNhRaXxUhe2hw=
|
||||
github.com/anotherhadi/ilovetui v0.1.6 h1:NKg+T1DpV08Q4r+iowFrXF+0bTd6Y2f4OFpFwhsfsyY=
|
||||
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/go.mod h1:ZY9tmq7sm5xIbd9bOK4onWV4S6X0u6GY7Vn0Yu86PYI=
|
||||
github.com/aymanbagabas/go-udiff v0.4.1 h1:OEIrQ8maEeDBXQDoGCbbTTXYJMYRCRO1fnodZ12Gv5o=
|
||||
|
||||
@@ -1,71 +1,10 @@
|
||||
package style
|
||||
|
||||
import (
|
||||
"strings"
|
||||
|
||||
"charm.land/bubbles/v2/paginator"
|
||||
"charm.land/bubbles/v2/textarea"
|
||||
"charm.land/bubbles/v2/viewport"
|
||||
"charm.land/lipgloss/v2"
|
||||
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 {
|
||||
base := lipgloss.NewStyle().Bold(true)
|
||||
switch sev {
|
||||
@@ -95,13 +34,3 @@ func StatusStyle(code, width int) lipgloss.Style {
|
||||
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
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package style
|
||||
|
||||
import (
|
||||
"charm.land/bubbles/v2/help"
|
||||
"charm.land/lipgloss/v2"
|
||||
ilovetui "github.com/anotherhadi/ilovetui"
|
||||
)
|
||||
@@ -9,9 +8,6 @@ import (
|
||||
type Styles struct {
|
||||
PanelEditing lipgloss.Style
|
||||
|
||||
PagerDotActive string
|
||||
PagerDotInactive string
|
||||
|
||||
methodGet lipgloss.Style
|
||||
methodPost lipgloss.Style
|
||||
methodPutPatch lipgloss.Style
|
||||
@@ -28,9 +24,6 @@ func Init() {
|
||||
Border(lipgloss.RoundedBorder()).
|
||||
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),
|
||||
methodPost: methodBase.Foreground(ilovetui.S.Warning),
|
||||
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 {
|
||||
switch method {
|
||||
case "GET":
|
||||
|
||||
@@ -212,9 +212,9 @@ type Model struct {
|
||||
|
||||
func New() Model {
|
||||
return Model{
|
||||
leftViewport: style.NewViewport(),
|
||||
rightViewport: style.NewViewport(),
|
||||
help: style.NewHelp(),
|
||||
leftViewport: ilovetui.NewViewport(),
|
||||
rightViewport: ilovetui.NewViewport(),
|
||||
help: ilovetui.NewHelp(),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -57,8 +57,8 @@ func (m *Model) renderPanels(panelH int) string {
|
||||
rightBorder = ilovetui.S.PanelFocused
|
||||
}
|
||||
|
||||
left := ilovetui.RenderWithTitle(leftBorder, leftTitle, style.ViewportView(&m.leftViewport), leftW, panelH)
|
||||
right := ilovetui.RenderWithTitle(rightBorder, rightTitle, style.ViewportView(&m.rightViewport), rightW, panelH)
|
||||
left := ilovetui.RenderWithTitle(leftBorder, leftTitle, ilovetui.ViewportView(&m.leftViewport), leftW, panelH)
|
||||
right := ilovetui.RenderWithTitle(rightBorder, rightTitle, ilovetui.ViewportView(&m.rightViewport), rightW, panelH)
|
||||
|
||||
return lipgloss.JoinHorizontal(lipgloss.Top, left, right)
|
||||
}
|
||||
|
||||
@@ -16,7 +16,6 @@ import (
|
||||
"charm.land/lipgloss/v2"
|
||||
ilovetui "github.com/anotherhadi/ilovetui"
|
||||
"github.com/anotherhadi/spilltea/internal/keys"
|
||||
"github.com/anotherhadi/spilltea/internal/style"
|
||||
)
|
||||
|
||||
func readDoc(name string) string {
|
||||
@@ -64,7 +63,7 @@ func New() Model {
|
||||
|
||||
return Model{
|
||||
viewport: viewport.New(),
|
||||
help: style.NewHelp(),
|
||||
help: ilovetui.NewHelp(),
|
||||
searchInput: ti,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,7 +14,6 @@ import (
|
||||
ilovetui "github.com/anotherhadi/ilovetui"
|
||||
"github.com/anotherhadi/spilltea/internal/db"
|
||||
"github.com/anotherhadi/spilltea/internal/keys"
|
||||
"github.com/anotherhadi/spilltea/internal/style"
|
||||
"github.com/anotherhadi/spilltea/internal/util"
|
||||
)
|
||||
|
||||
@@ -39,10 +38,10 @@ type Model struct {
|
||||
|
||||
func New() Model {
|
||||
return Model{
|
||||
listViewport: style.NewViewport(),
|
||||
bodyViewport: style.NewViewport(),
|
||||
pager: style.NewPaginator(),
|
||||
help: style.NewHelp(),
|
||||
listViewport: ilovetui.NewViewport(),
|
||||
bodyViewport: ilovetui.NewViewport(),
|
||||
pager: ilovetui.NewPaginator(),
|
||||
help: ilovetui.NewHelp(),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -76,7 +75,7 @@ func (m *Model) recalcSizes() {
|
||||
m.help.SetWidth(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
|
||||
if listVH < 0 {
|
||||
|
||||
@@ -17,7 +17,7 @@ func (m Model) View() tea.View {
|
||||
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,
|
||||
m.renderListPanel(m.width, listH),
|
||||
@@ -44,7 +44,7 @@ func (m *Model) renderBodyPanel(h int) string {
|
||||
if len(m.findings) > 0 {
|
||||
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 {
|
||||
|
||||
@@ -10,7 +10,6 @@ import (
|
||||
ilovetui "github.com/anotherhadi/ilovetui"
|
||||
"github.com/anotherhadi/spilltea/internal/db"
|
||||
"github.com/anotherhadi/spilltea/internal/keys"
|
||||
"github.com/anotherhadi/spilltea/internal/style"
|
||||
"github.com/anotherhadi/spilltea/internal/util"
|
||||
)
|
||||
|
||||
@@ -45,10 +44,10 @@ func New() Model {
|
||||
ti := textinput.New()
|
||||
ti.Prompt = ""
|
||||
return Model{
|
||||
listViewport: style.NewViewport(),
|
||||
bodyViewport: style.NewViewport(),
|
||||
pager: style.NewPaginator(),
|
||||
help: style.NewHelp(),
|
||||
listViewport: ilovetui.NewViewport(),
|
||||
bodyViewport: ilovetui.NewViewport(),
|
||||
pager: ilovetui.NewPaginator(),
|
||||
help: ilovetui.NewHelp(),
|
||||
searchInput: ti,
|
||||
}
|
||||
}
|
||||
@@ -125,7 +124,7 @@ func (m *Model) recalcSizes() {
|
||||
// 2 (padding) + 2 (prefix char + space)
|
||||
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
|
||||
if inner < 0 {
|
||||
|
||||
@@ -18,7 +18,7 @@ func (m Model) View() tea.View {
|
||||
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,
|
||||
m.renderListPanel(m.width, listH),
|
||||
@@ -45,7 +45,7 @@ func (m *Model) renderBodyPanel(h int) string {
|
||||
if m.focusedPanel == panelResponse {
|
||||
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 {
|
||||
|
||||
@@ -158,7 +158,7 @@ func (m *Model) listHalfWidths() (leftW, rightW int) {
|
||||
func (m *Model) recalcSizes() {
|
||||
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
|
||||
if bodyInner < 0 {
|
||||
|
||||
@@ -1,15 +1,11 @@
|
||||
package intercept
|
||||
|
||||
import (
|
||||
"charm.land/bubbles/v2/help"
|
||||
"charm.land/bubbles/v2/key"
|
||||
"github.com/anotherhadi/spilltea/internal/icons"
|
||||
"github.com/anotherhadi/spilltea/internal/keys"
|
||||
"github.com/anotherhadi/spilltea/internal/style"
|
||||
)
|
||||
|
||||
func newHelp() help.Model { return style.NewHelp() }
|
||||
|
||||
type interceptKeyMap struct{ width int }
|
||||
|
||||
func iconBinding(b key.Binding, icon string) key.Binding {
|
||||
|
||||
@@ -6,9 +6,9 @@ import (
|
||||
"charm.land/bubbles/v2/textarea"
|
||||
"charm.land/bubbles/v2/viewport"
|
||||
tea "charm.land/bubbletea/v2"
|
||||
ilovetui "github.com/anotherhadi/ilovetui"
|
||||
"github.com/anotherhadi/spilltea/internal/config"
|
||||
"github.com/anotherhadi/spilltea/internal/intercept"
|
||||
"github.com/anotherhadi/spilltea/internal/style"
|
||||
)
|
||||
|
||||
type panel int
|
||||
@@ -48,14 +48,14 @@ type Model struct {
|
||||
|
||||
func New(broker *intercept.Broker) Model {
|
||||
cfg := config.Global
|
||||
ta := style.NewTextarea(false)
|
||||
ta := ilovetui.NewTextarea(false)
|
||||
ta.Blur()
|
||||
|
||||
lv := style.NewViewport()
|
||||
rv := style.NewViewport()
|
||||
bv := style.NewViewport()
|
||||
p := style.NewPaginator()
|
||||
rp := style.NewPaginator()
|
||||
lv := ilovetui.NewViewport()
|
||||
rv := ilovetui.NewViewport()
|
||||
bv := ilovetui.NewViewport()
|
||||
p := ilovetui.NewPaginator()
|
||||
rp := ilovetui.NewPaginator()
|
||||
|
||||
broker.SetCaptureResponse(cfg.Intercept.DefaultCaptureResponse)
|
||||
|
||||
@@ -69,7 +69,7 @@ func New(broker *intercept.Broker) Model {
|
||||
textarea: ta,
|
||||
pager: p,
|
||||
responsePager: rp,
|
||||
help: newHelp(),
|
||||
help: ilovetui.NewHelp(),
|
||||
pendingEdits: make(map[*intercept.PendingRequest]string),
|
||||
pendingResponseEdits: make(map[*intercept.PendingResponse]string),
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ func (m Model) View() tea.View {
|
||||
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
|
||||
if m.captureResponse {
|
||||
@@ -82,7 +82,7 @@ func (m *Model) renderBodyPanel(h int) string {
|
||||
if m.editing {
|
||||
body = m.textarea.View()
|
||||
} else {
|
||||
body = style.ViewportView(&m.bodyViewport)
|
||||
body = ilovetui.ViewportView(&m.bodyViewport)
|
||||
}
|
||||
|
||||
border := ilovetui.S.Panel
|
||||
|
||||
@@ -13,7 +13,6 @@ import (
|
||||
ilovetui "github.com/anotherhadi/ilovetui"
|
||||
"github.com/anotherhadi/spilltea/internal/keys"
|
||||
"github.com/anotherhadi/spilltea/internal/plugins"
|
||||
"github.com/anotherhadi/spilltea/internal/style"
|
||||
)
|
||||
|
||||
type Model struct {
|
||||
@@ -37,7 +36,7 @@ type Model struct {
|
||||
}
|
||||
|
||||
func New(mgr *plugins.Manager) Model {
|
||||
ta := style.NewTextarea(true)
|
||||
ta := ilovetui.NewTextarea(true)
|
||||
ta.Placeholder = "plugin configuration..."
|
||||
ta.Blur()
|
||||
|
||||
@@ -46,12 +45,12 @@ func New(mgr *plugins.Manager) Model {
|
||||
|
||||
return Model{
|
||||
manager: mgr,
|
||||
listViewport: style.NewViewport(),
|
||||
detailViewport: style.NewViewport(),
|
||||
listViewport: ilovetui.NewViewport(),
|
||||
detailViewport: ilovetui.NewViewport(),
|
||||
textarea: ta,
|
||||
filterInput: fi,
|
||||
pager: style.NewPaginator(),
|
||||
help: style.NewHelp(),
|
||||
pager: ilovetui.NewPaginator(),
|
||||
help: ilovetui.NewHelp(),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -71,7 +70,7 @@ func (m *Model) recalcSizes() {
|
||||
}
|
||||
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
|
||||
if inner < 0 {
|
||||
|
||||
@@ -10,7 +10,6 @@ import (
|
||||
ilovetui "github.com/anotherhadi/ilovetui"
|
||||
"github.com/anotherhadi/spilltea/internal/icons"
|
||||
"github.com/anotherhadi/spilltea/internal/keys"
|
||||
"github.com/anotherhadi/spilltea/internal/style"
|
||||
"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"))))
|
||||
}
|
||||
|
||||
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,
|
||||
m.renderListPanel(m.width, listH),
|
||||
@@ -71,7 +70,7 @@ func (m *Model) renderDetailPanel(h int) string {
|
||||
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() {
|
||||
var configLabel string
|
||||
|
||||
@@ -12,7 +12,6 @@ import (
|
||||
ilovetui "github.com/anotherhadi/ilovetui"
|
||||
"github.com/anotherhadi/spilltea/internal/db"
|
||||
"github.com/anotherhadi/spilltea/internal/keys"
|
||||
"github.com/anotherhadi/spilltea/internal/style"
|
||||
)
|
||||
|
||||
type SendToReplayMsg struct {
|
||||
@@ -62,15 +61,15 @@ type Model struct {
|
||||
}
|
||||
|
||||
func New() Model {
|
||||
ta := style.NewTextarea(false)
|
||||
ta := ilovetui.NewTextarea(false)
|
||||
ta.Blur()
|
||||
return Model{
|
||||
listViewport: style.NewViewport(),
|
||||
requestViewport: style.NewViewport(),
|
||||
responseViewport: style.NewViewport(),
|
||||
listViewport: ilovetui.NewViewport(),
|
||||
requestViewport: ilovetui.NewViewport(),
|
||||
responseViewport: ilovetui.NewViewport(),
|
||||
textarea: ta,
|
||||
pager: style.NewPaginator(),
|
||||
help: style.NewHelp(),
|
||||
pager: ilovetui.NewPaginator(),
|
||||
help: ilovetui.NewHelp(),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -150,7 +149,7 @@ func (m *Model) SetSize(w, h int) {
|
||||
func (m *Model) recalcSizes() {
|
||||
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
|
||||
if listInner < 0 {
|
||||
|
||||
@@ -17,7 +17,7 @@ func (m Model) View() tea.View {
|
||||
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()
|
||||
|
||||
bodyRow := lipgloss.JoinHorizontal(lipgloss.Top,
|
||||
@@ -56,7 +56,7 @@ func (m *Model) renderRequestPanel(w, h int) string {
|
||||
body = m.textarea.View()
|
||||
border = ilovetui.S.PanelFocused
|
||||
} else {
|
||||
body = style.ViewportView(&m.requestViewport)
|
||||
body = ilovetui.ViewportView(&m.requestViewport)
|
||||
if m.focusedPanel == panelRequest {
|
||||
border = ilovetui.S.PanelFocused
|
||||
}
|
||||
@@ -69,7 +69,7 @@ func (m *Model) renderResponsePanel(w, h int) string {
|
||||
if !m.editing && m.focusedPanel == panelResponse {
|
||||
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 {
|
||||
|
||||
+2
-2
@@ -26,8 +26,8 @@ schema = 3
|
||||
hash = 'sha256-gAnPRdGP4yna4hiRIEDyBtDOVJqd7RU27wlPu96Rdf8='
|
||||
|
||||
[mod.'github.com/anotherhadi/ilovetui']
|
||||
version = 'v0.1.4'
|
||||
hash = 'sha256-WOwCI4gqNnQvnQG2Miadx+St02IiImAX3B7ne7DdblA='
|
||||
version = 'v0.1.6'
|
||||
hash = 'sha256-7E+7UFks5vM3XWCvX2joFmHGcW7qqnoox6ZPFglaLO4='
|
||||
|
||||
[mod.'github.com/atotto/clipboard']
|
||||
version = 'v0.1.4'
|
||||
|
||||
Reference in New Issue
Block a user