]> git.0d.be Git - barnard.git/commitdiff
uiterm: change Ui.Active to return View name
authorTim Cooper <tim.cooper@layeh.com>
Sun, 7 Dec 2014 02:15:04 +0000 (22:15 -0400)
committerTim Cooper <tim.cooper@layeh.com>
Sun, 7 Dec 2014 02:15:04 +0000 (22:15 -0400)
ui.go
uiterm/label.go
uiterm/textbox.go
uiterm/textview.go
uiterm/tree.go
uiterm/ui.go

diff --git a/ui.go b/ui.go
index 7b4f6fb97d922bfe8683ecd244be564e3dc67612..d9953d3be5d09b88f2c5bcb55bc45dfbc99bac30 100644 (file)
--- a/ui.go
+++ b/ui.go
@@ -5,9 +5,9 @@ import (
        "strings"
        "time"
 
+       "github.com/kennygrant/sanitize"
        "github.com/layeh/barnard/uiterm"
        "github.com/layeh/gumble/gumble"
-       "github.com/kennygrant/sanitize"
 )
 
 const (
@@ -91,9 +91,9 @@ func (b *Barnard) OnScrollOutputBottom(ui *uiterm.Ui, key uiterm.Key) {
 
 func (b *Barnard) OnFocusPress(ui *uiterm.Ui, key uiterm.Key) {
        active := b.Ui.Active()
-       if active == &b.UiInput {
+       if active == uiViewInput {
                b.Ui.SetActive(uiViewTree)
-       } else if active == &b.UiTree {
+       } else if active == uiViewTree {
                b.Ui.SetActive(uiViewInput)
        }
 }
index 5bc6652bc538294136105ea2828046d22dc76676..259c22d05eaba399aac4c9fb74638f571cc2a7f9 100644 (file)
@@ -11,7 +11,7 @@ type Label struct {
        Fg   Attribute
        Bg   Attribute
 
-       ui *Ui
+       ui             *Ui
        x0, y0, x1, y1 int
 }
 
index ff97a09c67c8e3d924839969c5979b9d8d9f0c4c..cda0c41c6561060dba0319b446ebf88f028588b4 100644 (file)
@@ -14,7 +14,7 @@ type Textbox struct {
 
        Input func(ui *Ui, textbox *Textbox, text string)
 
-       ui *Ui
+       ui             *Ui
        active         bool
        x0, y0, x1, y1 int
 }
index cf161b2aedc03e921131247a59cc5982a4e26621..395772e1b533caff2ee58a51e5765a27adb3220e 100644 (file)
@@ -12,9 +12,9 @@ type Textview struct {
        Fg          Attribute
        Bg          Attribute
 
-       parsedLines    []string
+       parsedLines []string
 
-       ui *Ui
+       ui             *Ui
        x0, y0, x1, y1 int
 }
 
index 135e937e3af2eff387a9c65231a955c9b9990e1e..c72a67f1ee124d3badf620aa4737ccf581422996 100644 (file)
@@ -26,10 +26,10 @@ type Tree struct {
        Generator TreeFunc
        Listener  TreeListener
 
-       lines          []renderedTreeItem
-       activeLine     int
+       lines      []renderedTreeItem
+       activeLine int
 
-       ui *Ui
+       ui             *Ui
        active         bool
        x0, y0, x1, y1 int
 }
index 39ddf02b3b100d9130f1371326107284ea39c98c..b9b1f8fd8fedd8022f4f92f48bd74100188f261e 100644 (file)
@@ -27,6 +27,7 @@ type Ui struct {
 }
 
 type uiElement struct {
+       Name           string
        X0, Y0, X1, Y1 int
        View           View
 }
@@ -58,8 +59,8 @@ func (ui *Ui) Refresh() {
        }
 }
 
-func (ui *Ui) Active() View {
-       return ui.activeElement.View
+func (ui *Ui) Active() string {
+       return ui.activeElement.Name
 }
 
 func (ui *Ui) SetActive(name string) {
@@ -138,6 +139,7 @@ func (ui *Ui) Add(name string, view View) error {
                return errors.New("view already exists")
        }
        ui.elements[name] = &uiElement{
+               Name: name,
                View: view,
        }
        view.uiInitialize(ui)