diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/calcurse.c | 12 | ||||
-rw-r--r-- | src/calcurse.h | 2 | ||||
-rw-r--r-- | src/calendar.c | 14 |
3 files changed, 15 insertions, 13 deletions
diff --git a/src/calcurse.c b/src/calcurse.c index 2540a1f..05d8f6a 100644 --- a/src/calcurse.c +++ b/src/calcurse.c @@ -478,7 +478,7 @@ main (int argc, char **argv) case KEY_MOVE_RIGHT: if (wins_slctd () == CAL || key == KEY_GENERIC_NEXT_DAY) { - calendar_move (RIGHT); + calendar_move (RIGHT, 1); inday = do_storage (1); wins_update (FLAG_CAL | FLAG_APP); } @@ -488,7 +488,7 @@ main (int argc, char **argv) case KEY_MOVE_LEFT: if (wins_slctd () == CAL || key == KEY_GENERIC_PREV_DAY) { - calendar_move (LEFT); + calendar_move (LEFT, 1); inday = do_storage (1); wins_update (FLAG_CAL | FLAG_APP); } @@ -498,7 +498,7 @@ main (int argc, char **argv) case KEY_MOVE_UP: if (wins_slctd () == CAL || key == KEY_GENERIC_PREV_WEEK) { - calendar_move (UP); + calendar_move (UP, 1); inday = do_storage (1); wins_update (FLAG_CAL | FLAG_APP); } @@ -521,7 +521,7 @@ main (int argc, char **argv) case KEY_MOVE_DOWN: if (wins_slctd () == CAL || key == KEY_GENERIC_NEXT_WEEK) { - calendar_move (DOWN); + calendar_move (DOWN, 1); inday = do_storage (1); wins_update (FLAG_CAL | FLAG_APP); } @@ -544,7 +544,7 @@ main (int argc, char **argv) case KEY_START_OF_WEEK: if (wins_slctd () == CAL) { - calendar_move (WEEK_START); + calendar_move (WEEK_START, 1); inday = do_storage (1); wins_update (FLAG_CAL | FLAG_APP); } @@ -553,7 +553,7 @@ main (int argc, char **argv) case KEY_END_OF_WEEK: if (wins_slctd () == CAL) { - calendar_move (WEEK_END); + calendar_move (WEEK_END, 1); inday = do_storage (1); wins_update (FLAG_CAL | FLAG_APP); } diff --git a/src/calcurse.h b/src/calcurse.h index aaf9e24..37bf2c2 100644 --- a/src/calcurse.h +++ b/src/calcurse.h @@ -611,7 +611,7 @@ long calendar_get_slctd_day_sec (void); void calendar_update_panel (struct window *); void calendar_goto_today (void); void calendar_change_day (int); -void calendar_move (enum move); +void calendar_move (enum move, int); long calendar_start_of_year (void); long calendar_end_of_year (void); char *calendar_get_pom (time_t); diff --git a/src/calendar.c b/src/calendar.c index 6664a93..ae2af26 100644 --- a/src/calendar.c +++ b/src/calendar.c @@ -665,7 +665,7 @@ calendar_change_day (int datefmt) } void -calendar_move (enum move move) +calendar_move (enum move move, int count) { int ret, days_to_remove, days_to_add; struct tm t; @@ -681,25 +681,25 @@ calendar_move (enum move move) if ((slctd_day.dd <= 7) && (slctd_day.mm == 1) && (slctd_day.yyyy == 1902)) return; - ret = date_change (&t, 0, -WEEKINDAYS); + ret = date_change (&t, 0, -count * WEEKINDAYS); break; case DOWN: if ((slctd_day.dd > days[slctd_day.mm - 1] - 7) && (slctd_day.mm == 12) && (slctd_day.yyyy == 2037)) return; - ret = date_change (&t, 0, WEEKINDAYS); + ret = date_change (&t, 0, count * WEEKINDAYS); break; case LEFT: if ((slctd_day.dd == 1) && (slctd_day.mm == 1) && (slctd_day.yyyy == 1902)) return; - ret = date_change (&t, 0, -1); + ret = date_change (&t, 0, -count); break; case RIGHT: if ((slctd_day.dd == 31) && (slctd_day.mm == 12) && (slctd_day.yyyy == 2037)) return; - ret = date_change (&t, 0, 1); + ret = date_change (&t, 0, count); break; case WEEK_START: /* Normalize struct tm to get week day number. */ @@ -708,7 +708,8 @@ calendar_move (enum move move) 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); + days_to_remove += (count - 1) * WEEKINDAYS; + ret = date_change (&t, 0, -days_to_remove); break; case WEEK_END: (void)mktime (&t); @@ -717,6 +718,7 @@ calendar_move (enum move move) else days_to_add = ((t.tm_wday == 0) ? WEEKINDAYS - 1 : WEEKINDAYS - 1 - t.tm_wday); + days_to_add += (count - 1) * WEEKINDAYS; ret = date_change (&t, 0, days_to_add); break; default: |