From ed1edb40423e5c0598ee647236c499d1389c6f52 Mon Sep 17 00:00:00 2001 From: Gregory Rudolph Date: Wed, 9 Oct 2019 11:48:01 -0400 Subject: [PATCH] Simplified editing with popup funcs in main --- cmdEdit.go | 24 ++++-------------------- 1 file changed, 4 insertions(+), 20 deletions(-) diff --git a/cmdEdit.go b/cmdEdit.go index dbfc766..aaebe84 100644 --- a/cmdEdit.go +++ b/cmdEdit.go @@ -6,8 +6,6 @@ import ( "fmt" "strconv" "strings" - - "github.com/jroimartin/gocui" ) func init() { @@ -37,24 +35,10 @@ func cmdEdit(cmd []string) { return } editString := origMessage.Result.Messages[0].Msg.Content.Text.Body - g.Update(func(g *gocui.Gui) error { - inputView, err := g.View("Input") - if err != nil { - return err - } else { - editString = fmt.Sprintf("/edit %d %s", messageId, editString) - fmt.Fprintf(inputView, editString) - viewX, viewY := inputView.Size() - if len(editString) < viewX { - viewX = len(editString) - viewY = 0 - } else { - viewX = viewX / len(editString) - } - inputView.MoveCursor(viewX, viewY, true) - } - return nil - }) + clearView("Edit") + popupView("Edit") + printToView("Edit", fmt.Sprintf("/e %d %s", messageId, editString)) + viewTitle("Edit", fmt.Sprintf(" Editing message %d ", messageId)) return } if len(cmd) < 3 {