diff --git a/ui.go b/ui.go index 7b4f6fb..d9953d3 100644 --- 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) } } diff --git a/uiterm/label.go b/uiterm/label.go index 5bc6652..259c22d 100644 --- a/uiterm/label.go +++ b/uiterm/label.go @@ -11,7 +11,7 @@ type Label struct { Fg Attribute Bg Attribute - ui *Ui + ui *Ui x0, y0, x1, y1 int } diff --git a/uiterm/textbox.go b/uiterm/textbox.go index ff97a09..cda0c41 100644 --- a/uiterm/textbox.go +++ b/uiterm/textbox.go @@ -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 } diff --git a/uiterm/textview.go b/uiterm/textview.go index cf161b2..395772e 100644 --- a/uiterm/textview.go +++ b/uiterm/textview.go @@ -12,9 +12,9 @@ type Textview struct { Fg Attribute Bg Attribute - parsedLines []string + parsedLines []string - ui *Ui + ui *Ui x0, y0, x1, y1 int } diff --git a/uiterm/tree.go b/uiterm/tree.go index 135e937..c72a67f 100644 --- a/uiterm/tree.go +++ b/uiterm/tree.go @@ -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 } diff --git a/uiterm/ui.go b/uiterm/ui.go index 39ddf02..b9b1f8f 100644 --- a/uiterm/ui.go +++ b/uiterm/ui.go @@ -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)