X-Git-Url: http://git.madism.org/?p=apps%2Fmadmutt.git;a=blobdiff_plain;f=keymap.c;h=b480455c9c5e7c67f69dba650fb3f2ece23d2aa4;hp=b76c948799228c3a322456c61e39da4f5d66dc26;hb=8889846011afe0d33ff155acce9afef5af306ae0;hpb=df70e07e24add1869bcc9b7af2277d9d0c09a281 diff --git a/keymap.c b/keymap.c index b76c948..b480455 100644 --- a/keymap.c +++ b/keymap.c @@ -1,19 +1,10 @@ /* + * Copyright notice from original mutt: * Copyright (C) 1996-2000,2002 Michael R. Elkins - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. + * + * This file is part of mutt-ng, see http://www.muttng.org/. + * It's licensed under the GNU General Public License, + * please see the file GPL in the top level source directory. */ #if HAVE_CONFIG_H @@ -21,12 +12,18 @@ #endif #include "mutt.h" +#include "buffer.h" +#include "ascii.h" #include "mutt_menu.h" #include "mutt_curses.h" #include "keymap.h" #include "mapping.h" #include "mutt_crypt.h" +#include "lib/mem.h" +#include "lib/intl.h" +#include "lib/str.h" + #include #include #include @@ -84,6 +81,9 @@ static struct mapping_t KeyNames[] = { {"", ' '}, #ifdef KEY_BTAB {"", KEY_BTAB}, +#endif +#ifdef KEY_NEXT + {"", KEY_NEXT}, #endif {NULL, 0} }; @@ -97,9 +97,9 @@ static struct keymap_t *allocKeys (int len, keycode_t * keys) { struct keymap_t *p; - p = safe_calloc (1, sizeof (struct keymap_t)); + p = mem_calloc (1, sizeof (struct keymap_t)); p->len = len; - p->keys = safe_malloc (len * sizeof (keycode_t)); + p->keys = mem_malloc (len * sizeof (keycode_t)); memcpy (p->keys, keys, len * sizeof (keycode_t)); return (p); } @@ -194,8 +194,8 @@ void km_bind (char *s, int menu, int op, char *macro, char *descr) map = allocKeys (len, buf); map->op = op; - map->macro = safe_strdup (macro); - map->descr = safe_strdup (descr); + map->macro = str_dup (macro); + map->descr = str_dup (descr); tmp = Keymaps[menu]; @@ -205,10 +205,10 @@ void km_bind (char *s, int menu, int op, char *macro, char *descr) do { len = tmp->eq; next = tmp->next; - FREE (&tmp->macro); - FREE (&tmp->keys); - FREE (&tmp->descr); - FREE (&tmp); + mem_free (&tmp->macro); + mem_free (&tmp->keys); + mem_free (&tmp->descr); + mem_free (&tmp); tmp = next; } while (tmp && len >= pos); @@ -252,7 +252,7 @@ static int get_op (struct binding_t *bindings, const char *start, size_t len) for (i = 0; bindings[i].name; i++) { if (!ascii_strncasecmp (start, bindings[i].name, len) && - mutt_strlen (bindings[i].name) == len) + str_len (bindings[i].name) == len) return bindings[i].op; } @@ -274,7 +274,7 @@ static char *get_func (struct binding_t *bindings, int op) static void push_string (char *s) { - char *pp, *p = s + mutt_strlen (s) - 1; + char *pp, *p = s + str_len (s) - 1; size_t l; int i, op = OP_NULL; @@ -321,7 +321,7 @@ static void push_string (char *s) } } } - mutt_ungetch (*p--, 0); + mutt_ungetch ((unsigned char) *p--, 0); } } @@ -493,7 +493,7 @@ int km_expand_key (char *s, size_t len, struct keymap_t *map) FOREVER { strfcpy (s, km_keyname (map->keys[p]), len); - len -= (l = mutt_strlen (s)); + len -= (l = str_len (s)); if (++p >= map->len || !len) return (1); @@ -712,7 +712,7 @@ static char *parse_keymap (int *menu, BUFFER * s, int maxmenus, int *nummenus, strfcpy (err->data, _("too few arguments"), err->dsize); } error: - FREE (&buf.data); + mem_free (&buf.data); return (NULL); } @@ -722,7 +722,7 @@ try_bind (char *key, int menu, char *func, struct binding_t *bindings) int i; for (i = 0; bindings[i].name; i++) - if (mutt_strcmp (func, bindings[i].name) == 0) { + if (str_cmp (func, bindings[i].name) == 0) { km_bindkey (key, menu, bindings[i].op); return (0); } @@ -812,7 +812,7 @@ int mutt_parse_bind (BUFFER * buf, BUFFER * s, unsigned long data, } } } - FREE (&key); + mem_free (&key); return (r); } @@ -837,7 +837,7 @@ int mutt_parse_macro (BUFFER * buf, BUFFER * s, unsigned long data, } else { if (MoreArgs (s)) { - seq = safe_strdup (buf->data); + seq = str_dup (buf->data); mutt_extract_token (buf, s, M_TOKEN_CONDENSE); if (MoreArgs (s)) { @@ -850,7 +850,7 @@ int mutt_parse_macro (BUFFER * buf, BUFFER * s, unsigned long data, } } - FREE (&seq); + mem_free (&seq); } else { for (i = 0; i < nummenus; ++i) { @@ -859,7 +859,7 @@ int mutt_parse_macro (BUFFER * buf, BUFFER * s, unsigned long data, } } } - FREE (&key); + mem_free (&key); return (r); } @@ -885,9 +885,9 @@ int mutt_parse_exec (BUFFER * buf, BUFFER * s, unsigned long data, && CurrentMenu != MENU_PAGER) bindings = OpGeneric; - ops[nops] = get_op (bindings, function, mutt_strlen (function)); + ops[nops] = get_op (bindings, function, str_len (function)); if (ops[nops] == OP_NULL && CurrentMenu != MENU_PAGER) - ops[nops] = get_op (OpGeneric, function, mutt_strlen (function)); + ops[nops] = get_op (OpGeneric, function, str_len (function)); if (ops[nops] == OP_NULL) { mutt_flushinp ();