Add key bindings to go to the previous/next month/year
In addition to generic key bindings for moving one day (week) forward/backward, define similar bindings for moving a month or a year. Of course, count prefixes are allowed here as well. Also add status bar hints and help texts. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
This commit is contained in:
parent
42c486d30d
commit
cabc22e032
@ -460,6 +460,30 @@ int main(int argc, char **argv)
|
||||
}
|
||||
break;
|
||||
|
||||
case KEY_GENERIC_PREV_MONTH:
|
||||
calendar_move(MONTH_PREV, count);
|
||||
inday = do_storage(1);
|
||||
wins_update(FLAG_CAL | FLAG_APP);
|
||||
break;
|
||||
|
||||
case KEY_GENERIC_NEXT_MONTH:
|
||||
calendar_move(MONTH_NEXT, count);
|
||||
inday = do_storage(1);
|
||||
wins_update(FLAG_CAL | FLAG_APP);
|
||||
break;
|
||||
|
||||
case KEY_GENERIC_PREV_YEAR:
|
||||
calendar_move(YEAR_PREV, count);
|
||||
inday = do_storage(1);
|
||||
wins_update(FLAG_CAL | FLAG_APP);
|
||||
break;
|
||||
|
||||
case KEY_GENERIC_NEXT_YEAR:
|
||||
calendar_move(YEAR_NEXT, count);
|
||||
inday = do_storage(1);
|
||||
wins_update(FLAG_CAL | FLAG_APP);
|
||||
break;
|
||||
|
||||
case KEY_START_OF_WEEK:
|
||||
if (wins_slctd() == CAL) {
|
||||
calendar_move(WEEK_START, count);
|
||||
|
@ -403,6 +403,10 @@ enum key {
|
||||
KEY_GENERIC_NEXT_DAY,
|
||||
KEY_GENERIC_PREV_WEEK,
|
||||
KEY_GENERIC_NEXT_WEEK,
|
||||
KEY_GENERIC_PREV_MONTH,
|
||||
KEY_GENERIC_NEXT_MONTH,
|
||||
KEY_GENERIC_PREV_YEAR,
|
||||
KEY_GENERIC_NEXT_YEAR,
|
||||
KEY_GENERIC_SCROLL_DOWN,
|
||||
KEY_GENERIC_SCROLL_UP,
|
||||
KEY_GENERIC_GOTO_TODAY,
|
||||
@ -539,7 +543,11 @@ enum move {
|
||||
WEEK_PREV,
|
||||
WEEK_NEXT,
|
||||
WEEK_START,
|
||||
WEEK_END
|
||||
WEEK_END,
|
||||
MONTH_PREV,
|
||||
MONTH_NEXT,
|
||||
YEAR_PREV,
|
||||
YEAR_NEXT
|
||||
};
|
||||
|
||||
/* Available color pairs. */
|
||||
|
@ -626,6 +626,18 @@ void calendar_move(enum move move, int count)
|
||||
case WEEK_NEXT:
|
||||
ret = date_change(&t, 0, count * WEEKINDAYS);
|
||||
break;
|
||||
case MONTH_PREV:
|
||||
ret = date_change(&t, -count, 0);
|
||||
break;
|
||||
case MONTH_NEXT:
|
||||
ret = date_change(&t, count, 0);
|
||||
break;
|
||||
case YEAR_PREV:
|
||||
ret = date_change(&t, -count * YEARINMONTHS, 0);
|
||||
break;
|
||||
case YEAR_NEXT:
|
||||
ret = date_change(&t, count * YEARINMONTHS, 0);
|
||||
break;
|
||||
case WEEK_START:
|
||||
/* Normalize struct tm to get week day number. */
|
||||
mktime(&t);
|
||||
|
16
src/help.c
16
src/help.c
@ -120,6 +120,10 @@ help_write_pad(struct window *win, char *title, char *text, enum key action)
|
||||
case KEY_GENERIC_NEXT_DAY:
|
||||
case KEY_GENERIC_PREV_WEEK:
|
||||
case KEY_GENERIC_NEXT_WEEK:
|
||||
case KEY_GENERIC_PREV_MONTH:
|
||||
case KEY_GENERIC_NEXT_MONTH:
|
||||
case KEY_GENERIC_PREV_YEAR:
|
||||
case KEY_GENERIC_NEXT_YEAR:
|
||||
case KEY_GENERIC_GOTO_TODAY:
|
||||
case KEY_GENERIC_CREDITS:
|
||||
case KEY_GENERIC_CUT:
|
||||
@ -216,6 +220,10 @@ static int wanted_page(int ch)
|
||||
case KEY_GENERIC_NEXT_DAY:
|
||||
case KEY_GENERIC_PREV_WEEK:
|
||||
case KEY_GENERIC_NEXT_WEEK:
|
||||
case KEY_GENERIC_PREV_MONTH:
|
||||
case KEY_GENERIC_NEXT_MONTH:
|
||||
case KEY_GENERIC_PREV_YEAR:
|
||||
case KEY_GENERIC_NEXT_YEAR:
|
||||
case KEY_GENERIC_GOTO_TODAY:
|
||||
page = HELP_GENERAL;
|
||||
break;
|
||||
@ -694,6 +702,10 @@ void help_screen(void)
|
||||
" '%s' : +1 Day -> move to next day\n"
|
||||
" '%s' : -1 Week -> move to previous week\n"
|
||||
" '%s' : +1 Week -> move to next week\n"
|
||||
" '%s' : -1 Month -> move to previous month\n"
|
||||
" '%s' : +1 Month -> move to next month\n"
|
||||
" '%s' : -1 Year -> move to previous year\n"
|
||||
" '%s' : +1 Year -> move to next year\n"
|
||||
" '%s' : Goto today -> move to current day\n"
|
||||
"\nThe '%s' and '%s' keys are used to scroll text upward or downward\n"
|
||||
"when inside specific screens such the help screens for example.\n"
|
||||
@ -706,6 +718,10 @@ void help_screen(void)
|
||||
keys_action_firstkey(KEY_GENERIC_NEXT_DAY),
|
||||
keys_action_firstkey(KEY_GENERIC_PREV_WEEK),
|
||||
keys_action_firstkey(KEY_GENERIC_NEXT_WEEK),
|
||||
keys_action_firstkey(KEY_GENERIC_PREV_MONTH),
|
||||
keys_action_firstkey(KEY_GENERIC_NEXT_MONTH),
|
||||
keys_action_firstkey(KEY_GENERIC_PREV_YEAR),
|
||||
keys_action_firstkey(KEY_GENERIC_NEXT_YEAR),
|
||||
keys_action_firstkey(KEY_GENERIC_GOTO_TODAY),
|
||||
keys_action_firstkey(KEY_GENERIC_SCROLL_UP),
|
||||
keys_action_firstkey(KEY_GENERIC_SCROLL_DOWN));
|
||||
|
17
src/keys.c
17
src/keys.c
@ -71,6 +71,10 @@ static struct keydef_s keydef[NBKEYS] = {
|
||||
{"generic-next-day", "C-l"},
|
||||
{"generic-prev-week", "C-k"},
|
||||
{"generic-next-week", "C-j"},
|
||||
{"generic-prev-month", "M"},
|
||||
{"generic-next-month", "m"},
|
||||
{"generic-prev-year", "Y"},
|
||||
{"generic-next-year", "y"},
|
||||
{"generic-scroll-down", "C-n"},
|
||||
{"generic-scroll-up", "C-p"},
|
||||
{"generic-goto-today", "C-g"},
|
||||
@ -466,6 +470,19 @@ void keys_popup_info(enum key key)
|
||||
info[KEY_GENERIC_NEXT_WEEK] =
|
||||
_
|
||||
("Move to next week in calendar, whichever panel is currently selected.");
|
||||
info[KEY_GENERIC_PREV_MONTH] =
|
||||
_("Move to previous month in calendar, whichever panel is currently "
|
||||
"selected");
|
||||
info[KEY_GENERIC_NEXT_MONTH] =
|
||||
_
|
||||
("Move to next month in calendar, whichever panel is currently "
|
||||
"selected.");
|
||||
info[KEY_GENERIC_PREV_YEAR] =
|
||||
_("Move to previous year in calendar, whichever panel is currently "
|
||||
"selected");
|
||||
info[KEY_GENERIC_NEXT_YEAR] =
|
||||
_
|
||||
("Move to next year in calendar, whichever panel is currently selected.");
|
||||
info[KEY_GENERIC_SCROLL_DOWN] =
|
||||
_
|
||||
("Scroll window down (e.g. when displaying text inside a popup window).");
|
||||
|
13
src/wins.c
13
src/wins.c
@ -601,6 +601,10 @@ void wins_status_bar(void)
|
||||
struct binding gnday = { _("+1 Day"), KEY_GENERIC_NEXT_DAY };
|
||||
struct binding gpweek = { _("-1 Week"), KEY_GENERIC_PREV_WEEK };
|
||||
struct binding gnweek = { _("+1 Week"), KEY_GENERIC_NEXT_WEEK };
|
||||
struct binding gpmonth = { _("-1 Month"), KEY_GENERIC_PREV_MONTH };
|
||||
struct binding gnmonth = { _("+1 Month"), KEY_GENERIC_NEXT_MONTH };
|
||||
struct binding gpyear = { _("-1 Year"), KEY_GENERIC_PREV_YEAR };
|
||||
struct binding gnyear = { _("+1 Year"), KEY_GENERIC_NEXT_YEAR };
|
||||
struct binding today = { _("Today"), KEY_GENERIC_GOTO_TODAY };
|
||||
struct binding nview = { _("Nxt View"), KEY_GENERIC_SCROLL_DOWN };
|
||||
struct binding pview = { _("Prv View"), KEY_GENERIC_SCROLL_UP };
|
||||
@ -626,19 +630,22 @@ void wins_status_bar(void)
|
||||
struct binding *bindings_cal[] = {
|
||||
&help, &quit, &save, &chgvu, &nview, &pview, &up, &down, &left, &right,
|
||||
&togo, &import, &export, &weekb, &weeke, &appt, &todo, &gpday, &gnday,
|
||||
&gpweek, &gnweek, &draw, &today, &conf
|
||||
&gpweek, &gnweek, &gpmonth, &gnmonth, &gpyear, &gnyear, &draw, &today,
|
||||
&conf
|
||||
};
|
||||
|
||||
struct binding *bindings_apoint[] = {
|
||||
&help, &quit, &save, &chgvu, &import, &export, &add, &del, &edit, &view,
|
||||
&pipe, &draw, &rept, &flag, &enote, &vnote, &up, &down, &gpday, &gnday,
|
||||
&gpweek, &gnweek, &togo, &today, &conf, &appt, &todo, &cut, &paste
|
||||
&gpweek, &gnweek, &gpmonth, &gnmonth, &gpyear, &gnyear, &togo, &today,
|
||||
&conf, &appt, &todo, &cut, &paste
|
||||
};
|
||||
|
||||
struct binding *bindings_todo[] = {
|
||||
&help, &quit, &save, &chgvu, &import, &export, &add, &del, &edit, &view,
|
||||
&pipe, &flag, &rprio, &lprio, &enote, &vnote, &up, &down, &gpday, &gnday,
|
||||
&gpweek, &gnweek, &togo, &today, &conf, &appt, &todo, &draw
|
||||
&gpweek, &gnweek, &gpmonth, &gnmonth, &gpyear, &gnyear, &togo, &today,
|
||||
&conf, &appt, &todo, &draw
|
||||
};
|
||||
|
||||
enum win active_panel = wins_slctd();
|
||||
|
Loading…
x
Reference in New Issue
Block a user