MCPcopy
hub / github.com/qustavo/httplab / openBodyFilePopup

Method openBodyFilePopup

ui/ui.go:724–755  ·  view source on GitHub ↗
(g *gocui.Gui)

Source from the content-addressed store, hash-verified

722}
723
724func (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
757func (ui *UI) nextBodyMode(g *gocui.Gui) error {
758 modes := []httplab.BodyMode{

Callers 1

onOpenFileFunction · 0.80

Calls 5

closePopupMethod · 0.95
openPopupMethod · 0.95
InfoMethod · 0.95
renderBodyMethod · 0.95
SetFileMethod · 0.80

Tested by

no test coverage detected