From 4d0c095947ed30d4f32e6db27eddbc4719fbcf9b Mon Sep 17 00:00:00 2001 From: Lukas Fleischer Date: Sun, 25 Nov 2012 10:47:47 +0100 Subject: Add compact panels support Add a configuration option that allows for switching to compact panel mode. In this mode, all window labels are hidden, so that there's more space for actual information. This patch doesn't add a configuration menu entry and doesn't add any documentation. Implements FR#7. Signed-off-by: Lukas Fleischer --- src/apoint.c | 2 +- src/calcurse.h | 3 ++- src/calendar.c | 13 ++++++++----- src/config.c | 1 + src/todo.c | 4 ++-- src/vars.c | 1 + src/wins.c | 16 ++++++++++------ 7 files changed, 25 insertions(+), 15 deletions(-) diff --git a/src/apoint.c b/src/apoint.c index a756fac..9b9257f 100644 --- a/src/apoint.c +++ b/src/apoint.c @@ -332,7 +332,7 @@ void apoint_update_panel(int which_pan) { int title_xpos; int bordr = 1; - int title_lines = 3; + int title_lines = conf.compact_panels ? 1 : 3; int app_width = win[APP].w - bordr; int app_length = win[APP].h - bordr - title_lines; long date; diff --git a/src/calcurse.h b/src/calcurse.h index 310b28d..041b865 100644 --- a/src/calcurse.h +++ b/src/calcurse.h @@ -147,7 +147,7 @@ #define MAXDAYSPERMONTH 31 /* Calendar window. */ -#define CALHEIGHT 12 +#define CALHEIGHT 8 /* Key definitions. */ #define CTRLVAL 0x1F @@ -250,6 +250,7 @@ struct conf { unsigned confirm_quit; unsigned confirm_delete; enum win default_panel; + unsigned compact_panels; unsigned system_dialogs; unsigned progress_bar; const char *editor; diff --git a/src/calendar.c b/src/calendar.c index 3d7698e..0eebd4e 100644 --- a/src/calendar.c +++ b/src/calendar.c @@ -278,7 +278,7 @@ static void draw_monthly_view(struct window *cwin, struct date *current_day, unsigned sunday_first) { - const int OFFY = 2 + (CALHEIGHT - 9) / 2; + const int OFFY = CALHEIGHT / 2 - (conf.compact_panels ? 3 : 1); struct date check_day; int c_day, c_day_1, day_1_sav, numdays, j; unsigned yr, mo; @@ -460,7 +460,7 @@ draw_weekly_view(struct window *cwin, struct date *current_day, { #define DAYSLICESNO 6 const int WCALWIDTH = 30; - const int OFFY = 2 + (CALHEIGHT - 9) / 2; + const int OFFY = CALHEIGHT / 2 - (conf.compact_panels ? 3 : 1); struct tm t; int OFFX, j, c_wday, days_to_remove, weeknum; @@ -484,7 +484,8 @@ draw_weekly_view(struct window *cwin, struct date *current_day, weeknum = ISO8601weeknum(&t); WINS_CALENDAR_LOCK; custom_apply_attr(cwin->p, ATTR_HIGHEST); - mvwprintw(cwin->p, 2, cwin->w - 9, "(# %02d)", weeknum); + mvwprintw(cwin->p, conf.compact_panels ? 0 : 2, cwin->w - 9, "(# %02d)", + weeknum); custom_remove_attr(cwin->p, ATTR_HIGHEST); WINS_CALENDAR_UNLOCK; @@ -578,8 +579,10 @@ void calendar_update_panel(struct window *cwin) calendar_store_current_date(¤t_day); WINS_CALENDAR_LOCK; - erase_window_part(cwin->p, 1, 3, cwin->w - 2, cwin->h - 2); - mvwhline(cwin->p, 2, 1, ACS_HLINE, cwin->w - 2); + erase_window_part(cwin->p, 1, conf.compact_panels ? 1 : 3, cwin->w - 2, + cwin->h - 2); + if (!conf.compact_panels) + mvwhline(cwin->p, 2, 1, ACS_HLINE, cwin->w - 2); WINS_CALENDAR_UNLOCK; sunday_first = calendar_week_begins_on_monday()? 0 : 1; diff --git a/src/config.c b/src/config.c index c601336..da562b2 100644 --- a/src/config.c +++ b/src/config.c @@ -86,6 +86,7 @@ static int config_serialize_input_datefmt(char *, void *); static const struct confvar confmap[] = { {"appearance.calendarview", config_parse_calendar_view, config_serialize_calendar_view, NULL}, + {"appearance.compactpanels", CONFIG_HANDLER_BOOL(conf.compact_panels)}, {"appearance.defaultpanel", config_parse_default_panel, config_serialize_default_panel, NULL}, {"appearance.layout", config_parse_layout, config_serialize_layout, NULL}, diff --git a/src/todo.c b/src/todo.c index e918905..2a207e2 100644 --- a/src/todo.c +++ b/src/todo.c @@ -275,9 +275,9 @@ void todo_update_panel(int which_pan) llist_item_t *i; int len = win[TOD].w - 8; int num_todo = 0; - int y_offset = 3, x_offset = 1; + int title_lines = conf.compact_panels ? 1 : 3; + int y_offset = title_lines, x_offset = 1; int t_realpos = -1; - int title_lines = 3; int todo_lines = 1; int max_items = win[TOD].h - 4; int incolor = -1; diff --git a/src/vars.c b/src/vars.c index 9192c5c..ac6654c 100644 --- a/src/vars.c +++ b/src/vars.c @@ -135,6 +135,7 @@ void vars_init(void) conf.auto_gc = 0; conf.periodic_save = 0; conf.default_panel = CAL; + conf.compact_panels = 0; conf.system_dialogs = 1; conf.progress_bar = 1; strncpy(conf.output_datefmt, "%D", 3); diff --git a/src/wins.c b/src/wins.c index 45da1d3..3e94aba 100644 --- a/src/wins.c +++ b/src/wins.c @@ -239,7 +239,8 @@ void wins_slctd_next(void) static void wins_init_panels(void) { - win[CAL].p = newwin(CALHEIGHT, wins_sbar_width(), win[CAL].y, win[CAL].x); + win[CAL].p = newwin(CALHEIGHT + (conf.compact_panels ? 2 : 4), + wins_sbar_width(), win[CAL].y, win[CAL].x); wins_show(win[CAL].p, _("Calendar")); win[APP].p = newwin(win[APP].h, win[APP].w, win[APP].y, win[APP].x); @@ -356,11 +357,14 @@ void wins_show(WINDOW * win, const char *label) int width = getmaxx(win); box(win, 0, 0); - mvwaddch(win, 2, 0, ACS_LTEE); - mvwhline(win, 2, 1, ACS_HLINE, width - 2); - mvwaddch(win, 2, width - 1, ACS_RTEE); - print_in_middle(win, 1, 0, width, label); + if (!conf.compact_panels) { + mvwaddch(win, 2, 0, ACS_LTEE); + mvwhline(win, 2, 1, ACS_HLINE, width - 2); + mvwaddch(win, 2, width - 1, ACS_RTEE); + + print_in_middle(win, 1, 0, width, label); + } } /* @@ -390,7 +394,7 @@ void wins_get_config(void) } win[CAL].w = wins_sbar_width(); - win[CAL].h = CALHEIGHT; + win[CAL].h = CALHEIGHT + (conf.compact_panels ? 2 : 4); if (layout <= 4) { /* APPOINTMENT is the biggest panel */ win[APP].w = col - win[CAL].w; -- cgit v1.2.3