Code

increment version number to 0.28
[ncmpc.git] / src / command.c
index 62d68a5e056a65a0db46457ed283c2b0a10adbda..f903165f57a113034df735373395a4a5a3d43a7f 100644 (file)
@@ -1,5 +1,5 @@
 /* ncmpc (Ncurses MPD Client)
- * (c) 2004-2010 The Music Player Daemon Project
+ * (c) 2004-2017 The Music Player Daemon Project
  * Project homepage: http://musicpd.org
  *
  * This program is free software; you can redistribute it and/or modify
  */
 
 #include "command.h"
-#include "config.h"
-#include "ncmpc.h"
 #include "i18n.h"
-#include "mpdclient.h"
-#include "screen.h"
+#include "ncmpc_curses.h"
 
+#include <assert.h>
 #include <ctype.h>
 #include <stdlib.h>
 #include <string.h>
@@ -89,9 +87,9 @@ static command_definition_t cmds[] = {
        { { 'v',  0, 0 }, 0, CMD_LIST_RANGE_SELECT, "range-select",
          N_("Range selection") },
        { { C('N'),  0, 0 }, 0, CMD_LIST_SCROLL_DOWN_LINE, "scroll-down-line",
-         N_("Scroll up one line") },
-       { { C('B'),  0, 0 }, 0, CMD_LIST_SCROLL_UP_LINE, "scroll-up-line",
          N_("Scroll down one line") },
+       { { C('B'),  0, 0 }, 0, CMD_LIST_SCROLL_UP_LINE, "scroll-up-line",
+         N_("Scroll up one line") },
        { { 'N',  0, 0 }, 0, CMD_LIST_SCROLL_DOWN_HALF, "scroll-down-half",
          N_("Scroll up half a screen") },
        { { 'B',  0, 0 }, 0, CMD_LIST_SCROLL_UP_HALF, "scroll-up-half",
@@ -438,22 +436,7 @@ get_key_command(int key)
        return find_key_command(key, cmds);
 }
 
-command_t
-get_keyboard_command(void)
-{
-       int key = wgetch(stdscr);
-       if (key == ERR || key == '\0')
-               return CMD_NONE;
-
-#ifdef HAVE_GETMOUSE
-       if (key == KEY_MOUSE)
-               return CMD_MOUSE_EVENT;
-#endif
-
-       return get_key_command(key);
-}
-
-int
+bool
 assign_keys(command_t command, int keys[MAX_COMMAND_KEYS])
 {
        for (size_t i = 0; cmds[i].name; i++) {
@@ -462,19 +445,19 @@ assign_keys(command_t command, int keys[MAX_COMMAND_KEYS])
 #ifndef NCMPC_MINI
                        cmds[i].flags |= COMMAND_KEY_MODIFIED;
 #endif
-                       return 0;
+                       return true;
                }
        }
 
-       return -1;
+       return false;
 }
 
 #ifndef NCMPC_MINI
 
-int
+bool
 check_key_bindings(command_definition_t *cp, char *buf, size_t bufsize)
 {
-       int retval = 0;
+       bool success = true;
 
        if (cp == NULL)
                cp = cmds;
@@ -505,15 +488,15 @@ check_key_bindings(command_definition_t *cp, char *buf, size_t bufsize)
                                }
                                cp[i].flags |= COMMAND_KEY_CONFLICT;
                                set_key_flags(cp, cmd, COMMAND_KEY_CONFLICT);
-                               retval = -1;
+                               success = false;
                        }
                }
        }
 
-       return retval;
+       return success;
 }
 
-int
+bool
 write_key_bindings(FILE *f, int flags)
 {
        if (flags & KEYDEF_WRITE_HEADER)
@@ -541,7 +524,7 @@ write_key_bindings(FILE *f, int flags)
                }
        }
 
-       return ferror(f);
+       return ferror(f) == 0;
 }
 
 #endif /* NCMPC_MINI */