Merge *Gui.Init() with *Gui.NewGui()

This commit is contained in:
Roi Martin 2016-10-24 02:24:41 +02:00
parent 550f04e523
commit ddbc9be671
16 changed files with 34 additions and 39 deletions

View File

@ -94,8 +94,8 @@ func quit(g *gocui.Gui, v *gocui.View) error {
}
func main() {
g := gocui.NewGui()
if err := g.Init(); err != nil {
g, err := gocui.NewGui()
if err != nil {
log.Panicln(err)
}
defer g.Close()

View File

@ -42,8 +42,8 @@ func layout(g *gocui.Gui) error {
}
func main() {
g := gocui.NewGui()
if err := g.Init(); err != nil {
g, err := gocui.NewGui()
if err != nil {
log.Panicln(err)
}

View File

@ -12,8 +12,8 @@ import (
)
func main() {
g := gocui.NewGui()
if err := g.Init(); err != nil {
g, err := gocui.NewGui()
if err != nil {
log.Panicln(err)
}
defer g.Close()

View File

@ -191,8 +191,8 @@ func layout(g *gocui.Gui) error {
}
func main() {
g := gocui.NewGui()
if err := g.Init(); err != nil {
g, err := gocui.NewGui()
if err != nil {
log.Panicln(err)
}
defer g.Close()

View File

@ -21,8 +21,8 @@ var (
)
func main() {
g := gocui.NewGui()
if err := g.Init(); err != nil {
g, err := gocui.NewGui()
if err != nil {
log.Panicln(err)
}
defer g.Close()

View File

@ -24,8 +24,8 @@ var (
)
func main() {
g := gocui.NewGui()
if err := g.Init(); err != nil {
g, err := gocui.NewGui()
if err != nil {
log.Panicln(err)
}
defer g.Close()

View File

@ -12,8 +12,8 @@ import (
)
func main() {
g := gocui.NewGui()
if err := g.Init(); err != nil {
g, err := gocui.NewGui()
if err != nil {
log.Panicln(err)
}
defer g.Close()

View File

@ -32,8 +32,8 @@ func quit(g *gocui.Gui, v *gocui.View) error {
}
func main() {
g := gocui.NewGui()
if err := g.Init(); err != nil {
g, err := gocui.NewGui()
if err != nil {
log.Panicln(err)
}
defer g.Close()

View File

@ -12,8 +12,8 @@ import (
)
func main() {
g := gocui.NewGui()
if err := g.Init(); err != nil {
g, err := gocui.NewGui()
if err != nil {
log.Fatalln(err)
}
defer g.Close()

View File

@ -12,8 +12,8 @@ import (
)
func main() {
g := gocui.NewGui()
if err := g.Init(); err != nil {
g, err := gocui.NewGui()
if err != nil {
log.Panicln(err)
}
defer g.Close()

View File

@ -12,8 +12,8 @@ import (
)
func main() {
g := gocui.NewGui()
if err := g.Init(); err != nil {
g, err := gocui.NewGui()
if err != nil {
log.Panicln(err)
}
defer g.Close()

View File

@ -56,8 +56,8 @@ func quit(g *gocui.Gui, v *gocui.View) error {
}
func main() {
g := gocui.NewGui()
if err := g.Init(); err != nil {
g, err := gocui.NewGui()
if err != nil {
log.Panicln(err)
}
defer g.Close()

View File

@ -15,8 +15,8 @@ import (
)
func main() {
g := gocui.NewGui()
if err := g.Init(); err != nil {
g, err := gocui.NewGui()
if err != nil {
log.Fatalln(err)
}
defer g.Close()

View File

@ -11,8 +11,8 @@ import (
)
func main() {
g := gocui.NewGui()
if err := g.Init(); err != nil {
g, err := gocui.NewGui()
if err != nil {
log.Panicln(err)
}
defer g.Close()

View File

@ -32,8 +32,8 @@ func quit(g *gocui.Gui, v *gocui.View) error {
}
func main() {
g := gocui.NewGui()
if err := g.Init(); err != nil {
g, err := gocui.NewGui()
if err != nil {
log.Panicln(err)
}
defer g.Close()

13
gui.go
View File

@ -66,23 +66,18 @@ type Gui struct {
}
// NewGui returns a new Gui object.
func NewGui() *Gui {
return &Gui{}
}
// Init initializes the library. This function must be called before
// any other functions.
func (g *Gui) Init() error {
func NewGui() (*Gui, error) {
if err := termbox.Init(); err != nil {
return err
return nil, err
}
g := &Gui{}
g.tbEvents = make(chan termbox.Event, 20)
g.userEvents = make(chan userEvent, 20)
g.maxX, g.maxY = termbox.Size()
g.BgColor, g.FgColor = ColorBlack, ColorWhite
g.SelBgColor, g.SelFgColor = ColorBlack, ColorWhite
g.Editor = DefaultEditor
return nil
return g, nil
}
// Close finalizes the library. It should be called after a successful