Bug #24: Cursor now moves to end of message

This commit is contained in:
2019-10-22 09:30:18 -04:00
parent e084c16ba8
commit 5eb23ff993
2 changed files with 17 additions and 0 deletions

View File

@ -49,6 +49,7 @@ func cmdEdit(cmd []string) {
popupView("Edit")
printToView("Edit", fmt.Sprintf("/e %d %s", messageID, editString))
setViewTitle("Edit", fmt.Sprintf(" Editing message %d ", messageID))
moveCursorToEnd("Edit")
return
}
if len(cmd) < 3 {

16
main.go
View File

@ -202,6 +202,22 @@ func popupView(viewName string) {
})
}
func moveCursorToEnd(viewName string) {
g.Update(func(g *gocui.Gui) error {
inputView, err := g.View(viewName)
if err != nil {
return err
}
inputString, _ := getInputString(viewName)
stringLen := len(inputString)
maxX, _ := inputView.Size()
x := stringLen % maxX
y := stringLen / maxX
inputView.MoveCursor(x, y, true)
return nil
})
}
func clearView(viewName string) {
g.Update(func(g *gocui.Gui) error {
inputView, err := g.View(viewName)