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