Rename displacement enumeration elements

* Rename "LEFT" to "DAY_PREV", "RIGHT" to "DAY_NEXT", "UP" to
  "WEEK_PREV" and "DOWN" to "WEEK_NEXT" to reflect the semantics of
  these operations. Remove the unneeded "MOVES" element.

* Reorder code to improve consistency.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
This commit is contained in:
Lukas Fleischer 2012-06-12 22:42:28 +02:00
parent 844d35e851
commit 42c486d30d
6 changed files with 44 additions and 45 deletions

View File

@ -398,19 +398,19 @@ int main(int argc, char **argv)
wins_update(FLAG_ALL); wins_update(FLAG_ALL);
break; break;
case KEY_GENERIC_NEXT_DAY: case KEY_GENERIC_PREV_DAY:
case KEY_MOVE_RIGHT: case KEY_MOVE_LEFT:
if (wins_slctd() == CAL || key == KEY_GENERIC_NEXT_DAY) { if (wins_slctd() == CAL || key == KEY_GENERIC_PREV_DAY) {
calendar_move(RIGHT, count); calendar_move(DAY_PREV, count);
inday = do_storage(1); inday = do_storage(1);
wins_update(FLAG_CAL | FLAG_APP); wins_update(FLAG_CAL | FLAG_APP);
} }
break; break;
case KEY_GENERIC_PREV_DAY: case KEY_GENERIC_NEXT_DAY:
case KEY_MOVE_LEFT: case KEY_MOVE_RIGHT:
if (wins_slctd() == CAL || key == KEY_GENERIC_PREV_DAY) { if (wins_slctd() == CAL || key == KEY_GENERIC_NEXT_DAY) {
calendar_move(LEFT, count); calendar_move(DAY_NEXT, count);
inday = do_storage(1); inday = do_storage(1);
wins_update(FLAG_CAL | FLAG_APP); wins_update(FLAG_CAL | FLAG_APP);
} }
@ -419,7 +419,7 @@ int main(int argc, char **argv)
case KEY_GENERIC_PREV_WEEK: case KEY_GENERIC_PREV_WEEK:
case KEY_MOVE_UP: case KEY_MOVE_UP:
if (wins_slctd() == CAL || key == KEY_GENERIC_PREV_WEEK) { if (wins_slctd() == CAL || key == KEY_GENERIC_PREV_WEEK) {
calendar_move(UP, count); calendar_move(WEEK_PREV, count);
inday = do_storage(1); inday = do_storage(1);
wins_update(FLAG_CAL | FLAG_APP); wins_update(FLAG_CAL | FLAG_APP);
} else if (wins_slctd() == APP) { } else if (wins_slctd() == APP) {
@ -441,7 +441,7 @@ int main(int argc, char **argv)
case KEY_GENERIC_NEXT_WEEK: case KEY_GENERIC_NEXT_WEEK:
case KEY_MOVE_DOWN: case KEY_MOVE_DOWN:
if (wins_slctd() == CAL || key == KEY_GENERIC_NEXT_WEEK) { if (wins_slctd() == CAL || key == KEY_GENERIC_NEXT_WEEK) {
calendar_move(DOWN, count); calendar_move(WEEK_NEXT, count);
inday = do_storage(1); inday = do_storage(1);
wins_update(FLAG_CAL | FLAG_APP); wins_update(FLAG_CAL | FLAG_APP);
} else if (wins_slctd() == APP) { } else if (wins_slctd() == APP) {

View File

@ -399,10 +399,10 @@ enum key {
KEY_GENERIC_REDRAW, KEY_GENERIC_REDRAW,
KEY_GENERIC_ADD_APPT, KEY_GENERIC_ADD_APPT,
KEY_GENERIC_ADD_TODO, KEY_GENERIC_ADD_TODO,
KEY_GENERIC_NEXT_DAY,
KEY_GENERIC_PREV_DAY, KEY_GENERIC_PREV_DAY,
KEY_GENERIC_NEXT_WEEK, KEY_GENERIC_NEXT_DAY,
KEY_GENERIC_PREV_WEEK, KEY_GENERIC_PREV_WEEK,
KEY_GENERIC_NEXT_WEEK,
KEY_GENERIC_SCROLL_DOWN, KEY_GENERIC_SCROLL_DOWN,
KEY_GENERIC_SCROLL_UP, KEY_GENERIC_SCROLL_UP,
KEY_GENERIC_GOTO_TODAY, KEY_GENERIC_GOTO_TODAY,
@ -534,13 +534,12 @@ enum wday {
/* Possible movements inside calendar. */ /* Possible movements inside calendar. */
enum move { enum move {
UP, DAY_PREV,
DOWN, DAY_NEXT,
LEFT, WEEK_PREV,
RIGHT, WEEK_NEXT,
WEEK_START, WEEK_START,
WEEK_END, WEEK_END
MOVES
}; };
/* Available color pairs. */ /* Available color pairs. */

View File

@ -614,18 +614,18 @@ void calendar_move(enum move move, int count)
t.tm_year = slctd_day.yyyy - 1900; t.tm_year = slctd_day.yyyy - 1900;
switch (move) { switch (move) {
case UP: case DAY_PREV:
ret = date_change(&t, 0, -count * WEEKINDAYS);
break;
case DOWN:
ret = date_change(&t, 0, count * WEEKINDAYS);
break;
case LEFT:
ret = date_change(&t, 0, -count); ret = date_change(&t, 0, -count);
break; break;
case RIGHT: case DAY_NEXT:
ret = date_change(&t, 0, count); ret = date_change(&t, 0, count);
break; break;
case WEEK_PREV:
ret = date_change(&t, 0, -count * WEEKINDAYS);
break;
case WEEK_NEXT:
ret = date_change(&t, 0, count * WEEKINDAYS);
break;
case WEEK_START: case WEEK_START:
/* Normalize struct tm to get week day number. */ /* Normalize struct tm to get week day number. */
mktime(&t); mktime(&t);

View File

@ -116,10 +116,10 @@ help_write_pad(struct window *win, char *title, char *text, enum key action)
case KEY_GENERIC_REDRAW: case KEY_GENERIC_REDRAW:
case KEY_GENERIC_ADD_APPT: case KEY_GENERIC_ADD_APPT:
case KEY_GENERIC_ADD_TODO: case KEY_GENERIC_ADD_TODO:
case KEY_GENERIC_NEXT_DAY:
case KEY_GENERIC_PREV_DAY: case KEY_GENERIC_PREV_DAY:
case KEY_GENERIC_NEXT_WEEK: case KEY_GENERIC_NEXT_DAY:
case KEY_GENERIC_PREV_WEEK: case KEY_GENERIC_PREV_WEEK:
case KEY_GENERIC_NEXT_WEEK:
case KEY_GENERIC_GOTO_TODAY: case KEY_GENERIC_GOTO_TODAY:
case KEY_GENERIC_CREDITS: case KEY_GENERIC_CREDITS:
case KEY_GENERIC_CUT: case KEY_GENERIC_CUT:
@ -212,10 +212,10 @@ static int wanted_page(int ch)
case KEY_GENERIC_REDRAW: case KEY_GENERIC_REDRAW:
case KEY_GENERIC_ADD_APPT: case KEY_GENERIC_ADD_APPT:
case KEY_GENERIC_ADD_TODO: case KEY_GENERIC_ADD_TODO:
case KEY_GENERIC_NEXT_DAY:
case KEY_GENERIC_PREV_DAY: case KEY_GENERIC_PREV_DAY:
case KEY_GENERIC_NEXT_WEEK: case KEY_GENERIC_NEXT_DAY:
case KEY_GENERIC_PREV_WEEK: case KEY_GENERIC_PREV_WEEK:
case KEY_GENERIC_NEXT_WEEK:
case KEY_GENERIC_GOTO_TODAY: case KEY_GENERIC_GOTO_TODAY:
page = HELP_GENERAL; page = HELP_GENERAL;
break; break;

View File

@ -67,10 +67,10 @@ static struct keydef_s keydef[NBKEYS] = {
{"generic-redraw", "C-r"}, {"generic-redraw", "C-r"},
{"generic-add-appt", "C-a"}, {"generic-add-appt", "C-a"},
{"generic-add-todo", "C-t"}, {"generic-add-todo", "C-t"},
{"generic-next-day", "C-l"},
{"generic-prev-day", "C-h"}, {"generic-prev-day", "C-h"},
{"generic-next-week", "C-j"}, {"generic-next-day", "C-l"},
{"generic-prev-week", "C-k"}, {"generic-prev-week", "C-k"},
{"generic-next-week", "C-j"},
{"generic-scroll-down", "C-n"}, {"generic-scroll-down", "C-n"},
{"generic-scroll-up", "C-p"}, {"generic-scroll-up", "C-p"},
{"generic-goto-today", "C-g"}, {"generic-goto-today", "C-g"},
@ -455,17 +455,17 @@ void keys_popup_info(enum key key)
_("Add an appointment, whichever panel is currently selected."); _("Add an appointment, whichever panel is currently selected.");
info[KEY_GENERIC_ADD_TODO] = info[KEY_GENERIC_ADD_TODO] =
_("Add a todo item, whichever panel is currently selected."); _("Add a todo item, whichever panel is currently selected.");
info[KEY_GENERIC_NEXT_DAY] =
_("Move to next day in calendar, whichever panel is currently selected.");
info[KEY_GENERIC_PREV_DAY] = info[KEY_GENERIC_PREV_DAY] =
_("Move to previous day in calendar, whichever panel is currently " _("Move to previous day in calendar, whichever panel is currently "
"selected."); "selected.");
info[KEY_GENERIC_NEXT_WEEK] = info[KEY_GENERIC_NEXT_DAY] =
_ _("Move to next day in calendar, whichever panel is currently selected.");
("Move to next week in calendar, whichever panel is currently selected.");
info[KEY_GENERIC_PREV_WEEK] = info[KEY_GENERIC_PREV_WEEK] =
_("Move to previous week in calendar, whichever panel is currently " _("Move to previous week in calendar, whichever panel is currently "
"selected"); "selected");
info[KEY_GENERIC_NEXT_WEEK] =
_
("Move to next week in calendar, whichever panel is currently selected.");
info[KEY_GENERIC_SCROLL_DOWN] = info[KEY_GENERIC_SCROLL_DOWN] =
_ _
("Scroll window down (e.g. when displaying text inside a popup window)."); ("Scroll window down (e.g. when displaying text inside a popup window).");

View File

@ -597,10 +597,10 @@ void wins_status_bar(void)
struct binding draw = { _("Redraw"), KEY_GENERIC_REDRAW }; struct binding draw = { _("Redraw"), KEY_GENERIC_REDRAW };
struct binding appt = { _("Add Appt"), KEY_GENERIC_ADD_APPT }; struct binding appt = { _("Add Appt"), KEY_GENERIC_ADD_APPT };
struct binding todo = { _("Add Todo"), KEY_GENERIC_ADD_TODO }; struct binding todo = { _("Add Todo"), KEY_GENERIC_ADD_TODO };
struct binding gnday = { _("+1 Day"), KEY_GENERIC_NEXT_DAY };
struct binding gpday = { _("-1 Day"), KEY_GENERIC_PREV_DAY }; struct binding gpday = { _("-1 Day"), KEY_GENERIC_PREV_DAY };
struct binding gnweek = { _("+1 Week"), KEY_GENERIC_NEXT_WEEK }; struct binding gnday = { _("+1 Day"), KEY_GENERIC_NEXT_DAY };
struct binding gpweek = { _("-1 Week"), KEY_GENERIC_PREV_WEEK }; struct binding gpweek = { _("-1 Week"), KEY_GENERIC_PREV_WEEK };
struct binding gnweek = { _("+1 Week"), KEY_GENERIC_NEXT_WEEK };
struct binding today = { _("Today"), KEY_GENERIC_GOTO_TODAY }; struct binding today = { _("Today"), KEY_GENERIC_GOTO_TODAY };
struct binding nview = { _("Nxt View"), KEY_GENERIC_SCROLL_DOWN }; struct binding nview = { _("Nxt View"), KEY_GENERIC_SCROLL_DOWN };
struct binding pview = { _("Prv View"), KEY_GENERIC_SCROLL_UP }; struct binding pview = { _("Prv View"), KEY_GENERIC_SCROLL_UP };
@ -625,20 +625,20 @@ void wins_status_bar(void)
struct binding *bindings_cal[] = { struct binding *bindings_cal[] = {
&help, &quit, &save, &chgvu, &nview, &pview, &up, &down, &left, &right, &help, &quit, &save, &chgvu, &nview, &pview, &up, &down, &left, &right,
&togo, &import, &export, &weekb, &weeke, &appt, &todo, &gnday, &gpday, &togo, &import, &export, &weekb, &weeke, &appt, &todo, &gpday, &gnday,
&gnweek, &gpweek, &draw, &today, &conf &gpweek, &gnweek, &draw, &today, &conf
}; };
struct binding *bindings_apoint[] = { struct binding *bindings_apoint[] = {
&help, &quit, &save, &chgvu, &import, &export, &add, &del, &edit, &view, &help, &quit, &save, &chgvu, &import, &export, &add, &del, &edit, &view,
&pipe, &draw, &rept, &flag, &enote, &vnote, &up, &down, &gnday, &gpday, &pipe, &draw, &rept, &flag, &enote, &vnote, &up, &down, &gpday, &gnday,
&gnweek, &gpweek, &togo, &today, &conf, &appt, &todo, &cut, &paste &gpweek, &gnweek, &togo, &today, &conf, &appt, &todo, &cut, &paste
}; };
struct binding *bindings_todo[] = { struct binding *bindings_todo[] = {
&help, &quit, &save, &chgvu, &import, &export, &add, &del, &edit, &view, &help, &quit, &save, &chgvu, &import, &export, &add, &del, &edit, &view,
&pipe, &flag, &rprio, &lprio, &enote, &vnote, &up, &down, &gnday, &gpday, &pipe, &flag, &rprio, &lprio, &enote, &vnote, &up, &down, &gpday, &gnday,
&gnweek, &gpweek, &togo, &today, &conf, &appt, &todo, &draw &gpweek, &gnweek, &togo, &today, &conf, &appt, &todo, &draw
}; };
enum win active_panel = wins_slctd(); enum win active_panel = wins_slctd();