projects
/
apps
/
madmutt.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
exit str_cmp enters m_strcmp
[apps/madmutt.git]
/
keymap.c
diff --git
a/keymap.c
b/keymap.c
index
61058f7
..
76ac63c
100644
(file)
--- a/
keymap.c
+++ b/
keymap.c
@@
-11,18
+11,19
@@
# include "config.h"
#endif
# include "config.h"
#endif
+#include <lib-lib/mem.h>
+#include <lib-lib/ascii.h>
+#include <lib-lib/str.h>
+#include <lib-lib/macros.h>
+#include <lib-lib/buffer.h>
+
#include "mutt.h"
#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 "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 <stdlib.h>
#include <string.h>
#include <stdlib.h>
#include <string.h>
@@
-81,6
+82,9
@@
static struct mapping_t KeyNames[] = {
{"<Space>", ' '},
#ifdef KEY_BTAB
{"<BackTab>", KEY_BTAB},
{"<Space>", ' '},
#ifdef KEY_BTAB
{"<BackTab>", KEY_BTAB},
+#endif
+#ifdef KEY_NEXT
+ {"<Next>", KEY_NEXT},
#endif
{NULL, 0}
};
#endif
{NULL, 0}
};
@@
-90,15
+94,14
@@
int LastKey;
struct keymap_t *Keymaps[MENU_MAX];
struct keymap_t *Keymaps[MENU_MAX];
-static struct keymap_t *allocKeys
(int len, keycode_t *
keys)
+static struct keymap_t *allocKeys
(int len, keycode_t *
keys)
{
{
- struct keymap_t *p;
+
struct keymap_t *p;
- p = mem_calloc (1, sizeof (struct keymap_t));
- p->len = len;
- p->keys = mem_malloc (len * sizeof (keycode_t));
- memcpy (p->keys, keys, len * sizeof (keycode_t));
- return (p);
+ p = p_new(struct keymap_t, 1);
+ p->len = len;
+ p->keys = p_dup(keys, len);
+ return p;
}
static int parse_fkey (char *s)
}
static int parse_fkey (char *s)
@@
-134,7
+137,7
@@
static int parse_keycode (const char *s)
return -1;
}
return -1;
}
-static int parsekeys (char *str, keycode_t * d, int max)
+static int parsekeys (c
onst c
har *str, keycode_t * d, int max)
{
int n, len = max;
char buff[SHORT_STRING];
{
int n, len = max;
char buff[SHORT_STRING];
@@
-181,7
+184,7
@@
static int parsekeys (char *str, keycode_t * d, int max)
/* insert a key sequence into the specified map. the map is sorted by ASCII
* value (lowest to highest)
*/
/* insert a key sequence into the specified map. the map is sorted by ASCII
* value (lowest to highest)
*/
-void km_bind (char *s, int menu, int op, char *macro, char *descr)
+void km_bind (c
onst c
har *s, int menu, int op, char *macro, char *descr)
{
struct keymap_t *map, *tmp, *last = NULL, *next;
keycode_t buf[MAX_SEQ];
{
struct keymap_t *map, *tmp, *last = NULL, *next;
keycode_t buf[MAX_SEQ];
@@
-191,8
+194,8
@@
void km_bind (char *s, int menu, int op, char *macro, char *descr)
map = allocKeys (len, buf);
map->op = op;
map = allocKeys (len, buf);
map->op = op;
- map->macro =
str_dup
(macro);
- map->descr =
str_dup
(descr);
+ map->macro =
m_strdup
(macro);
+ map->descr =
m_strdup
(descr);
tmp = Keymaps[menu];
tmp = Keymaps[menu];
@@
-202,10
+205,10
@@
void km_bind (char *s, int menu, int op, char *macro, char *descr)
do {
len = tmp->eq;
next = tmp->next;
do {
len = tmp->eq;
next = tmp->next;
-
mem_free
(&tmp->macro);
-
mem_free
(&tmp->keys);
-
mem_free
(&tmp->descr);
-
mem_free
(&tmp);
+
p_delete
(&tmp->macro);
+
p_delete
(&tmp->keys);
+
p_delete
(&tmp->descr);
+
p_delete
(&tmp);
tmp = next;
}
while (tmp && len >= pos);
tmp = next;
}
while (tmp && len >= pos);
@@
-238,7
+241,7
@@
void km_bind (char *s, int menu, int op, char *macro, char *descr)
Keymaps[menu] = map;
}
Keymaps[menu] = map;
}
-void km_bindkey (char *s, int menu, int op)
+void km_bindkey (c
onst c
har *s, int menu, int op)
{
km_bind (s, menu, op, NULL, NULL);
}
{
km_bind (s, menu, op, NULL, NULL);
}
@@
-249,14
+252,14
@@
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) &&
for (i = 0; bindings[i].name; i++) {
if (!ascii_strncasecmp (start, bindings[i].name, len) &&
-
str_len
(bindings[i].name) == len)
+
m_strlen
(bindings[i].name) == len)
return bindings[i].op;
}
return OP_NULL;
}
return bindings[i].op;
}
return OP_NULL;
}
-static char *get_func (struct binding_t *bindings, int op)
+static c
onst c
har *get_func (struct binding_t *bindings, int op)
{
int i;
{
int i;
@@
-271,7
+274,7
@@
static char *get_func (struct binding_t *bindings, int op)
static void push_string (char *s)
{
static void push_string (char *s)
{
- char *pp, *p = s +
str_len
(s) - 1;
+ char *pp, *p = s +
m_strlen
(s) - 1;
size_t l;
int i, op = OP_NULL;
size_t l;
int i, op = OP_NULL;
@@
-318,7
+321,7
@@
static void push_string (char *s)
}
}
}
}
}
}
- mutt_ungetch (*p--, 0);
+ mutt_ungetch (
(unsigned char)
*p--, 0);
}
}
}
}
@@
-372,7
+375,7
@@
int km_dokey (int menu)
/* do we have an op already? */
if (tmp.op) {
/* do we have an op already? */
if (tmp.op) {
- char *func = NULL;
+ c
onst c
har *func = NULL;
struct binding_t *bindings;
/* is this a valid op for this menu? */
struct binding_t *bindings;
/* is this a valid op for this menu? */
@@
-451,10
+454,10
@@
static void create_bindings (struct binding_t *map, int menu)
km_bindkey (map[i].seq, menu, map[i].op);
}
km_bindkey (map[i].seq, menu, map[i].op);
}
-c
har *km_keyname
(int c)
+c
onst char *km_keyname
(int c)
{
static char buf[10];
{
static char buf[10];
- char *p;
+ c
onst c
har *p;
if ((p = mutt_getnamebyvalue (c, KeyNames)))
return p;
if ((p = mutt_getnamebyvalue (c, KeyNames)))
return p;
@@
-490,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);
FOREVER {
strfcpy (s, km_keyname (map->keys[p]), len);
- len -= (l =
str_len
(s));
+ len -= (l =
m_strlen
(s));
if (++p >= map->len || !len)
return (1);
if (++p >= map->len || !len)
return (1);
@@
-513,7
+516,7
@@
struct keymap_t *km_find_func (int menu, int func)
void km_init (void)
{
void km_init (void)
{
-
memset (Keymaps, 0, sizeof (struct keymap_t *) *
MENU_MAX);
+
p_clear(Keymaps,
MENU_MAX);
create_bindings (OpAttach, MENU_ATTACH);
create_bindings (OpBrowser, MENU_FOLDER);
create_bindings (OpAttach, MENU_ATTACH);
create_bindings (OpBrowser, MENU_FOLDER);
@@
-674,7
+677,7
@@
static char *parse_keymap (int *menu, BUFFER * s, int maxmenus, int *nummenus,
int i = 0;
char *p, *q;
int i = 0;
char *p, *q;
-
memset (&buf, 0, sizeof (buf)
);
+
p_clear(&buf, 1
);
/* menu name */
mutt_extract_token (&buf, s, 0);
/* menu name */
mutt_extract_token (&buf, s, 0);
@@
-709,7
+712,7
@@
static char *parse_keymap (int *menu, BUFFER * s, int maxmenus, int *nummenus,
strfcpy (err->data, _("too few arguments"), err->dsize);
}
error:
strfcpy (err->data, _("too few arguments"), err->dsize);
}
error:
-
mem_free
(&buf.data);
+
p_delete
(&buf.data);
return (NULL);
}
return (NULL);
}
@@
-719,7
+722,7
@@
try_bind (char *key, int menu, char *func, struct binding_t *bindings)
int i;
for (i = 0; bindings[i].name; i++)
int i;
for (i = 0; bindings[i].name; i++)
- if (
str_cmp
(func, bindings[i].name) == 0) {
+ if (
m_strcmp
(func, bindings[i].name) == 0) {
km_bindkey (key, menu, bindings[i].op);
return (0);
}
km_bindkey (key, menu, bindings[i].op);
return (0);
}
@@
-809,7
+812,7
@@
int mutt_parse_bind (BUFFER * buf, BUFFER * s, unsigned long data,
}
}
}
}
}
}
-
mem_free
(&key);
+
p_delete
(&key);
return (r);
}
return (r);
}
@@
-834,7
+837,7
@@
int mutt_parse_macro (BUFFER * buf, BUFFER * s, unsigned long data,
}
else {
if (MoreArgs (s)) {
}
else {
if (MoreArgs (s)) {
- seq =
str_dup
(buf->data);
+ seq =
m_strdup
(buf->data);
mutt_extract_token (buf, s, M_TOKEN_CONDENSE);
if (MoreArgs (s)) {
mutt_extract_token (buf, s, M_TOKEN_CONDENSE);
if (MoreArgs (s)) {
@@
-847,7
+850,7
@@
int mutt_parse_macro (BUFFER * buf, BUFFER * s, unsigned long data,
}
}
}
}
-
mem_free
(&seq);
+
p_delete
(&seq);
}
else {
for (i = 0; i < nummenus; ++i) {
}
else {
for (i = 0; i < nummenus; ++i) {
@@
-856,7
+859,7
@@
int mutt_parse_macro (BUFFER * buf, BUFFER * s, unsigned long data,
}
}
}
}
}
}
-
mem_free
(&key);
+
p_delete
(&key);
return (r);
}
return (r);
}
@@
-882,9
+885,9
@@
int mutt_parse_exec (BUFFER * buf, BUFFER * s, unsigned long data,
&& CurrentMenu != MENU_PAGER)
bindings = OpGeneric;
&& CurrentMenu != MENU_PAGER)
bindings = OpGeneric;
- ops[nops] = get_op (bindings, function,
str_len
(function));
+ ops[nops] = get_op (bindings, function,
m_strlen
(function));
if (ops[nops] == OP_NULL && CurrentMenu != MENU_PAGER)
if (ops[nops] == OP_NULL && CurrentMenu != MENU_PAGER)
- ops[nops] = get_op (OpGeneric, function,
str_len
(function));
+ ops[nops] = get_op (OpGeneric, function,
m_strlen
(function));
if (ops[nops] == OP_NULL) {
mutt_flushinp ();
if (ops[nops] == OP_NULL) {
mutt_flushinp ();