summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: e7c6e5f)
raw | patch | inline | side by side (parent: e7c6e5f)
author | Max Kellermann <max@duempel.org> | |
Mon, 14 Jul 2014 08:52:20 +0000 (10:52 +0200) | ||
committer | Max Kellermann <max@duempel.org> | |
Mon, 14 Jul 2014 08:52:20 +0000 (10:52 +0200) |
src/command.c | patch | blob | history |
diff --git a/src/command.c b/src/command.c
index 5621b165650b34fd2197b846755ee3c3967ef242..62d68a5e056a65a0db46457ed283c2b0a10adbda 100644 (file)
--- a/src/command.c
+++ b/src/command.c
if (max != 0)
return max;
- size_t len;
- command_definition_t *p;
-
- for (p = c; p->name != NULL; p++) {
+ for (command_definition_t *p = c; p->name != NULL; p++) {
/*
* width and length are considered the same here, as command
* names are not translated.
*/
- len = (size_t) strlen(p->name);
+ size_t len = strlen(p->name);
if (len > max)
max = len;
}
const char *
key2str(int key)
{
- static char buf[32];
- int i;
-
- buf[0] = 0;
switch(key) {
+ static char buf[32];
+
case 0:
return _("Undefined");
case ' ':
case KEY_IC:
return _("Insert");
default:
- for (i = 0; i <= 63; i++)
+ for (int i = 0; i <= 63; i++)
if (key == KEY_F(i)) {
g_snprintf(buf, 32, _("F%d"), i );
return buf;
g_snprintf(buf, 32, "%c", key);
else
g_snprintf(buf, 32, "0x%03X", key);
+ return buf;
}
-
- return buf;
}
void
command_dump_keys(void)
{
- for (int i = 0; cmds[i].description; i++)
+ for (size_t i = 0; cmds[i].description; i++)
if (cmds[i].command != CMD_NONE)
printf(" %20s : %s\n",
get_key_names(cmds[i].command, true),
static void
set_key_flags(command_definition_t *cp, command_t command, int flags)
{
- for (int i = 0; cp[i].name; i++) {
+ for (size_t i = 0; cp[i].name; i++) {
if (cp[i].command == command) {
cp[i].flags |= flags;
break;
if (!all)
return keystr;
- for (int j = 1; j < MAX_COMMAND_KEYS &&
+ for (unsigned j = 1; j < MAX_COMMAND_KEYS &&
cmds[i].keys[j] > 0; j++) {
g_strlcat(keystr, " ", sizeof(keystr));
g_strlcat(keystr, key2str(cmds[i].keys[j]), sizeof(keystr));
const char *
get_key_description(command_t command)
{
- for (int i = 0; cmds[i].description; i++)
+ for (size_t i = 0; cmds[i].description; i++)
if (cmds[i].command == command)
return _(cmds[i].description);
const char *
get_key_command_name(command_t command)
{
- for (int i = 0; cmds[i].name; i++)
+ for (size_t i = 0; cmds[i].name; i++)
if (cmds[i].command == command)
return cmds[i].name;
command_t
get_key_command_from_name(const char *name)
{
- for (int i = 0; cmds[i].name; i++)
+ for (size_t i = 0; cmds[i].name; i++)
if (strcmp(name, cmds[i].name) == 0)
return cmds[i].command;
assert(key != 0);
assert(c != NULL);
- for (int i = 0; c[i].name; i++) {
+ for (size_t i = 0; c[i].name; i++) {
for (int j = 0; j < MAX_COMMAND_KEYS; j++)
if (c[i].keys[j] == key)
return c[i].command;
command_t
get_keyboard_command(void)
{
- int key;
-
- key = wgetch(stdscr);
+ int key = wgetch(stdscr);
if (key == ERR || key == '\0')
return CMD_NONE;
int
assign_keys(command_t command, int keys[MAX_COMMAND_KEYS])
{
- for (int i = 0; cmds[i].name; i++) {
+ for (size_t i = 0; cmds[i].name; i++) {
if (cmds[i].command == command) {
memcpy(cmds[i].keys, keys, sizeof(int)*MAX_COMMAND_KEYS);
#ifndef NCMPC_MINI
int
check_key_bindings(command_definition_t *cp, char *buf, size_t bufsize)
{
- int i;
int retval = 0;
if (cp == NULL)
cp = cmds;
- for (i = 0; cp[i].name; i++)
+ for (size_t i = 0; cp[i].name; i++)
cp[i].flags &= ~COMMAND_KEY_CONFLICT;
- for (i = 0; cp[i].name; i++) {
+ for (size_t i = 0; cp[i].name; i++) {
int j;
command_t cmd;
if (flags & KEYDEF_WRITE_HEADER)
fprintf(f, "## Key bindings for ncmpc (generated by ncmpc)\n\n");
- for (int i = 0; cmds[i].name && !ferror(f); i++) {
+ for (size_t i = 0; cmds[i].name && !ferror(f); i++) {
if (cmds[i].flags & COMMAND_KEY_MODIFIED ||
flags & KEYDEF_WRITE_ALL) {
fprintf(f, "## %s\n", cmds[i].description);