Skip to content

Commit 9572a18

Browse files
committed
Register prj plugin tab autocompletion ##projects
1 parent 7f69fcc commit 9572a18

1 file changed

Lines changed: 30 additions & 0 deletions

File tree

libr/core/p/core_prj.c

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -902,13 +902,43 @@ static bool callback(RCorePluginSession *cps, const char *input) {
902902
return false;
903903
}
904904

905+
static bool plugin_init(RCorePluginSession *cps) {
906+
RCore *core = cps->core;
907+
if (!core || !core->autocomplete) {
908+
return true;
909+
}
910+
if (r_core_autocomplete_find (core->autocomplete, "prj", true)) {
911+
return true;
912+
}
913+
RCoreAutocomplete *root = r_core_autocomplete_add (core->autocomplete, "prj", R_CORE_AUTOCMPLT_DFLT, true);
914+
if (!root) {
915+
return true;
916+
}
917+
const char *subs[] = { "save", "load", "open", "info", "r2", NULL };
918+
int i;
919+
for (i = 0; subs[i]; i++) {
920+
r_core_autocomplete_add (root, subs[i], R_CORE_AUTOCMPLT_FILE, true);
921+
}
922+
return true;
923+
}
924+
925+
static bool plugin_fini(RCorePluginSession *cps) {
926+
RCore *core = cps->core;
927+
if (core && core->autocomplete) {
928+
r_core_autocomplete_remove (core->autocomplete, "prj");
929+
}
930+
return true;
931+
}
932+
905933
RCorePlugin r_core_plugin_prj = {
906934
.meta = {
907935
.name = "prj",
908936
.desc = "Experimental binary projects",
909937
.author = "pancake",
910938
.license = "MIT",
911939
},
940+
.init = plugin_init,
941+
.fini = plugin_fini,
912942
.call = callback,
913943
};
914944

0 commit comments

Comments
 (0)