mirror of
https://github.com/anotherhadi/spilltea.git
synced 2026-05-20 09:42:34 +02:00
Rename auto-forward -> toggle-intercept
Signed-off-by: Hadi <112569860+anotherhadi@users.noreply.github.com>
This commit is contained in:
@@ -33,7 +33,7 @@ type Config struct {
|
|||||||
} `mapstructure:"tui"`
|
} `mapstructure:"tui"`
|
||||||
|
|
||||||
Intercept struct {
|
Intercept struct {
|
||||||
DefaultAutoForward bool `mapstructure:"default_auto_forward"`
|
DefaultInterceptEnabled bool `mapstructure:"default_intercept_enabled"`
|
||||||
DefaultCaptureResponse bool `mapstructure:"default_capture_response"`
|
DefaultCaptureResponse bool `mapstructure:"default_capture_response"`
|
||||||
AutoForwardRegex []string `mapstructure:"auto_forward_regex"`
|
AutoForwardRegex []string `mapstructure:"auto_forward_regex"`
|
||||||
} `mapstructure:"intercept"`
|
} `mapstructure:"intercept"`
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ app:
|
|||||||
plugins_dir: ~/.config/spilltea/plugins
|
plugins_dir: ~/.config/spilltea/plugins
|
||||||
|
|
||||||
intercept:
|
intercept:
|
||||||
default_auto_forward: false
|
default_intercept_enabled: true
|
||||||
default_capture_response: false
|
default_capture_response: false
|
||||||
auto_forward_regex:
|
auto_forward_regex:
|
||||||
- '\.(js|css|png|gif|ico|woff2?|ttf|svg)(\?.*)?$'
|
- '\.(js|css|png|gif|ico|woff2?|ttf|svg)(\?.*)?$'
|
||||||
@@ -61,7 +61,7 @@ keybindings:
|
|||||||
forward_all: "F"
|
forward_all: "F"
|
||||||
drop: "d"
|
drop: "d"
|
||||||
drop_all: "D"
|
drop_all: "D"
|
||||||
auto_forward: "a"
|
toggle_intercept: "a"
|
||||||
capture_response: "r"
|
capture_response: "r"
|
||||||
undo_edits: "ctrl+z"
|
undo_edits: "ctrl+z"
|
||||||
edit: "e,enter"
|
edit: "e,enter"
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ type InterceptKeys struct {
|
|||||||
ForwardAll string `mapstructure:"forward_all"`
|
ForwardAll string `mapstructure:"forward_all"`
|
||||||
Drop string `mapstructure:"drop"`
|
Drop string `mapstructure:"drop"`
|
||||||
DropAll string `mapstructure:"drop_all"`
|
DropAll string `mapstructure:"drop_all"`
|
||||||
AutoForward string `mapstructure:"auto_forward"`
|
ToggleIntercept string `mapstructure:"toggle_intercept"`
|
||||||
CaptureResponse string `mapstructure:"capture_response"`
|
CaptureResponse string `mapstructure:"capture_response"`
|
||||||
UndoEdits string `mapstructure:"undo_edits"`
|
UndoEdits string `mapstructure:"undo_edits"`
|
||||||
Edit string `mapstructure:"edit"`
|
Edit string `mapstructure:"edit"`
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ type InterceptKeyMap struct {
|
|||||||
ForwardAll key.Binding
|
ForwardAll key.Binding
|
||||||
Drop key.Binding
|
Drop key.Binding
|
||||||
DropAll key.Binding
|
DropAll key.Binding
|
||||||
AutoForward key.Binding
|
ToggleIntercept key.Binding
|
||||||
CaptureResponse key.Binding
|
CaptureResponse key.Binding
|
||||||
UndoEdits key.Binding
|
UndoEdits key.Binding
|
||||||
Edit key.Binding
|
Edit key.Binding
|
||||||
@@ -23,7 +23,7 @@ func newInterceptKeyMap(cfg config.InterceptKeys) InterceptKeyMap {
|
|||||||
ForwardAll: binding(cfg.ForwardAll, "forward all"),
|
ForwardAll: binding(cfg.ForwardAll, "forward all"),
|
||||||
Drop: binding(cfg.Drop, "drop"),
|
Drop: binding(cfg.Drop, "drop"),
|
||||||
DropAll: binding(cfg.DropAll, "drop all"),
|
DropAll: binding(cfg.DropAll, "drop all"),
|
||||||
AutoForward: binding(cfg.AutoForward, "auto forward"),
|
ToggleIntercept: binding(cfg.ToggleIntercept, "toggle intercept"),
|
||||||
CaptureResponse: binding(cfg.CaptureResponse, "capture response"),
|
CaptureResponse: binding(cfg.CaptureResponse, "capture response"),
|
||||||
UndoEdits: binding(cfg.UndoEdits, "undo edits"),
|
UndoEdits: binding(cfg.UndoEdits, "undo edits"),
|
||||||
Edit: binding(cfg.Edit, "edit"),
|
Edit: binding(cfg.Edit, "edit"),
|
||||||
@@ -36,6 +36,6 @@ func (ic InterceptKeyMap) Bindings() []key.Binding {
|
|||||||
ic.Forward, ic.ForwardAll,
|
ic.Forward, ic.ForwardAll,
|
||||||
ic.Drop, ic.DropAll,
|
ic.Drop, ic.DropAll,
|
||||||
ic.Edit, ic.EditExternal, ic.UndoEdits,
|
ic.Edit, ic.EditExternal, ic.UndoEdits,
|
||||||
ic.AutoForward, ic.CaptureResponse,
|
ic.ToggleIntercept, ic.CaptureResponse,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,8 +36,8 @@ func RenderWithTitle(border lipgloss.Style, title, content string, width, height
|
|||||||
if fillW < 0 {
|
if fillW < 0 {
|
||||||
fillW = 0
|
fillW = 0
|
||||||
}
|
}
|
||||||
topLine := "╭" + label + strings.Repeat("─", fillW) + "╮"
|
bc := lipgloss.NewStyle().Foreground(border.GetBorderTopForeground())
|
||||||
topLine = lipgloss.NewStyle().Foreground(border.GetBorderTopForeground()).Render(topLine)
|
topLine := bc.Render("╭ ") + bc.Render(title) + bc.Render(" "+strings.Repeat("─", fillW)+"╮")
|
||||||
|
|
||||||
return lipgloss.JoinVertical(lipgloss.Left, topLine, box)
|
return lipgloss.JoinVertical(lipgloss.Left, topLine, box)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ type Model struct {
|
|||||||
responseCursor int
|
responseCursor int
|
||||||
|
|
||||||
editing bool
|
editing bool
|
||||||
autoForward bool
|
interceptEnabled bool
|
||||||
pendingEdits map[*intercept.PendingRequest]string
|
pendingEdits map[*intercept.PendingRequest]string
|
||||||
pendingResponseEdits map[*intercept.PendingResponse]string
|
pendingResponseEdits map[*intercept.PendingResponse]string
|
||||||
|
|
||||||
@@ -59,8 +59,8 @@ func New(broker *intercept.Broker) Model {
|
|||||||
broker.SetCaptureResponse(cfg.Intercept.DefaultCaptureResponse)
|
broker.SetCaptureResponse(cfg.Intercept.DefaultCaptureResponse)
|
||||||
|
|
||||||
return Model{
|
return Model{
|
||||||
broker: broker,
|
broker: broker,
|
||||||
autoForward: cfg.Intercept.DefaultAutoForward,
|
interceptEnabled: cfg.Intercept.DefaultInterceptEnabled,
|
||||||
captureResponse: cfg.Intercept.DefaultCaptureResponse,
|
captureResponse: cfg.Intercept.DefaultCaptureResponse,
|
||||||
listViewport: lv,
|
listViewport: lv,
|
||||||
responseViewport: rv,
|
responseViewport: rv,
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
|
|||||||
|
|
||||||
switch msg := msg.(type) {
|
switch msg := msg.(type) {
|
||||||
case intercept.RequestArrivedMsg:
|
case intercept.RequestArrivedMsg:
|
||||||
if m.autoForward {
|
if !m.interceptEnabled {
|
||||||
m.broker.Decide(msg.Req, intercept.Forward)
|
m.broker.Decide(msg.Req, intercept.Forward)
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
@@ -152,9 +152,9 @@ func (m Model) updateNormalMode(msg tea.KeyPressMsg, cmds *[]tea.Cmd) (tea.Model
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
case key.Matches(msg, keys.Keys.Intercept.AutoForward):
|
case key.Matches(msg, keys.Keys.Intercept.ToggleIntercept):
|
||||||
m.autoForward = !m.autoForward
|
m.interceptEnabled = !m.interceptEnabled
|
||||||
if m.autoForward {
|
if !m.interceptEnabled {
|
||||||
for len(m.queue) > 0 {
|
for len(m.queue) > 0 {
|
||||||
m.applyAndDecide(intercept.Forward)
|
m.applyAndDecide(intercept.Forward)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -52,8 +52,8 @@ func (m *Model) renderListPanel(w, h int) string {
|
|||||||
)
|
)
|
||||||
|
|
||||||
title := icons.I.Request + "Requests"
|
title := icons.I.Request + "Requests"
|
||||||
if m.autoForward {
|
if !m.interceptEnabled {
|
||||||
title += " [auto forward]"
|
title += " " + lipgloss.NewStyle().Foreground(style.S.Error).Render("[intercept off]")
|
||||||
}
|
}
|
||||||
return style.RenderWithTitle(border, title, inner, w, h)
|
return style.RenderWithTitle(border, title, inner, w, h)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user