Compare commits

...

6 Commits

Author SHA1 Message Date
Jeff Carr 86aa5fb001 reverse in STDOUT is no longer the default 2025-09-03 01:56:01 -05:00
Jeff Carr 262426fb44 make the help menu appear when libnotify is clicked 2025-09-03 01:23:22 -05:00
Jeff Carr ec0807ce2b minor 2025-08-16 21:49:54 -05:00
Jeff Carr ce1d9457f9 syntax change 2025-06-04 06:34:06 -05:00
Jeff Carr 664ce4dfae rm old code 2025-04-30 14:41:27 -05:00
Jeff Carr 7b6af30194 text edit box kinda works sometimes 2025-04-24 19:28:33 -05:00
12 changed files with 60 additions and 36 deletions

1
.gitignore vendored
View File

@ -5,3 +5,4 @@
go.mod
go.sum
gocui
resources/*.so

View File

@ -25,7 +25,7 @@ custom:
clean:
rm -f gocui *.so go.*
rm -f *.pb.go *.patch
go-mod-clean --purge
go-mod-clean purge
# Test the README.md & doc.go file
# this runs pkgsite, the binary that does dev.go.dev

View File

@ -58,6 +58,7 @@ func registerHandlers(g *gocui.Gui) {
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("", '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 (?)
}
@ -103,7 +104,9 @@ func theDarkness(g *gocui.Gui, v *gocui.View) error {
log.Info("you have seen the light")
} else {
me.dark = true
log.Info("you have entered into darkness")
log.Info("you have entered into darkness (you may need to trigger SIGWINCH)")
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
}
@ -138,11 +141,13 @@ func doEsc(g *gocui.Gui, v *gocui.View) error {
me.dropdown.tk.Hide()
me.dropdown.active = false
log.Info("escaped from dropdown")
me.baseGui.SetCurrentView(me.notify.clock.tk.cuiName)
}
if me.textbox.active {
me.textbox.tk.Hide()
me.textbox.active = false
log.Info("escaped from textbox")
me.baseGui.SetCurrentView(me.notify.clock.tk.cuiName)
}
return nil
}
@ -180,6 +185,19 @@ func theFind(g *gocui.Gui, v *gocui.View) error {
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)
func theLetterD(g *gocui.Gui, v *gocui.View) error {
// widgets that don't have physical existance in

View File

@ -77,12 +77,20 @@ func stdoutHome(g *gocui.Gui, v *gocui.View) error {
}
func stdoutArrowUp(g *gocui.Gui, v *gocui.View) error {
if me.stdout.reverse {
stdoutWheelsDown()
} else {
stdoutWheelsUp()
}
return nil
}
func stdoutArrowDown(g *gocui.Gui, v *gocui.View) error {
if me.stdout.reverse {
stdoutWheelsUp()
} else {
stdoutWheelsDown()
}
return nil
}

13
find.go
View File

@ -129,13 +129,6 @@ 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
for _, tk := range me.allwin {
if tk.window.active {
@ -152,12 +145,6 @@ func findWindowUnderMouse() *guiWidget {
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 {
if win.full.inRect(w, h) {
// log.Info(fmt.Sprintf("findWindowUnderMouse() found %s window (%dx%d)", win.cuiName, w, h))

20
help.go
View File

@ -25,16 +25,20 @@ import (
var helpText []string = []string{"Help Menu",
"",
"Tab: toggle through windows",
"O: toggle STDOUT",
"H: toggle this gocui menu",
"L: toggle light/dark mode",
"CTRL-c: quit()",
"Tab toggle through windows",
"'O' toggle STDOUT",
"'H' toggle this gocui menu",
"'D' toggle light/dark mode",
"CTRL-z background to shell",
"CTRL-c quit()",
"",
"Debugging:",
"S: Supermouse mode",
"M: list all widget positions",
"L: list all widgets in tree",
"'S' Supermouse mode",
"'M' list all widget positions",
"'L' list all widgets in tree",
"<Pgup> scroll up the STDOUT window",
"<Pgdn> scroll down the STDOUT window",
"'r' reverse STDOUT scrolling",
}
func hideHelp() {

View File

@ -108,7 +108,6 @@ func toolkitInit() {
if me.textbox.tk == nil {
log.Log(INFO, "gocui toolkitInit() initTextbox me.ok =", me.ok)
initTextbox()
me.textbox.tk.prepTextbox()
}
// TEST TEXTBOX END
}
@ -457,7 +456,6 @@ func newWindowTrigger() {
}
if me.textbox.tk == nil {
initTextbox()
me.textbox.tk.prepTextbox()
}
tk.makeWindowActive()
me.myTree.Unlock()

View File

@ -150,6 +150,17 @@ func setNotifyIconText(s string) {
me.notify.icon.tk.setColorNotifyIcon()
me.baseGui.SetViewOnTop(me.notify.icon.tk.v.Name())
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

View File

@ -162,10 +162,10 @@ func (tk *guiWidget) GetText() string {
return ""
}
// hack. use "textbox widget" to "disable" user events
func hideDisable() {
if me.textbox.tk == nil {
initTextbox()
me.textbox.tk.prepTextbox()
}
me.textbox.tk.Hide()
@ -177,6 +177,7 @@ func hideDisable() {
// me.baseGui.DeleteView(me.textbox.tk.v.Name())
}
// hack. use "textbox widget" to "disable" user events
func showDisable() {
if me.textbox.tk == nil {
initTextbox()

View File

@ -211,7 +211,9 @@ func (tk *guiWidget) refreshStdout() {
// chop off the last lines in the buffer
chop := len(me.stdout.outputS) - (me.stdout.pager + me.stdout.h)
cur = append(cur, me.stdout.outputS[chop:chop+me.stdout.h]...)
if me.stdout.reverse {
slices.Reverse(cur)
}
tk.v.Clear()
fmt.Fprintln(tk.v, strings.Join(cur, "\n"))
}

View File

@ -120,6 +120,7 @@ type stdout struct {
outputS []string // the buffer of all the output
pager int // allows the user to page through the buffer
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

View File

@ -210,13 +210,6 @@ func (tk *guiWidget) makeWindowActive() {
tk.redrawWindow(tk.gocuiSize.w0, tk.gocuiSize.h0)
setThingsOnTop() // sets help, Stdout, etc on the top after windows have been redrawn
/*
// print out the window list // TODO: put this in libnotify
for _, tk := range me.allwin {
log.Info("makeWindowActive() Window", tk.labelN, tk.window.active, tk.window.order)
}
*/
}
func (tk *guiWidget) makeTK(ddItems []string) {