regex/doGui.go

105 lines
2.0 KiB
Go

// Copyright 2017-2025 WIT.COM Inc. All rights reserved.
// Use of this source code is governed by the GPL 3.0
package main
// An app to submit patches for the 30 GO GUI repos
import (
"fmt"
"os"
"time"
"go.wit.com/gui"
"go.wit.com/lib/debugger"
"go.wit.com/lib/gadgets"
"go.wit.com/lib/gui/logsettings"
"go.wit.com/lib/gui/shell"
"go.wit.com/log"
)
func debug() {
time.Sleep(2 * time.Second)
for {
log.Info("idle loop() todo: could check for things here")
time.Sleep(90 * time.Second)
}
}
func doGui() {
me.myGui = gui.New()
// me.myGui.SetAppDefaultPlugin(me.forge.Config.DefaultGui)
me.myGui.Default()
win := gadgets.NewGenericWindow("regex: a WIT Cloud private AI tool", "Current Conversations")
drawWindow(win)
win.Custom = func() {
log.Warn("MAIN WINDOW CLOSE")
me.myGui.StandardExit()
os.Exit(0)
}
me.mainWindow = win
// sits here forever
debug()
}
func drawWindow(win *gadgets.GenericWindow) {
grid := win.Group.RawGrid()
grid.NewLabel("label worked")
grid.NextRow()
var insertWin *gadgets.GenericWindow
s := fmt.Sprintf("Show Chat Entries (%d)", me.chats.Len())
grid.NewButton(s, func() {
// if the window exists, just toggle it open or closed
if insertWin != nil {
insertWin.Toggle()
return
}
insertWin = makeChatsWindow()
})
grid.NewButton("simple hello", func() {
err := simpleHello()
if err != nil {
badExit(err)
}
})
grid.NewButton("submit question", func() {
doEditorOnce()
})
grid.NewButton("print playback", func() {
shell.RunVerbose([]string{"regex", "playback"})
})
grid.NewButton("clean", func() {
doClean()
})
grid.NextRow()
grid.NewButton("debugger", func() {
debugger.DebugWindow()
})
grid.NewButton("logging", func() {
logsettings.LogWindow()
})
}
// old things before they are removed, deprecated, fixed, etc
func makeOldStuff() *gadgets.GenericWindow {
oldWin := gadgets.NewGenericWindow("old code", "old code on it's way out")
grid := oldWin.Group.RawGrid()
grid.NewButton("Release Window", func() {
log.Info("todo: move releaser here")
})
return oldWin
}