Remove aerc specific code from the ui

Separatiing the ui code from aerc makes it usable as a library in
other projects.
This commit is contained in:
Nicolai Dagestad 2019-08-03 17:17:13 +02:00 committed by Drew DeVault
parent 63f934ee71
commit 0847464da1
2 changed files with 10 additions and 8 deletions

View File

@ -150,12 +150,16 @@ func main() {
return getCompletions(aerc, cmd)
}, &commands.CmdHistory)
ui, err = libui.Initialize(conf, aerc)
ui, err = libui.Initialize(aerc)
if err != nil {
panic(err)
}
defer ui.Close()
if conf.Ui.MouseEnabled {
ui.EnableMouse()
}
logger.Println("Starting Unix server")
as, err := lib.StartServer(logger)
if err != nil {

View File

@ -4,8 +4,6 @@ import (
"sync/atomic"
"github.com/gdamore/tcell"
"git.sr.ht/~sircmpwn/aerc/config"
)
type UI struct {
@ -18,8 +16,7 @@ type UI struct {
invalid int32 // access via atomic
}
func Initialize(conf *config.AercConfig,
content DrawableInteractiveBeeper) (*UI, error) {
func Initialize(content DrawableInteractiveBeeper) (*UI, error) {
screen, err := tcell.NewScreen()
if err != nil {
@ -32,9 +29,6 @@ func Initialize(conf *config.AercConfig,
screen.Clear()
screen.HideCursor()
if conf.Ui.MouseEnabled {
screen.EnableMouse()
}
width, height := screen.Size()
@ -101,3 +95,7 @@ func (state *UI) Tick() bool {
return more
}
func (state *UI) EnableMouse() {
state.screen.EnableMouse()
}