summaryrefslogtreecommitdiff
path: root/src/calendar.c
diff options
context:
space:
mode:
authorLukas Fleischer <calcurse@cryptocrack.de>2011-09-29 16:22:07 +0200
committerLukas Fleischer <calcurse@cryptocrack.de>2011-10-06 12:37:06 +0200
commit2d5ce0d95c50003074943eaa05b3c35255286279 (patch)
tree55d8b66076ef2a7e354aceb29e0fbad9c136d934 /src/calendar.c
parent6bdc36b15a15c98bbb33582908740346675485cc (diff)
downloadcalcurse-2d5ce0d95c50003074943eaa05b3c35255286279.zip
src/calendar.c: Add a count parameter to calendar_move()
Allows for moving more than one step forward/backward. This is not used anywhere yet but a key binding will likely be added in one of the following patches. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
Diffstat (limited to 'src/calendar.c')
-rw-r--r--src/calendar.c14
1 files changed, 8 insertions, 6 deletions
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: