summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--eventMouse.go2
-rw-r--r--eventMouseClick.go3
-rw-r--r--structs.go6
-rw-r--r--treeDraw.go32
-rw-r--r--treeWidget.go15
-rw-r--r--view.go47
-rw-r--r--window.go1
7 files changed, 29 insertions, 77 deletions
diff --git a/eventMouse.go b/eventMouse.go
index a83dcf5..b7c209f 100644
--- a/eventMouse.go
+++ b/eventMouse.go
@@ -88,7 +88,7 @@ func mouseDown(g *gocui.Gui, v *gocui.View) error {
}
}
}
- tk.dumpWidget("mouse drag()")
+ tk.dumpWidget("mouse drag()" + tk.labelN)
me.currentDrag = tk
tk.dragW = w - tk.gocuiSize.w0
tk.dragH = h - tk.gocuiSize.h0
diff --git a/eventMouseClick.go b/eventMouseClick.go
index a04c992..222cb81 100644
--- a/eventMouseClick.go
+++ b/eventMouseClick.go
@@ -13,13 +13,10 @@ func (tk *guiWidget) doWindowClick(w int, h int) {
// if there is a current window, hide it
if me.currentWindow != nil {
me.currentWindow.setColor(&colorWindow)
- // me.currentWindow.hideWidgets()
- me.currentWindow.isCurrent = false
}
// now set this window as the current window
me.currentWindow = tk
- me.currentWindow.isCurrent = true
tk.redrawWindow(w, h)
setThingsOnTop() // sets help, Stdout, etc on the top after windows have been redrawn
diff --git a/structs.go b/structs.go
index e57c69a..f444e65 100644
--- a/structs.go
+++ b/structs.go
@@ -128,6 +128,7 @@ type window struct {
active bool // means this window is the active one
isBG bool // means this is the background widget. There is only one of these
order int // what level the window is on
+ resize bool // only set the title once
}
type guiWidget struct {
@@ -154,7 +155,6 @@ type guiWidget struct {
force rectType // force widget within these boundries (using this to debug window dragging)
startW int // ?
startH int // ?
- isCurrent bool // is this the currently displayed Window or Tab?
isFake bool // widget types like 'box' are 'false'
widths map[int]int // how tall each row in the grid is
heights map[int]int // how wide each column in the grid is
@@ -162,8 +162,8 @@ type guiWidget struct {
frame bool // ?
selectedTab *tree.Node // for a window, this is currently selected tab
color *colorT // what color to use
- resize bool // the window is currently being resized
- isBG bool // means this is the background widget. There is only one of these
+ // resize bool // the window is currently being resized
+ isBG bool // means this is the background widget. There is only one of these
}
// from the gocui devs:
diff --git a/treeDraw.go b/treeDraw.go
index c876ee5..86eb673 100644
--- a/treeDraw.go
+++ b/treeDraw.go
@@ -38,19 +38,17 @@ func (tk *guiWidget) drawView() {
c := tk.gocuiSize.w1
d := tk.gocuiSize.h1
+ // this is all terrible. This sets the title. kinda
if tk.node.WidgetType == widget.Window {
- if !tk.resize {
- tk.resize = true
- tk.textResize() // resize window only once
- } else {
- tk.full.w0 = tk.force.w0
- tk.full.h0 = tk.force.h0
- // for windows, make it the full size
- a = tk.full.w0
- b = tk.full.h0
- c = tk.full.w0 + 20
- d = tk.full.h0 + 2
- }
+ tk.textResize()
+ tk.full.w0 = tk.force.w0
+ tk.full.h0 = tk.force.h0
+
+ // for windows, make it the full size
+ a = tk.full.w0
+ b = tk.full.h0
+ c = tk.full.w0 + tk.gocuiSize.Width()
+ d = tk.full.h0 + tk.gocuiSize.Height()
} else {
if tk.internal {
// do nothing
@@ -76,16 +74,6 @@ func (tk *guiWidget) drawView() {
return
}
- // this sets up the keybinding for the name of the window
- // does this really need to be done? I think we probably already
- // know everything about where all the widgets are so we could bypass
- // the gocui package and just handle all the mouse events internally here (?)
- // for now, the w.v.Name is a string "1", "2", "3", etc from the widgetId
-
- // set the binding for this gocui view now that it has been created
- // gocui handles overlaps of views so it will run on the view that is clicked on
- // me.baseGui.SetKeybinding(w.v.Name(), gocui.MouseLeft, gocui.ModNone, click)
-
// this actually sends the text to display to gocui
tk.v.Wrap = true
tk.v.Frame = tk.frame
diff --git a/treeWidget.go b/treeWidget.go
index 784aac4..bd9c947 100644
--- a/treeWidget.go
+++ b/treeWidget.go
@@ -73,21 +73,6 @@ func (w *guiWidget) deleteView() {
w.v = nil
}
-func (w *guiWidget) IsCurrent() bool {
- if w.node.WidgetType == widget.Tab {
- return w.isCurrent
- }
- if w.node.WidgetType == widget.Window {
- // log.Log(GOCUI, "IsCurrent() found current window", w.cuiName, w.String())
- // log.Log(GOCUI, "IsCurrent() window w.isCurrent =", w.isCurrent)
- return w.isCurrent
- }
- if w.node.WidgetType == widget.Root {
- return false
- }
- return w.parent.IsCurrent()
-}
-
func (tk *guiWidget) String() string {
return tk.node.String()
}
diff --git a/view.go b/view.go
index 35ed732..c6cd296 100644
--- a/view.go
+++ b/view.go
@@ -4,53 +4,34 @@
package main
import (
- "bufio"
"strings"
- "go.wit.com/log"
"go.wit.com/widget"
)
-func splitLines(s string) []string {
- var lines []string
- sc := bufio.NewScanner(strings.NewReader(s))
- for sc.Scan() {
- lines = append(lines, sc.Text())
- }
- return lines
-}
+// expands the gocuiSize rectangle to fit
+// all the text in tk.labelN
+func (tk *guiWidget) textResize() {
+ var w, h int = 0, 0
-func (w *guiWidget) textResize() bool {
- // w := n.tk
- var width, height int = 0, 0
- var changed bool = false
-
- for i, s := range splitLines(w.labelN) {
- log.Log(INFO, "textResize() len =", len(s), i, s)
- if width < len(s) {
- width = len(s)
+ for _, s := range strings.Split(tk.labelN, "\n") {
+ s = strings.TrimSpace(s)
+ // log.Log(INFO, "textResize() len =", len(s), i, s)
+ if w < len(s) {
+ w = len(s)
}
- height += 1
- }
- if w.gocuiSize.w1 != w.gocuiSize.w0+width+me.FramePadW {
- w.gocuiSize.w1 = w.gocuiSize.w0 + width + me.FramePadW
- changed = true
+ h += 1
}
- if w.gocuiSize.h1 != w.gocuiSize.h0+height+me.FramePadH {
- w.gocuiSize.h1 = w.gocuiSize.h0 + height + me.FramePadH
- changed = true
- }
- if changed {
- // w.showWidgetPlacement("textResize() changed")
- }
- return changed
+
+ // this is old code. now move this somewhere smarter
+ tk.gocuiSize.w1 = tk.gocuiSize.w0 + w + me.FramePadW // TODO: move this FramePadW out of here
+ tk.gocuiSize.h1 = tk.gocuiSize.h0 + h + me.FramePadH // TODO: fix this size computation
}
func (w *guiWidget) hideWidgets() {
if w == nil {
return
}
- w.isCurrent = false
switch w.node.WidgetType {
case widget.Root:
case widget.Flag:
diff --git a/window.go b/window.go
index 621bae1..412096c 100644
--- a/window.go
+++ b/window.go
@@ -156,6 +156,7 @@ func (tk *guiWidget) makeWindowActive() {
for _, tk := range me.allwin {
tk.window.order += 1
tk.window.active = false
+ tk.setColor(&colorWindow) // color for inactive windows
}
// set this window as the active one