summaryrefslogtreecommitdiffstats
path: root/src/calcurse.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/calcurse.c')
-rw-r--r--src/calcurse.c544
1 files changed, 272 insertions, 272 deletions
diff --git a/src/calcurse.c b/src/calcurse.c
index 3231869..6a90f57 100644
--- a/src/calcurse.c
+++ b/src/calcurse.c
@@ -42,7 +42,7 @@
* Calcurse is a text-based personal organizer which helps keeping track
* of events and everyday tasks. It contains a calendar, a 'todo' list,
* and puts your appointments in order. The user interface is configurable,
- * and one can choose between different color schemes and layouts.
+ * and one can choose between different color schemes and layouts.
* All of the commands are documented within an online help system.
*/
int
@@ -61,7 +61,7 @@ main (int argc, char **argv)
unsigned day_changed = 0;
char *no_color_support =
_("Sorry, colors are not supported by your terminal\n"
- "(Press [ENTER] to continue)");
+ "(Press [ENTER] to continue)");
char *quit_message = _("Do you really want to quit ?");
char choices[] = "[y/n] ";
@@ -75,7 +75,7 @@ main (int argc, char **argv)
apoint_llist_init ();
recur_apoint_llist_init ();
- /*
+ /*
* Begin by parsing and handling command line arguments.
* The data path is also initialized here.
*/
@@ -88,7 +88,7 @@ main (int argc, char **argv)
dmon_stop ();
io_set_lock ();
}
-
+
/* Begin of interactive mode with ncurses interface. */
sigs_init (); /* signal handling init */
initscr (); /* start the curses mode */
@@ -109,10 +109,10 @@ main (int argc, char **argv)
#ifdef NCURSES_VERSION
if (use_default_colors () != ERR)
- {
- background = -1;
- foreground = -1;
- }
+ {
+ background = -1;
+ foreground = -1;
+ }
#endif /* NCURSES_VERSION */
/* Color assignment */
@@ -139,7 +139,7 @@ main (int argc, char **argv)
notify_init_bar ();
wins_reset_status_page ();
- /*
+ /*
* Read the data from files : first the user
* configuration (the display is then updated), and then
* the todo list, appointments and events.
@@ -160,119 +160,119 @@ main (int argc, char **argv)
calendar_start_date_thread ();
if (conf.periodic_save > 0)
io_start_psave_thread (&conf);
-
+
/* User input */
for (;;)
{
int key;
-
+
do_update = 1;
key = keys_getch (win[STA].p);
switch (key)
- {
- case ERR:
- do_update = 0;
- break;
-
- case KEY_GENERIC_REDRAW:
- case KEY_RESIZE:
- do_update = 0;
- wins_reset ();
- break;
-
- case KEY_GENERIC_CHANGE_VIEW:
- wins_reset_status_page ();
- /* Need to save the previously highlighted event. */
- switch (wins_slctd ())
- {
- case TOD:
- sav_hilt_tod = todo_hilt ();
- todo_hilt_set (0);
- break;
- case APP:
- sav_hilt_app = apoint_hilt ();
- apoint_hilt_set (0);
- break;
- default:
- break;
- }
- wins_slctd_next ();
-
- /* Select the event to highlight. */
- switch (wins_slctd ())
- {
- case TOD:
- if ((sav_hilt_tod == 0) && (todo_nb () != 0))
- todo_hilt_set (1);
- else
- todo_hilt_set (sav_hilt_tod);
- break;
- case APP:
- if ((sav_hilt_app == 0)
+ {
+ case ERR:
+ do_update = 0;
+ break;
+
+ case KEY_GENERIC_REDRAW:
+ case KEY_RESIZE:
+ do_update = 0;
+ wins_reset ();
+ break;
+
+ case KEY_GENERIC_CHANGE_VIEW:
+ wins_reset_status_page ();
+ /* Need to save the previously highlighted event. */
+ switch (wins_slctd ())
+ {
+ case TOD:
+ sav_hilt_tod = todo_hilt ();
+ todo_hilt_set (0);
+ break;
+ case APP:
+ sav_hilt_app = apoint_hilt ();
+ apoint_hilt_set (0);
+ break;
+ default:
+ break;
+ }
+ wins_slctd_next ();
+
+ /* Select the event to highlight. */
+ switch (wins_slctd ())
+ {
+ case TOD:
+ if ((sav_hilt_tod == 0) && (todo_nb () != 0))
+ todo_hilt_set (1);
+ else
+ todo_hilt_set (sav_hilt_tod);
+ break;
+ case APP:
+ if ((sav_hilt_app == 0)
&& ((inday.nb_events + inday.nb_apoints) != 0))
- apoint_hilt_set (1);
- else
- apoint_hilt_set (sav_hilt_app);
- break;
- default:
- break;
- }
- break;
+ apoint_hilt_set (1);
+ else
+ apoint_hilt_set (sav_hilt_app);
+ break;
+ default:
+ break;
+ }
+ break;
case KEY_GENERIC_OTHER_CMD:
- wins_other_status_page (wins_slctd ());
- break;
+ wins_other_status_page (wins_slctd ());
+ break;
case KEY_GENERIC_GOTO:
case KEY_GENERIC_GOTO_TODAY:
- wins_erase_status_bar ();
- calendar_set_current_date ();
+ wins_erase_status_bar ();
+ calendar_set_current_date ();
if (key == KEY_GENERIC_GOTO_TODAY)
calendar_goto_today ();
else
calendar_change_day (conf.input_datefmt);
- do_storage = 1;
- day_changed = 1;
- break;
+ do_storage = 1;
+ day_changed = 1;
+ break;
case KEY_VIEW_ITEM:
- if ((wins_slctd () == APP) && (apoint_hilt () != 0))
- day_popup_item ();
- else if ((wins_slctd () == TOD) && (todo_hilt () != 0))
- item_in_popup (NULL, NULL, todo_saved_mesg (), _("To do :"));
- break;
+ if ((wins_slctd () == APP) && (apoint_hilt () != 0))
+ day_popup_item ();
+ else if ((wins_slctd () == TOD) && (todo_hilt () != 0))
+ item_in_popup (NULL, NULL, todo_saved_mesg (), _("To do :"));
+ break;
case KEY_GENERIC_CONFIG_MENU:
- wins_erase_status_bar ();
- custom_config_bar ();
- while ((key = wgetch (win[STA].p)) != 'q')
- {
- switch (key)
- {
- case 'C':
- case 'c':
- if (has_colors ())
- custom_color_config ();
- else
- {
- colorize = 0;
- wins_erase_status_bar ();
- mvwprintw (win[STA].p, 0, 0, _(no_color_support));
- wgetch (win[STA].p);
- }
- break;
- case 'L':
- case 'l':
- custom_layout_config ();
- break;
- case 'G':
- case 'g':
- custom_general_config (&conf);
- break;
- case 'N':
- case 'n':
- notify_config_bar ();
- break;
+ wins_erase_status_bar ();
+ custom_config_bar ();
+ while ((key = wgetch (win[STA].p)) != 'q')
+ {
+ switch (key)
+ {
+ case 'C':
+ case 'c':
+ if (has_colors ())
+ custom_color_config ();
+ else
+ {
+ colorize = 0;
+ wins_erase_status_bar ();
+ mvwprintw (win[STA].p, 0, 0, _(no_color_support));
+ wgetch (win[STA].p);
+ }
+ break;
+ case 'L':
+ case 'l':
+ custom_layout_config ();
+ break;
+ case 'G':
+ case 'g':
+ custom_general_config (&conf);
+ break;
+ case 'N':
+ case 'n':
+ notify_config_bar ();
+ break;
case 'K':
case 'k':
custom_keys_config ();
@@ -281,59 +281,59 @@ main (int argc, char **argv)
case 'S':
custom_sidebar_config ();
break;
- }
- wins_reset ();
- wins_update ();
- do_storage = 1;
- wins_erase_status_bar ();
- custom_config_bar ();
- }
- wins_update ();
- break;
+ }
+ wins_reset ();
+ wins_update ();
+ do_storage = 1;
+ wins_erase_status_bar ();
+ custom_config_bar ();
+ }
+ wins_update ();
+ break;
case KEY_GENERIC_ADD_APPT:
- apoint_add ();
- do_storage = 1;
- break;
+ apoint_add ();
+ do_storage = 1;
+ break;
case KEY_GENERIC_ADD_TODO:
- todo_new_item ();
- if (todo_hilt () == 0 && todo_nb () == 1)
- todo_hilt_increase ();
- break;
+ todo_new_item ();
+ if (todo_hilt () == 0 && todo_nb () == 1)
+ todo_hilt_increase ();
+ break;
case KEY_ADD_ITEM:
- switch (wins_slctd ())
- {
- case APP:
- apoint_add ();
- do_storage = 1;
- break;
- case TOD:
- todo_new_item ();
- if (todo_hilt () == 0 && todo_nb () == 1)
- todo_hilt_increase ();
- break;
- default:
- break;
- }
- break;
+ switch (wins_slctd ())
+ {
+ case APP:
+ apoint_add ();
+ do_storage = 1;
+ break;
+ case TOD:
+ todo_new_item ();
+ if (todo_hilt () == 0 && todo_nb () == 1)
+ todo_hilt_increase ();
+ break;
+ default:
+ break;
+ }
+ break;
case KEY_EDIT_ITEM:
- if (wins_slctd () == APP && apoint_hilt () != 0)
- day_edit_item (&conf);
- else if (wins_slctd () == TOD && todo_hilt () != 0)
- todo_edit_item ();
- do_storage = 1;
- break;
+ if (wins_slctd () == APP && apoint_hilt () != 0)
+ day_edit_item (&conf);
+ else if (wins_slctd () == TOD && todo_hilt () != 0)
+ todo_edit_item ();
+ do_storage = 1;
+ break;
case KEY_DEL_ITEM:
- if (wins_slctd () == APP && apoint_hilt () != 0)
- apoint_delete (&conf, &inday.nb_events, &inday.nb_apoints);
- else if (wins_slctd () == TOD && todo_hilt () != 0)
- todo_delete (&conf);
- do_storage = 1;
- break;
+ if (wins_slctd () == APP && apoint_hilt () != 0)
+ apoint_delete (&conf, &inday.nb_events, &inday.nb_apoints);
+ else if (wins_slctd () == TOD && todo_hilt () != 0)
+ todo_delete (&conf);
+ do_storage = 1;
+ break;
case KEY_GENERIC_CUT:
if (wins_slctd () == APP && apoint_hilt () != 0)
@@ -351,116 +351,116 @@ main (int argc, char **argv)
do_storage = 1;
}
break;
-
+
case KEY_REPEAT_ITEM:
- if (wins_slctd () == APP && apoint_hilt () != 0)
- recur_repeat_item (&conf);
- do_storage = 1;
- break;
+ if (wins_slctd () == APP && apoint_hilt () != 0)
+ recur_repeat_item (&conf);
+ do_storage = 1;
+ break;
case KEY_FLAG_ITEM:
- if (wins_slctd () == APP && apoint_hilt () != 0)
- apoint_switch_notify ();
+ if (wins_slctd () == APP && apoint_hilt () != 0)
+ apoint_switch_notify ();
else if (wins_slctd () == TOD && todo_hilt () != 0)
todo_flag ();
- do_storage = 1;
- break;
+ do_storage = 1;
+ break;
case KEY_RAISE_PRIORITY:
case KEY_LOWER_PRIORITY:
- if (wins_slctd () == TOD && todo_hilt () != 0)
- {
- todo_chg_priority (key);
- if (todo_hilt_pos () < 0)
- todo_set_first (todo_hilt ());
- else if (todo_hilt_pos () >= win[TOD].h - 4)
- todo_set_first (todo_hilt () - win[TOD].h + 5);
- }
- break;
+ if (wins_slctd () == TOD && todo_hilt () != 0)
+ {
+ todo_chg_priority (key);
+ if (todo_hilt_pos () < 0)
+ todo_set_first (todo_hilt ());
+ else if (todo_hilt_pos () >= win[TOD].h - 4)
+ todo_set_first (todo_hilt () - win[TOD].h + 5);
+ }
+ break;
case KEY_EDIT_NOTE:
- if (wins_slctd () == APP && apoint_hilt () != 0)
- day_edit_note (conf.editor);
- else if (wins_slctd () == TOD && todo_hilt () != 0)
- todo_edit_note (conf.editor);
- do_storage = 1;
- break;
+ if (wins_slctd () == APP && apoint_hilt () != 0)
+ day_edit_note (conf.editor);
+ else if (wins_slctd () == TOD && todo_hilt () != 0)
+ todo_edit_note (conf.editor);
+ do_storage = 1;
+ break;
case KEY_VIEW_NOTE:
- if (wins_slctd () == APP && apoint_hilt () != 0)
- day_view_note (conf.pager);
- else if (wins_slctd () == TOD && todo_hilt () != 0)
- todo_view_note (conf.pager);
- break;
+ if (wins_slctd () == APP && apoint_hilt () != 0)
+ day_view_note (conf.pager);
+ else if (wins_slctd () == TOD && todo_hilt () != 0)
+ todo_view_note (conf.pager);
+ break;
case KEY_GENERIC_HELP:
- wins_status_bar ();
- help_screen ();
- break;
+ wins_status_bar ();
+ help_screen ();
+ break;
case KEY_GENERIC_SAVE:
- io_save_cal (&conf, IO_SAVE_DISPLAY_BAR);
- break;
+ io_save_cal (&conf, IO_SAVE_DISPLAY_BAR);
+ break;
case KEY_GENERIC_IMPORT:
wins_erase_status_bar ();
io_import_data (IO_IMPORT_ICAL, &conf, NULL);
do_storage = 1;
break;
-
+
case KEY_GENERIC_EXPORT:
wins_erase_status_bar ();
io_export_bar ();
while ((key = wgetch (win[STA].p)) != 'q')
- {
- switch (key)
- {
- case 'I':
- case 'i':
+ {
+ switch (key)
+ {
+ case 'I':
+ case 'i':
io_export_data (IO_EXPORT_ICAL, &conf);
- break;
- case 'P':
- case 'p':
+ break;
+ case 'P':
+ case 'p':
io_export_data (IO_EXPORT_PCAL, &conf);
- break;
- }
- wins_reset ();
- wins_update ();
- do_storage = 1;
- wins_erase_status_bar ();
- io_export_bar ();
- }
- wins_update ();
- break;
+ break;
+ }
+ wins_reset ();
+ wins_update ();
+ do_storage = 1;
+ wins_erase_status_bar ();
+ io_export_bar ();
+ }
+ wins_update ();
+ break;
case KEY_GENERIC_NEXT_DAY:
case KEY_MOVE_RIGHT:
- if (wins_slctd () == CAL || key == KEY_GENERIC_NEXT_DAY)
- {
- do_storage = 1;
- day_changed = 1;
- calendar_move (RIGHT);
- }
- break;
+ if (wins_slctd () == CAL || key == KEY_GENERIC_NEXT_DAY)
+ {
+ do_storage = 1;
+ day_changed = 1;
+ calendar_move (RIGHT);
+ }
+ break;
case KEY_GENERIC_PREV_DAY:
case KEY_MOVE_LEFT:
- if (wins_slctd () == CAL || key == KEY_GENERIC_PREV_DAY)
- {
- do_storage = 1;
- day_changed = 1;
- calendar_move (LEFT);
- }
- break;
+ if (wins_slctd () == CAL || key == KEY_GENERIC_PREV_DAY)
+ {
+ do_storage = 1;
+ day_changed = 1;
+ calendar_move (LEFT);
+ }
+ break;
case KEY_GENERIC_PREV_WEEK:
case KEY_MOVE_UP:
- if (wins_slctd () == CAL || key == KEY_GENERIC_PREV_WEEK)
- {
- do_storage = 1;
- day_changed = 1;
- calendar_move (UP);
- }
+ if (wins_slctd () == CAL || key == KEY_GENERIC_PREV_WEEK)
+ {
+ do_storage = 1;
+ day_changed = 1;
+ calendar_move (UP);
+ }
else if ((wins_slctd () == APP) && (apoint_hilt () > 1))
{
apoint_hilt_decrease ();
@@ -476,12 +476,12 @@ main (int argc, char **argv)
case KEY_GENERIC_NEXT_WEEK:
case KEY_MOVE_DOWN:
- if (wins_slctd () == CAL || key == KEY_GENERIC_NEXT_WEEK)
- {
- do_storage = 1;
- day_changed = 1;
- calendar_move (DOWN);
- }
+ if (wins_slctd () == CAL || key == KEY_GENERIC_NEXT_WEEK)
+ {
+ do_storage = 1;
+ day_changed = 1;
+ calendar_move (DOWN);
+ }
else if ((wins_slctd () == APP) &&
(apoint_hilt () < inday.nb_events + inday.nb_apoints))
{
@@ -498,20 +498,20 @@ main (int argc, char **argv)
case KEY_START_OF_WEEK:
if (wins_slctd () == CAL)
- {
- do_storage = 1;
- day_changed = 1;
- calendar_move (WEEK_START);
- }
+ {
+ do_storage = 1;
+ day_changed = 1;
+ calendar_move (WEEK_START);
+ }
break;
case KEY_END_OF_WEEK:
if (wins_slctd () == CAL)
- {
- do_storage = 1;
- day_changed = 1;
- calendar_move (WEEK_END);
- }
+ {
+ do_storage = 1;
+ day_changed = 1;
+ calendar_move (WEEK_END);
+ }
break;
case KEY_GENERIC_SCROLL_UP:
@@ -523,47 +523,47 @@ main (int argc, char **argv)
if (wins_slctd () == CAL)
calendar_view_next ();
break;
-
- case KEY_GENERIC_QUIT:
- if (conf.auto_save)
- io_save_cal (&conf, IO_SAVE_DISPLAY_BAR);
-
- if (conf.confirm_quit)
- {
- status_mesg (_(quit_message), choices);
- key = wgetch (win[STA].p);
- if (key == 'y')
- exit_calcurse (EXIT_SUCCESS);
- else
- {
- wins_erase_status_bar ();
- break;
- }
- }
- else
- exit_calcurse (EXIT_SUCCESS);
- break;
-
- default:
- do_update = 0;
- break;
- }
+
+ case KEY_GENERIC_QUIT:
+ if (conf.auto_save)
+ io_save_cal (&conf, IO_SAVE_DISPLAY_BAR);
+
+ if (conf.confirm_quit)
+ {
+ status_mesg (_(quit_message), choices);
+ key = wgetch (win[STA].p);
+ if (key == 'y')
+ exit_calcurse (EXIT_SUCCESS);
+ else
+ {
+ wins_erase_status_bar ();
+ break;
+ }
+ }
+ else
+ exit_calcurse (EXIT_SUCCESS);
+ break;
+
+ default:
+ do_update = 0;
+ break;
+ }
if (do_storage)
- {
- inday = *day_process_storage (calendar_get_slctd_day (),
- day_changed, &inday);
- do_storage = !do_storage;
- if (day_changed)
- {
- sav_hilt_app = 0;
- day_changed = !day_changed;
- if ((wins_slctd () == APP) &&
- (inday.nb_events + inday.nb_apoints != 0))
- apoint_hilt_set (1);
- }
- }
+ {
+ inday = *day_process_storage (calendar_get_slctd_day (),
+ day_changed, &inday);
+ do_storage = !do_storage;
+ if (day_changed)
+ {
+ sav_hilt_app = 0;
+ day_changed = !day_changed;
+ if ((wins_slctd () == APP) &&
+ (inday.nb_events + inday.nb_apoints != 0))
+ apoint_hilt_set (1);
+ }
+ }
if (do_update)
- wins_update ();
+ wins_update ();
}
}