removing old crappy code finally

This commit is contained in:
Jeff Carr 2025-02-06 02:40:44 -06:00
parent 3faacd6c43
commit 88e9594b93
7 changed files with 84 additions and 66 deletions

View File

@ -100,11 +100,11 @@ func theNotsure(g *gocui.Gui, v *gocui.View) error {
} }
func theStdout(g *gocui.Gui, v *gocui.View) error { func theStdout(g *gocui.Gui, v *gocui.View) error {
if me.outputOnTop { if me.stdout.outputOnTop {
me.outputOnTop = false me.stdout.outputOnTop = false
me.baseGui.SetViewOnBottom("msg") me.baseGui.SetViewOnBottom("msg")
} else { } else {
me.outputOnTop = true me.stdout.outputOnTop = true
me.baseGui.SetViewOnTop("msg") me.baseGui.SetViewOnTop("msg")
} }
return nil return nil

View File

@ -140,8 +140,8 @@ func msgDown(g *gocui.Gui, v *gocui.View) error {
vx, vy, _, _, err := g.ViewPosition("msg") vx, vy, _, _, err := g.ViewPosition("msg")
if err == nil { if err == nil {
xOffset = initialMouseX - vx me.stdout.offsetW = initialMouseX - vx
yOffset = initialMouseY - vy me.stdout.offsetH = initialMouseY - vy
} }
log.Info("setting mousedown to true") log.Info("setting mousedown to true")
// msgMouseDown = true // msgMouseDown = true

View File

@ -110,16 +110,14 @@ func (tk *guiWidget) moveNew() {
} else { } else {
// log.Info("NOT MOVE FLAG. PASSING MOVE TO MSG", tk.node.WidgetType) // log.Info("NOT MOVE FLAG. PASSING MOVE TO MSG", tk.node.WidgetType)
// tk.dumpWidget("moveNew() MSG" + tk.cuiName) // tk.dumpWidget("moveNew() MSG" + tk.cuiName)
outputW := 180 w0 := w - me.stdout.offsetW
outputH := 40 h0 := h - me.stdout.offsetH
w0 := w - xOffset w1 := w - me.stdout.offsetW + me.stdout.w
h0 := h - yOffset h1 := h - me.stdout.offsetH + me.stdout.h
w1 := w - xOffset + outputW
h1 := h - yOffset + outputH + me.FramePadH
me.baseGui.SetView("msg", w0, h0, w1, h1, 0) me.baseGui.SetView("msg", w0, h0, w1, h1, 0)
me.startOutputW = w - xOffset // me.startOutputW = w - me.stdout.offsetW
me.startOutputH = h - yOffset // me.startOutputH = h - me.stdout.offsetH
me.baseGui.SetViewOnBottom("msg") me.baseGui.SetViewOnBottom("msg")
tk.gocuiSize.w0 = w0 tk.gocuiSize.w0 = w0

View File

@ -102,7 +102,7 @@ func setThingsOnTop() {
} }
me.baseGui.SetViewOnTop("help") me.baseGui.SetViewOnTop("help")
if me.outputOnTop { if me.stdout.outputOnTop {
me.baseGui.SetViewOnTop("msg") me.baseGui.SetViewOnTop("msg")
} else { } else {
me.baseGui.SetViewOnBottom("msg") me.baseGui.SetViewOnBottom("msg")

View File

@ -38,6 +38,9 @@ func init() {
// init the config struct default values // init the config struct default values
Set(&me, "default") Set(&me, "default")
me.stdout.w = 180
me.stdout.h = 40
// Set(&me, "dense") // Set(&me, "dense")
me.myTree = tree.New() me.myTree = tree.New()

View File

@ -34,10 +34,7 @@ func showMsg(g *gocui.Gui, v *gocui.View) error {
} }
func makeOutputWidget(g *gocui.Gui, stringFromMouseClick string) *gocui.View { func makeOutputWidget(g *gocui.Gui, stringFromMouseClick string) *gocui.View {
maxX, maxY := g.Size() // maxX, maxY := g.Size()
var outputW int = 180
var outputH int = 40
if me.treeRoot == nil { if me.treeRoot == nil {
// keep skipping this until the binary tree is initialized // keep skipping this until the binary tree is initialized
@ -57,11 +54,13 @@ func makeOutputWidget(g *gocui.Gui, stringFromMouseClick string) *gocui.View {
tk := me.logStdout tk := me.logStdout
// tk.gocuiSize.w0 = maxX - 32 // tk.gocuiSize.w0 = maxX - 32
// tk.gocuiSize.h0 = maxY / 2 // tk.gocuiSize.h0 = maxY / 2
tk.gocuiSize.w0 = me.startOutputW tk.gocuiSize.w0 = 30
tk.gocuiSize.h0 = me.startOutputH tk.gocuiSize.h0 = 10
tk.gocuiSize.w1 = tk.gocuiSize.w0 + outputW tk.gocuiSize.w1 = tk.gocuiSize.w0 + me.stdout.w
tk.gocuiSize.h1 = tk.gocuiSize.h0 + outputH tk.gocuiSize.h1 = tk.gocuiSize.h0 + me.stdout.h
} }
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)
@ -69,14 +68,21 @@ func makeOutputWidget(g *gocui.Gui, stringFromMouseClick string) *gocui.View {
log.Log(NOW, "makeoutputwindow() msg != nil. WTF now? err =", err) log.Log(NOW, "makeoutputwindow() msg != nil. WTF now? err =", err)
} }
if me.startOutputW == 0 { /*
me.startOutputW = maxX - 132 if me.startOutputW == 0 {
} me.startOutputW = maxX - 132
if me.startOutputW == 0 { }
me.startOutputH = maxY / 2 if me.startOutputW == 0 {
} me.startOutputH = maxY / 2
}
*/
v, err = g.SetView("msg", me.startOutputW, me.startOutputH, maxX/2+outputW, maxY/2+outputH, 0) a := me.logStdout.gocuiSize.w0
b := me.logStdout.gocuiSize.h0
c := me.logStdout.gocuiSize.w1
d := me.logStdout.gocuiSize.h1
v, err = g.SetView("msg", a, b, c, d, 0)
// v, err = g.SetView("msg", me.startOutputW, me.startOutputH, maxX/2+me.stdout.w, maxY/2+me.stdout.h, 0)
if errors.Is(err, gocui.ErrUnknownView) { if errors.Is(err, gocui.ErrUnknownView) {
log.Log(NOW, "makeoutputwindow() this is supposed to happen?", err) log.Log(NOW, "makeoutputwindow() this is supposed to happen?", err)
} }

View File

@ -36,47 +36,58 @@ type config struct {
ctrlDown *tree.Node // shown if you click the mouse when the ctrl key is pressed ctrlDown *tree.Node // shown if you click the mouse when the ctrl key is pressed
currentWindow *guiWidget // this is the current tab or window to show currentWindow *guiWidget // this is the current tab or window to show
logStdout *guiWidget // where to show STDOUT logStdout *guiWidget // where to show STDOUT
startOutputW int // ? // startOutputW int // ?
startOutputH int // ? // startOutputH int // ?
helpLabel *gocui.View // ? helpLabel *gocui.View // ?
showHelp bool // toggle boolean for the help menu (deprecate?) showHelp bool // toggle boolean for the help menu (deprecate?)
outputOnTop bool // is the STDOUT window on top? dropdownW *guiWidget // grab the dropdown choices from this widget
// dropdownV *guiWidget // this is a floating widget that we show whenever the user clicks on a FramePadW int `default:"1" dense:"0"` // When the widget has a frame, like a button, it adds 2 lines runes on each side
dropdownW *guiWidget // grab the dropdown choices from this widget FramePadH int `default:"1" dense:"0"` // When the widget has a frame, like a button, it adds 2 lines runes on each side
FramePadW int `default:"1" dense:"0"` // When the widget has a frame, like a button, it adds 2 lines runes on each side PadW int `default:"1" dense:"0"` // pad spacing
FramePadH int `default:"1" dense:"0"` // When the widget has a frame, like a button, it adds 2 lines runes on each side PadH int `default:"1" dense:"0"` // pad spacing
PadW int `default:"1" dense:"0"` // pad spacing WindowW int `default:"8" dense:"0"` // how far down to start Window or Tab headings
PadH int `default:"1" dense:"0"` // pad spacing WindowH int `default:"-1"` // how far down to start Window or Tab headings
WindowW int `default:"8" dense:"0"` // how far down to start Window or Tab headings TabW int `default:"5" dense:"0"` // how far down to start Window or Tab headings
WindowH int `default:"-1"` // how far down to start Window or Tab headings TabH int `default:"1" dense:"0"` // how far down to start Window or Tab headings
TabW int `default:"5" dense:"0"` // how far down to start Window or Tab headings WindowPadW int `default:"8" dense:"0"` // additional amount of space to put between window & tab widgets
TabH int `default:"1" dense:"0"` // how far down to start Window or Tab headings TabPadW int `default:"4" dense:"0"` // additional amount of space to put between window & tab widgets
WindowPadW int `default:"8" dense:"0"` // additional amount of space to put between window & tab widgets GroupPadW int `default:"2" dense:"1"` // additional amount of space to indent on a group
TabPadW int `default:"4" dense:"0"` // additional amount of space to put between window & tab widgets BoxPadW int `default:"2" dense:"1"` // additional amount of space to indent on a box
GroupPadW int `default:"2" dense:"1"` // additional amount of space to indent on a group GridPadW int `default:"2" dense:"1"` // additional amount of space to indent on a grid
BoxPadW int `default:"2" dense:"1"` // additional amount of space to indent on a box RawW int `default:"1"` // the raw beginning of each window (or tab)
GridPadW int `default:"2" dense:"1"` // additional amount of space to indent on a grid RawH int `default:"5"` // the raw beginning of each window (or tab)
RawW int `default:"1"` // the raw beginning of each window (or tab) FakeW int `default:"20"` // offset for the hidden widgets
RawH int `default:"5"` // the raw beginning of each window (or tab) padded bool // add space between things like buttons
FakeW int `default:"20"` // offset for the hidden widgets bookshelf bool // do you want things arranged in the box like a bookshelf or a stack?
padded bool // add space between things like buttons canvas bool // if set to true, the windows are a raw canvas
bookshelf bool // do you want things arranged in the box like a bookshelf or a stack? menubar bool // for windows
canvas bool // if set to true, the windows are a raw canvas stretchy bool // expand things like buttons to the maximum size
menubar bool // for windows margin bool // add space around the frames of windows
stretchy bool // expand things like buttons to the maximum size writeMutex sync.Mutex // writeMutex protects writes to *guiWidget (it's global right now maybe)
margin bool // add space around the frames of windows dtoggle bool // is a dropdown or combobox currently active?
writeMutex sync.Mutex // writeMutex protects writes to *guiWidget (it's global right now maybe) ecount int // counts how many mouse and keyboard events have occurred
dtoggle bool // is a dropdown or combobox currently active? supermouse bool // prints out every widget found while you move the mouse around
ecount int // counts how many mouse and keyboard events have occurred depth int // used for listWidgets() debugging
supermouse bool // prints out every widget found while you move the mouse around globalMouseDown bool // yep, mouse is pressed
depth int // used for listWidgets() debugging newWindowTrigger chan bool // work around hack to redraw windows a bit after NewWindow()
globalMouseDown bool // yep, mouse is pressed stdout stdout // information for the STDOUT window
newWindowTrigger chan bool // work around hack to redraw windows a bit after NewWindow() }
// settings for the stdout window
type stdout struct {
w int // the width
h int // the width
outputOnTop bool // is the STDOUT window on top?
offscreenW int // where to place the window offscreen
offscreenH int // where to place the window offscreen
offsetW int // the current 'w' offset
offsetH int // the current 'h' offset
} }
// deprecate these // deprecate these
var ( var (
initialMouseX, initialMouseY, xOffset, yOffset int initialMouseX, initialMouseY int
// initialMouseX, initialMouseY, xOffset, yOffset int
// msgMouseDown bool // msgMouseDown bool
) )