mirror of
https://github.com/radareorg/radare2.git
synced 2024-12-02 18:27:18 +00:00
Autocomplete eco color themes
This commit is contained in:
parent
1ab7c43efe
commit
961e9479dc
@ -45,7 +45,38 @@ static bool nextpal_item(RCore *core, int mode, const char *file, int ctr) {
|
||||
return true;
|
||||
}
|
||||
|
||||
R_API RList *r_core_list_themes(RCore *core) {
|
||||
RList *files = NULL;
|
||||
RListIter *iter;
|
||||
const char *fn;
|
||||
int ctr = 0;
|
||||
char *home = r_str_home (".config/radare2/cons/");
|
||||
|
||||
RList *list = r_list_new ();
|
||||
getNext = false;
|
||||
if (home) {
|
||||
files = r_sys_dir (home);
|
||||
r_list_foreach (files, iter, fn) {
|
||||
if (*fn && *fn != '.') {
|
||||
r_list_append (list, strdup (fn));
|
||||
}
|
||||
}
|
||||
r_list_free (files);
|
||||
R_FREE (home);
|
||||
}
|
||||
files = r_sys_dir (R2_DATDIR"/radare2/"R2_VERSION"/cons/");
|
||||
r_list_foreach (files, iter, fn) {
|
||||
if (*fn && *fn != '.') {
|
||||
r_list_append (list, strdup (fn));
|
||||
}
|
||||
}
|
||||
r_list_free (files);
|
||||
files = NULL;
|
||||
return list;
|
||||
}
|
||||
|
||||
static void nextpal(RCore *core, int mode) {
|
||||
// TODO: use r_core_list_themes() here instead of rewalking all the time
|
||||
RList *files = NULL;
|
||||
RListIter *iter;
|
||||
const char *fn;
|
||||
|
@ -532,7 +532,7 @@ static const char *radare_argv[] = {
|
||||
"?", "?v", "whereis", "which", "ls", "rm", "mkdir", "pwd", "cat", "less",
|
||||
"dH", "ds", "dso", "dsl", "dc", "dd", "dm", "db ", "db-",
|
||||
"dp", "dr", "dcu", "dmd", "dmp", "dml",
|
||||
"ec","ecs",
|
||||
"ec","ecs", "eco",
|
||||
"S", "S.", "S*", "S-", "S=", "Sa", "Sa-", "Sd", "Sl", "SSj", "Sr",
|
||||
"s", "s+", "s++", "s-", "s--", "s*", "sa", "sb", "sr",
|
||||
"!", "!!",
|
||||
@ -606,12 +606,12 @@ static int autocomplete(RLine *line) {
|
||||
}
|
||||
tmp_argv_heap = false;
|
||||
#define ADDARG(x) if (!strncmp (line->buffer.data+7, x, strlen (line->buffer.data+7))) { tmp_argv[j++] = x; }
|
||||
ADDARG("node");
|
||||
ADDARG("vala");
|
||||
ADDARG("ruby");
|
||||
ADDARG("newlisp");
|
||||
ADDARG("perl");
|
||||
ADDARG("python");
|
||||
ADDARG ("node");
|
||||
ADDARG ("vala");
|
||||
ADDARG ("ruby");
|
||||
ADDARG ("newlisp");
|
||||
ADDARG ("perl");
|
||||
ADDARG ("python");
|
||||
tmp_argv[j] = NULL;
|
||||
line->completion.argc = j;
|
||||
line->completion.argv = tmp_argv;
|
||||
@ -661,7 +661,6 @@ static int autocomplete(RLine *line) {
|
||||
if (!l_ptr) {
|
||||
l_ptr = line->buffer.data + len;
|
||||
}
|
||||
|
||||
r_list_foreach (vars, iter, var) {
|
||||
if (!strncmp (f_ptr, var->name, l_ptr - f_ptr)) {
|
||||
tmp_argv[j++] = strdup (var->name);
|
||||
@ -670,6 +669,21 @@ static int autocomplete(RLine *line) {
|
||||
tmp_argv[j] = NULL;
|
||||
line->completion.argc = j;
|
||||
line->completion.argv = tmp_argv;
|
||||
} else if ((!strncmp (line->buffer.data, "eco ", 4))) {
|
||||
int i = 0;
|
||||
int chr = 4;
|
||||
int len = strlen (line->buffer.data + 4);
|
||||
char *theme;
|
||||
RList *themes = r_core_list_themes (core);
|
||||
r_list_foreach (themes, iter, theme) {
|
||||
if (!len || !strncmp (line->buffer.data + 4, theme, len)) {
|
||||
tmp_argv[i++] = strdup (theme);
|
||||
}
|
||||
}
|
||||
tmp_argv[i] = NULL;
|
||||
r_list_free (themes);
|
||||
line->completion.argc = i;
|
||||
line->completion.argv = tmp_argv;
|
||||
} else if ((!strncmp (line->buffer.data, "te ", 3))) {
|
||||
int i = 0;
|
||||
SdbList *l = sdb_foreach_list (core->anal->sdb_types);
|
||||
@ -959,10 +973,12 @@ openfile:
|
||||
}
|
||||
} else {
|
||||
int i, j;
|
||||
for (i=j=0; i<CMDS && radare_argv[i]; i++)
|
||||
for (i=j=0; i<CMDS && radare_argv[i]; i++) {
|
||||
if (!strncmp (radare_argv[i], line->buffer.data,
|
||||
line->buffer.index))
|
||||
line->buffer.index)) {
|
||||
tmp_argv[j++] = radare_argv[i];
|
||||
}
|
||||
}
|
||||
tmp_argv[j] = NULL;
|
||||
line->completion.argc = j;
|
||||
line->completion.argv = tmp_argv;
|
||||
|
@ -183,6 +183,7 @@ typedef int (*RCoreSearchCallback)(RCore *core, ut64 from, ut8 *buf, int len);
|
||||
|
||||
#ifdef R_API
|
||||
//#define r_core_ncast(x) (RCore*)(size_t)(x)
|
||||
R_API RList *r_core_list_themes (RCore *core);
|
||||
R_API RCons *r_core_get_cons (RCore *core);
|
||||
R_API RBin *r_core_get_bin (RCore *core);
|
||||
R_API RConfig *r_core_get_config (RCore *core);
|
||||
|
Loading…
Reference in New Issue
Block a user