* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+#include <string.h>
#include <ncurses.h>
+#include "util.h"
+#include "conf.h"
+#include "date.h"
+#include "cal.h"
+#include "view.h"
+
+/* Constant data */
+#define PAD " "
+
/* Static data */
static WINDOW *win;
+/* Helper functions */
+static void heading(WINDOW *win, char *label)
+{
+ wattron(win, A_BOLD);
+ wprintw(win, "%s", label);
+ wattroff(win, A_BOLD);
+}
+
+static void checkbox(WINDOW *win, char *label, int *value)
+{
+ wprintw(win, PAD "[%c] %s", *value?'x':' ', label);
+}
+
/* Settings init */
void settings_init(WINDOW *_win)
{
/* Settings draw */
void settings_draw(void)
{
- mvwprintw(win, 0, 1, "%s\n", "settings");
+ int wtype = 0, wname = 0;
+
+ /* Figure out cal widths */
+ for (cal_t *cal = CALS; cal; cal = cal->next) {
+ if (strlen(cal->type) > wtype)
+ wtype = strlen(cal->type);
+ if (strlen(cal->name) > wname)
+ wname = strlen(cal->name);
+ }
+
+ heading(win, "Current Settings\n");
+ checkbox(win, "Compact layout\n", &COMPACT);
+
+ heading(win, "\nLoaded Calendars\n");
+ for (cal_t *cal = CALS; cal; cal = cal->next)
+ wprintw(win, PAD "%s:%*s \"%s\"%*s - %s\n",
+ cal->type, wtype-strlen(cal->type), "",
+ cal->name, wname-strlen(cal->name), "",
+ cal->desc ?: "(no description)");
}
/* Settings run */