static struct gui_theme theme;
-static void com_help(void);
-static void com_reread_conf(void);
-static void com_enlarge_top_win(void);
-static void com_shrink_top_win(void);
-static void com_version(void);
-__noreturn static void com_quit(void);
-static void com_refresh(void);
-static void com_ll_incr(void);
-static void com_ll_decr(void);
-static void com_prev_theme(void);
-static void com_next_theme(void);
-static void com_scroll_up(void);
-static void com_scroll_down(void);
-static void com_page_up(void);
-static void com_page_down(void);
-static void com_cancel_scrolling(void);
-static void com_scroll_top(void);
-
-static struct gui_command command_list[] = {
- {
- .key = "?",
- .name = "help",
- .description = "print help",
- .handler = com_help
- }, {
- .key = "+",
- .name = "enlarge_win",
- .description = "enlarge the top window",
- .handler = com_enlarge_top_win
- }, {
- .key = "-",
- .name = "shrink_win",
- .description = "shrink the top window",
- .handler = com_shrink_top_win
- }, {
- .key = "r",
- .name = "reread_conf",
- .description = "reread configuration file",
- .handler = com_reread_conf
- }, {
- .key = "q",
- .name = "quit",
- .description = "exit para_gui",
- .handler = com_quit
- }, {
- .key = "^L",
- .name = "refresh",
- .description = "redraw the screen",
- .handler = com_refresh
- }, {
- .key = ".",
- .name = "next_theme",
- .description = "switch to next theme",
- .handler = com_next_theme
- }, {
- .key = ",",
- .name = "prev_theme",
- .description = "switch to previous stream",
- .handler = com_prev_theme
- }, {
- .key = ">",
- .name = "ll_incr",
- .description = "increase loglevel (decreases verbosity)",
- .handler = com_ll_incr
- }, {
- .key = "<",
- .name = "ll_decr",
- .description = "decrease loglevel (increases verbosity)",
- .handler = com_ll_decr
- }, {
- .key = "V",
- .name = "version",
- .description = "show the para_gui version",
- .handler = com_version
- }, {
- .key = "<up>",
- .name = "scroll_up",
- .description = "scroll up one line",
- .handler = com_scroll_up
- }, {
- .key = "<down>",
- .name = "scroll_down",
- .description = "scroll down one line",
- .handler = com_scroll_down
- }, {
- .key = "<ppage>",
- .name = "page_up",
- .description = "scroll up one page",
- .handler = com_page_up
- }, {
- .key = "<npage>",
- .name = "page_down",
- .description = "scroll down one page",
- .handler = com_page_down
- }, {
- .key = "<home>",
- .name = "scroll_top",
- .description = "scroll to top of buffer",
- .handler = com_scroll_top
- }, {
- .key = "<end>",
- .name = "cancel_scroll",
- .description = "deactivate scroll mode",
- .handler = com_cancel_scrolling
- }, {
- .handler = NULL
- }
-};
+#define GUI_COMMANDS \
+ GUI_COMMAND(help, "?", "print help") \
+ GUI_COMMAND(enlarge_top_win, "+", "enlarge the top window") \
+ GUI_COMMAND(shrink_top_win, "-", "shrink the top window") \
+ GUI_COMMAND(reread_conf, "r", "reread configuration file") \
+ GUI_COMMAND(quit, "q", "exit para_gui") \
+ GUI_COMMAND(refresh, "^L", "redraw the screen") \
+ GUI_COMMAND(next_theme, ".", "switch to next theme") \
+ GUI_COMMAND(prev_theme, ",", "switch to previous theme") \
+ GUI_COMMAND(ll_incr, ">", "increase loglevel (decreases verbosity)") \
+ GUI_COMMAND(ll_decr, "<", "decrease loglevel (increases verbosity)") \
+ GUI_COMMAND(version, "V", "show the para_gui version") \
+ GUI_COMMAND(scroll_up, "<up>", "scroll up one line") \
+ GUI_COMMAND(scroll_down, "<down>", "scroll_down") \
+ GUI_COMMAND(page_up, "<ppage>", "scroll up one page") \
+ GUI_COMMAND(page_down, "<npage>", "scroll down one page") \
+ GUI_COMMAND(scroll_top, "<home>", "scroll to top of buffer") \
+ GUI_COMMAND(cancel_scroll, "<end>", "deactivate scroll mode") \
+
+/* declare command handlers */
+#define GUI_COMMAND(_c, _k, _d) \
+ static void com_ ## _c(void);
+GUI_COMMANDS
+
+#undef GUI_COMMAND
+
+/* define command array */
+#define GUI_COMMAND(_c, _k, _d) \
+ { \
+ .key = _k, \
+ .name = #_c, \
+ .description = _d, \
+ .handler = com_ ## _c \
+ },
+
+static struct gui_command command_list[] = {GUI_COMMANDS {.name = NULL}};
static int find_cmd_byname(char *name)
{
print_in_bar(COLOR_ERRMSG, "top of buffer is shown\n");
}
-static void com_cancel_scrolling(void)
+static void com_cancel_scroll(void)
{
if (scroll_position == 0) {