diff options
Diffstat (limited to 'src/keys.c')
-rw-r--r-- | src/keys.c | 65 |
1 files changed, 41 insertions, 24 deletions
@@ -81,16 +81,17 @@ static struct keydef_s keydef[NBKEYS] = { {"generic-scroll-up", "C-p"}, {"generic-goto-today", "C-g"}, - {"move-right", "l L"}, - {"move-left", "h H"}, - {"move-down", "j J"}, - {"move-up", "k K"}, + {"move-right", "l L RGT"}, + {"move-left", "h H LFT"}, + {"move-down", "j J DWN"}, + {"move-up", "k K UP"}, {"start-of-week", "0"}, {"end-of-week", "$"}, {"add-item", "a A"}, {"del-item", "d D"}, {"edit-item", "e E"}, {"view-item", "v V"}, + {"pipe-item", "|"}, {"flag-item", "!"}, {"repeat", "r R"}, {"edit-note", "n N"}, @@ -124,7 +125,7 @@ dump_intro (FILE *fd) "# A description of what each ACTION keyword is used for is available\n" "# from calcurse online configuration menu.\n"); - (void)fprintf (fd, "%s\n", intro); + fprintf (fd, "%s\n", intro); } void @@ -170,7 +171,7 @@ keys_dump_defaults (char *file) dump_intro (fd); for (i = 0; i < NBKEYS; i++) - (void)fprintf (fd, "%s %s\n", keydef[i].label, keydef[i].binding); + fprintf (fd, "%s %s\n", keydef[i].label, keydef[i].binding); file_close (fd, __FILE_POS__); } @@ -193,11 +194,26 @@ keys_get_action (int pressed) } enum key -keys_getch (WINDOW *win) +keys_getch (WINDOW *win, int *count) { - int ch; + int ch = '0'; + + if (count) + { + *count = 0; + do + { + *count = *count * 10 + ch - '0'; + ch = wgetch (win); + } + while ((ch == '0' && *count > 0) || (ch >= '1' && ch <= '9')); + + if (*count == 0) + *count = 1; + } + else + ch = wgetch (win); - ch = wgetch (win); switch (ch) { case KEY_RESIZE: @@ -258,7 +274,7 @@ del_key_str (enum key action, int key) if (action < 0 || action > NBKEYS) return; - (void)strncpy (oldstr, keys_int2str (key), BUFSIZ); + strncpy (oldstr, keys_int2str (key), BUFSIZ); for (i = &keys[action]; *i; i = &(*i)->next) { if (!strcmp ((*i)->str, oldstr)) @@ -391,7 +407,7 @@ keys_action_nkey (enum key action, int keynum) return key->str; i++; } - return (char *)0; + return NULL; } char * @@ -407,8 +423,8 @@ keys_action_allkeys (enum key action) for (i = keys[action]; i; i = i->next) { const int MAXLEN = sizeof (keystr) - 1 - strlen (keystr); - (void)strncat (keystr, i->str, MAXLEN - 1); - (void)strncat (keystr, CHAR_SPACE, 1); + strncat (keystr, i->str, MAXLEN - 1); + strncat (keystr, CHAR_SPACE, 1); } return keystr; @@ -424,22 +440,22 @@ keys_format_label (char *key, int keylen) int i; if (keylen > BUFSIZ) - return (char *)0; + return NULL; bzero (fmtkey, sizeof (fmtkey)); if (len == 0) - (void)snprintf (fmtkey, sizeof (fmtkey), "?"); + strncpy (fmtkey, "?", sizeof (fmtkey)); else if (len <= keylen) { for (i = 0; i < keylen - len; i++) fmtkey[i] = ' '; - (void)strncat (fmtkey, key, keylen); + strncat (fmtkey, key, keylen); } else { for (i = 0; i < keylen - 1; i++) fmtkey[i] = key[i]; - (void)strncat (fmtkey, dot, strlen (dot)); + strncat (fmtkey, dot, strlen (dot)); } return fmtkey; } @@ -463,15 +479,14 @@ keys_display_bindings_bar (WINDOW *win, struct binding **binding, int first_key, const int KEY_POS = j * cmdlen; const int LABEL_POS = j * cmdlen + KEYS_KEYLEN + 1; - (void)strncpy (key, keys_action_firstkey (binding[i]->action), - KEYS_KEYLEN); + strncpy (key, keys_action_firstkey (binding[i]->action), KEYS_KEYLEN); fmtkey = keys_format_label (key, KEYS_KEYLEN); custom_apply_attr (win, ATTR_HIGHEST); mvwprintw (win, 0, KEY_POS, fmtkey); if (i + 1 != last_key) { - (void)strncpy (key, keys_action_firstkey (binding[i + 1]->action), - KEYS_KEYLEN); + strncpy (key, keys_action_firstkey (binding[i + 1]->action), + KEYS_KEYLEN); key[KEYS_KEYLEN] = 0; fmtkey = keys_format_label (key, KEYS_KEYLEN); mvwprintw (win, 1, KEY_POS, fmtkey); @@ -567,6 +582,8 @@ keys_popup_info (enum key key) _("Flag the currently selected item as important."); info[KEY_REPEAT_ITEM] = _("Repeat an item"); + info[KEY_PIPE_ITEM] = + _("Pipe the currently selected item to an external program."); info[KEY_EDIT_NOTE] = _("Attach (or edit if one exists) a note to the currently selected item"); info[KEY_VIEW_NOTE] = @@ -583,7 +600,7 @@ keys_popup_info (enum key key) #define WINCOL (col - 4) infowin = popup (WINROW, WINCOL, (row - WINROW) / 2, (col - WINCOL) / 2, keydef[key].label, info[key], 1); - (void)keys_getch (infowin); + keys_getch (infowin, NULL); delwin (infowin); #undef WINROW #undef WINCOL @@ -597,7 +614,7 @@ keys_save_bindings (FILE *fd) EXIT_IF (fd == NULL, _("FATAL ERROR: null file pointer.")); dump_intro (fd); for (i = 0; i < NBKEYS; i++) - (void)fprintf (fd, "%s %s\n", keydef[i].label, keys_action_allkeys (i)); + fprintf (fd, "%s %s\n", keydef[i].label, keys_action_allkeys (i)); } int @@ -624,7 +641,7 @@ keys_fill_missing (void) { char *p, tmpbuf[BUFSIZ]; - (void)strncpy (tmpbuf, keydef[i].binding, BUFSIZ); + strncpy (tmpbuf, keydef[i].binding, BUFSIZ); p = tmpbuf; for (;;) { |