Browse Source

Simplified editing with popup funcs in main

pull/2/head
Gregory Rudolph 5 years ago
parent
commit
ed1edb4042
  1. 24
      cmdEdit.go

24
cmdEdit.go

@ -6,8 +6,6 @@ import (
"fmt" "fmt"
"strconv" "strconv"
"strings" "strings"
"github.com/jroimartin/gocui"
) )
func init() { func init() {
@ -37,24 +35,10 @@ func cmdEdit(cmd []string) {
return return
} }
editString := origMessage.Result.Messages[0].Msg.Content.Text.Body editString := origMessage.Result.Messages[0].Msg.Content.Text.Body
g.Update(func(g *gocui.Gui) error { clearView("Edit")
inputView, err := g.View("Input") popupView("Edit")
if err != nil { printToView("Edit", fmt.Sprintf("/e %d %s", messageId, editString))
return err viewTitle("Edit", fmt.Sprintf(" Editing message %d ", messageId))
} 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
})
return return
} }
if len(cmd) < 3 { if len(cmd) < 3 {

Loading…
Cancel
Save