Compare commits
No commits in common. "guimaster" and "v0.22.43" have entirely different histories.
|
@ -5,4 +5,3 @@
|
||||||
go.mod
|
go.mod
|
||||||
go.sum
|
go.sum
|
||||||
gocui
|
gocui
|
||||||
resources/*.so
|
|
||||||
|
|
2
Makefile
2
Makefile
|
@ -25,7 +25,7 @@ custom:
|
||||||
clean:
|
clean:
|
||||||
rm -f gocui *.so go.*
|
rm -f gocui *.so go.*
|
||||||
rm -f *.pb.go *.patch
|
rm -f *.pb.go *.patch
|
||||||
go-mod-clean purge
|
go-mod-clean --purge
|
||||||
|
|
||||||
# Test the README.md & doc.go file
|
# Test the README.md & doc.go file
|
||||||
# this runs pkgsite, the binary that does dev.go.dev
|
# this runs pkgsite, the binary that does dev.go.dev
|
||||||
|
|
|
@ -58,7 +58,6 @@ func registerHandlers(g *gocui.Gui) {
|
||||||
g.SetKeybinding("", 'L', gocui.ModNone, printWidgetTree) // 'L' list all widgets in tree view
|
g.SetKeybinding("", 'L', gocui.ModNone, printWidgetTree) // 'L' list all widgets in tree view
|
||||||
g.SetKeybinding("", 'f', gocui.ModNone, theFind) // 'f' shows what is under your mouse
|
g.SetKeybinding("", 'f', gocui.ModNone, theFind) // 'f' shows what is under your mouse
|
||||||
g.SetKeybinding("", 'd', gocui.ModNone, theLetterD) // 'd' toggles on and off debugging buttons
|
g.SetKeybinding("", 'd', gocui.ModNone, theLetterD) // 'd' toggles on and off debugging buttons
|
||||||
g.SetKeybinding("", 'r', gocui.ModNone, reverseStdout) // 'r' turns scrolling of STDOUT upside down
|
|
||||||
g.SetKeybinding("", 'q', gocui.ModNone, quit) // 'q' only exits gocui. plugin stays alive (?)
|
g.SetKeybinding("", 'q', gocui.ModNone, quit) // 'q' only exits gocui. plugin stays alive (?)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -104,9 +103,7 @@ func theDarkness(g *gocui.Gui, v *gocui.View) error {
|
||||||
log.Info("you have seen the light")
|
log.Info("you have seen the light")
|
||||||
} else {
|
} else {
|
||||||
me.dark = true
|
me.dark = true
|
||||||
log.Info("you have entered into darkness (you may need to trigger SIGWINCH)")
|
log.Info("you have entered into darkness")
|
||||||
log.Info("or maybe open a new window. notsure. This obviously isn't finished.")
|
|
||||||
log.Info("submit patches to this and you will definitely get free cloud credits at WIT")
|
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -141,13 +138,11 @@ func doEsc(g *gocui.Gui, v *gocui.View) error {
|
||||||
me.dropdown.tk.Hide()
|
me.dropdown.tk.Hide()
|
||||||
me.dropdown.active = false
|
me.dropdown.active = false
|
||||||
log.Info("escaped from dropdown")
|
log.Info("escaped from dropdown")
|
||||||
me.baseGui.SetCurrentView(me.notify.clock.tk.cuiName)
|
|
||||||
}
|
}
|
||||||
if me.textbox.active {
|
if me.textbox.active {
|
||||||
me.textbox.tk.Hide()
|
me.textbox.tk.Hide()
|
||||||
me.textbox.active = false
|
me.textbox.active = false
|
||||||
log.Info("escaped from textbox")
|
log.Info("escaped from textbox")
|
||||||
me.baseGui.SetCurrentView(me.notify.clock.tk.cuiName)
|
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -185,19 +180,6 @@ func theFind(g *gocui.Gui, v *gocui.View) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func reverseStdout(g *gocui.Gui, v *gocui.View) error {
|
|
||||||
if me.stdout.reverse {
|
|
||||||
me.stdout.reverse = false
|
|
||||||
log.Info("stdout scrolling normal")
|
|
||||||
} else {
|
|
||||||
me.stdout.reverse = true
|
|
||||||
log.Info("stdout scrolling is reversed. this is sometimes useful when you")
|
|
||||||
log.Info("only need to see a few most recent lines and have the STDOUT window")
|
|
||||||
log.Info("take up minimal realestate at the bottom of your window")
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// is run whenever anyone hits 'd' (in an open space)
|
// is run whenever anyone hits 'd' (in an open space)
|
||||||
func theLetterD(g *gocui.Gui, v *gocui.View) error {
|
func theLetterD(g *gocui.Gui, v *gocui.View) error {
|
||||||
// widgets that don't have physical existance in
|
// widgets that don't have physical existance in
|
||||||
|
|
|
@ -77,20 +77,12 @@ func stdoutHome(g *gocui.Gui, v *gocui.View) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func stdoutArrowUp(g *gocui.Gui, v *gocui.View) error {
|
func stdoutArrowUp(g *gocui.Gui, v *gocui.View) error {
|
||||||
if me.stdout.reverse {
|
stdoutWheelsUp()
|
||||||
stdoutWheelsDown()
|
|
||||||
} else {
|
|
||||||
stdoutWheelsUp()
|
|
||||||
}
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func stdoutArrowDown(g *gocui.Gui, v *gocui.View) error {
|
func stdoutArrowDown(g *gocui.Gui, v *gocui.View) error {
|
||||||
if me.stdout.reverse {
|
stdoutWheelsDown()
|
||||||
stdoutWheelsUp()
|
|
||||||
} else {
|
|
||||||
stdoutWheelsDown()
|
|
||||||
}
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,6 @@ package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
|
||||||
|
|
||||||
"github.com/awesome-gocui/gocui"
|
"github.com/awesome-gocui/gocui"
|
||||||
"go.wit.com/log"
|
"go.wit.com/log"
|
||||||
|
@ -40,36 +39,6 @@ func quit(g *gocui.Gui, v *gocui.View) error {
|
||||||
return gocui.ErrQuit
|
return gocui.ErrQuit
|
||||||
}
|
}
|
||||||
|
|
||||||
func (tk *guiWidget) SetView() error {
|
|
||||||
if me.baseGui == nil {
|
|
||||||
return fmt.Errorf("me.baseGui == nil")
|
|
||||||
}
|
|
||||||
|
|
||||||
r := new(rectType)
|
|
||||||
r.w0 = tk.gocuiSize.w0
|
|
||||||
r.h0 = tk.gocuiSize.h0
|
|
||||||
r.w1 = tk.gocuiSize.w1
|
|
||||||
r.h1 = tk.gocuiSize.h1
|
|
||||||
|
|
||||||
return tk.SetViewRect(r)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (tk *guiWidget) SetViewRect(r *rectType) error {
|
|
||||||
if me.baseGui == nil {
|
|
||||||
return fmt.Errorf("me.baseGui == nil")
|
|
||||||
}
|
|
||||||
|
|
||||||
var err error
|
|
||||||
tk.v, err = me.baseGui.SetView(tk.cuiName, r.w0, r.h0, r.w1, r.h1, 0)
|
|
||||||
if err != nil {
|
|
||||||
if !errors.Is(err, gocui.ErrUnknownView) {
|
|
||||||
log.Log(ERROR, "SetView() global failed on name =", tk.cuiName)
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func SetView(name string, x0, y0, x1, y1 int, overlaps byte) *gocui.View {
|
func SetView(name string, x0, y0, x1, y1 int, overlaps byte) *gocui.View {
|
||||||
if me.baseGui == nil {
|
if me.baseGui == nil {
|
||||||
log.Log(ERROR, "SetView() ERROR: me.baseGui == nil")
|
log.Log(ERROR, "SetView() ERROR: me.baseGui == nil")
|
||||||
|
|
|
@ -27,7 +27,7 @@ func doMouseClick(w int, h int) {
|
||||||
// can't drag or do anything when dropdown or textbox are visible
|
// can't drag or do anything when dropdown or textbox are visible
|
||||||
for _, tk := range findByXY(w, h) {
|
for _, tk := range findByXY(w, h) {
|
||||||
if tk.WidgetId() == me.dropdown.wId {
|
if tk.WidgetId() == me.dropdown.wId {
|
||||||
log.Info("got dropdown click", w, h, tk.cuiName)
|
log.Info("got dropdwon click", w, h, tk.cuiName)
|
||||||
tk.dropdownClicked(w, h)
|
tk.dropdownClicked(w, h)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -107,7 +107,6 @@ func doMouseClick(w int, h int) {
|
||||||
tk.showDropdown()
|
tk.showDropdown()
|
||||||
return
|
return
|
||||||
case widget.Textbox:
|
case widget.Textbox:
|
||||||
log.Log(WARN, "TODO: textbox click")
|
|
||||||
tk.prepTextbox()
|
tk.prepTextbox()
|
||||||
return
|
return
|
||||||
case widget.Label:
|
case widget.Label:
|
||||||
|
|
|
@ -111,7 +111,15 @@ func (tk *guiWidget) moveNew() {
|
||||||
tk.makeWindowActive()
|
tk.makeWindowActive()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
|
if tk.WidgetType() == widget.Flag {
|
||||||
|
me.baseGui.SetView(tk.cuiName, w-3, h-3, w+20, h+20, 0)
|
||||||
|
// tk.verifyRect()
|
||||||
|
s := fmt.Sprintf("move(%dx%d) %s ###", w, h, tk.cuiName)
|
||||||
|
tk.dumpWidget(s)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
*/
|
||||||
if tk.WidgetType() == widget.Stdout {
|
if tk.WidgetType() == widget.Stdout {
|
||||||
if me.mouse.resize {
|
if me.mouse.resize {
|
||||||
newW := w - me.stdout.lastW
|
newW := w - me.stdout.lastW
|
||||||
|
|
13
find.go
13
find.go
|
@ -129,6 +129,13 @@ func findWindowUnderMouse() *guiWidget {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
// print out the window list
|
||||||
|
for _, tk := range me.allwin {
|
||||||
|
log.Info("findWindowUnderMouse() print:", tk.labelN, tk.window.active, tk.window.order)
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
// now check if the active window is below the mouse
|
// now check if the active window is below the mouse
|
||||||
for _, tk := range me.allwin {
|
for _, tk := range me.allwin {
|
||||||
if tk.window.active {
|
if tk.window.active {
|
||||||
|
@ -145,6 +152,12 @@ func findWindowUnderMouse() *guiWidget {
|
||||||
return a.window.order - b.window.order
|
return a.window.order - b.window.order
|
||||||
})
|
})
|
||||||
|
|
||||||
|
/*
|
||||||
|
// print out the window list
|
||||||
|
for _, tk := range me.allwin {
|
||||||
|
log.Info("findWindowUnderMouse() print:", tk.labelN, tk.window.active, tk.window.order)
|
||||||
|
}
|
||||||
|
*/
|
||||||
for _, win := range me.allwin {
|
for _, win := range me.allwin {
|
||||||
if win.full.inRect(w, h) {
|
if win.full.inRect(w, h) {
|
||||||
// log.Info(fmt.Sprintf("findWindowUnderMouse() found %s window (%dx%d)", win.cuiName, w, h))
|
// log.Info(fmt.Sprintf("findWindowUnderMouse() found %s window (%dx%d)", win.cuiName, w, h))
|
||||||
|
|
20
help.go
20
help.go
|
@ -25,20 +25,16 @@ import (
|
||||||
|
|
||||||
var helpText []string = []string{"Help Menu",
|
var helpText []string = []string{"Help Menu",
|
||||||
"",
|
"",
|
||||||
"Tab toggle through windows",
|
"Tab: toggle through windows",
|
||||||
"'O' toggle STDOUT",
|
"O: toggle STDOUT",
|
||||||
"'H' toggle this gocui menu",
|
"H: toggle this gocui menu",
|
||||||
"'D' toggle light/dark mode",
|
"L: toggle light/dark mode",
|
||||||
"CTRL-z background to shell",
|
"CTRL-c: quit()",
|
||||||
"CTRL-c quit()",
|
|
||||||
"",
|
"",
|
||||||
"Debugging:",
|
"Debugging:",
|
||||||
"'S' Supermouse mode",
|
"S: Supermouse mode",
|
||||||
"'M' list all widget positions",
|
"M: list all widget positions",
|
||||||
"'L' list all widgets in tree",
|
"L: list all widgets in tree",
|
||||||
"<Pgup> scroll up the STDOUT window",
|
|
||||||
"<Pgdn> scroll down the STDOUT window",
|
|
||||||
"'r' reverse STDOUT scrolling",
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func hideHelp() {
|
func hideHelp() {
|
||||||
|
|
2
init.go
2
init.go
|
@ -108,6 +108,7 @@ func toolkitInit() {
|
||||||
if me.textbox.tk == nil {
|
if me.textbox.tk == nil {
|
||||||
log.Log(INFO, "gocui toolkitInit() initTextbox me.ok =", me.ok)
|
log.Log(INFO, "gocui toolkitInit() initTextbox me.ok =", me.ok)
|
||||||
initTextbox()
|
initTextbox()
|
||||||
|
me.textbox.tk.prepTextbox()
|
||||||
}
|
}
|
||||||
// TEST TEXTBOX END
|
// TEST TEXTBOX END
|
||||||
}
|
}
|
||||||
|
@ -456,6 +457,7 @@ func newWindowTrigger() {
|
||||||
}
|
}
|
||||||
if me.textbox.tk == nil {
|
if me.textbox.tk == nil {
|
||||||
initTextbox()
|
initTextbox()
|
||||||
|
me.textbox.tk.prepTextbox()
|
||||||
}
|
}
|
||||||
tk.makeWindowActive()
|
tk.makeWindowActive()
|
||||||
me.myTree.Unlock()
|
me.myTree.Unlock()
|
||||||
|
|
67
libnotify.go
67
libnotify.go
|
@ -150,17 +150,6 @@ func setNotifyIconText(s string) {
|
||||||
me.notify.icon.tk.setColorNotifyIcon()
|
me.notify.icon.tk.setColorNotifyIcon()
|
||||||
me.baseGui.SetViewOnTop(me.notify.icon.tk.v.Name())
|
me.baseGui.SetViewOnTop(me.notify.icon.tk.v.Name())
|
||||||
log.Info("setNotifyIconText() updated menu to:", me.notify.icon.tk.labelN)
|
log.Info("setNotifyIconText() updated menu to:", me.notify.icon.tk.labelN)
|
||||||
// print out the window list // TODO: put this in libnotify
|
|
||||||
for _, tk := range me.allwin {
|
|
||||||
log.Info("known window Window", tk.labelN, tk.window.active, tk.window.order)
|
|
||||||
}
|
|
||||||
if s == "[X]" {
|
|
||||||
log.Warn("should turn on help window here")
|
|
||||||
showHelp()
|
|
||||||
} else {
|
|
||||||
log.Warn("should turn off help window here")
|
|
||||||
hideHelp()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// in the very end of redrawing things, this will place the help and stdout on the top or botton
|
// in the very end of redrawing things, this will place the help and stdout on the top or botton
|
||||||
|
@ -218,14 +207,15 @@ func hardDrawUnderMouse(tk *guiWidget, name string) {
|
||||||
tk.Hide()
|
tk.Hide()
|
||||||
}
|
}
|
||||||
w, h := me.baseGui.MousePosition()
|
w, h := me.baseGui.MousePosition()
|
||||||
r := new(rectType)
|
a := w
|
||||||
r.w0 = w
|
b := h
|
||||||
r.h0 = h
|
c := w + 8
|
||||||
r.w1 = w + 8
|
d := h + 4
|
||||||
r.h1 = h + 4
|
var err error
|
||||||
if err := tk.SetViewRect(r); err != nil {
|
tk.v, err = me.baseGui.SetView(tk.cuiName, a, b, c, d, 0)
|
||||||
log.Info("hardDrawUnderMouse() err", tk.cuiName, err)
|
if err == nil {
|
||||||
tk.dumpWidget("hardDrawERR")
|
log.Info("hardDrawUnderMouse() err ok widget", tk.cuiName)
|
||||||
|
tk.dumpWidget("hard draw err")
|
||||||
}
|
}
|
||||||
tk.v.Frame = false
|
tk.v.Frame = false
|
||||||
tk.v.Clear()
|
tk.v.Clear()
|
||||||
|
@ -236,14 +226,20 @@ func hardDrawAtgocuiSize(tk *guiWidget) {
|
||||||
if tk.v != nil {
|
if tk.v != nil {
|
||||||
tk.Hide()
|
tk.Hide()
|
||||||
}
|
}
|
||||||
if err := tk.SetView(); err != nil {
|
a := tk.gocuiSize.w0
|
||||||
|
b := tk.gocuiSize.h0
|
||||||
|
c := tk.gocuiSize.w1
|
||||||
|
d := tk.gocuiSize.h1
|
||||||
|
var err error
|
||||||
|
tk.v, err = me.baseGui.SetView(tk.cuiName, a, b, c, d, 0)
|
||||||
|
if err == nil {
|
||||||
log.Info("hardDrawAtgocuiSize() err ok widget", tk.cuiName)
|
log.Info("hardDrawAtgocuiSize() err ok widget", tk.cuiName)
|
||||||
tk.dumpWidget("hardDrawERR")
|
tk.dumpWidget("hard draw err")
|
||||||
}
|
}
|
||||||
tk.v.Frame = false
|
tk.v.Frame = false
|
||||||
tk.v.Clear()
|
tk.v.Clear()
|
||||||
tk.v.WriteString(tk.labelN)
|
tk.v.WriteString(tk.labelN)
|
||||||
// log.Verbose("hardDrawAtgocuiSize() err ok widget", tk.cuiName, a, b, c, d, tk.v.Name())
|
log.Verbose("hardDrawAtgocuiSize() err ok widget", tk.cuiName, a, b, c, d, tk.v.Name())
|
||||||
}
|
}
|
||||||
|
|
||||||
func sigWinchIcon() {
|
func sigWinchIcon() {
|
||||||
|
@ -256,15 +252,20 @@ func sigWinchIcon() {
|
||||||
func sigWinchBG() {
|
func sigWinchBG() {
|
||||||
tk := me.BG.tk
|
tk := me.BG.tk
|
||||||
w, h := me.baseGui.Size()
|
w, h := me.baseGui.Size()
|
||||||
tk.gocuiSize.w0 = -1
|
a := -1
|
||||||
tk.gocuiSize.h0 = -1
|
b := -1
|
||||||
tk.gocuiSize.w1 = w + 1
|
c := w + 1
|
||||||
tk.gocuiSize.h1 = h + 1
|
d := h + 1
|
||||||
if err := tk.SetView(); err != nil {
|
var err error
|
||||||
tk.dumpWidget("sigWinchBGerr()")
|
tk.v, err = me.baseGui.SetView(tk.cuiName, a, b, c, d, 0)
|
||||||
log.Log(ERROR, "sigWinchBG()", err)
|
if err == nil {
|
||||||
|
if tk.v == nil {
|
||||||
|
tk.dumpWidget("drawView() err")
|
||||||
|
log.Log(ERROR, "drawView() internal plugin error err = nil")
|
||||||
|
}
|
||||||
|
return
|
||||||
}
|
}
|
||||||
log.Log(INFO, "background resized to", tk.gocuiSize)
|
log.Log(INFO, "background resized to", a, b, c, d)
|
||||||
}
|
}
|
||||||
|
|
||||||
// find the "BG" widget and set it to the background on the very very bottom
|
// find the "BG" widget and set it to the background on the very very bottom
|
||||||
|
@ -287,9 +288,5 @@ func setBottomBG() {
|
||||||
tk.v.Clear()
|
tk.v.Clear()
|
||||||
me.baseGui.SetViewOnBottom(tk.cuiName)
|
me.baseGui.SetViewOnBottom(tk.cuiName)
|
||||||
w, h := me.baseGui.Size()
|
w, h := me.baseGui.Size()
|
||||||
tk.gocuiSize.w0 = -1
|
me.baseGui.SetView(tk.cuiName, -1, -1, w+1, h+1, 0)
|
||||||
tk.gocuiSize.h0 = -1
|
|
||||||
tk.gocuiSize.w1 = w + 1
|
|
||||||
tk.gocuiSize.h1 = h + 1
|
|
||||||
tk.SetView()
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -162,10 +162,10 @@ func (tk *guiWidget) GetText() string {
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
// hack. use "textbox widget" to "disable" user events
|
|
||||||
func hideDisable() {
|
func hideDisable() {
|
||||||
if me.textbox.tk == nil {
|
if me.textbox.tk == nil {
|
||||||
initTextbox()
|
initTextbox()
|
||||||
|
me.textbox.tk.prepTextbox()
|
||||||
}
|
}
|
||||||
|
|
||||||
me.textbox.tk.Hide()
|
me.textbox.tk.Hide()
|
||||||
|
@ -177,7 +177,6 @@ func hideDisable() {
|
||||||
// me.baseGui.DeleteView(me.textbox.tk.v.Name())
|
// me.baseGui.DeleteView(me.textbox.tk.v.Name())
|
||||||
}
|
}
|
||||||
|
|
||||||
// hack. use "textbox widget" to "disable" user events
|
|
||||||
func showDisable() {
|
func showDisable() {
|
||||||
if me.textbox.tk == nil {
|
if me.textbox.tk == nil {
|
||||||
initTextbox()
|
initTextbox()
|
||||||
|
@ -201,7 +200,7 @@ func showDisable() {
|
||||||
me.textbox.tk.v.Editable = true
|
me.textbox.tk.v.Editable = true
|
||||||
me.textbox.tk.v.Wrap = true
|
me.textbox.tk.v.Wrap = true
|
||||||
|
|
||||||
me.textbox.tk.SetViewRect(r)
|
me.baseGui.SetView(me.textbox.tk.cuiName, r.w0, r.h0, r.w1, r.h1, 0)
|
||||||
me.baseGui.SetCurrentView(me.textbox.tk.v.Name())
|
me.baseGui.SetCurrentView(me.textbox.tk.v.Name())
|
||||||
|
|
||||||
// bind the enter key to a function so we can close the textbox
|
// bind the enter key to a function so we can close the textbox
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"slices"
|
"slices"
|
||||||
"strings"
|
"strings"
|
||||||
|
@ -45,7 +46,6 @@ func coreStdout() {
|
||||||
me.stdout.tk = initWidget(n)
|
me.stdout.tk = initWidget(n)
|
||||||
|
|
||||||
tk := me.stdout.tk
|
tk := me.stdout.tk
|
||||||
tk.cuiName = "msg"
|
|
||||||
tk.gocuiSize.w0 = me.stdout.lastW
|
tk.gocuiSize.w0 = me.stdout.lastW
|
||||||
tk.gocuiSize.h0 = me.stdout.lastH
|
tk.gocuiSize.h0 = me.stdout.lastH
|
||||||
tk.gocuiSize.w1 = tk.gocuiSize.w0 + me.stdout.w
|
tk.gocuiSize.w1 = tk.gocuiSize.w0 + me.stdout.w
|
||||||
|
@ -64,9 +64,6 @@ func makeOutputWidget(g *gocui.Gui, stringFromMouseClick string) *gocui.View {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
me.stdout.tk.cuiName = "msg"
|
|
||||||
me.stdout.tk.SetView()
|
|
||||||
|
|
||||||
v, err := g.View("msg")
|
v, err := g.View("msg")
|
||||||
if v == nil {
|
if v == nil {
|
||||||
// log.Log(NOW, "makeoutputwindow() this is supposed to happen. v == nil", err)
|
// log.Log(NOW, "makeoutputwindow() this is supposed to happen. v == nil", err)
|
||||||
|
@ -75,7 +72,27 @@ func makeOutputWidget(g *gocui.Gui, stringFromMouseClick string) *gocui.View {
|
||||||
return v
|
return v
|
||||||
}
|
}
|
||||||
|
|
||||||
v = me.stdout.tk.v
|
rect := me.stdout.tk.gocuiSize
|
||||||
|
v, err = g.SetView("msg", rect.w0, rect.h0, rect.w1, rect.h1, 0)
|
||||||
|
|
||||||
|
if errors.Is(err, gocui.ErrUnknownView) {
|
||||||
|
// log.Log(NOW, "makeoutputwindow() this is supposed to happen?", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
if v == nil {
|
||||||
|
log.Log(NOW, "makeoutputwindow() BAD: v == nil && err =", err)
|
||||||
|
}
|
||||||
|
log.Log(NOW, "makeoutputwindow() create output window failed", err)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
if v == nil {
|
||||||
|
log.Log(NOW, "makeoutputwindow() msg == nil. WTF now? err =", err)
|
||||||
|
return nil
|
||||||
|
} else {
|
||||||
|
me.stdout.tk.v = v
|
||||||
|
}
|
||||||
|
|
||||||
v.Clear()
|
v.Clear()
|
||||||
v.SelBgColor = gocui.ColorCyan
|
v.SelBgColor = gocui.ColorCyan
|
||||||
|
@ -84,8 +101,16 @@ func makeOutputWidget(g *gocui.Gui, stringFromMouseClick string) *gocui.View {
|
||||||
// g.SetViewOnBottom("msg")
|
// g.SetViewOnBottom("msg")
|
||||||
// setBottomBG()
|
// setBottomBG()
|
||||||
|
|
||||||
|
me.stdout.tk.v = v
|
||||||
me.stdout.tk.DrawAt(me.stdout.lastW, me.stdout.lastH)
|
me.stdout.tk.DrawAt(me.stdout.lastW, me.stdout.lastH)
|
||||||
relocateStdoutOffscreen()
|
relocateStdoutOffscreen()
|
||||||
|
/*
|
||||||
|
if me.stdout.outputOffscreen {
|
||||||
|
me.stdout.tk.relocateStdout(me.stdout.lastW, me.stdout.lastH)
|
||||||
|
} else {
|
||||||
|
relocateStdoutOffscreen()
|
||||||
|
}
|
||||||
|
*/
|
||||||
return v
|
return v
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -103,22 +128,6 @@ func relocateStdoutOffscreen() {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (tk *guiWidget) relocateStdout(w int, h int) {
|
func (tk *guiWidget) relocateStdout(w int, h int) {
|
||||||
if me.stdout.w < 8 {
|
|
||||||
me.stdout.w = 8
|
|
||||||
}
|
|
||||||
|
|
||||||
if me.stdout.h < 4 {
|
|
||||||
me.stdout.h = 4
|
|
||||||
}
|
|
||||||
|
|
||||||
if w+me.stdout.w < 2 {
|
|
||||||
w = 2
|
|
||||||
}
|
|
||||||
|
|
||||||
if h+me.stdout.h < 2 {
|
|
||||||
h = 2
|
|
||||||
}
|
|
||||||
|
|
||||||
w0 := w
|
w0 := w
|
||||||
h0 := h
|
h0 := h
|
||||||
w1 := w + me.stdout.w
|
w1 := w + me.stdout.w
|
||||||
|
@ -134,7 +143,8 @@ func (tk *guiWidget) relocateStdout(w int, h int) {
|
||||||
tk.full.h0 = h0
|
tk.full.h0 = h0
|
||||||
tk.full.h1 = h1
|
tk.full.h1 = h1
|
||||||
|
|
||||||
tk.SetView()
|
me.baseGui.SetView("msg", w0, h0, w1, h1, 0)
|
||||||
|
// me.baseGui.SetViewOnBottom("msg")
|
||||||
}
|
}
|
||||||
|
|
||||||
// from the gocui devs:
|
// from the gocui devs:
|
||||||
|
@ -211,9 +221,7 @@ func (tk *guiWidget) refreshStdout() {
|
||||||
// chop off the last lines in the buffer
|
// chop off the last lines in the buffer
|
||||||
chop := len(me.stdout.outputS) - (me.stdout.pager + me.stdout.h)
|
chop := len(me.stdout.outputS) - (me.stdout.pager + me.stdout.h)
|
||||||
cur = append(cur, me.stdout.outputS[chop:chop+me.stdout.h]...)
|
cur = append(cur, me.stdout.outputS[chop:chop+me.stdout.h]...)
|
||||||
if me.stdout.reverse {
|
slices.Reverse(cur)
|
||||||
slices.Reverse(cur)
|
|
||||||
}
|
|
||||||
tk.v.Clear()
|
tk.v.Clear()
|
||||||
fmt.Fprintln(tk.v, strings.Join(cur, "\n"))
|
fmt.Fprintln(tk.v, strings.Join(cur, "\n"))
|
||||||
}
|
}
|
||||||
|
|
|
@ -120,7 +120,6 @@ type stdout struct {
|
||||||
outputS []string // the buffer of all the output
|
outputS []string // the buffer of all the output
|
||||||
pager int // allows the user to page through the buffer
|
pager int // allows the user to page through the buffer
|
||||||
changed bool // indicates the user has changed stdout. gocui should remember the state here
|
changed bool // indicates the user has changed stdout. gocui should remember the state here
|
||||||
reverse bool // flip the STDOUT upside down so new STDOUT lines are at the top
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// settings for the dropdown window
|
// settings for the dropdown window
|
||||||
|
|
30
textbox.go
30
textbox.go
|
@ -7,7 +7,6 @@ package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
|
||||||
|
|
||||||
"github.com/awesome-gocui/gocui"
|
"github.com/awesome-gocui/gocui"
|
||||||
log "go.wit.com/log"
|
log "go.wit.com/log"
|
||||||
|
@ -41,7 +40,7 @@ func initTextbox() {
|
||||||
func (callertk *guiWidget) prepTextbox() {
|
func (callertk *guiWidget) prepTextbox() {
|
||||||
initTextbox()
|
initTextbox()
|
||||||
if me.textbox.tk == nil {
|
if me.textbox.tk == nil {
|
||||||
log.Log(WARN, "prepTextbox() Is Broken")
|
log.Log(GOCUI, "prepTextbox() Is Broken")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -52,35 +51,21 @@ func (callertk *guiWidget) prepTextbox() {
|
||||||
r.w1 = r.w0 + 24
|
r.w1 = r.w0 + 24
|
||||||
r.h1 = r.h0 + 2
|
r.h1 = r.h0 + 2
|
||||||
me.textbox.tk.forceSizes(r)
|
me.textbox.tk.forceSizes(r)
|
||||||
me.textbox.tk.dumpWidget("after sizes")
|
// me.textbox.tk.dumpWidget("after sizes")
|
||||||
|
|
||||||
me.textbox.callerTK = callertk
|
me.textbox.callerTK = callertk
|
||||||
|
|
||||||
if me.textbox.tk.v != nil {
|
// showTextbox(callertk.String())
|
||||||
log.Log(WARN, "WARNING textbox DeleteView()")
|
|
||||||
log.Log(WARN, "WARNING textbox DeleteView()")
|
|
||||||
log.Log(WARN, "WARNING textbox DeleteView()")
|
|
||||||
me.baseGui.DeleteView(me.textbox.tk.cuiName)
|
|
||||||
time.Sleep(time.Second)
|
|
||||||
}
|
|
||||||
|
|
||||||
if err := me.textbox.tk.SetViewRect(r); err != nil {
|
|
||||||
log.Log(WARN, "textbox SetViewRect() failed", err, "view name =", me.textbox.tk.cuiName)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
// me.textbox.tk.Show() // actually makes the gocui view. TODO: redo this?
|
|
||||||
showTextbox(callertk.String())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func showTextbox(callers string) {
|
func showTextbox(callers string) {
|
||||||
// tk := me.textbox.tk
|
// tk := me.textbox.tk
|
||||||
// me.textbox.tk.dumpWidget("after sizes")
|
// me.textbox.tk.dumpWidget("after sizes")
|
||||||
log.Log(WARN, "showTextbox() caller string =", callers)
|
|
||||||
|
|
||||||
// me.textbox.tk.Show() // actually makes the gocui view. TODO: redo this
|
// me.textbox.tk.Show() // actually makes the gocui view. TODO: redo this
|
||||||
|
|
||||||
if me.textbox.tk.v == nil {
|
if me.textbox.tk.v == nil {
|
||||||
log.Log(WARN, "textbox.tk.v == nil showTextbox() is broken")
|
log.Info("wtf went wrong")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -93,8 +78,8 @@ func showTextbox(callers string) {
|
||||||
me.textbox.tk.v.Editable = true
|
me.textbox.tk.v.Editable = true
|
||||||
me.textbox.tk.v.Wrap = true
|
me.textbox.tk.v.Wrap = true
|
||||||
|
|
||||||
me.textbox.tk.SetView()
|
r := me.textbox.tk.gocuiSize
|
||||||
|
me.baseGui.SetView(me.textbox.tk.cuiName, r.w0, r.h0, r.w1, r.h1, 0)
|
||||||
me.baseGui.SetCurrentView(me.textbox.tk.v.Name())
|
me.baseGui.SetCurrentView(me.textbox.tk.v.Name())
|
||||||
|
|
||||||
// bind the enter key to a function so we can close the textbox
|
// bind the enter key to a function so we can close the textbox
|
||||||
|
@ -102,8 +87,7 @@ func showTextbox(callers string) {
|
||||||
|
|
||||||
me.textbox.active = true
|
me.textbox.active = true
|
||||||
|
|
||||||
me.baseGui.SetViewOnTop(me.textbox.tk.v.Name())
|
// me.textbox.dumpWidget("showTextbox()")
|
||||||
me.textbox.tk.dumpWidget("showTextbox()")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func theCloseTheTextbox(g *gocui.Gui, v *gocui.View) error {
|
func theCloseTheTextbox(g *gocui.Gui, v *gocui.View) error {
|
||||||
|
|
28
window.go
28
window.go
|
@ -100,7 +100,6 @@ func (tk *guiWidget) redrawWindow(w int, h int) {
|
||||||
|
|
||||||
// set the window frame below the window widget, but this resizes the window widget it seems
|
// set the window frame below the window widget, but this resizes the window widget it seems
|
||||||
me.baseGui.SetViewBeneath(tk.windowFrame.cuiName, tk.cuiName, 1)
|
me.baseGui.SetViewBeneath(tk.windowFrame.cuiName, tk.cuiName, 1)
|
||||||
|
|
||||||
// so now we have to resize the window frame, but this moves it to the top?
|
// so now we have to resize the window frame, but this moves it to the top?
|
||||||
me.baseGui.SetView(tk.windowFrame.cuiName, tk.windowFrame.full.w0, tk.windowFrame.full.h0, tk.windowFrame.full.w1, tk.windowFrame.full.h1, 0)
|
me.baseGui.SetView(tk.windowFrame.cuiName, tk.windowFrame.full.w0, tk.windowFrame.full.h0, tk.windowFrame.full.w1, tk.windowFrame.full.h1, 0)
|
||||||
|
|
||||||
|
@ -210,6 +209,13 @@ func (tk *guiWidget) makeWindowActive() {
|
||||||
|
|
||||||
tk.redrawWindow(tk.gocuiSize.w0, tk.gocuiSize.h0)
|
tk.redrawWindow(tk.gocuiSize.w0, tk.gocuiSize.h0)
|
||||||
setThingsOnTop() // sets help, Stdout, etc on the top after windows have been redrawn
|
setThingsOnTop() // sets help, Stdout, etc on the top after windows have been redrawn
|
||||||
|
|
||||||
|
/*
|
||||||
|
// print out the window list
|
||||||
|
for _, tk := range me.allwin {
|
||||||
|
log.Info("makeWindowActive() Window", tk.labelN, tk.window.active, tk.window.order)
|
||||||
|
}
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
func (tk *guiWidget) makeTK(ddItems []string) {
|
func (tk *guiWidget) makeTK(ddItems []string) {
|
||||||
|
@ -220,7 +226,25 @@ func (tk *guiWidget) makeTK(ddItems []string) {
|
||||||
tk.gocuiSize.w1 = 120
|
tk.gocuiSize.w1 = 120
|
||||||
tk.gocuiSize.h0 = 15
|
tk.gocuiSize.h0 = 15
|
||||||
tk.gocuiSize.h1 = 18
|
tk.gocuiSize.h1 = 18
|
||||||
|
/*
|
||||||
|
var err error
|
||||||
|
tk.v, err = me.baseGui.SetView(tk.cuiName,
|
||||||
|
tk.gocuiSize.w0,
|
||||||
|
tk.gocuiSize.h0,
|
||||||
|
tk.gocuiSize.w1,
|
||||||
|
tk.gocuiSize.h1, 0)
|
||||||
|
if err != nil {
|
||||||
|
log.Info("makeTK() err", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if tk.v == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
tk.v.Wrap = true
|
||||||
|
tk.v.Frame = true
|
||||||
|
tk.v.Clear()
|
||||||
|
fmt.Fprint(tk.v, items)
|
||||||
|
*/
|
||||||
tk.Show()
|
tk.Show()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue