2020-01-18 19:24:35 +00:00
|
|
|
/*
|
|
|
|
Pominal
|
2020-02-11 16:27:47 +00:00
|
|
|
Copyright (C) 2020 Daniel Anglin
|
2020-01-18 19:24:35 +00:00
|
|
|
|
|
|
|
This program is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
|
|
|
|
"github.com/rivo/tview"
|
|
|
|
)
|
|
|
|
|
|
|
|
func newInfoUI() *tview.TextView {
|
|
|
|
i := tview.NewTextView()
|
|
|
|
i.SetBorder(true)
|
|
|
|
i.SetTitle(" Pominal ")
|
|
|
|
i.SetTitleAlign(tview.AlignLeft)
|
|
|
|
|
|
|
|
return i
|
|
|
|
}
|
|
|
|
|
|
|
|
func newTimerUI(app *tview.Application) *tview.TextView {
|
|
|
|
t := tview.NewTextView().SetTextAlign(tview.AlignCenter).SetChangedFunc(func() {
|
|
|
|
app.Draw()
|
|
|
|
})
|
|
|
|
t.SetBorder(true)
|
|
|
|
|
|
|
|
return t
|
|
|
|
}
|
|
|
|
|
|
|
|
func newFlex(info, timer *tview.TextView) *tview.Flex {
|
|
|
|
f := tview.NewFlex().AddItem(info, 30, 1, false).AddItem(timer, 50, 1, false)
|
2020-01-20 20:29:45 +00:00
|
|
|
f.SetRect(0, 0, 80, 20)
|
2020-01-18 19:24:35 +00:00
|
|
|
|
|
|
|
return f
|
|
|
|
}
|
|
|
|
|
|
|
|
func drawInfo(t *tview.TextView, pominalCycle, workSessions, maxWorkSessions int, label string) {
|
|
|
|
t.Clear()
|
|
|
|
fmt.Fprintf(t, "\nPominal cycle: %d\nWork session: %d of %d\nSession: %s", pominalCycle, workSessions, maxWorkSessions, label)
|
|
|
|
}
|
|
|
|
|
|
|
|
func drawTimer(t *tview.TextView, countdown float64) {
|
|
|
|
t.Clear()
|
2020-01-24 09:51:21 +00:00
|
|
|
|
|
|
|
secondsPerMinute := 60
|
|
|
|
fmt.Fprintf(t, "\nTime remaining:\n%02d:%02d", int(countdown)/secondsPerMinute, int(countdown)%secondsPerMinute)
|
2020-01-18 19:24:35 +00:00
|
|
|
}
|