diff --git a/README.md b/README.md
index a7f853f..c6033fb 100644
--- a/README.md
+++ b/README.md
@@ -46,6 +46,7 @@ Keybinding | Description
Ctlr+J, Tab | Next view
Ctlr+T | Toggle context specific search
Alt+H | Toggle history
+Ctrl+Q | Toggle requests view
Down | Move down one view line
Up | Move up one view line
Page down | Move down one view page
diff --git a/commands.go b/commands.go
index f312896..3a5634a 100644
--- a/commands.go
+++ b/commands.go
@@ -119,6 +119,9 @@ var COMMANDS map[string]func(string, *App) CommandFunc = map[string]func(string,
return nil
}
},
+ "requests": func(_ string, a *App) CommandFunc {
+ return a.ToggleRequests
+ },
}
func scrollView(v *gocui.View, dy int) error {
diff --git a/config/config.go b/config/config.go
index f0dec95..59f121e 100644
--- a/config/config.go
+++ b/config/config.go
@@ -66,6 +66,7 @@ var DefaultKeys = map[string]map[string]string{
"CtrlJ": "nextView",
"CtrlK": "prevView",
"AltH": "history",
+ "CtrlQ": "requests",
"F2": "focus url",
"F3": "focus get",
"F4": "focus method",
diff --git a/sample-config.toml b/sample-config.toml
index b8df352..5f725cd 100644
--- a/sample-config.toml
+++ b/sample-config.toml
@@ -23,6 +23,7 @@ Tab = "nextView"
CtrlJ = "nextView"
CtrlK = "prevView"
AltH = "history"
+CtrlQ = "requests"
F2 = "focus url"
F3 = "focus get"
F4 = "focus method"
diff --git a/wuzz.go b/wuzz.go
index 258bcb7..2cf5cd9 100644
--- a/wuzz.go
+++ b/wuzz.go
@@ -65,6 +65,7 @@ const (
SAVE_RESULT_VIEW = "save-result"
METHOD_LIST_VIEW = "method-list"
HELP_VIEW = "help"
+ REQUESTS_VIEW = "requests"
)
var VIEW_TITLES = map[string]string{
@@ -341,6 +342,7 @@ type App struct {
history []*Request
config *config.Config
statusLine *StatusLine
+ Requests []os.FileInfo
}
type ViewEditor struct {
@@ -1172,6 +1174,19 @@ func (a *App) SetKeys(g *gocui.Gui) error {
a.closePopup(g, SAVE_RESULT_VIEW)
return nil
})
+
+ g.SetKeybinding(REQUESTS_VIEW, gocui.KeyArrowDown, gocui.ModNone, cursDown)
+ g.SetKeybinding(REQUESTS_VIEW, gocui.KeyArrowUp, gocui.ModNone, cursUp)
+ g.SetKeybinding(REQUESTS_VIEW, gocui.KeyEnter, gocui.ModNone, func(g *gocui.Gui, v *gocui.View) error {
+ _, cy := v.Cursor()
+ // TODO error
+ if len(a.Requests) <= cy {
+ return nil
+ }
+ a.LoadRequest(g, a.Requests[cy].Name())
+ a.closePopup(g, REQUESTS_VIEW)
+ return nil
+ })
return nil
}
@@ -1398,6 +1413,39 @@ func (a *App) ToggleMethodList(g *gocui.Gui, _ *gocui.View) (err error) {
return
}
+func (a *App) ToggleRequests(g *gocui.Gui, _ *gocui.View) (err error) {
+ // Destroy if present
+ if a.currentPopup == REQUESTS_VIEW {
+ a.closePopup(g, REQUESTS_VIEW)
+ return
+ }
+
+ dir, err := os.Getwd()
+ if err != nil {
+ return
+ }
+ files, err := ioutil.ReadDir(dir)
+ a.Requests = files
+ if err != nil {
+ return
+ }
+
+ requestsView, err := a.CreatePopupView(REQUESTS_VIEW, 100, len(files), g)
+ if err != nil {
+ return
+ }
+ requestsView.Title = VIEW_TITLES[REQUESTS_VIEW]
+ for _, r := range files {
+ if r.IsDir() {
+ continue
+ }
+ fmt.Fprintln(requestsView, r.Name())
+ }
+ g.SetViewOnTop(REQUESTS_VIEW)
+ g.SetCurrentView(REQUESTS_VIEW)
+ return
+}
+
func (a *App) OpenSaveDialog(title string, g *gocui.Gui, save func(g *gocui.Gui, v *gocui.View) error) error {
dialog, err := a.CreatePopupView(SAVE_DIALOG_VIEW, 60, 1, g)
if err != nil {