From cee092a9f8ff3910be36c5fb73da2b81924b3e1a Mon Sep 17 00:00:00 2001 From: "Roi Martin (@nibble_ds)" Date: Sat, 11 Jan 2014 20:29:16 +0100 Subject: [PATCH] Clean up API --- gui.go | 12 ++++++------ keybinding.go | 6 +++--- view.go | 4 ++-- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/gui.go b/gui.go index 6e7b1bd..a767954 100644 --- a/gui.go +++ b/gui.go @@ -19,7 +19,7 @@ type Gui struct { views []*View currentView *View layout func(*Gui) error - keybindings []*Keybinding + keybindings []*keybinding maxX, maxY int } @@ -75,7 +75,7 @@ func (g *Gui) SetView(name string, x0, y0, x1, y1 int) (v *View, err error) { return v, nil } - v = NewView(name, x0, y0, x1, y1) + v = newView(name, x0, y0, x1, y1) v.bgColor, v.fgColor = g.BgColor, g.FgColor v.selBgColor, v.selFgColor = g.SelBgColor, g.SelFgColor g.views = append(g.views, v) @@ -112,13 +112,13 @@ func (g *Gui) SetCurrentView(name string) (err error) { } func (g *Gui) SetKeybinding(viewname string, key interface{}, mod Modifier, cb KeybindingCB) (err error) { - var kb *Keybinding + var kb *keybinding switch k := key.(type) { case Key: - kb = NewKeybinding(viewname, k, 0, mod, cb) + kb = newKeybinding(viewname, k, 0, mod, cb) case rune: - kb = NewKeybinding(viewname, 0, k, mod, cb) + kb = newKeybinding(viewname, 0, k, mod, cb) default: return errors.New("unknown type") } @@ -203,7 +203,7 @@ func (g *Gui) draw() (err error) { } for _, v := range g.views { - if err := v.Draw(); err != nil { + if err := v.draw(); err != nil { return err } } diff --git a/keybinding.go b/keybinding.go index b976ac5..7d7cddb 100644 --- a/keybinding.go +++ b/keybinding.go @@ -86,7 +86,7 @@ const ( ModAlt Modifier = Modifier(termbox.ModAlt) ) -type Keybinding struct { +type keybinding struct { ViewName string Key Key Ch rune @@ -94,8 +94,8 @@ type Keybinding struct { CB KeybindingCB } -func NewKeybinding(viewname string, key Key, ch rune, mod Modifier, cb KeybindingCB) (kb *Keybinding) { - kb = &Keybinding{ +func newKeybinding(viewname string, key Key, ch rune, mod Modifier, cb KeybindingCB) (kb *keybinding) { + kb = &keybinding{ ViewName: viewname, Key: key, Ch: ch, diff --git a/view.go b/view.go index 51ee78c..39b0a58 100644 --- a/view.go +++ b/view.go @@ -19,7 +19,7 @@ type View struct { selBgColor, selFgColor Attribute } -func NewView(name string, x0, y0, x1, y1 int) (v *View) { +func newView(name string, x0, y0, x1, y1 int) (v *View) { v = &View{ Name: name, X0: x0, @@ -79,7 +79,7 @@ func (v *View) Write(p []byte) (n int, err error) { return len(pr), nil } -func (v *View) Draw() (err error) { +func (v *View) draw() (err error) { maxX, maxY := v.Size() buf := bytes.NewBufferString(string(v.buffer)) br := bufio.NewReader(buf)