mirror of
https://github.com/radareorg/radare2.git
synced 2025-02-27 17:46:01 +00:00
Fix #13738 - Autocomplete $aliases ##cons
This commit is contained in:
parent
022550293c
commit
cfdd09c838
@ -188,12 +188,10 @@ R_API int r_cmd_add_long(RCmd *cmd, const char *lcmd, const char *scmd, const ch
|
||||
}
|
||||
|
||||
R_API int r_cmd_add(RCmd *c, const char *cmd, const char *desc, r_cmd_callback(cb)) {
|
||||
struct r_cmd_item_t *item;
|
||||
int idx = (ut8)cmd[0];
|
||||
|
||||
item = c->cmds[idx];
|
||||
RCmdItem *item = c->cmds[idx];
|
||||
if (!item) {
|
||||
item = R_NEW (RCmdItem);
|
||||
item = R_NEW0 (RCmdItem);
|
||||
c->cmds[idx] = item;
|
||||
}
|
||||
strncpy (item->cmd, cmd, sizeof (item->cmd)-1);
|
||||
|
@ -817,7 +817,7 @@ static const char *radare_argv[] = {
|
||||
"whereis", "which", "ls", "rm", "mkdir", "pwd", "cat", "less", "exit", "quit",
|
||||
"#?", "#!", "#sha1", "#crc32", "#pcprint", "#sha256", "#sha512", "#md4", "#md5",
|
||||
"#!python", "#!vala", "#!pipe",
|
||||
"*?", "*",
|
||||
"*?", "*", "$",
|
||||
"(", "(*", "(-", "()", ".?", ".", "..", "...", ".:", ".--", ".-", ".!", ".(", "./", ".*",
|
||||
"_?", "_",
|
||||
"=?", "=", "=<", "=!", "=+", "=-", "==", "=!=", "!=!", "=:", "=&:",
|
||||
@ -1821,6 +1821,17 @@ static int autocomplete(RLine *line) {
|
||||
ls_free (l);
|
||||
line->completion.argc = i;
|
||||
line->completion.argv = tmp_argv;
|
||||
} else if (!strncmp (line->buffer.data, "$", 1)) {
|
||||
int i, j = 0;
|
||||
for (i = 0; i < core->rcmd->aliases.count; i++) {
|
||||
const char *key = core->rcmd->aliases.keys[i];
|
||||
int len = strlen (line->buffer.data);
|
||||
if (!len || !strncmp (line->buffer.data, key, len)) {
|
||||
tmp_argv[j++] = strdup (key);
|
||||
}
|
||||
}
|
||||
line->completion.argc = j;
|
||||
line->completion.argv = tmp_argv;
|
||||
} else if (!strncmp (line->buffer.data, "ts ", 3)
|
||||
|| !strncmp (line->buffer.data, "ta ", 3)
|
||||
|| !strncmp (line->buffer.data, "tp ", 3)
|
||||
@ -1835,9 +1846,10 @@ static int autocomplete(RLine *line) {
|
||||
int chr = (line->buffer.data[2] == ' ')? 3: 4;
|
||||
ls_foreach (l, iter, kv) {
|
||||
int len = strlen (line->buffer.data + chr);
|
||||
if (!len || !strncmp (line->buffer.data + chr, sdbkv_key (kv), len)) {
|
||||
const char *key = sdbkv_key (kv);
|
||||
if (!len || !strncmp (line->buffer.data + chr, key, len)) {
|
||||
if (!strncmp (sdbkv_value (kv), "struct", strlen ("struct") + 1)) {
|
||||
tmp_argv[i++] = strdup (sdbkv_key (kv));
|
||||
tmp_argv[i++] = strdup (key);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user