~geb/sup

a5f9132971131d7b78c592f3771a70a01d409c1d — John Gebbie 1 year, 11 months ago 8fcbc2c
less goroutines
1 files changed, 15 insertions(+), 24 deletions(-)

M main.go
M main.go => main.go +15 -24
@@ 593,34 593,25 @@ func (app *App) Run() int {

	updates := app.sync()

	// Resize with terminal
	go func() {
		var width, height int
		for range time.Tick(200 * time.Millisecond) {
			w, h := tui.TermSize(0)
			if w != width || h != height {
				updates <- func() {
					app.UI.Resize(w, h)
					app.UI.Render()
				}
				width, height = w, h
			}
		}
	}()

	// Refresh every minute
	go func() {
		for range time.Tick(time.Minute) {
			updates <- func() { app.UI.Render() }
		}
	}()

	// Mainloop
	app.roomsScreen()
	app.UI.Resize(tui.TermSize(0))
	width, height := tui.TermSize(0)
	app.UI.Resize(width, height)
	app.UI.Render()

	// Mainloop
	resize := time.Tick(200 * time.Millisecond)
	refresh := time.Tick(time.Minute)
	for {
		select {
		case <- resize:
			w, h := tui.TermSize(0)
			if w != width || h != height {
				app.UI.Resize(w, h)
				app.UI.Render()
				width, height = w, h
			}
		case <- refresh:
			app.UI.Render()
		case ev := <- inputEvents:
			if cmd, ok := app.UI.Handle(ev); ok {
				code := app.Do(cmd)