summary refs log tree commit diff stats
path: root/cmd
diff options
context:
space:
mode:
authorDrew DeVault <sir@cmpwn.com>2018-02-27 21:17:26 -0500
committerDrew DeVault <sir@cmpwn.com>2018-02-27 21:17:26 -0500
commitcab3771e17286788913255a6abe858b476166837 (patch)
tree85c626c779e380bb6a9d7ddd6cba69ef33cf919d /cmd
parenta073d7613fac7c79b7909d93a0dd7bfea05d5c9d (diff)
downloadaerc-cab3771e17286788913255a6abe858b476166837.tar.gz
Pull main aerc UI into widget
Diffstat (limited to 'cmd')
-rw-r--r--cmd/aerc/main.go71
1 files changed, 1 insertions, 70 deletions
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