diff options
| author | Jeff Carr <[email protected]> | 2025-02-11 13:22:23 -0600 |
|---|---|---|
| committer | Jeff Carr <[email protected]> | 2025-02-11 13:22:23 -0600 |
| commit | 733c595c54cdbf8e54c7c09c69e8f4d4415b04f6 (patch) | |
| tree | db6659339219677e5179d254f8532ebd3a641ae8 /plugin.go | |
| parent | 535646335af49fa8f27ba28ef62d2f96cac2f451 (diff) | |
disable and enable doesn't crash
Diffstat (limited to 'plugin.go')
| -rw-r--r-- | plugin.go | 113 |
1 files changed, 76 insertions, 37 deletions
@@ -7,6 +7,7 @@ import ( // if you include more than just this import // then your plugin might be doing something un-ideal (just a guess from 2023/02/27) + "github.com/awesome-gocui/gocui" "go.wit.com/log" "go.wit.com/toolkits/tree" "go.wit.com/widget" @@ -224,27 +225,57 @@ func (tk *guiWidget) Disable() { log.Log(NOW, "widget is nil") return } - tk.enable = false - tk.node.State.Enable = false - // log.Info("disable widget in gocui", tk.node.WidgetType, tk.node.ProgName()) - switch tk.node.WidgetType { - case widget.Box: - // log.Info("todo: blank out the window here", tk.String()) - r := new(rectType) - // startW, startH := tk.Position() - r.w0 = 0 - r.h0 = 0 - r.w1 = r.w0 + 24 - r.h1 = r.h0 + 2 - me.textbox.tk.forceSizes(r) - showTextbox("Running...") - return - case widget.Button: - tk.setColorDisable() - return - default: - tk.dumpWidget("fixme: disable") - } + initTextbox() + tk.prepTextbox() + r := new(rectType) + r.w0 = 2 + r.h0 = 1 + r.w1 = r.w0 + 24 + r.h1 = r.h0 + 2 + me.textbox.tk.forceSizes(r) + me.textbox.tk.Show() // actually makes the gocui view. TODO: redo this + log.Info("textbox should be shown") + // showTextbox("Running...") + me.textbox.tk.dumpWidget("shown?") + + me.textbox.tk.setColorModal() + me.textbox.tk.v.Clear() + me.textbox.tk.v.WriteString("Running...") + + me.textbox.tk.v.Editable = true + me.textbox.tk.v.Wrap = true + + me.baseGui.SetView(me.textbox.tk.cuiName, r.w0, r.h0, r.w1, r.h1, 0) + me.baseGui.SetCurrentView(me.textbox.tk.v.Name()) + + // bind the enter key to a function so we can close the textbox + me.baseGui.SetKeybinding(me.textbox.tk.v.Name(), gocui.KeyEnter, gocui.ModNone, theCloseTheTextbox) + + me.textbox.active = true + + /* + tk.enable = false + tk.node.State.Enable = false + // log.Info("disable widget in gocui", tk.node.WidgetType, tk.node.ProgName()) + switch tk.node.WidgetType { + case widget.Box: + // log.Info("todo: blank out the window here", tk.String()) + r := new(rectType) + // startW, startH := tk.Position() + r.w0 = 0 + r.h0 = 0 + r.w1 = r.w0 + 24 + r.h1 = r.h0 + 2 + me.textbox.tk.forceSizes(r) + showTextbox("Running...") + return + case widget.Button: + tk.setColorDisable() + return + default: + tk.dumpWidget("fixme: disable") + } + */ } func (tk *guiWidget) Enable() { @@ -252,20 +283,28 @@ func (tk *guiWidget) Enable() { log.Log(NOW, "widget is nil") return } - tk.enable = true - tk.node.State.Enable = true - // log.Info("enable widget in gocui", tk.node.WidgetType, tk.node.ProgName()) - switch tk.node.WidgetType { - case widget.Box: - // log.Info("todo: un blank the window here") - me.textbox.tk.Hide() - me.textbox.active = false - // log.Info("escaped from textbox") - return - case widget.Button: - tk.restoreEnableColor() - return - default: - tk.dumpWidget("fixme: enable") - } + initTextbox() + tk.prepTextbox() + + me.textbox.tk.Hide() + /* + initTextbox() + + tk.enable = true + tk.node.State.Enable = true + // log.Info("enable widget in gocui", tk.node.WidgetType, tk.node.ProgName()) + switch tk.node.WidgetType { + case widget.Box: + // log.Info("todo: un blank the window here") + me.textbox.tk.Hide() + me.textbox.active = false + // log.Info("escaped from textbox") + return + case widget.Button: + tk.restoreEnableColor() + return + default: + tk.dumpWidget("fixme: enable") + } + */ } |
