Ver código fonte

uiterm: change Ui.Active to return View name

master
Tim Cooper 10 anos atrás
pai
commit
54584f8e30
6 arquivos alterados com 14 adições e 12 exclusões
  1. +3
    -3
      ui.go
  2. +1
    -1
      uiterm/label.go
  3. +1
    -1
      uiterm/textbox.go
  4. +2
    -2
      uiterm/textview.go
  5. +3
    -3
      uiterm/tree.go
  6. +4
    -2
      uiterm/ui.go

+ 3
- 3
ui.go Ver arquivo

@@ -5,9 +5,9 @@ import (
"strings" "strings"
"time" "time"


"github.com/kennygrant/sanitize"
"github.com/layeh/barnard/uiterm" "github.com/layeh/barnard/uiterm"
"github.com/layeh/gumble/gumble" "github.com/layeh/gumble/gumble"
"github.com/kennygrant/sanitize"
) )


const ( 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) { func (b *Barnard) OnFocusPress(ui *uiterm.Ui, key uiterm.Key) {
active := b.Ui.Active() active := b.Ui.Active()
if active == &b.UiInput {
if active == uiViewInput {
b.Ui.SetActive(uiViewTree) b.Ui.SetActive(uiViewTree)
} else if active == &b.UiTree {
} else if active == uiViewTree {
b.Ui.SetActive(uiViewInput) b.Ui.SetActive(uiViewInput)
} }
} }


+ 1
- 1
uiterm/label.go Ver arquivo

@@ -11,7 +11,7 @@ type Label struct {
Fg Attribute Fg Attribute
Bg Attribute Bg Attribute


ui *Ui
ui *Ui
x0, y0, x1, y1 int x0, y0, x1, y1 int
} }




+ 1
- 1
uiterm/textbox.go Ver arquivo

@@ -14,7 +14,7 @@ type Textbox struct {


Input func(ui *Ui, textbox *Textbox, text string) Input func(ui *Ui, textbox *Textbox, text string)


ui *Ui
ui *Ui
active bool active bool
x0, y0, x1, y1 int x0, y0, x1, y1 int
} }


+ 2
- 2
uiterm/textview.go Ver arquivo

@@ -12,9 +12,9 @@ type Textview struct {
Fg Attribute Fg Attribute
Bg Attribute Bg Attribute


parsedLines []string
parsedLines []string


ui *Ui
ui *Ui
x0, y0, x1, y1 int x0, y0, x1, y1 int
} }




+ 3
- 3
uiterm/tree.go Ver arquivo

@@ -26,10 +26,10 @@ type Tree struct {
Generator TreeFunc Generator TreeFunc
Listener TreeListener Listener TreeListener


lines []renderedTreeItem
activeLine int
lines []renderedTreeItem
activeLine int


ui *Ui
ui *Ui
active bool active bool
x0, y0, x1, y1 int x0, y0, x1, y1 int
} }


+ 4
- 2
uiterm/ui.go Ver arquivo

@@ -27,6 +27,7 @@ type Ui struct {
} }


type uiElement struct { type uiElement struct {
Name string
X0, Y0, X1, Y1 int X0, Y0, X1, Y1 int
View View 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) { 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") return errors.New("view already exists")
} }
ui.elements[name] = &uiElement{ ui.elements[name] = &uiElement{
Name: name,
View: view, View: view,
} }
view.uiInitialize(ui) view.uiInitialize(ui)


Carregando…
Cancelar
Salvar