|
|
|
@ -4,12 +4,14 @@ import (
|
|
|
|
|
"fmt"
|
|
|
|
|
"log"
|
|
|
|
|
"strconv"
|
|
|
|
|
"strings"
|
|
|
|
|
|
|
|
|
|
"github.com/xxjwxc/public/tools"
|
|
|
|
|
|
|
|
|
|
"github.com/xxjwxc/gormt/data/config"
|
|
|
|
|
|
|
|
|
|
"github.com/jroimartin/gocui"
|
|
|
|
|
"github.com/xxjwxc/public/myclipboard"
|
|
|
|
|
"github.com/xxjwxc/public/mycui"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
@ -77,7 +79,7 @@ func mainLayout(g *gocui.Gui) error {
|
|
|
|
|
// }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if v, err := g.SetView(_viewDefine, division(maxX, uiPart[0]), 1, maxX-1, maxY-1); err != nil {
|
|
|
|
|
if v, err := g.SetView(_viewDefine, division(maxX, uiPart[0]), 1, maxX-1, maxY-3); err != nil {
|
|
|
|
|
if err != gocui.ErrUnknownView {
|
|
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
@ -103,6 +105,11 @@ func nemuLayOut(g *gocui.Gui) {
|
|
|
|
|
AddHandler(gocui.KeyArrowUp, menuDlg.prevButton).AddHandler(gocui.KeyArrowDown, menuDlg.nextButton).
|
|
|
|
|
AddHandler(gocui.KeyEnter, enterSet).AddHandler(gocui.MouseLeft, enterSet))
|
|
|
|
|
|
|
|
|
|
maxX, maxY := g.Size() // division(maxY, uiPart[1])
|
|
|
|
|
clipboardBtn = mycui.NewButton(g, _clipboardBtn, SLocalize(_clipboardBtn), division(maxX, uiPart[0])+2, maxY-3, 5).
|
|
|
|
|
AddHandler(gocui.KeyEnter, enterClipboard).AddHandler(gocui.MouseLeft, enterClipboard)
|
|
|
|
|
clipboardBtn.Draw()
|
|
|
|
|
|
|
|
|
|
menuDlg.Draw()
|
|
|
|
|
menuFocusButton(g)
|
|
|
|
|
}
|
|
|
|
@ -163,6 +170,24 @@ func addlog(g *gocui.Gui, str string) error {
|
|
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func enterClipboard(g *gocui.Gui, v *gocui.View) error {
|
|
|
|
|
myclipboard.Set(copyInfo)
|
|
|
|
|
|
|
|
|
|
maxX, _ := g.Size()
|
|
|
|
|
modal := mycui.NewModal(g, division(maxX, uiPart[0])+5, 10, division(maxX, uiPart[0])+35).
|
|
|
|
|
SetTextColor(gocui.ColorRed).SetText("copy success \n 已 复 制 到 剪 切 板 ")
|
|
|
|
|
modal.Mouse = true
|
|
|
|
|
// modal.SetBgColor(gocui.ColorRed)
|
|
|
|
|
_handle := func(g *gocui.Gui, v *gocui.View) error {
|
|
|
|
|
modal.Close()
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
modal.AddButton("ok", "OK", gocui.KeyEnter, _handle).AddHandler(gocui.MouseLeft, _handle)
|
|
|
|
|
modal.Draw()
|
|
|
|
|
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func enterRun(g *gocui.Gui, v *gocui.View) error {
|
|
|
|
|
setlog(g, "run .... ing")
|
|
|
|
|
generate(g, v)
|
|
|
|
@ -242,12 +267,14 @@ func buttonSave(g *gocui.Gui, v *gocui.View) error {
|
|
|
|
|
port, err := strconv.Atoi(mp["db_port"])
|
|
|
|
|
if err != nil {
|
|
|
|
|
modal := mycui.NewModal(g, division(maxX, uiPart[0])+5, 10, division(maxX, uiPart[0])+35).SetTextColor(gocui.ColorRed).SetText("port error")
|
|
|
|
|
// modal.SetBgColor(gocui.ColorRed)
|
|
|
|
|
modal.AddButton("ok", "OK", gocui.KeyEnter, func(g *gocui.Gui, v *gocui.View) error {
|
|
|
|
|
|
|
|
|
|
_handle := func(g *gocui.Gui, v *gocui.View) error {
|
|
|
|
|
modal.Close()
|
|
|
|
|
form.SetCurrentItem(form.GetCurrentItem())
|
|
|
|
|
return nil
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
// modal.SetBgColor(gocui.ColorRed)
|
|
|
|
|
modal.AddButton("ok", "OK", gocui.KeyEnter, _handle).AddHandler(gocui.MouseLeft, _handle)
|
|
|
|
|
|
|
|
|
|
modal.Draw()
|
|
|
|
|
return nil
|
|
|
|
@ -273,11 +300,12 @@ func buttonSave(g *gocui.Gui, v *gocui.View) error {
|
|
|
|
|
|
|
|
|
|
config.SaveToFile()
|
|
|
|
|
modal := mycui.NewModal(g, division(maxX, uiPart[0])+5, 10, division(maxX, uiPart[0])+35).SetText("save success")
|
|
|
|
|
modal.AddButton("ok", "OK", gocui.KeyEnter, func(g *gocui.Gui, v *gocui.View) error {
|
|
|
|
|
_handle := func(g *gocui.Gui, v *gocui.View) error {
|
|
|
|
|
modal.Close()
|
|
|
|
|
buttonCancel(g, v)
|
|
|
|
|
return nil
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
modal.AddButton("ok", "OK", gocui.KeyEnter, _handle).AddHandler(gocui.MouseLeft, _handle)
|
|
|
|
|
modal.Draw()
|
|
|
|
|
|
|
|
|
|
return nil
|
|
|
|
@ -306,10 +334,11 @@ func showStruct(g *gocui.Gui, v *gocui.View) error {
|
|
|
|
|
l = ""
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var out []string
|
|
|
|
|
var out, out1 []string
|
|
|
|
|
for _, v := range gPkg.Structs {
|
|
|
|
|
if v.Name == l {
|
|
|
|
|
out = v.GeneratesColor()
|
|
|
|
|
out1 = v.Generates()
|
|
|
|
|
break
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -318,6 +347,9 @@ func showStruct(g *gocui.Gui, v *gocui.View) error {
|
|
|
|
|
for _, v := range out {
|
|
|
|
|
addlog(g, v)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
copyInfo = strings.Join(out1, "")
|
|
|
|
|
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|