]> git.0d.be Git - barnard.git/commitdiff
uiterm: make View interface methods private
authorTim Cooper <tim.cooper@layeh.com>
Sun, 7 Dec 2014 01:48:11 +0000 (21:48 -0400)
committerTim Cooper <tim.cooper@layeh.com>
Sun, 7 Dec 2014 01:48:11 +0000 (21:48 -0400)
uiterm/label.go
uiterm/textbox.go
uiterm/textview.go
uiterm/tree.go
uiterm/ui.go
uiterm/view.go

index 3e772e561a3e0def4f637a7ee8353641f88886f9..cde1de1ef76de7430b87ce172d04aa79a418e4c1 100644 (file)
@@ -14,17 +14,17 @@ type Label struct {
        x0, y0, x1, y1 int
 }
 
-func (l *Label) SetActive(ui *Ui, active bool) {
+func (l *Label) setActive(ui *Ui, active bool) {
 }
 
-func (l *Label) SetBounds(ui *Ui, x0, y0, x1, y1 int) {
+func (l *Label) setBounds(ui *Ui, x0, y0, x1, y1 int) {
        l.x0 = x0
        l.y0 = y0
        l.x1 = x1
        l.y1 = y1
 }
 
-func (l *Label) Draw(ui *Ui) {
+func (l *Label) draw(ui *Ui) {
        reader := strings.NewReader(l.Text)
        for y := l.y0; y < l.y1; y++ {
                for x := l.x0; x < l.x1; x++ {
@@ -39,8 +39,8 @@ func (l *Label) Draw(ui *Ui) {
        }
 }
 
-func (l *Label) KeyEvent(ui *Ui, mod Modifier, key Key) {
+func (l *Label) keyEvent(ui *Ui, mod Modifier, key Key) {
 }
 
-func (l *Label) CharacterEvent(ui *Ui, chr rune) {
+func (l *Label) characterEvent(ui *Ui, chr rune) {
 }
index 54726cd82ad98c637adb9df8620daaa9d93f8946..a1b38b4a135d1adad7148f0e96b4c50902352311 100644 (file)
@@ -20,18 +20,18 @@ type Textbox struct {
        x0, y0, x1, y1 int
 }
 
-func (t *Textbox) SetBounds(ui *Ui, x0, y0, x1, y1 int) {
+func (t *Textbox) setBounds(ui *Ui, x0, y0, x1, y1 int) {
        t.x0 = x0
        t.y0 = y0
        t.x1 = x1
        t.y1 = y1
 }
 
-func (t *Textbox) SetActive(ui *Ui, active bool) {
+func (t *Textbox) setActive(ui *Ui, active bool) {
        t.active = active
 }
 
-func (t *Textbox) Draw(ui *Ui) {
+func (t *Textbox) draw(ui *Ui) {
        var setCursor = false
        reader := strings.NewReader(t.Text)
        for y := t.y0; y < t.y1; y++ {
@@ -51,7 +51,7 @@ func (t *Textbox) Draw(ui *Ui) {
        }
 }
 
-func (t *Textbox) KeyEvent(ui *Ui, mod Modifier, key Key) {
+func (t *Textbox) keyEvent(ui *Ui, mod Modifier, key Key) {
        redraw := false
        switch key {
        case KeyCtrlC:
@@ -76,13 +76,13 @@ func (t *Textbox) KeyEvent(ui *Ui, mod Modifier, key Key) {
                }
        }
        if redraw {
-               t.Draw(ui)
+               t.draw(ui)
                termbox.Flush()
        }
 }
 
-func (t *Textbox) CharacterEvent(ui *Ui, chr rune) {
+func (t *Textbox) characterEvent(ui *Ui, chr rune) {
        t.Text = t.Text + string(chr)
-       t.Draw(ui)
+       t.draw(ui)
        termbox.Flush()
 }
index cc80fd4cd16af06f7211629cbeb9a4423a4d2f9c..1d0666bc6dfc47157b3a65bf9dec02f1b8e46f32 100644 (file)
@@ -16,10 +16,10 @@ type Textview struct {
        x0, y0, x1, y1 int
 }
 
-func (t *Textview) SetActive(ui *Ui, active bool) {
+func (t *Textview) setActive(ui *Ui, active bool) {
 }
 
-func (t *Textview) SetBounds(ui *Ui, x0, y0, x1, y1 int) {
+func (t *Textview) setBounds(ui *Ui, x0, y0, x1, y1 int) {
        t.x0 = x0
        t.y0 = y0
        t.x1 = x1
@@ -96,7 +96,7 @@ func (t *Textview) Clear() {
        t.parsedLines = nil
 }
 
-func (t *Textview) Draw(ui *Ui) {
+func (t *Textview) draw(ui *Ui) {
        var reader *strings.Reader
        line := len(t.parsedLines) - 1 - t.CurrentLine
        if line < 0 {
@@ -134,8 +134,8 @@ func (t *Textview) Draw(ui *Ui) {
        }
 }
 
-func (t *Textview) KeyEvent(ui *Ui, mod Modifier, key Key) {
+func (t *Textview) keyEvent(ui *Ui, mod Modifier, key Key) {
 }
 
-func (t *Textview) CharacterEvent(ui *Ui, chr rune) {
+func (t *Textview) characterEvent(ui *Ui, chr rune) {
 }
index 2c55f0e9e28613e227c63d2d07b5ede1f58fb595..1516bc977f5bfeaa997ec9737c534c3aa747282a 100644 (file)
@@ -42,7 +42,7 @@ func bounded(i, lower, upper int) int {
        return i
 }
 
-func (t *Tree) SetBounds(ui *Ui, x0, y0, x1, y1 int) {
+func (t *Tree) setBounds(ui *Ui, x0, y0, x1, y1 int) {
        t.x0 = x0
        t.y0 = y0
        t.x1 = x1
@@ -85,7 +85,7 @@ func (t *Tree) rebuild_rec(parent TreeItem, level int) []renderedTreeItem {
        return lines
 }
 
-func (t *Tree) Draw(ui *Ui) {
+func (t *Tree) draw(ui *Ui) {
        if t.lines == nil {
                t.Rebuild()
        }
@@ -118,11 +118,11 @@ func (t *Tree) Draw(ui *Ui) {
        }
 }
 
-func (t *Tree) SetActive(ui *Ui, active bool) {
+func (t *Tree) setActive(ui *Ui, active bool) {
        t.active = active
 }
 
-func (t *Tree) KeyEvent(ui *Ui, mod Modifier, key Key) {
+func (t *Tree) keyEvent(ui *Ui, mod Modifier, key Key) {
        switch key {
        case KeyArrowUp:
                t.activeLine = bounded(t.activeLine-1, 0, len(t.lines)-1)
@@ -136,5 +136,5 @@ func (t *Tree) KeyEvent(ui *Ui, mod Modifier, key Key) {
        ui.Refresh()
 }
 
-func (t *Tree) CharacterEvent(ui *Ui, ch rune) {
+func (t *Tree) characterEvent(ui *Ui, ch rune) {
 }
index 9a47132d8de98698bdf2166fbf9a557d4919c39a..bb4d10bb56673de30b9ae51fd274d95a59b248df 100644 (file)
@@ -52,7 +52,7 @@ func (ui *Ui) Refresh() {
                termbox.Clear(termbox.Attribute(ui.fg), termbox.Attribute(ui.bg))
                termbox.HideCursor()
                for _, element := range ui.elements {
-                       element.View.Draw(ui)
+                       element.View.draw(ui)
                }
                termbox.Flush()
        }
@@ -65,11 +65,11 @@ func (ui *Ui) Active() View {
 func (ui *Ui) SetActive(name string) {
        element, _ := ui.elements[name]
        if ui.activeElement != nil {
-               ui.activeElement.View.SetActive(ui, false)
+               ui.activeElement.View.setActive(ui, false)
        }
        ui.activeElement = element
        if element != nil {
-               element.View.SetActive(ui, true)
+               element.View.setActive(ui, true)
        }
        ui.Refresh()
 }
@@ -123,7 +123,7 @@ func (ui *Ui) Run() error {
 
 func (ui *Ui) onCharacterEvent(ch rune) {
        if ui.activeElement != nil {
-               ui.activeElement.View.CharacterEvent(ui, ch)
+               ui.activeElement.View.characterEvent(ui, ch)
        }
 }
 
@@ -134,7 +134,7 @@ func (ui *Ui) onKeyEvent(mod Modifier, key Key) {
                }
        }
        if ui.activeElement != nil {
-               ui.activeElement.View.KeyEvent(ui, mod, key)
+               ui.activeElement.View.keyEvent(ui, mod, key)
        }
 }
 
@@ -154,7 +154,7 @@ func (ui *Ui) SetView(name string, x0, y0, x1, y1 int, view View) {
                        View: view,
                }
        }
-       view.SetBounds(ui, x0, y0, x1, y1)
+       view.setBounds(ui, x0, y0, x1, y1)
 }
 
 func (ui *Ui) View(name string) View {
index 61e907029ff104a5ce14b7a76f15520566cd479b..c33d1a6908c354421b4e3a63071c9b20affce6ac 100644 (file)
@@ -1,9 +1,9 @@
 package uiterm
 
 type View interface {
-       SetBounds(ui *Ui, x0, y0, x1, y1 int)
-       Draw(ui *Ui)
-       SetActive(ui *Ui, active bool)
-       KeyEvent(ui *Ui, mod Modifier, key Key)
-       CharacterEvent(ui *Ui, ch rune)
+       setActive(ui *Ui, active bool)
+       setBounds(ui *Ui, x0, y0, x1, y1 int)
+       draw(ui *Ui)
+       keyEvent(ui *Ui, mod Modifier, key Key)
+       characterEvent(ui *Ui, ch rune)
 }