2023-04-12 22:21:57 -05:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"errors"
|
|
|
|
"fmt"
|
|
|
|
|
|
|
|
"github.com/awesome-gocui/gocui"
|
|
|
|
)
|
|
|
|
|
2023-04-13 07:04:41 -05:00
|
|
|
var outputW int = 80
|
|
|
|
var outputH int = 24
|
|
|
|
|
2023-04-12 22:21:57 -05:00
|
|
|
func moveMsg(g *gocui.Gui) {
|
|
|
|
mx, my := g.MousePosition()
|
|
|
|
if !movingMsg && (mx != initialMouseX || my != initialMouseY) {
|
|
|
|
movingMsg = true
|
|
|
|
}
|
2023-04-13 07:04:41 -05:00
|
|
|
g.SetView("msg", mx-xOffset, my-yOffset, mx-xOffset+outputW, my-yOffset+outputH, 0)
|
2023-04-24 14:17:43 -05:00
|
|
|
g.SetViewOnBottom("msg")
|
2023-04-12 22:21:57 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
func showMsg(g *gocui.Gui, v *gocui.View) error {
|
|
|
|
var l string
|
|
|
|
var err error
|
|
|
|
|
|
|
|
if _, err := g.SetCurrentView(v.Name()); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
_, cy := v.Cursor()
|
|
|
|
if l, err = v.Line(cy); err != nil {
|
|
|
|
l = ""
|
|
|
|
}
|
|
|
|
|
2023-04-24 06:22:14 -05:00
|
|
|
makeOutputWidget(g, l)
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func makeOutputWidget(g *gocui.Gui, stringFromMouseClick string) {
|
2023-04-12 22:21:57 -05:00
|
|
|
maxX, maxY := g.Size()
|
2023-04-24 06:22:14 -05:00
|
|
|
v, err := g.SetView("msg", maxX-32, maxY/2, maxX/2+outputW, maxY/2+outputH, 0)
|
|
|
|
// help, err := g.SetView("help", maxX-32, 0, maxX-1, 13, 0)
|
|
|
|
if errors.Is(err, gocui.ErrUnknownView) {
|
|
|
|
log("this is supposed to happen?", err)
|
2023-04-12 22:21:57 -05:00
|
|
|
}
|
2023-04-24 06:22:14 -05:00
|
|
|
|
|
|
|
if (err != nil) {
|
|
|
|
log("create output window failed", err)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
v.Clear()
|
|
|
|
v.SelBgColor = gocui.ColorCyan
|
|
|
|
v.SelFgColor = gocui.ColorBlack
|
|
|
|
fmt.Fprintln(v, "figure out how to capture STDOUT to here\n" + stringFromMouseClick)
|
|
|
|
g.SetViewOnBottom("msg")
|
2023-04-24 14:17:43 -05:00
|
|
|
// g.SetViewOnBottom(v.Name())
|
2023-04-24 06:22:14 -05:00
|
|
|
return
|
2023-04-12 22:21:57 -05:00
|
|
|
}
|