(g *gocui.Gui)
| 722 | } |
| 723 | |
| 724 | func (ui *UI) openBodyFilePopup(g *gocui.Gui) error { |
| 725 | if err := ui.closePopup(g, ui.currentPopup); err != nil { |
| 726 | return err |
| 727 | } |
| 728 | |
| 729 | popup, err := ui.openPopup(g, FileDialogView, 20, 2) |
| 730 | if err != nil { |
| 731 | return err |
| 732 | } |
| 733 | |
| 734 | g.Cursor = true |
| 735 | popup.Title = "Open Body File" |
| 736 | popup.Editable = true |
| 737 | |
| 738 | onEnter := func(g *gocui.Gui, v *gocui.View) error { |
| 739 | path := strings.Trim(v.Buffer(), " \n") |
| 740 | if path == "" { |
| 741 | return ui.closePopup(g, popup.Name()) |
| 742 | } |
| 743 | |
| 744 | if err := ui.resp.Body.SetFile(path); err != nil { |
| 745 | ui.Info(g, "%+v", err) |
| 746 | } else { |
| 747 | if err := ui.renderBody(g); err != nil { |
| 748 | return err |
| 749 | } |
| 750 | } |
| 751 | return ui.closePopup(g, popup.Name()) |
| 752 | } |
| 753 | |
| 754 | return g.SetKeybinding(popup.Name(), gocui.KeyEnter, gocui.ModNone, onEnter) |
| 755 | } |
| 756 | |
| 757 | func (ui *UI) nextBodyMode(g *gocui.Gui) error { |
| 758 | modes := []httplab.BodyMode{ |
no test coverage detected