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/>.
28 void week_init(WINDOW *_win)
38 const float hstep = (float)(COLS-x)/5.0;
40 /* Get start of week */
42 month_t month = MONTH;
44 int shift = day_of_week(year, month, day);
45 add_days(&year, &month, &day, -shift+MON);
48 mvwprintw(win, 1, 0, "%s", month_to_str(MONTH));
49 for (int d = 0; d < 5; d++) {
51 const char *str = hstep >= 10 ? day_to_string(d+MON) : day_to_str(d+MON);
52 mvwprintw(win, 0, x+ROUND(d*hstep), "%02d/%02d", month+1, day+1);
53 mvwprintw(win, 1, x+ROUND(d*hstep), "%s", str);
54 add_days(&year, &month, &day, 1);
59 for (int h = 0; h < (LINES-6)/4+1; h++)
60 mvwprintw(win, 3+h*4, 0,"%02d:%02d", (start+h)%12, 0);
63 mvwhline(win, y-1, 0, ACS_HLINE, COLS);
64 for (int d = 0; d < 5; d++)
65 mvwvline(win, y, x+ROUND(d*hstep)-1, ACS_VLINE, LINES-y-2);
69 int week_run(int key, mmask_t btn, int row, int col)