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:
parent
63f934ee71
commit
0847464da1
2 changed files with 10 additions and 8 deletions
6
aerc.go
6
aerc.go
|
@ -150,12 +150,16 @@ func main() {
|
||||||
return getCompletions(aerc, cmd)
|
return getCompletions(aerc, cmd)
|
||||||
}, &commands.CmdHistory)
|
}, &commands.CmdHistory)
|
||||||
|
|
||||||
ui, err = libui.Initialize(conf, aerc)
|
ui, err = libui.Initialize(aerc)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
defer ui.Close()
|
defer ui.Close()
|
||||||
|
|
||||||
|
if conf.Ui.MouseEnabled {
|
||||||
|
ui.EnableMouse()
|
||||||
|
}
|
||||||
|
|
||||||
logger.Println("Starting Unix server")
|
logger.Println("Starting Unix server")
|
||||||
as, err := lib.StartServer(logger)
|
as, err := lib.StartServer(logger)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
12
lib/ui/ui.go
12
lib/ui/ui.go
|
@ -4,8 +4,6 @@ import (
|
||||||
"sync/atomic"
|
"sync/atomic"
|
||||||
|
|
||||||
"github.com/gdamore/tcell"
|
"github.com/gdamore/tcell"
|
||||||
|
|
||||||
"git.sr.ht/~sircmpwn/aerc/config"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type UI struct {
|
type UI struct {
|
||||||
|
@ -18,8 +16,7 @@ type UI struct {
|
||||||
invalid int32 // access via atomic
|
invalid int32 // access via atomic
|
||||||
}
|
}
|
||||||
|
|
||||||
func Initialize(conf *config.AercConfig,
|
func Initialize(content DrawableInteractiveBeeper) (*UI, error) {
|
||||||
content DrawableInteractiveBeeper) (*UI, error) {
|
|
||||||
|
|
||||||
screen, err := tcell.NewScreen()
|
screen, err := tcell.NewScreen()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -32,9 +29,6 @@ func Initialize(conf *config.AercConfig,
|
||||||
|
|
||||||
screen.Clear()
|
screen.Clear()
|
||||||
screen.HideCursor()
|
screen.HideCursor()
|
||||||
if conf.Ui.MouseEnabled {
|
|
||||||
screen.EnableMouse()
|
|
||||||
}
|
|
||||||
|
|
||||||
width, height := screen.Size()
|
width, height := screen.Size()
|
||||||
|
|
||||||
|
@ -101,3 +95,7 @@ func (state *UI) Tick() bool {
|
||||||
|
|
||||||
return more
|
return more
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (state *UI) EnableMouse() {
|
||||||
|
state.screen.EnableMouse()
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue