2 * Copyright (C) 2012 Andy Spencer <andy753421@gmail.com>
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
30 /* Helper functions */
31 static void print_month(month_t month, int y, int x)
33 const char *name = month_to_string(month);
34 const int start = start_of_month(YEAR, month);
35 const char days = days_in_month(YEAR, month);
36 mvwprintw(win, y, x+MW/2-strlen(name)/2, "%s", name);
38 for (int d = 0; d < 7; d++)
39 wprintw(win, "%-3s", day_to_st(d));
40 for (int d = 0; d < days; d++) {
41 int row = (start + d) / 7;
42 int col = (start + d) % 7;
43 mvwprintw(win, y+2+row, x+col*3, "%2d", d+1);
48 void year_init(WINDOW *_win)
61 /* Determine heights */
62 for (int m = 0; m < 12; m++) {
63 int weeks = weeks_in_month(YEAR, m);
64 h[m/3] = MAX(h[m/3], weeks+2);
66 int sum = h[0]+h[1]+h[2]+h[3];
69 mvwprintw(win, y++, COLS/2-2, "%d", YEAR);
72 for (int m = 0; m < 12; m++) {
84 mvwvline(win, y, x+(MW+3)*1-2, ACS_VLINE, sum+3);
85 mvwvline(win, y, x+(MW+3)*2-2, ACS_VLINE, sum+3);
86 for (int i = 0; i < 3; i++) {
88 mvwhline(win, y, x, ACS_HLINE, w);
89 mvwaddch(win, y, x+(MW+3)*1-2, ACS_PLUS);
90 mvwaddch(win, y, x+(MW+3)*2-2, ACS_PLUS);
96 int year_run(int key, mmask_t btn, int row, int col)