working on delete table

This commit is contained in:
Jeff Carr 2025-03-04 14:33:39 -06:00
parent 96eac58cf5
commit a88937c508
5 changed files with 64 additions and 48 deletions

View File

@ -4,6 +4,7 @@
package main
import (
"github.com/awesome-gocui/gocui"
"go.wit.com/log"
"go.wit.com/widget"
)
@ -115,6 +116,12 @@ func doMouseClick(w int, h int) {
}
}
// todo: use this?
func ctrlDown(g *gocui.Gui, v *gocui.View) error {
log.Info("todo: clicked with ctrlDown")
return nil
}
func doMouseDoubleClick(w int, h int) {
me.mouse.double = false
// log.Printf("actually a double click (%d,%d)", w, h)

50
find.go
View File

@ -176,12 +176,6 @@ func findWindowUnderMouse() *guiWidget {
return nil
}
// todo: use this?
func ctrlDown(g *gocui.Gui, v *gocui.View) error {
log.Info("todo: clicked with ctrlDown")
return nil
}
func (tk *guiWidget) findParentWindow() *guiWidget {
if tk.WidgetType() == widget.Window {
return tk
@ -191,3 +185,47 @@ func (tk *guiWidget) findParentWindow() *guiWidget {
}
return tk.parent.findParentWindow()
}
func (tk *guiWidget) findWidgetByName(name string) *guiWidget {
if tk.cuiName == name {
return tk
}
for _, child := range tk.children {
found := child.findWidgetByName(name)
if found != nil {
return found
}
}
return nil
}
func (tk *guiWidget) findWidgetByView(v *gocui.View) *guiWidget {
if tk.v == v {
return tk
}
if tk.cuiName == v.Name() {
log.Log(NOW, "findWidget() error. names are mismatched or out of sync", tk.cuiName)
log.Log(NOW, "findWidget() or maybe the view has been deleted")
// return tk
}
for _, child := range tk.children {
found := child.findWidgetByView(v)
if found != nil {
return found
}
}
return nil
}
func (tk *guiWidget) findWidgetById(id int) *guiWidget {
if tk.WidgetId() == id {
return tk
}
for _, child := range tk.children {
found := child.findWidgetById(id)
if found != nil {
return found
}
}
return nil
}

View File

@ -153,7 +153,6 @@ type libnotify struct {
icon internalTK // libnotify menu icon
window internalTK // the libnotify menu
help internalTK // the help menu
// menuWindow internalTK // libnotify menu window
}
// this is the gocui way

View File

@ -13,7 +13,8 @@ import (
"go.wit.com/widget"
)
func initWindowPB(pb *guipb.Widget) *guiWidget {
/*
func initGridPB(pb *guipb.Widget) *guiWidget {
var w *guiWidget
w = new(guiWidget)
@ -24,6 +25,7 @@ func initWindowPB(pb *guipb.Widget) *guiWidget {
w.labelN = pb.Name
return w
}
*/
func initGridPB(pb *guipb.Widget) *guiWidget {
var w *guiWidget
@ -42,19 +44,21 @@ func showTable(t *guipb.Table) {
return
}
log.Info("gocui: table.Title", t.Title)
if t.Window == nil {
log.Info("gocui: missing window widget. tree plugin error")
return
}
log.Info("gocui: need to add window here id =", t.Window.Id, t.Window.Name)
// log.Info("gocui: need to add window here id =", t.Window.Id, t.Window.Name)
if t.Grid == nil {
log.Info("gocui: missing grid widget. tree plugin error")
return
}
root := me.treeRoot.TK.(*guiWidget)
parent := root.findWidgetById(int(t.Parent.Id))
if parent == nil {
log.Info("gocui: show table error. parent.Id not found", t.Parent.Id)
return
}
log.Info("gocui: need to add grid here id =", t.Grid.Id)
win := initWindowPB(t.Window)
grid := initWindowPB(t.Window)
grid.parent = win
grid := initGridPB(t.Grid)
grid.parent = parent
}
func enableWidget(n *tree.Node) {

View File

@ -7,7 +7,6 @@ import (
"strconv"
"strings"
"github.com/awesome-gocui/gocui"
"go.wit.com/log"
"go.wit.com/toolkits/tree"
"go.wit.com/widget"
@ -121,34 +120,3 @@ func (tk *guiWidget) SetVisible(b bool) {
tk.Hide()
}
}
func (tk *guiWidget) findWidgetByName(name string) *guiWidget {
if tk.cuiName == name {
return tk
}
for _, child := range tk.children {
found := child.findWidgetByName(name)
if found != nil {
return found
}
}
return nil
}
func (tk *guiWidget) findWidgetByView(v *gocui.View) *guiWidget {
if tk.v == v {
return tk
}
if tk.cuiName == v.Name() {
log.Log(NOW, "findWidget() error. names are mismatched or out of sync", tk.cuiName)
log.Log(NOW, "findWidget() or maybe the view has been deleted")
// return tk
}
for _, child := range tk.children {
found := child.findWidgetByView(v)
if found != nil {
return found
}
}
return nil
}