From cab3771e17286788913255a6abe858b476166837 Mon Sep 17 00:00:00 2001 From: Drew DeVault Date: Tue, 27 Feb 2018 21:17:26 -0500 Subject: Pull main aerc UI into widget --- cmd/aerc/main.go | 71 +------------------------------------------------------- 1 file changed, 1 insertion(+), 70 deletions(-) (limited to 'cmd') diff --git a/cmd/aerc/main.go b/cmd/aerc/main.go index 009b5eb..3030ee9 100644 --- a/cmd/aerc/main.go +++ b/cmd/aerc/main.go @@ -8,31 +8,12 @@ import ( "time" "github.com/mattn/go-isatty" - tb "github.com/nsf/termbox-go" "git.sr.ht/~sircmpwn/aerc2/config" libui "git.sr.ht/~sircmpwn/aerc2/lib/ui" "git.sr.ht/~sircmpwn/aerc2/widgets" ) -type fill rune - -func (f fill) Draw(ctx *libui.Context) { - for x := 0; x < ctx.Width(); x += 1 { - for y := 0; y < ctx.Height(); y += 1 { - ctx.SetCell(x, y, rune(f), tb.ColorDefault, tb.ColorDefault) - } - } -} - -func (f fill) OnInvalidate(callback func(d libui.Drawable)) { - // no-op -} - -func (f fill) Invalidate() { - // no-op -} - func main() { var logOut io.Writer var logger *log.Logger @@ -49,62 +30,12 @@ func main() { panic(err) } - tabs := libui.NewTabs() - tabs.Add(fill('★'), "白い星") - tabs.Add(fill('☆'), "empty stars") - - grid := libui.NewGrid().Rows([]libui.GridSpec{ - libui.GridSpec{libui.SIZE_EXACT, 1}, - libui.GridSpec{libui.SIZE_WEIGHT, 1}, - libui.GridSpec{libui.SIZE_EXACT, 1}, - }).Columns([]libui.GridSpec{ - libui.GridSpec{libui.SIZE_EXACT, 20}, - libui.GridSpec{libui.SIZE_WEIGHT, 1}, - }) - - // TODO: move sidebar into tab content, probably - grid.AddChild(libui.NewText("aerc"). - Strategy(libui.TEXT_CENTER). - Color(tb.ColorBlack, tb.ColorWhite)) - // sidebar placeholder: - grid.AddChild(libui.NewBordered( - fill('.'), libui.BORDER_RIGHT)).At(1, 0).Span(2, 1) - grid.AddChild(tabs.TabStrip).At(0, 1) - grid.AddChild(tabs.TabContent).At(1, 1) - - statusbar := libui.NewStack() - grid.AddChild(statusbar).At(2, 1) - - statusline := widgets.NewStatusLine() - statusline.Push("test status!", 6*time.Second) - statusline.Push("test error!", 3*time.Second). - Color(tb.ColorRed, tb.ColorBlack) - statusbar.Push(statusline) - - exline := widgets.NewExLine(func(command string) { - statusbar.Pop() - logger.Printf("TODO: execute command: %s\n", command) - }, func() { - statusbar.Pop() - }) - statusbar.Push(exline) - - ui, err := libui.Initialize(conf, grid) + ui, err := libui.Initialize(conf, widgets.NewAerc(logger)) if err != nil { panic(err) } defer ui.Close() - // TODO: this should be a stack - ui.AddInteractive(exline) - - go (func() { - for { - time.Sleep(1 * time.Second) - tabs.Select((tabs.Selected + 1) % 2) - } - })() - for !ui.Exit { if !ui.Tick() { // ~60 FPS -- cgit v1.2.3