Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ Keybinding | Description
<kbd>Ctrl+K</kbd>, <kbd>Shift+Tab</kbd> | Previous view
<kbd>Ctlr+J</kbd>, <kbd>Tab</kbd> | Next view
<kbd>Ctlr+T</kbd> | Toggle context specific search
<kbd>Ctrl+L</kbd> | Clear all tabs to default
<kbd>Alt+H</kbd> | Toggle history
<kbd>Down</kbd> | Move down one view line
<kbd>Up</kbd> | Move up one view line
Expand Down
11 changes: 11 additions & 0 deletions commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,17 @@ var COMMANDS map[string]func(string, *App) CommandFunc = map[string]func(string,
return nil
}
},
"clearTabs": func(_ string, a *App) CommandFunc {
return func(g *gocui.Gui, _ *gocui.View) error {
if a.currentPopup != "" {
return nil
}

a.restoreRequest(g, 0, true)
g.SetCurrentView(URL_VIEW)
return nil
}
},
}

func scrollView(v *gocui.View, dy int) error {
Expand Down
1 change: 1 addition & 0 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ var DefaultKeys = map[string]map[string]string{
"CtrlO": "openEditor",
"CtrlT": "toggleContextSpecificSearch",
"CtrlX": "clearHistory",
"CtrlL": "clearTabs",
"Tab": "nextView",
"CtrlJ": "nextView",
"CtrlK": "prevView",
Expand Down
1 change: 1 addition & 0 deletions sample-config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ CtrlF = "loadRequest"
CtrlE = "saveRequest"
CtrlT = "toggleContextSpecificSearch"
CtrlX = "clearHistory"
CtrlL = "clearTabs"
Tab = "nextView"
CtrlJ = "nextView"
CtrlK = "prevView"
Expand Down
37 changes: 29 additions & 8 deletions wuzz.go
Original file line number Diff line number Diff line change
Expand Up @@ -1102,6 +1102,16 @@ func (a *App) SetKeys(g *gocui.Gui) error {
return nil
})

g.SetKeybinding(ALL_VIEWS, gocui.KeyCtrlL, gocui.ModNone, func(g *gocui.Gui, v *gocui.View) error {
if a.currentPopup != "" {
return nil
}

a.restoreRequest(g, 0, true)
g.SetCurrentView(URL_VIEW)
return nil
})

g.SetKeybinding(REQUEST_METHOD_VIEW, gocui.KeyEnter, gocui.ModNone, a.ToggleMethodList)

cursDown := func(g *gocui.Gui, v *gocui.View) error {
Expand All @@ -1126,7 +1136,7 @@ func (a *App) SetKeys(g *gocui.Gui) error {
if len(a.history) <= cy {
return nil
}
a.restoreRequest(g, cy)
a.restoreRequest(g, cy, false)
return nil
})

Expand Down Expand Up @@ -1445,13 +1455,19 @@ func (a *App) OpenSaveResultView(saveResult string, g *gocui.Gui) (err error) {
return err
}

func (a *App) restoreRequest(g *gocui.Gui, idx int) {
if idx < 0 || idx >= len(a.history) {
func (a *App) restoreRequest(g *gocui.Gui, idx int, isCleanToggle bool) {
if (idx < 0 || idx >= len(a.history)) && !isCleanToggle {
return
}
a.closePopup(g, HISTORY_VIEW)
a.historyIndex = idx
r := a.history[idx]
r := &Request{
Url: fmt.Sprintf("%s://", a.config.General.DefaultURLScheme),
Method: http.MethodGet,
}
if !isCleanToggle {
a.closePopup(g, HISTORY_VIEW)
a.historyIndex = idx
r = a.history[idx]
}

v, _ := g.View(URL_VIEW)
setViewTextAndCursor(v, r.Url)
Expand All @@ -1471,8 +1487,13 @@ func (a *App) restoreRequest(g *gocui.Gui, idx int) {
v, _ = g.View(RESPONSE_HEADERS_VIEW)
setViewTextAndCursor(v, r.ResponseHeaders)

a.PrintBody(g)

switch isCleanToggle {
case true:
v, _ = g.View(RESPONSE_BODY_VIEW)
setViewTextAndCursor(v, "")
default:
a.PrintBody(g)
}
}

func (a *App) LoadConfig(configPath string) error {
Expand Down