diff options
Diffstat (limited to 'src')
-rwxr-xr-x | src/calcurse.c | 34 | ||||
-rwxr-xr-x | src/calendar.c | 45 | ||||
-rwxr-xr-x | src/calendar.h | 5 | ||||
-rwxr-xr-x | src/help.c | 23 | ||||
-rwxr-xr-x | src/utils.c | 23 | ||||
-rwxr-xr-x | src/utils.h | 8 |
6 files changed, 98 insertions, 40 deletions
diff --git a/src/calcurse.c b/src/calcurse.c index 8e64e90..cd9b31c 100755 --- a/src/calcurse.c +++ b/src/calcurse.c @@ -1,4 +1,4 @@ -/* $calcurse: calcurse.c,v 1.63 2008/04/26 15:35:26 culot Exp $ */ +/* $calcurse: calcurse.c,v 1.64 2008/08/03 18:41:55 culot Exp $ */ /* * Calcurse - text-based organizer @@ -219,11 +219,15 @@ main (int argc, char **argv) other_status_page (wins_slctd ()); break; + case CTRL ('G'): case 'G': case 'g': /* Goto function */ erase_status_bar (); calendar_set_current_date (); - calendar_change_day (conf.input_datefmt); + if (ch == CTRL ('G')) + calendar_goto_today (); + else + calendar_change_day (conf.input_datefmt); do_storage = true; day_changed = true; break; @@ -383,7 +387,7 @@ main (int argc, char **argv) io_export_data (IO_EXPORT_INTERACTIVE, &conf); break; - case (261): /* right arrow */ + case KEY_RIGHT: case ('L'): case ('l'): case CTRL ('L'): @@ -395,7 +399,7 @@ main (int argc, char **argv) } break; - case (260): /* left arrow */ + case KEY_LEFT: case ('H'): case ('h'): case CTRL ('H'): @@ -407,7 +411,7 @@ main (int argc, char **argv) } break; - case (259): /* up arrow */ + case KEY_UP: case ('K'): case ('k'): case CTRL ('K'): @@ -433,7 +437,7 @@ main (int argc, char **argv) } break; - case (258): /* down arrow */ + case KEY_DOWN: case ('J'): case ('j'): case CTRL ('J'): @@ -460,6 +464,24 @@ main (int argc, char **argv) } break; + case '0': + if (wins_slctd () == CAL) + { + do_storage = true; + day_changed = true; + calendar_move (WEEK_START); + } + break; + + case '$': + if (wins_slctd () == CAL) + { + do_storage = true; + day_changed = true; + calendar_move (WEEK_END); + } + break; + case ('Q'): /* Quit calcurse :( */ case ('q'): if (conf.auto_save) diff --git a/src/calendar.c b/src/calendar.c index 6c1d957..c6a4676 100755 --- a/src/calendar.c +++ b/src/calendar.c @@ -1,4 +1,4 @@ -/* $calcurse: calendar.c,v 1.15 2008/04/12 21:14:03 culot Exp $ */ +/* $calcurse: calendar.c,v 1.16 2008/08/03 18:41:55 culot Exp $ */ /* * Calcurse - text-based organizer @@ -327,12 +327,23 @@ calendar_update_panel (WINDOW *cwin) wnoutrefresh (cwin); } +/* Set the selected day in calendar to current day. */ +void +calendar_goto_today (void) +{ + date_t today; + + calendar_store_current_date (&today); + slctd_day.dd = today.dd; + slctd_day.mm = today.mm; + slctd_day.yyyy = today.yyyy; +} + /* * Ask for a date to jump to, then check the correctness of that date * and jump to it. * If the entered date is empty, automatically jump to the current date. - * today is the current day given to that routine, and slctd_day is updated - * with the newly selected date. + * slctd_day is updated with the newly selected date. */ void calendar_change_day (int datefmt) @@ -340,7 +351,6 @@ calendar_change_day (int datefmt) #define LDAY 11 char selected_day[LDAY] = ""; char outstr[BUFSIZ]; - date_t today; int dday, dmonth, dyear; int wrong_day = 1; char *mesg_line1 = @@ -359,12 +369,8 @@ calendar_change_day (int datefmt) { if (strlen (selected_day) == 0) { - calendar_store_current_date (&today); - /* go to today */ wrong_day = 0; - slctd_day.dd = today.dd; - slctd_day.mm = today.mm; - slctd_day.yyyy = today.yyyy; + calendar_goto_today (); } else if (strlen (selected_day) != LDAY - 1) { @@ -414,7 +420,7 @@ date_change (struct tm *date, int delta_month, int delta_day) void calendar_move (move_t move) { - int ret; + int ret, days_to_remove, days_to_add; struct tm t; memset (&t, 0, sizeof (struct tm)); @@ -422,6 +428,7 @@ calendar_move (move_t move) t.tm_mon = slctd_day.mm - 1; t.tm_year = slctd_day.yyyy - 1900; + ret = 1; switch (move) { case UP: @@ -448,6 +455,24 @@ calendar_move (move_t move) return; ret = date_change (&t, 0, 1); break; + case WEEK_START: + /* Normalize struct tm to get week day number. */ + mktime (&t); + if (calendar_week_begins_on_monday ()) + days_to_remove = ((t.tm_wday == 0) ? WEEKINDAYS - 1 : t.tm_wday - 1); + else + days_to_remove = ((t.tm_wday == 0) ? 0 : t.tm_wday); + ret = date_change (&t, 0, 0 - days_to_remove); + break; + case WEEK_END: + mktime (&t); + if (calendar_week_begins_on_monday ()) + days_to_add = ((t.tm_wday == 0) ? 0 : WEEKINDAYS - t.tm_wday); + else + days_to_add = ((t.tm_wday == 0) ? + WEEKINDAYS - 1 : WEEKINDAYS - 1 - t.tm_wday); + ret = date_change (&t, 0, days_to_add); + break; default: ret = 1; /* NOTREACHED */ diff --git a/src/calendar.h b/src/calendar.h index 3e1736d..dab98a1 100755 --- a/src/calendar.h +++ b/src/calendar.h @@ -1,4 +1,4 @@ -/* $calcurse: calendar.h,v 1.10 2008/04/12 21:14:03 culot Exp $ */ +/* $calcurse: calendar.h,v 1.11 2008/08/03 18:41:55 culot Exp $ */ /* * Calcurse - text-based organizer @@ -72,6 +72,8 @@ typedef enum DOWN, LEFT, RIGHT, + WEEK_START, + WEEK_END, MOVES } move_t; @@ -87,6 +89,7 @@ void calendar_init_slctd_day (void); date_t *calendar_get_slctd_day (void); long calendar_get_slctd_day_sec (void); void calendar_update_panel (WINDOW *); +void calendar_goto_today (void); void calendar_change_day (int); void calendar_move (move_t); char *calendar_get_pom (time_t); @@ -1,4 +1,4 @@ -/* $calcurse: help.c,v 1.26 2008/04/20 09:33:09 culot Exp $ */ +/* $calcurse: help.c,v 1.27 2008/08/03 18:41:55 culot Exp $ */ /* * Calcurse - text-based organizer @@ -175,6 +175,7 @@ wanted_page (int ch) case CTRL ('j'): case CTRL ('k'): case CTRL ('l'): + case CTRL ('g'): page = HELP_GENERAL; break; @@ -186,14 +187,16 @@ wanted_page (int ch) page = HELP_EXPORT; break; + case '0': + case '$': case 'h': case 'l': case 'j': case 'k': - case 259: - case 258: - case 260: - case 261: + case KEY_UP: + case KEY_DOWN: + case KEY_RIGHT: + case KEY_LEFT: page = HELP_DISPLACEMENT; break; @@ -315,6 +318,9 @@ help_screen (void) " move to previous day H < > L move to next day\n" " J v \n" " move to next week\n" + "\nMoreover, while inside the calendar panel, the '0' (zero) key moves\n" + "to the first day of the week, and the '$' key selects the last day of\n" + "the week.\n" "\nWhen the Appointment or ToDo panel is selected, the up and down keys\n" "(respectively K or up arrow, and J or down arrow) allows you to select\n" "an item from those lists."); @@ -350,7 +356,9 @@ help_screen (void) "\nUsing this command, you do not need to travel to that day using\n" "the displacement keys inside the calendar panel.\n" "If you hit [ENTER] without specifying any date, Calcurse checks the\n" - "system current date and you will be taken to that date."); + "system current date and you will be taken to that date.\n" + "\nNotice that pressing ^G (Control + G), whatever panel is\n" + "selected, will select current day in the calendar."); hscr[HELP_DELETE].title = _("Delete:\n"); hscr[HELP_DELETE].text = @@ -534,7 +542,8 @@ help_screen (void) " '^H' : -1 Day -> move to previous day\n" " '^L' : +1 Day -> move to next day\n" " '^K' : -1 Week -> move to previous week\n" - " '^J' : +1 Week -> move to next week"); + " '^J' : +1 Week -> move to next week\n" + " '^G' : Goto today -> move to current day"); hscr[HELP_OTHER].title = _("OtherCmd:\n"); hscr[HELP_OTHER].text = diff --git a/src/utils.c b/src/utils.c index 7f89f90..0263482 100755 --- a/src/utils.c +++ b/src/utils.c @@ -1,4 +1,4 @@ -/* $calcurse: utils.c,v 1.45 2008/04/12 21:14:03 culot Exp $ */ +/* $calcurse: utils.c,v 1.46 2008/08/03 18:41:55 culot Exp $ */ /* * Calcurse - text-based organizer @@ -442,19 +442,22 @@ status_bar (void) binding_t eday = { "^HL", _("-+1 Day") }; binding_t ewek = { "^KJ", _("-+1 Week") }; binding_t othr = { " O", _("OtherCmd") }; + binding_t today = {" ^G", _("Today") }; + binding_t weekb = {" 0", _("beg Week") }; + binding_t weeke = {" $", _("end Week") }; binding_t *binding[TOTAL_CMDS] = { /* calendar keys */ - &help, &quit, &save, &export, &day, &week, &tab, &togo, &appt, - &todo, &conf, &othr, &eday, &ewek, &draw, &othr, + &help, &quit, &save, &export, &day, &week, &weekb, &weeke, &tab, + &togo, &conf, &othr, &appt, &todo, &eday, &ewek, &draw, &today, &othr, /* appointment keys */ &help, &quit, &save, &export, &add, &del, &edit, &view, &rept, &updn, &flag, &othr, &enote, &vnote, &appt, &todo, &eday, &ewek, - &conf, &togo, &tab, &draw, &othr, + &conf, &togo, &tab, &draw, &today, &othr, /* todo keys */ &help, &quit, &save, &export, &add, &del, &edit, &view, &prio, &updn, &tab, &othr, &enote, &vnote, &appt, &todo, &eday, &ewek, - &conf, &togo, &draw, &othr + &conf, &togo, &draw, &today, &othr }; /* Total length of a command. */ @@ -764,15 +767,11 @@ other_status_page (int panel) default: ierror (error, IERROR_FATAL); } - max_page = ceil (nb_item / (2 * CMDS_PER_LINE)) + 1; + max_page = ceil (nb_item / (2 * CMDS_PER_LINE + 1)) + 1; if (status_page < max_page) - { - status_page++; - } + status_page++; else - { - status_page = 1; - } + status_page = 1; } /* Returns the beginning of current day in seconds from 1900. */ diff --git a/src/utils.h b/src/utils.h index c51b7ae..35e4c96 100755 --- a/src/utils.h +++ b/src/utils.h @@ -1,4 +1,4 @@ -/* $calcurse: utils.h,v 1.29 2008/04/12 21:14:03 culot Exp $ */ +/* $calcurse: utils.h,v 1.30 2008/08/03 18:41:55 culot Exp $ */ /* * Calcurse - text-based organizer @@ -38,9 +38,9 @@ #define SPC 32 /* ASCII code for white space */ -#define NB_CAL_CMDS 16 /* number of commands while in cal view */ -#define NB_APP_CMDS 23 /* same thing while in appointment view */ -#define NB_TOD_CMDS 22 /* same thing while in todo view */ +#define NB_CAL_CMDS 19 /* number of commands while in cal view */ +#define NB_APP_CMDS 24 /* same thing while in appointment view */ +#define NB_TOD_CMDS 23 /* same thing while in todo view */ #define TOTAL_CMDS NB_CAL_CMDS + NB_APP_CMDS + NB_TOD_CMDS #define NB_PANELS 3 /* 3 panels: CALENDAR, APPOINTMENT, TODO */ #define CMDS_PER_LINE 6 /* max number of commands per line */ |