summaryrefslogtreecommitdiff
path: root/src/custom.c
diff options
context:
space:
mode:
authorLukas Fleischer <calcurse@cryptocrack.de>2011-03-14 19:00:08 +0100
committerLukas Fleischer <calcurse@cryptocrack.de>2011-03-14 19:03:53 +0100
commit9c9fd5da15573a702efe5adc054c96a9eb8aa0ce (patch)
tree47b14650b9dc34e032a9e744651b1b921365d206 /src/custom.c
parent55262a30743095ad4dbc14dc06f4487be11f9bd8 (diff)
downloadcalcurse-9c9fd5da15573a702efe5adc054c96a9eb8aa0ce.zip
Overall indentation fixes.
Use spaces instead of tabs for source code indentation only, strip trailing whitespaces from lines. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
Diffstat (limited to 'src/custom.c')
-rw-r--r--src/custom.c794
1 files changed, 397 insertions, 397 deletions
diff --git a/src/custom.c b/src/custom.c
index 667e05d..29a6261 100644
--- a/src/custom.c
+++ b/src/custom.c
@@ -87,8 +87,8 @@ fill_config_var (char *string)
}
}
-/*
- * Load user color theme from file.
+/*
+ * Load user color theme from file.
* Need to handle calcurse versions prior to 1.8, where colors where handled
* differently (number between 1 and 8).
*/
@@ -106,37 +106,37 @@ custom_load_color (char *color, int background)
{
/* New version configuration */
if (sscanf (color, "%s on %s", c[0], c[1]) != AWAITED_COLORS)
- {
+ {
EXIT (_("missing colors in config file"));
- /* NOTREACHED */
- }
+ /* NOTREACHED */
+ }
for (i = 0; i < AWAITED_COLORS; i++)
- {
- if (!strncmp (c[i], "black", 5))
- colr[i] = COLOR_BLACK;
- else if (!strncmp (c[i], "red", 3))
- colr[i] = COLOR_RED;
- else if (!strncmp (c[i], "green", 5))
- colr[i] = COLOR_GREEN;
- else if (!strncmp (c[i], "yellow", 6))
- colr[i] = COLOR_YELLOW;
- else if (!strncmp (c[i], "blue", 4))
- colr[i] = COLOR_BLUE;
- else if (!strncmp (c[i], "magenta", 7))
- colr[i] = COLOR_MAGENTA;
- else if (!strncmp (c[i], "cyan", 4))
- colr[i] = COLOR_CYAN;
- else if (!strncmp (c[i], "white", 5))
- colr[i] = COLOR_WHITE;
- else if (!strncmp (c[i], "default", 7))
- colr[i] = background;
- else
- {
+ {
+ if (!strncmp (c[i], "black", 5))
+ colr[i] = COLOR_BLACK;
+ else if (!strncmp (c[i], "red", 3))
+ colr[i] = COLOR_RED;
+ else if (!strncmp (c[i], "green", 5))
+ colr[i] = COLOR_GREEN;
+ else if (!strncmp (c[i], "yellow", 6))
+ colr[i] = COLOR_YELLOW;
+ else if (!strncmp (c[i], "blue", 4))
+ colr[i] = COLOR_BLUE;
+ else if (!strncmp (c[i], "magenta", 7))
+ colr[i] = COLOR_MAGENTA;
+ else if (!strncmp (c[i], "cyan", 4))
+ colr[i] = COLOR_CYAN;
+ else if (!strncmp (c[i], "white", 5))
+ colr[i] = COLOR_WHITE;
+ else if (!strncmp (c[i], "default", 7))
+ colr[i] = background;
+ else
+ {
EXIT (_("wrong color name"));
- /* NOTREACHED */
- }
- }
+ /* NOTREACHED */
+ }
+ }
init_pair (COLR_CUSTOM, colr[0], colr[1]);
}
else if (len > 0 && len < 2)
@@ -145,38 +145,38 @@ custom_load_color (char *color, int background)
color_num = atoi (color);
switch (color_num)
- {
- case 0:
- colorize = 0;
- break;
- case 1:
- init_pair (COLR_CUSTOM, COLOR_RED, background);
- break;
- case 2:
- init_pair (COLR_CUSTOM, COLOR_GREEN, background);
- break;
- case 3:
- init_pair (COLR_CUSTOM, COLOR_BLUE, background);
- break;
- case 4:
- init_pair (COLR_CUSTOM, COLOR_CYAN, background);
- break;
- case 5:
- init_pair (COLR_CUSTOM, COLOR_YELLOW, background);
- break;
- case 6:
- init_pair (COLR_CUSTOM, COLOR_BLACK, COLR_GREEN);
- break;
- case 7:
- init_pair (COLR_CUSTOM, COLOR_BLACK, COLR_YELLOW);
- break;
- case 8:
- init_pair (COLR_CUSTOM, COLOR_RED, COLR_BLUE);
- break;
- default:
+ {
+ case 0:
+ colorize = 0;
+ break;
+ case 1:
+ init_pair (COLR_CUSTOM, COLOR_RED, background);
+ break;
+ case 2:
+ init_pair (COLR_CUSTOM, COLOR_GREEN, background);
+ break;
+ case 3:
+ init_pair (COLR_CUSTOM, COLOR_BLUE, background);
+ break;
+ case 4:
+ init_pair (COLR_CUSTOM, COLOR_CYAN, background);
+ break;
+ case 5:
+ init_pair (COLR_CUSTOM, COLOR_YELLOW, background);
+ break;
+ case 6:
+ init_pair (COLR_CUSTOM, COLOR_BLACK, COLR_GREEN);
+ break;
+ case 7:
+ init_pair (COLR_CUSTOM, COLOR_BLACK, COLR_YELLOW);
+ break;
+ case 8:
+ init_pair (COLR_CUSTOM, COLOR_RED, COLR_BLUE);
+ break;
+ default:
EXIT (_("wrong color number"));
- /* NOTREACHED */
- }
+ /* NOTREACHED */
+ }
}
else
{
@@ -185,7 +185,7 @@ custom_load_color (char *color, int background)
}
}
-/*
+/*
* Define window attributes (for both color and non-color terminals):
* ATTR_HIGHEST are for window titles
* ATTR_HIGH are for month and days names
@@ -256,144 +256,144 @@ custom_load_conf (struct conf *conf, int background)
for (;;)
{
if (fgets (buf, sizeof buf, data_file) == NULL)
- {
- break;
- }
+ {
+ break;
+ }
io_extract_data (e_conf, buf, sizeof buf);
switch (var)
- {
- case CUSTOM_CONF_NOVARIABLE:
- break;
- case CUSTOM_CONF_AUTOSAVE:
- conf->auto_save = fill_config_var (e_conf);
- var = 0;
- break;
- case CUSTOM_CONF_PERIODICSAVE:
- conf->periodic_save = atoi (e_conf);
- if (conf->periodic_save < 0)
- conf->periodic_save = 0;
- var = 0;
- break;
- case CUSTOM_CONF_CONFIRMQUIT:
- conf->confirm_quit = fill_config_var (e_conf);
- var = 0;
- break;
- case CUSTOM_CONF_CONFIRMDELETE:
- conf->confirm_delete = fill_config_var (e_conf);
- var = 0;
- break;
- case CUSTOM_CONF_SKIPSYSTEMDIALOGS:
- conf->skip_system_dialogs = fill_config_var (e_conf);
- var = 0;
- break;
- case CUSTOM_CONF_SKIPPROGRESSBAR:
- conf->skip_progress_bar = fill_config_var (e_conf);
- var = 0;
- break;
+ {
+ case CUSTOM_CONF_NOVARIABLE:
+ break;
+ case CUSTOM_CONF_AUTOSAVE:
+ conf->auto_save = fill_config_var (e_conf);
+ var = 0;
+ break;
+ case CUSTOM_CONF_PERIODICSAVE:
+ conf->periodic_save = atoi (e_conf);
+ if (conf->periodic_save < 0)
+ conf->periodic_save = 0;
+ var = 0;
+ break;
+ case CUSTOM_CONF_CONFIRMQUIT:
+ conf->confirm_quit = fill_config_var (e_conf);
+ var = 0;
+ break;
+ case CUSTOM_CONF_CONFIRMDELETE:
+ conf->confirm_delete = fill_config_var (e_conf);
+ var = 0;
+ break;
+ case CUSTOM_CONF_SKIPSYSTEMDIALOGS:
+ conf->skip_system_dialogs = fill_config_var (e_conf);
+ var = 0;
+ break;
+ case CUSTOM_CONF_SKIPPROGRESSBAR:
+ conf->skip_progress_bar = fill_config_var (e_conf);
+ var = 0;
+ break;
case CUSTOM_CONF_CALENDAR_DEFAULTVIEW:
calendar_set_view (atoi (e_conf));
var = 0;
break;
- case CUSTOM_CONF_WEEKBEGINSONMONDAY:
- if (fill_config_var (e_conf))
- calendar_set_first_day_of_week (MONDAY);
- else
- calendar_set_first_day_of_week (SUNDAY);
- var = 0;
- break;
- case CUSTOM_CONF_COLORTHEME:
- custom_load_color (e_conf, background);
- var = 0;
- break;
- case CUSTOM_CONF_LAYOUT:
- wins_set_layout (atoi (e_conf));
- var = 0;
- break;
+ case CUSTOM_CONF_WEEKBEGINSONMONDAY:
+ if (fill_config_var (e_conf))
+ calendar_set_first_day_of_week (MONDAY);
+ else
+ calendar_set_first_day_of_week (SUNDAY);
+ var = 0;
+ break;
+ case CUSTOM_CONF_COLORTHEME:
+ custom_load_color (e_conf, background);
+ var = 0;
+ break;
+ case CUSTOM_CONF_LAYOUT:
+ wins_set_layout (atoi (e_conf));
+ var = 0;
+ break;
case CUSTOM_CONF_SBAR_WIDTH:
wins_set_sbar_width (atoi (e_conf));
var = 0;
break;
- case CUSTOM_CONF_NOTIFYBARSHOW:
- nbar.show = fill_config_var (e_conf);
- var = 0;
- break;
- case CUSTOM_CONF_NOTIFYBARDATE:
- (void)strncpy (nbar.datefmt, e_conf, strlen (e_conf) + 1);
- var = 0;
- break;
- case CUSTOM_CONF_NOTIFYBARCLOCK:
- (void)strncpy (nbar.timefmt, e_conf, strlen (e_conf) + 1);
- var = 0;
- break;
- case CUSTOM_CONF_NOTIFYBARWARNING:
- nbar.cntdwn = atoi (e_conf);
- var = 0;
- break;
- case CUSTOM_CONF_NOTIFYBARCOMMAND:
- (void)strncpy (nbar.cmd, e_conf, strlen (e_conf) + 1);
- var = 0;
- break;
- case CUSTOM_CONF_OUTPUTDATEFMT:
- if (e_conf[0] != '\0')
- (void)strncpy (conf->output_datefmt, e_conf, strlen (e_conf) + 1);
- var = 0;
- break;
- case CUSTOM_CONF_INPUTDATEFMT:
- conf->input_datefmt = atoi (e_conf);
- if (conf->input_datefmt <= 0 || conf->input_datefmt >= DATE_FORMATS)
- conf->input_datefmt = 1;
- var = 0;
- break;
- case CUSTOM_CONF_DMON_ENABLE:
- dmon.enable = fill_config_var (e_conf);
- var = 0;
- break;
- case CUSTOM_CONF_DMON_LOG:
- dmon.log = fill_config_var (e_conf);
- var = 0;
- break;
- default:
+ case CUSTOM_CONF_NOTIFYBARSHOW:
+ nbar.show = fill_config_var (e_conf);
+ var = 0;
+ break;
+ case CUSTOM_CONF_NOTIFYBARDATE:
+ (void)strncpy (nbar.datefmt, e_conf, strlen (e_conf) + 1);
+ var = 0;
+ break;
+ case CUSTOM_CONF_NOTIFYBARCLOCK:
+ (void)strncpy (nbar.timefmt, e_conf, strlen (e_conf) + 1);
+ var = 0;
+ break;
+ case CUSTOM_CONF_NOTIFYBARWARNING:
+ nbar.cntdwn = atoi (e_conf);
+ var = 0;
+ break;
+ case CUSTOM_CONF_NOTIFYBARCOMMAND:
+ (void)strncpy (nbar.cmd, e_conf, strlen (e_conf) + 1);
+ var = 0;
+ break;
+ case CUSTOM_CONF_OUTPUTDATEFMT:
+ if (e_conf[0] != '\0')
+ (void)strncpy (conf->output_datefmt, e_conf, strlen (e_conf) + 1);
+ var = 0;
+ break;
+ case CUSTOM_CONF_INPUTDATEFMT:
+ conf->input_datefmt = atoi (e_conf);
+ if (conf->input_datefmt <= 0 || conf->input_datefmt >= DATE_FORMATS)
+ conf->input_datefmt = 1;
+ var = 0;
+ break;
+ case CUSTOM_CONF_DMON_ENABLE:
+ dmon.enable = fill_config_var (e_conf);
+ var = 0;
+ break;
+ case CUSTOM_CONF_DMON_LOG:
+ dmon.log = fill_config_var (e_conf);
+ var = 0;
+ break;
+ default:
EXIT (_("configuration variable unknown"));
- /* NOTREACHED */
- }
+ /* NOTREACHED */
+ }
if (strncmp (e_conf, "auto_save=", 10) == 0)
- var = CUSTOM_CONF_AUTOSAVE;
+ var = CUSTOM_CONF_AUTOSAVE;
else if (strncmp (e_conf, "periodic_save=", 14) == 0)
var = CUSTOM_CONF_PERIODICSAVE;
else if (strncmp (e_conf, "confirm_quit=", 13) == 0)
- var = CUSTOM_CONF_CONFIRMQUIT;
+ var = CUSTOM_CONF_CONFIRMQUIT;
else if (strncmp (e_conf, "confirm_delete=", 15) == 0)
- var = CUSTOM_CONF_CONFIRMDELETE;
+ var = CUSTOM_CONF_CONFIRMDELETE;
else if (strncmp (e_conf, "skip_system_dialogs=", 20) == 0)
- var = CUSTOM_CONF_SKIPSYSTEMDIALOGS;
+ var = CUSTOM_CONF_SKIPSYSTEMDIALOGS;
else if (strncmp (e_conf, "skip_progress_bar=", 18) == 0)
- var = CUSTOM_CONF_SKIPPROGRESSBAR;
+ var = CUSTOM_CONF_SKIPPROGRESSBAR;
else if (strncmp (e_conf, "calendar_default_view=", 22) == 0)
var = CUSTOM_CONF_CALENDAR_DEFAULTVIEW;
else if (strncmp (e_conf, "week_begins_on_monday=", 22) == 0)
- var = CUSTOM_CONF_WEEKBEGINSONMONDAY;
+ var = CUSTOM_CONF_WEEKBEGINSONMONDAY;
else if (strncmp (e_conf, "color-theme=", 12) == 0)
- var = CUSTOM_CONF_COLORTHEME;
+ var = CUSTOM_CONF_COLORTHEME;
else if (strncmp (e_conf, "layout=", 7) == 0)
- var = CUSTOM_CONF_LAYOUT;
+ var = CUSTOM_CONF_LAYOUT;
else if (strncmp (e_conf, "side-bar_width=", 15) == 0)
var = CUSTOM_CONF_SBAR_WIDTH;
else if (strncmp (e_conf, "notify-bar_show=", 16) == 0)
- var = CUSTOM_CONF_NOTIFYBARSHOW;
+ var = CUSTOM_CONF_NOTIFYBARSHOW;
else if (strncmp (e_conf, "notify-bar_date=", 16) == 0)
- var = CUSTOM_CONF_NOTIFYBARDATE;
+ var = CUSTOM_CONF_NOTIFYBARDATE;
else if (strncmp (e_conf, "notify-bar_clock=", 17) == 0)
- var = CUSTOM_CONF_NOTIFYBARCLOCK;
+ var = CUSTOM_CONF_NOTIFYBARCLOCK;
else if (strncmp (e_conf, "notify-bar_warning=", 19) == 0)
- var = CUSTOM_CONF_NOTIFYBARWARNING;
+ var = CUSTOM_CONF_NOTIFYBARWARNING;
else if (strncmp (e_conf, "notify-bar_command=", 19) == 0)
- var = CUSTOM_CONF_NOTIFYBARCOMMAND;
+ var = CUSTOM_CONF_NOTIFYBARCOMMAND;
else if (strncmp (e_conf, "output_datefmt=", 15) == 0)
- var = CUSTOM_CONF_OUTPUTDATEFMT;
+ var = CUSTOM_CONF_OUTPUTDATEFMT;
else if (strncmp (e_conf, "input_datefmt=", 14) == 0)
- var = CUSTOM_CONF_INPUTDATEFMT;
+ var = CUSTOM_CONF_INPUTDATEFMT;
else if (strncmp (e_conf, "notify-daemon_enable=", 21) == 0)
var = CUSTOM_CONF_DMON_ENABLE;
else if (strncmp (e_conf, "notify-daemon_log=", 18) == 0)
@@ -417,17 +417,17 @@ custom_config_bar (void)
mvwprintw (win[STA].p, 1, 2 + SPC, "S");
mvwprintw (win[STA].p, 0, 2 + 2 * SPC, "C");
mvwprintw (win[STA].p, 1, 2 + 2 * SPC, "N");
- mvwprintw (win[STA].p, 0, 2 + 3 * SPC, "K");
+ mvwprintw (win[STA].p, 0, 2 + 3 * SPC, "K");
custom_remove_attr (win[STA].p, ATTR_HIGHEST);
mvwprintw (win[STA].p, 0, 2 + SMLSPC, _("Exit"));
mvwprintw (win[STA].p, 1, 2 + SMLSPC, _("General"));
mvwprintw (win[STA].p, 0, 2 + SPC + SMLSPC, _("Layout"));
mvwprintw (win[STA].p, 1, 2 + SPC + SMLSPC, _("Sidebar"));
- mvwprintw (win[STA].p, 0, 2 + 2 * SPC + SMLSPC, _("Color"));
+ mvwprintw (win[STA].p, 0, 2 + 2 * SPC + SMLSPC, _("Color"));
mvwprintw (win[STA].p, 1, 2 + 2 * SPC + SMLSPC, _("Notify"));
mvwprintw (win[STA].p, 0, 2 + 3 * SPC + SMLSPC, _("Keys"));
-
+
wnoutrefresh (win[STA].p);
wmove (win[STA].p, 0, 0);
wins_doupdate ();
@@ -443,7 +443,7 @@ layout_selection_bar (void)
struct binding left = {_("Left"), KEY_MOVE_LEFT};
struct binding right = {_("Right"), KEY_MOVE_RIGHT};
struct binding help = {_("Help"), KEY_GENERIC_HELP};
-
+
struct binding *binding[] = {&quit, &select, &up, &down, &left, &right, &help};
int binding_size = sizeof (binding) / sizeof (binding[0]);
@@ -463,13 +463,13 @@ display_layout_config (struct window *lwin, int mark, int cursor,
#define LAYOUTH 5
#define LAYOUTW 9
char *box = "[ ]";
- const int BOXSIZ = strlen (box);
+ const int BOXSIZ = strlen (box);
const int NBCOLS = NBLAYOUTS / LAYOUTSPERCOL;
const int COLSIZ = LAYOUTW + BOXSIZ + 1;
const int XSPC = (col - NBCOLS * COLSIZ) / (NBCOLS + 1);
const int XOFST = (col - NBCOLS * (XSPC + COLSIZ)) / 2;
const int YSPC = (row - 8 - LAYOUTSPERCOL * LAYOUTH) / (LAYOUTSPERCOL + 1);
- const int YOFST = (row - LAYOUTSPERCOL * (YSPC + LAYOUTH)) / 2;
+ const int YOFST = (row - LAYOUTSPERCOL * (YSPC + LAYOUTH)) / 2;
enum {YPOS, XPOS, NBPOS};
int pos[NBLAYOUTS][NBPOS];
char *layouts[LAYOUTH][NBLAYOUTS] = {
@@ -490,7 +490,7 @@ display_layout_config (struct window *lwin, int mark, int cursor,
if (need_reset)
{
char label[BUFSIZ];
-
+
(void)snprintf (label, BUFSIZ, _("layout configuration"));
custom_confwin_init (lwin, label);
}
@@ -498,7 +498,7 @@ display_layout_config (struct window *lwin, int mark, int cursor,
for (i = 0; i < NBLAYOUTS; i++)
{
int j;
-
+
mvwprintw (lwin->p, pos[i][YPOS] + 2, pos[i][XPOS], box);
if (i == mark)
custom_apply_attr (lwin->p, ATTR_HIGHEST);
@@ -512,7 +512,7 @@ display_layout_config (struct window *lwin, int mark, int cursor,
}
mvwaddch (lwin->p, pos[mark][YPOS] + 2, pos[mark][XPOS] + 1, MARK);
mvwaddch (lwin->p, pos[cursor][YPOS] + 2, pos[cursor][XPOS] + 1, CURSOR);
-
+
layout_selection_bar ();
wnoutrefresh (win[STA].p);
wnoutrefresh (lwin->p);
@@ -533,13 +533,13 @@ custom_layout_config (void)
"displayed inside calcurse screen. \n"
"It is possible to choose between eight different configurations.\n"
"\nIn the configuration representations, letters correspond to:\n\n"
- " 'c' -> calendar panel\n\n"
+ " 'c' -> calendar panel\n\n"
" 'a' -> appointment panel\n\n"
" 't' -> todo panel\n\n");
-
- need_reset = 1;
+
+ need_reset = 1;
conf_win.p = (WINDOW *)0;
- cursor = mark = wins_layout () - 1;
+ cursor = mark = wins_layout () - 1;
clear ();
display_layout_config (&conf_win, mark, cursor, need_reset);
@@ -547,13 +547,13 @@ custom_layout_config (void)
{
need_reset = 0;
switch (ch)
- {
- case KEY_RESIZE:
- endwin ();
- wins_refresh ();
- curs_set (0);
- need_reset = 1;
- break;
+ {
+ case KEY_RESIZE:
+ endwin ();
+ wins_refresh ();
+ curs_set (0);
+ need_reset = 1;
+ break;
case KEY_GENERIC_HELP:
help_wins_init (&hwin, 0, 0,
(notify_bar ()) ? row - 3 : row - 2, col);
@@ -564,29 +564,29 @@ custom_layout_config (void)
wins_scrollwin_delete (&hwin);
need_reset = 1;
break;
- case KEY_GENERIC_SELECT:
+ case KEY_GENERIC_SELECT:
mark = cursor;
- break;
- case KEY_MOVE_DOWN:
- if (cursor % LAYOUTSPERCOL < LAYOUTSPERCOL - 1)
- cursor++;
- break;
- case KEY_MOVE_UP:
- if (cursor % LAYOUTSPERCOL > 0)
- cursor--;
- break;
- case KEY_MOVE_LEFT:
- if (cursor >= LAYOUTSPERCOL)
- cursor -= LAYOUTSPERCOL;
- break;
- case KEY_MOVE_RIGHT:
- if (cursor < NBLAYOUTS - LAYOUTSPERCOL)
- cursor += LAYOUTSPERCOL;
- break;
- case KEY_GENERIC_CANCEL:
- need_reset = 1;
- break;
- }
+ break;
+ case KEY_MOVE_DOWN:
+ if (cursor % LAYOUTSPERCOL < LAYOUTSPERCOL - 1)
+ cursor++;
+ break;
+ case KEY_MOVE_UP:
+ if (cursor % LAYOUTSPERCOL > 0)
+ cursor--;
+ break;
+ case KEY_MOVE_LEFT:
+ if (cursor >= LAYOUTSPERCOL)
+ cursor -= LAYOUTSPERCOL;
+ break;
+ case KEY_MOVE_RIGHT:
+ if (cursor < NBLAYOUTS - LAYOUTSPERCOL)
+ cursor += LAYOUTSPERCOL;
+ break;
+ case KEY_GENERIC_CANCEL:
+ need_reset = 1;
+ break;
+ }
display_layout_config (&conf_win, mark, cursor, need_reset);
}
wins_set_layout (mark + 1);
@@ -602,7 +602,7 @@ custom_sidebar_config (void)
{
struct scrollwin hwin;
struct binding quit = {_("Exit"), KEY_GENERIC_QUIT};
- struct binding inc = {_("Width +"), KEY_MOVE_UP};
+ struct binding inc = {_("Width +"), KEY_MOVE_UP};
struct binding dec = {_("Width -"), KEY_MOVE_DOWN};
struct binding help = {_("Help"), KEY_GENERIC_HELP};
struct binding *binding[] = {&inc, &dec, &help, &quit};
@@ -620,7 +620,7 @@ custom_sidebar_config (void)
keys_display_bindings_bar (win[STA].p, binding, 0, binding_size);
wins_doupdate ();
- while ((ch = keys_getch (win[STA].p)) != KEY_GENERIC_QUIT)
+ while ((ch = keys_getch (win[STA].p)) != KEY_GENERIC_QUIT)
{
switch (ch)
{
@@ -658,8 +658,8 @@ set_confwin_attr (struct window *cwin)
cwin->x = cwin->y = 0;
}
-/*
- * Create a configuration window and initialize status and notification bar
+/*
+ * Create a configuration window and initialize status and notification bar
* (useful in case of window resize).
*/
void
@@ -671,10 +671,10 @@ custom_confwin_init (struct window *confwin, char *label)
confwin->x + confwin->w, confwin->y + confwin->h);
(void)delwin (confwin->p);
}
-
+
wins_get_config ();
set_confwin_attr (confwin);
- confwin->p = newwin (confwin->h, col, 0, 0);
+ confwin->p = newwin (confwin->h, col, 0, 0);
box (confwin->p, 0, 0);
wins_show (confwin->p, label);
delwin (win[STA].p);
@@ -698,7 +698,7 @@ color_selection_bar (void)
struct binding left = {_("Left"), KEY_MOVE_LEFT};
struct binding right = {_("Right"), KEY_MOVE_RIGHT};
-
+
struct binding *binding[] = {
&quit, &nocolor, &up, &down, &left, &right, &select
};
@@ -707,13 +707,13 @@ color_selection_bar (void)
keys_display_bindings_bar (win[STA].p, binding, 0, binding_size);
}
-/*
+/*
* Used to display available colors in color configuration menu.
* This is useful for window resizing.
*/
static void
display_color_config (struct window *cwin, int *mark_fore, int *mark_back,
- int cursor, int need_reset, int theme_changed)
+ int cursor, int need_reset, int theme_changed)
{
#define SIZE (2 * (NBUSERCOLORS + 1))
#define DEFAULTCOLOR 255
@@ -764,34 +764,34 @@ display_color_config (struct window *cwin, int *mark_fore, int *mark_back,
if (colorize)
{
if (theme_changed)
- {
- pair_content (colr[*mark_fore], &colr_fore, 0L);
- if (colr_fore == 255)
- colr_fore = -1;
- pair_content (colr[*mark_back], &colr_back, 0L);
- if (colr_back == 255)
- colr_back = -1;
- init_pair (COLR_CUSTOM, colr_fore, colr_back);
- }
+ {
+ pair_content (colr[*mark_fore], &colr_fore, 0L);
+ if (colr_fore == 255)
+ colr_fore = -1;
+ pair_content (colr[*mark_back], &colr_back, 0L);
+ if (colr_back == 255)
+ colr_back = -1;
+ init_pair (COLR_CUSTOM, colr_fore, colr_back);
+ }
else
- {
- /* Retrieve the actual color theme. */
- pair_content (COLR_CUSTOM, &colr_fore, &colr_back);
-
- if ((colr_fore == DEFAULTCOLOR) || (colr_fore == DEFAULTCOLOR_EXT))
- *mark_fore = NBUSERCOLORS;
- else
- for (i = 0; i < NBUSERCOLORS + 1; i++)
- if (colr_fore == colr[i])
- *mark_fore = i;
-
- if ((colr_back == DEFAULTCOLOR) || (colr_back == DEFAULTCOLOR_EXT))
- *mark_back = SIZE - 1;
- else
- for (i = 0; i < NBUSERCOLORS + 1; i++)
- if (colr_back == colr[NBUSERCOLORS + 1 + i])
- *mark_back = NBUSERCOLORS + 1 + i;
- }
+ {
+ /* Retrieve the actual color theme. */
+ pair_content (COLR_CUSTOM, &colr_fore, &colr_back);
+
+ if ((colr_fore == DEFAULTCOLOR) || (colr_fore == DEFAULTCOLOR_EXT))
+ *mark_fore = NBUSERCOLORS;
+ else
+ for (i = 0; i < NBUSERCOLORS + 1; i++)
+ if (colr_fore == colr[i])
+ *mark_fore = i;
+
+ if ((colr_back == DEFAULTCOLOR) || (colr_back == DEFAULTCOLOR_EXT))
+ *mark_back = SIZE - 1;
+ else
+ for (i = 0; i < NBUSERCOLORS + 1; i++)
+ if (colr_back == colr[NBUSERCOLORS + 1 + i])
+ *mark_back = NBUSERCOLORS + 1 + i;
+ }
}
/* color boxes */
@@ -810,9 +810,9 @@ display_color_config (struct window *cwin, int *mark_fore, int *mark_back,
mvwprintw (cwin->p, pos[i][YPOS], pos[i][XPOS] + XOFST, bar);
wattroff (cwin->p, COLOR_PAIR (colr[i]));
mvwprintw (cwin->p, pos[NBUSERCOLORS][YPOS] + 1,
- pos[NBUSERCOLORS][XPOS] + XOFST, default_txt);
+ pos[NBUSERCOLORS][XPOS] + XOFST, default_txt);
mvwprintw (cwin->p, pos[SIZE - 1][YPOS] + 1,
- pos[SIZE - 1][XPOS] + XOFST, default_txt);
+ pos[SIZE - 1][XPOS] + XOFST, default_txt);
custom_apply_attr (cwin->p, ATTR_HIGHEST);
mvwprintw (cwin->p, Y, XFORE + XOFST, fore_txt);
@@ -822,9 +822,9 @@ display_color_config (struct window *cwin, int *mark_fore, int *mark_back,
if (colorize)
{
mvwaddch (cwin->p, pos[*mark_fore][YPOS],
- pos[*mark_fore][XPOS] + 1, MARK);
+ pos[*mark_fore][XPOS] + 1, MARK);
mvwaddch (cwin->p, pos[*mark_back][YPOS],
- pos[*mark_back][XPOS] + 1, MARK);
+ pos[*mark_back][XPOS] + 1, MARK);
}
mvwaddch (cwin->p, pos[cursor][YPOS], pos[cursor][XPOS] + 1, CURSOR);
@@ -853,7 +853,7 @@ custom_color_config (void)
conf_win.p = 0;
set_confwin_attr (&conf_win);
display_color_config (&conf_win, &mark_fore, &mark_back, cursor,
- need_reset, theme_changed);
+ need_reset, theme_changed);
while ((ch = keys_getch (win[STA].p)) != KEY_GENERIC_QUIT)
{
@@ -861,60 +861,60 @@ custom_color_config (void)
theme_changed = 0;
switch (ch)
- {
- case KEY_RESIZE:
- endwin ();
- wins_refresh ();
- curs_set (0);
- need_reset = 1;
- break;
-
- case KEY_GENERIC_SELECT:
- colorize = 1;
- need_reset = 1;
- theme_changed = 1;
- if (cursor > NBUSERCOLORS)
- mark_back = cursor;
- else
- mark_fore = cursor;
- break;
-
- case KEY_MOVE_DOWN:
- if (cursor < SIZE - 1)
- ++cursor;
- break;
-
- case KEY_MOVE_UP:
- if (cursor > 0)
- --cursor;
- break;
-
- case KEY_MOVE_LEFT:
- if (cursor > NBUSERCOLORS)
- cursor -= (NBUSERCOLORS + 1);
- break;
-
- case KEY_MOVE_RIGHT:
- if (cursor <= NBUSERCOLORS)
- cursor += (NBUSERCOLORS + 1);
- break;
-
- case KEY_GENERIC_CANCEL:
- colorize = 0;
- need_reset = 1;
- break;
- }
+ {
+ case KEY_RESIZE:
+ endwin ();
+ wins_refresh ();
+ curs_set (0);
+ need_reset = 1;
+ break;
+
+ case KEY_GENERIC_SELECT:
+ colorize = 1;
+ need_reset = 1;
+ theme_changed = 1;
+ if (cursor > NBUSERCOLORS)
+ mark_back = cursor;
+ else
+ mark_fore = cursor;
+ break;
+
+ case KEY_MOVE_DOWN:
+ if (cursor < SIZE - 1)
+ ++cursor;
+ break;
+
+ case KEY_MOVE_UP:
+ if (cursor > 0)
+ --cursor;
+ break;
+
+ case KEY_MOVE_LEFT:
+ if (cursor > NBUSERCOLORS)
+ cursor -= (NBUSERCOLORS + 1);
+ break;
+
+ case KEY_MOVE_RIGHT:
+ if (cursor <= NBUSERCOLORS)
+ cursor += (NBUSERCOLORS + 1);
+ break;
+
+ case KEY_GENERIC_CANCEL:
+ colorize = 0;
+ need_reset = 1;
+ break;
+ }
display_color_config (&conf_win, &mark_fore, &mark_back, cursor,
- need_reset, theme_changed);
+ need_reset, theme_changed);
}
delwin (conf_win.p);
}
-/*
+/*
* Return a string defining the color theme in the form:
* foreground color 'on' background color
* in order to dump this data in the configuration file.
- * Color numbers follow the ncurses library definitions.
+ * Color numbers follow the ncurses library definitions.
* If ncurses library was compiled with --enable-ext-funcs,
* then default color is -1.
*/
@@ -947,17 +947,17 @@ custom_color_theme_name (char *theme_name)
{
pair_content (COLR_CUSTOM, &color[0], &color[1]);
for (i = 0; i < NBCOLORS; i++)
- {
- if ((color[i] == DEFAULTCOLOR) || (color[i] == DEFAULTCOLOR_EXT))
- color_name[i] = default_color;
- else if (color[i] >= 0 && color[i] <= MAXCOLORS)
- color_name[i] = name[color[i]];
- else
- {
+ {
+ if ((color[i] == DEFAULTCOLOR) || (color[i] == DEFAULTCOLOR_EXT))
+ color_name[i] = default_color;
+ else if (color[i] >= 0 && color[i] <= MAXCOLORS)
+ color_name[i] = name[color[i]];
+ else
+ {
EXIT (_("unknown color"));
- /* NOTREACHED */
- }
- }
+ /* NOTREACHED */
+ }
+ }
(void)snprintf (theme_name, BUFSIZ, "%s on %s", color_name[0],
color_name[1]);
}
@@ -984,7 +984,7 @@ print_general_options (WINDOW *win, struct conf *conf)
int y;
char *opt[NB_OPTIONS] = {
_("auto_save = "),
- _("periodic_save = "),
+ _("periodic_save = "),
_("confirm_quit = "),
_("confirm_delete = "),
_("skip_system_dialogs = "),
@@ -993,13 +993,13 @@ print_general_options (WINDOW *win, struct conf *conf)
_("output_datefmt = "),
_("input_datefmt = ")
};
-
+
y = 0;
mvwprintw (win, y, XPOS, "[1] %s ", opt[AUTO_SAVE]);
print_bool_option_incolor (win, conf->auto_save, y,
XPOS + 4 + strlen (opt[AUTO_SAVE]));
mvwprintw (win, y + 1, XPOS,
- _("(if set to YES, automatic save is done when quitting)"));
+ _("(if set to YES, automatic save is done when quitting)"));
y += YOFF;
mvwprintw (win, y, XPOS, "[2] %s ", opt[PERIODIC_SAVE]);
custom_apply_attr (win, ATTR_HIGHEST);
@@ -1007,41 +1007,41 @@ print_general_options (WINDOW *win, struct conf *conf)
conf->periodic_save);
custom_remove_attr (win, ATTR_HIGHEST);
mvwprintw (win, y + 1, XPOS,
- _("(if not null, automatically save data every 'periodic_save' "
+ _("(if not null, automatically save data every 'periodic_save' "
"minutes)"));
y += YOFF;
mvwprintw (win, y, XPOS, "[3] %s ", opt[CONFIRM_QUIT]);
print_bool_option_incolor (win, conf->confirm_quit, y,
XPOS + 4 + strlen (opt[CONFIRM_QUIT]));
mvwprintw (win, y + 1, XPOS,
- _("(if set to YES, confirmation is required before quitting)"));
+ _("(if set to YES, confirmation is required before quitting)"));
y += YOFF;
mvwprintw (win, y, XPOS, "[4] %s ", opt[CONFIRM_DELETE]);
print_bool_option_incolor (win, conf->confirm_delete, y,
XPOS + 4 + strlen (opt[CONFIRM_DELETE]));
mvwprintw (win, y + 1, XPOS,
- _("(if set to YES, confirmation is required "
+ _("(if set to YES, confirmation is required "
"before deleting an event)"));
y += YOFF;
mvwprintw (win, y, XPOS, "[5] %s ", opt[SKIP_SYSTEM_DIAGS]);
print_bool_option_incolor (win, conf->skip_system_dialogs, y,
XPOS + 4 + strlen (opt[SKIP_SYSTEM_DIAGS]));
mvwprintw (win, y + 1, XPOS,
- _("(if set to YES, messages about loaded "
+ _("(if set to YES, messages about loaded "
"and saved data will not be displayed)"));
y += YOFF;
mvwprintw (win, y, XPOS, "[6] %s ", opt[SKIP_PROGRESS_BAR]);
print_bool_option_incolor (win, conf->skip_progress_bar, y,
XPOS + 4 + strlen (opt[SKIP_PROGRESS_BAR]));
mvwprintw (win, y + 1, XPOS,
- _("(if set to YES, progress bar will not be displayed "
+ _("(if set to YES, progress bar will not be displayed "
"when saving data)"));
y += YOFF;
mvwprintw (win, y, XPOS, "[7] %s ", opt[WEEK_BEGINS_MONDAY]);
print_bool_option_incolor (win, calendar_week_begins_on_monday (), y,
XPOS + 4 + strlen (opt[WEEK_BEGINS_MONDAY]));
mvwprintw (win, y + 1, XPOS,
- _("(if set to YES, monday is the first day of the week, "
+ _("(if set to YES, monday is the first day of the week, "
"else it is sunday)"));
y += YOFF;
mvwprintw (win, y, XPOS, "[8] %s ", opt[OUTPUT_DATE_FMT]);
@@ -1050,7 +1050,7 @@ print_general_options (WINDOW *win, struct conf *conf)
conf->output_datefmt);
custom_remove_attr (win, ATTR_HIGHEST);
mvwprintw (win, y + 1, XPOS,
- _("(Format of the date to be displayed in non-interactive mode)"));
+ _("(Format of the date to be displayed in non-interactive mode)"));
y += YOFF;
mvwprintw (win, y, XPOS, "[9] %s ", opt[INPUT_DATE_FMT]);
custom_apply_attr (win, ATTR_HIGHEST);
@@ -1077,7 +1077,7 @@ custom_set_swsiz (struct scrollwin *sw)
sw->pad.h = BUFSIZ;
sw->pad.w = col - 2 * sw->pad.x - 1;
}
-
+
/* General configuration. */
void
custom_general_config (struct conf *conf)
@@ -1110,86 +1110,86 @@ custom_general_config (struct conf *conf)
while ((ch = wgetch (win[STA].p)) != 'q')
{
buf[0] = '\0';
-
+
switch (ch)
- {
- case KEY_RESIZE:
+ {
+ case KEY_RESIZE:
wins_get_config ();
wins_reset ();
- wins_scrollwin_delete (&cwin);
- wins_scrollwin_init (&cwin);
+ wins_scrollwin_delete (&cwin);
+ wins_scrollwin_init (&cwin);
custom_set_swsiz (&cwin);
wins_show (cwin.win.p, cwin.label);
- cwin.first_visible_line = 0;
- delwin (win[STA].p);
- win[STA].p = newwin (win[STA].h, win[STA].w, win[STA].y,
- win[STA].x);
- keypad (win[STA].p, TRUE);
- if (notify_bar ())
- {
- notify_reinit_bar ();
- notify_update_bar ();
- }
- break;
+ cwin.first_visible_line = 0;
+ delwin (win[STA].p);
+ win[STA].p = newwin (win[STA].h, win[STA].w, win[STA].y,
+ win[STA].x);
+ keypad (win[STA].p, TRUE);
+ if (notify_bar ())
+ {
+ notify_reinit_bar ();
+ notify_update_bar ();
+ }
+ break;
case CTRL ('N'):
wins_scrollwin_down (&cwin, 1);
- break;
+ break;
case CTRL ('P'):
wins_scrollwin_up (&cwin, 1);
- break;
- case '1':
- conf->auto_save = !conf->auto_save;
- break;
- case '2':
- status_mesg (periodic_save_str, "");
- if (updatestring (win[STA].p, &buf, 0, 1) == 0)
- {
- int val = atoi (buf);
- if (val >= 0)
- conf->periodic_save = val;
+ break;
+ case '1':
+ conf->auto_save = !conf->auto_save;
+ break;
+ case '2':
+ status_mesg (periodic_save_str, "");
+ if (updatestring (win[STA].p, &buf, 0, 1) == 0)
+ {
+ int val = atoi (buf);
+ if (val >= 0)
+ conf->periodic_save = val;
if (conf->periodic_save > 0)
io_start_psave_thread (conf);
else if (conf->periodic_save == 0)
io_stop_psave_thread ();
- }
- status_mesg (number_str, keys);
- break;
- case '3':
- conf->confirm_quit = !conf->confirm_quit;
- break;
- case '4':
- conf->confirm_delete = !conf->confirm_delete;
- break;
- case '5':
- conf->skip_system_dialogs = !conf->skip_system_dialogs;
- break;
- case '6':
- conf->skip_progress_bar = !conf->skip_progress_bar;
- break;
- case '7':
- calendar_change_first_day_of_week ();
- break;
- case '8':
- status_mesg (output_datefmt_str, "");
- (void)strncpy (buf, conf->output_datefmt,
+ }
+ status_mesg (number_str, keys);
+ break;
+ case '3':
+ conf->confirm_quit = !conf->confirm_quit;
+ break;
+ case '4':
+ conf->confirm_delete = !conf->confirm_delete;
+ break;
+ case '5':
+ conf->skip_system_dialogs = !conf->skip_system_dialogs;
+ break;
+ case '6':
+ conf->skip_progress_bar = !conf->skip_progress_bar;
+ break;
+ case '7':
+ calendar_change_first_day_of_week ();
+ break;
+ case '8':
+ status_mesg (output_datefmt_str, "");
+ (void)strncpy (buf, conf->output_datefmt,
strlen (conf->output_datefmt) + 1);
- if (updatestring (win[STA].p, &buf, 0, 1) == 0)
- {
- (void)strncpy (conf->output_datefmt, buf, strlen (buf) + 1);
- }
- status_mesg (number_str, keys);
- break;
- case '9':
- status_mesg (input_datefmt_str, "");
- if (updatestring (win[STA].p, &buf, 0, 1) == 0)
- {
- int val = atoi (buf);
- if (val > 0 && val <= DATE_FORMATS)
- conf->input_datefmt = val;
- }
- status_mesg (number_str, keys);
- break;
- }
+ if (updatestring (win[STA].p, &buf, 0, 1) == 0)
+ {
+ (void)strncpy (conf->output_datefmt, buf, strlen (buf) + 1);
+ }
+ status_mesg (number_str, keys);
+ break;
+ case '9':
+ status_mesg (input_datefmt_str, "");
+ if (updatestring (win[STA].p, &buf, 0, 1) == 0)
+ {
+ int val = atoi (buf);
+ if (val > 0 && val <= DATE_FORMATS)
+ conf->input_datefmt = val;
+ }
+ status_mesg (number_str, keys);
+ break;
+ }
status_mesg (number_str, keys);
cwin.total_lines = print_general_options (cwin.pad.p, conf);
wins_scrollwin_display (&cwin);
@@ -1225,14 +1225,14 @@ print_keys_bindings (WINDOW *win, int selected_row, int selected_elm, int yoff)
char actionstr[BUFSIZ];
int nbkeys;
- nbkeys = keys_action_count_keys (action);
+ nbkeys = keys_action_count_keys (action);
(void)snprintf (actionstr, BUFSIZ, "%s", keys_get_label (action));
if (action == selected_row)
custom_apply_attr (win, ATTR_HIGHEST);
mvwprintw (win, y, XPOS, "%s ", actionstr);
mvwprintw (win, y, EQUALPOS, "=");
if (nbkeys == 0)
- mvwprintw (win, y, KEYPOS, _("undefined"));
+ mvwprintw (win, y, KEYPOS, _("undefined"));
if (action == selected_row)
custom_remove_attr (win, ATTR_HIGHEST);
if (nbkeys > 0)
@@ -1241,14 +1241,14 @@ print_keys_bindings (WINDOW *win, int selected_row, int selected_elm, int yoff)
{
char *key;
int pos;
-
+
pos = KEYPOS;
while ((key = keys_action_nkey (action, noelm)) != 0)
{
if (noelm == selected_elm)
print_key_incolor (win, key, y, pos);
else
- mvwprintw (win, y, pos, "%s ", key);
+ mvwprintw (win, y, pos, "%s ", key);
noelm++;
pos += strlen (key) + 1;
}
@@ -1260,7 +1260,7 @@ print_keys_bindings (WINDOW *win, int selected_row, int selected_elm, int yoff)
}
y += yoff;
}
-
+
return noelm;
}
@@ -1275,7 +1275,7 @@ custom_keys_config_bar (void)
struct binding down = {_("Down"), KEY_MOVE_DOWN};
struct binding left = {_("Prev Key"), KEY_MOVE_LEFT};
struct binding right = {_("Next Key"), KEY_MOVE_RIGHT};
-
+
struct binding *binding[] = {
&quit, &info, &add, &del, &up, &down, &left, &right
};
@@ -1294,7 +1294,7 @@ custom_keys_config (void)
WINDOW *grabwin;
const int LINESPERKEY = 2;
const int LABELLINES = 3;
-
+
clear ();
custom_set_swsiz (&kwin);
nbdisplayed = (kwin.win.h - LABELLINES) / LINESPERKEY;
@@ -1314,7 +1314,7 @@ custom_keys_config (void)
ch = keys_getch (win[STA].p);
switch (ch)
- {
+ {
case KEY_MOVE_UP:
if (selrow > 0)
{
@@ -1327,8 +1327,8 @@ custom_keys_config (void)
wins_scrollwin_up (&kwin, LINESPERKEY);
}
}
- break;
- case KEY_MOVE_DOWN:
+ break;
+ case KEY_MOVE_DOWN:
if (selrow < NBKEYS - 1)
{
selrow++;
@@ -1340,7 +1340,7 @@ custom_keys_config (void)
wins_scrollwin_down (&kwin, LINESPERKEY);
}
}
- break;
+ break;
case KEY_MOVE_LEFT:
if (selelm > 0)
selelm--;
@@ -1383,7 +1383,7 @@ custom_keys_config (void)
if (used)
{
enum key action;
-
+
action = keys_get_action (keyval);
WARN_MSG (_("This key is already in use for %s, "
"please choose another one."),
@@ -1393,10 +1393,10 @@ custom_keys_config (void)
LINESPERKEY);
wins_scrollwin_display (&kwin);
}
- delwin (grabwin);
+ delwin (grabwin);
}
while (used || not_recognized);
- nbrowelm++;
+ nbrowelm++;
if (selelm < nbrowelm - 1)
selelm++;
#undef WINROW
@@ -1414,11 +1414,11 @@ custom_keys_config (void)
if (keys_check_missing_bindings () != 0)
{
WARN_MSG (_("Some actions do not have any associated "
- "key bindings!"));
+ "key bindings!"));
}
wins_scrollwin_delete (&kwin);
return;
- }
+ }
custom_keys_config_bar ();
werase (kwin.pad.p);
nbrowelm = print_keys_bindings (kwin.pad.p, selrow, selelm, LINESPERKEY);