Compare commits

..

2 commits

Author SHA1 Message Date
Petar Kapriš da53b8c6b6 Move style definitions from Main.go to drw.go 2022-03-04 17:08:30 +01:00
Petar Kapriš 56fa219d2d Edit wall-movement functions in drw for clarity 2022-03-04 16:36:25 +01:00
3 changed files with 16 additions and 10 deletions

View file

@ -22,9 +22,6 @@ func main() {
if err := drw.Wall.Init(); err != nil {
log.Fatalf("%+v", err)
}
drw.DefStyle = tcell.StyleDefault.Background(tcell.ColorReset).Foreground(tcell.ColorReset)
drw.TodayStyle = tcell.StyleDefault.Background(tcell.ColorReset).Foreground(tcell.GetColor("blue")).Bold(true).Reverse(true)
drw.SelStyle = tcell.StyleDefault.Background(tcell.ColorReset).Foreground(tcell.GetColor("green")).Bold(true)
drw.Wall.SetStyle(drw.DefStyle)
drw.Wall.Clear()

View file

@ -15,9 +15,18 @@ var (
)
var (
DefStyle tcell.Style
TodayStyle tcell.Style
SelStyle tcell.Style
DefStyle tcell.Style = tcell.StyleDefault.
Background(tcell.ColorReset).
Foreground(tcell.ColorReset)
TodayStyle tcell.Style = tcell.StyleDefault.
Background(tcell.ColorReset).
Foreground(tcell.GetColor("blue")).
Bold(true).
Reverse(true)
SelStyle tcell.Style = tcell.StyleDefault.
Background(tcell.ColorReset).
Foreground(tcell.GetColor("green")).
Bold(true)
)
func centeredText(s string, x, y, width int, scr tcell.Screen, style tcell.Style) {

View file

@ -44,8 +44,8 @@ func monthHeight(m time.Month) int {
func bottomOfMonth(m time.Month, w time.Weekday) (time time.Time) {
last := lastDay(m)
day := last.Day()
day := last.Day()
if w > last.Weekday() {
day -= 7
}
@ -102,7 +102,7 @@ func MoveUp() {
newTime := util.SelTime.AddDate(0, 0, -7)
if newTime.Month() == util.SelTime.Month() {
util.SelTime = newTime
} else if int(util.SelTime.Month()) > monthsWide {
} else if int(util.SelTime.Month())-monthsWide >= 1 {
newMonth := util.SelTime.Month() - time.Month(monthsWide)
util.SelTime = bottomOfMonth(newMonth, weekday)
}
@ -113,7 +113,7 @@ func MoveDown() {
newTime := util.SelTime.AddDate(0, 0, +7)
if newTime.Month() == util.SelTime.Month() {
util.SelTime = newTime
} else if int(util.SelTime.Month()) <= (12-1)/monthsWide*monthsWide {
} else if int(util.SelTime.Month())+monthsWide <= 12 {
newMonth := util.SelTime.Month() + time.Month(monthsWide)
util.SelTime = topOfMonth(newMonth, weekday)
}
@ -122,7 +122,7 @@ func MoveDown() {
func MoveRight() {
if util.SelTime.Weekday() != time.Sunday && util.SelTime.Day() != lastDay(util.SelTime.Month()).Day() {
util.SelTime = util.SelTime.AddDate(0, 0, 1)
} else if int(util.SelTime.Month())%monthsWide != 0 && int(util.SelTime.Month()) != 12 {
} else if int(util.SelTime.Month())%monthsWide != 0 && util.SelTime.Month() != time.December {
util.SelTime = leftmostInRow(util.SelTime.Month()+1, rowInMonth(util.SelTime.Month(), util.SelTime.Day()))
}
}