summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 29ebb7c)
raw | patch | inline | side by side (parent: 29ebb7c)
author | Jonas Fonseca <jonas.fonseca@savoirfairelinux.com> | |
Fri, 11 Dec 2009 22:52:47 +0000 (17:52 -0500) | ||
committer | Jonas Fonseca <jonas.fonseca@savoirfairelinux.com> | |
Fri, 11 Dec 2009 23:12:39 +0000 (18:12 -0500) |
tig.c | patch | blob | history |
index 399567b07416ba63bb9a5bd4790f5fd0722c0cad..08b2993b7f8a664384c5f4812055162d85448682 100644 (file)
--- a/tig.c
+++ b/tig.c
}
static void
-toggle_date_option(enum date *date)
+toggle_enum_option_do(unsigned int *opt, const char *help,
+ const struct enum_map *map, size_t size)
{
- static const char *help[] = {
- "no",
- "default",
- "relative",
- "short"
- };
-
- *date = (*date + 1) % ARRAY_SIZE(help);
+ *opt = (*opt + 1) % size;
redraw_display(FALSE);
- report("Displaying %s dates", help[*date]);
+ report("Displaying %s %s", enum_name(map[*opt]), help);
}
+#define toggle_enum_option(opt, help, map) \
+ toggle_enum_option_do(opt, help, map, ARRAY_SIZE(map))
+
+#define toggle_date() toggle_enum_option(&opt_date, "dates", date_map)
+
static void
toggle_view_option(bool *option, const char *help)
{
if (prompt_menu("Toggle option", menu, &selected)) {
if (menu[selected].data == &opt_date)
- toggle_date_option(menu[selected].data);
+ toggle_date();
else
toggle_view_option(menu[selected].data, menu[selected].text);
}
break;
case REQ_TOGGLE_DATE:
- toggle_date_option(&opt_date);
+ toggle_date();
break;
case REQ_TOGGLE_AUTHOR: