Add scr.fileprompt config option

This commit is contained in:
pancake 2014-07-04 01:44:14 +02:00
parent ea384ec166
commit f0824ce120
2 changed files with 16 additions and 5 deletions

View File

@ -878,6 +878,7 @@ R_API int r_core_config_init(RCore *core) {
SETCB("scr.nkey", "hit", &cb_scrnkey, "Select the seek mode in visual");
SETCB("scr.pager", "", &cb_pager, "Select pager program (used if output doesn't fit on window)");
SETPREF("scr.pipecolor", "false", "Enable colors when using pipes if true");
SETPREF("scr.fileprompt", "false", "Show/hide user prompt (used by r2 -q)");
SETCB("scr.prompt", "true", &cb_scrprompt, "Show/hide user prompt (used by r2 -q)");
SETCB("scr.rows", "0", &cb_scrrows, "Set the rows number");
SETCB("scr.tee", "", &cb_teefile, "Pipe console output to file if not empty");

View File

@ -699,8 +699,8 @@ R_API int r_core_prompt(RCore *r, int sync) {
int ret, rnv;
char line[4096];
char prompt[64];
const char *filename = "";
const char *cmdprompt = r_config_get (r->config, "cmd.prompt");
const char *BEGIN = r->cons->pal.prompt;
const char *END = r->cons->pal.reset;
rnv = r->num->value;
@ -714,6 +714,8 @@ R_API int r_core_prompt(RCore *r, int sync) {
if (!r_line_singleton ()->echo)
*prompt = 0;
if (r_config_get_i (r->config, "scr.fileprompt"))
filename = r->io->desc->name;
// TODO: also in visual prompt and disasm/hexdump ?
if (r_config_get_i (r->config, "asm.segoff")) {
ut32 a, b;
@ -722,20 +724,28 @@ R_API int r_core_prompt(RCore *r, int sync) {
#if __UNIX__
if (r_config_get_i (r->config, "scr.color"))
snprintf (prompt, sizeof (prompt),
"%s[%04x:%04x]>%s ",
"%s%s%s[%04x:%04x]>%s ",
filename, *filename?" ":"",
BEGIN, a, b, END);
else
#endif
snprintf (prompt, sizeof (prompt), "[%04x:%04x]> ", a, b);
snprintf (prompt, sizeof (prompt),
"%s%s[%04x:%04x]> ",
filename, *filename?" ":"",
a, b);
} else {
#if __UNIX__
if (r_config_get_i (r->config, "scr.color"))
snprintf (prompt, sizeof (prompt),
"%s[0x%08"PFMT64x"]>%s ",
"%s%s%s[0x%08"PFMT64x"]>%s ",
filename, *filename?" ":"",
BEGIN, r->offset, END);
else
#endif
snprintf (prompt, sizeof (prompt), "[0x%08"PFMT64x"]> ", r->offset);
snprintf (prompt, sizeof (prompt),
"%s%s[0x%08"PFMT64x"]> ",
filename, *filename?" ":"",
r->offset);
}
r_line_set_prompt (prompt);
ret = r_cons_fgets (line, sizeof (line), 0, NULL);