gotop/termui/init.go

27 lines
614 B
Go
Raw Normal View History

2018-02-19 15:25:02 +08:00
package termui
2018-02-19 15:51:55 +08:00
import (
tb "github.com/nsf/termbox-go"
)
2018-02-19 15:25:02 +08:00
// Init initializes termui library. This function should be called before any others.
// After initialization, the library must be finalized by 'Close' function.
func Init() error {
if err := tb.Init(); err != nil {
return err
}
tb.SetInputMode(tb.InputEsc | tb.InputMouse)
tb.SetOutputMode(tb.Output256)
Body = NewGrid()
Body.Width, Body.Height = tb.Size()
return nil
}
2018-02-23 16:42:39 +08:00
// Close finalizes termui library.
// It should be called after successful initialization when termui's functionality isn't required anymore.
2018-02-19 15:25:02 +08:00
func Close() {
tb.Close()
}