fix arrow up & down on scrolling stdout

This commit is contained in:
Jeff Carr 2025-03-25 08:56:33 -05:00
parent 1552eedc18
commit 36514cbb68
5 changed files with 37 additions and 34 deletions

View File

@ -86,7 +86,8 @@ func (tk *guiWidget) dumpWidget(s string) {
} else {
end = fmt.Sprintf("%-8s %-8s %s", tk.WidgetType(), tk.cuiName, tk.String())
}
if tk.findParentTable() != nil {
if tk.node.InTable() {
// log.Log(GOCUI, "findParentTAble()", tk.labelN, tk.cuiName, tk.node.WidgetId)
end += " (table)"
}
log.Log(GOCUI, s1, s, end)

View File

@ -109,22 +109,12 @@ func theDarkness(g *gocui.Gui, v *gocui.View) error {
}
func wheelsUp(g *gocui.Gui, v *gocui.View) error {
// log.Info("private wheels up")
me.stdout.pager -= 2
if me.stdout.pager < 0 {
me.stdout.pager = 0
}
me.stdout.tk.refreshStdout()
stdoutWheelsUp()
return nil
}
func wheelsDown(g *gocui.Gui, v *gocui.View) error {
// log.Info("you've landed")
me.stdout.pager += 2
if me.stdout.pager > len(me.stdout.outputS) {
me.stdout.pager = len(me.stdout.outputS)
}
me.stdout.tk.refreshStdout()
stdoutWheelsDown()
return nil
}

View File

@ -77,14 +77,12 @@ func stdoutHome(g *gocui.Gui, v *gocui.View) error {
}
func stdoutArrowUp(g *gocui.Gui, v *gocui.View) error {
me.stdout.pager += 1
me.stdout.tk.refreshStdout()
stdoutWheelsUp()
return nil
}
func stdoutArrowDown(g *gocui.Gui, v *gocui.View) error {
me.stdout.pager -= 1
me.stdout.tk.refreshStdout()
stdoutWheelsDown()
return nil
}
@ -103,3 +101,23 @@ func stdoutPgdn(g *gocui.Gui, v *gocui.View) error {
tk.refreshStdout()
return nil
}
// scrolling up with the mouse wheel (or trackpad)
func stdoutWheelsUp() {
// log.Info("private wheels up")
me.stdout.pager -= 2
if me.stdout.pager < 0 {
me.stdout.pager = 0
}
me.stdout.tk.refreshStdout()
}
// scrolling down with the mouse wheel (or trackpad)
func stdoutWheelsDown() {
// log.Info("you've landed")
me.stdout.pager += 2
if me.stdout.pager > len(me.stdout.outputS) {
me.stdout.pager = len(me.stdout.outputS)
}
me.stdout.tk.refreshStdout()
}

14
find.go
View File

@ -186,20 +186,6 @@ func (tk *guiWidget) findParentWindow() *guiWidget {
return tk.parent.findParentWindow()
}
func (tk *guiWidget) findParentTable() *guiWidget {
if tk.isTable {
log.Info("findParentTAble()", tk.labelN, tk.cuiName, tk.node.WidgetId)
return tk
}
if tk.node.WidgetId == 0 {
return nil
}
if tk.parent == nil {
return nil
}
return tk.parent.findParentWindow()
}
func (tk *guiWidget) findWidgetByName(name string) *guiWidget {
if tk.cuiName == name {
return tk

14
init.go
View File

@ -148,6 +148,12 @@ func initPlugin() {
me.stdout.disable = true
}
}
if val, err := me.myTree.ConfigFind("stdoutoffscreen"); err == nil {
if val == "false" {
// log.Log(NOW, "gocui: START ON SCREEN TRUE")
me.stdout.startOnscreen = true
}
}
if val, err := me.myTree.ConfigFind("dark"); err == nil {
if val == "true" {
me.dark = true
@ -190,11 +196,12 @@ func initPlugin() {
if val, err := me.myTree.ConfigFind("stdoutsize"); err == nil {
parts := strings.Fields(val)
if len(parts) == 4 {
log.Info("initial stdout settings:", parts)
log.Info("initial stdout settings:", parts, "setting startOnscreen = true")
me.stdout.w, _ = strconv.Atoi(parts[0])
me.stdout.h, _ = strconv.Atoi(parts[1])
me.stdout.lastW, _ = strconv.Atoi(parts[2])
me.stdout.lastH, _ = strconv.Atoi(parts[3])
me.stdout.startOnscreen = true
} else {
log.Info("initial stdout settings parse error:", parts)
}
@ -393,9 +400,8 @@ func refreshGocui() {
me.refresh = false
}
if me.stdout.changed {
log.Log(NOW, "newWindowTrigger() TODO: gocui should save the stdout size & location here")
me.stdout.changed = false
me.stdout.tk.dumpWidget("save")
lastRefresh = time.Now()
new1 := new(tree.ToolkitConfig)
new1.Plugin = "gocui"
new1.Name = "stdoutsize"
@ -403,6 +409,8 @@ func refreshGocui() {
height := me.stdout.tk.gocuiSize.h1 - me.stdout.tk.gocuiSize.h0
new1.Value = fmt.Sprintf("%d %d %d %d", width, height, me.stdout.tk.gocuiSize.w0, me.stdout.tk.gocuiSize.h0)
me.myTree.ConfigSave(new1)
// log.Log(NOW, "newWindowTrigger() gocui setting stdout size =", new1.Value)
// me.stdout.tk.dumpWidget("save")
}
}