mirror of
https://github.com/radareorg/radare2.git
synced 2025-02-03 04:05:06 +00:00
Add 'on' as in 'r2 -n'
This commit is contained in:
parent
903bd49dfd
commit
888bd62819
@ -654,9 +654,7 @@ static int cmd_visual(void *data, const char *input) {
|
||||
return R_FALSE;
|
||||
if (!r_config_get_i (core->config, "scr.interactive"))
|
||||
return R_FALSE;
|
||||
r_cons_show_cursor (R_FALSE);
|
||||
ret = r_core_visual ((RCore *)data, input);
|
||||
r_cons_show_cursor (R_TRUE);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* radare - LGPL - Copyright 2009-2012 // pancake<nopcode.org> */
|
||||
/* radare - LGPL - Copyright 2009-2013 - pancake */
|
||||
|
||||
static int cmd_open(void *data, const char *input) {
|
||||
RCore *core = (RCore*)data;
|
||||
@ -7,6 +7,7 @@ static int cmd_open(void *data, const char *input) {
|
||||
RCoreFile *file;
|
||||
RListIter *iter;
|
||||
int num = -1;
|
||||
int isn = 0;
|
||||
ut64 addr;
|
||||
char *ptr;
|
||||
|
||||
@ -17,23 +18,26 @@ static int cmd_open(void *data, const char *input) {
|
||||
case '+':
|
||||
perms = R_IO_READ|R_IO_WRITE;
|
||||
input++;
|
||||
case 'n':
|
||||
// like in r2 -n
|
||||
isn = 1;
|
||||
case ' ':
|
||||
ptr = strchr (input+1, ' ');
|
||||
if (ptr && ptr[1]=='0' && ptr[2]=='x') { // hack to fix opening files with space in path
|
||||
*ptr = '\0';
|
||||
addr = r_num_math (core->num, ptr+1);
|
||||
} else {
|
||||
num = atoi (input+1);
|
||||
num = atoi (ptr? ptr: input+1);
|
||||
addr = 0LL;
|
||||
}
|
||||
if (num<=0) {
|
||||
file = r_core_file_open (core, input+1, perms, addr);
|
||||
const char *file = ptr? ptr+1: input+1;
|
||||
file = r_core_file_open (core, file, perms, addr);
|
||||
if (file) {
|
||||
// MUST CLEAN BEFORE LOADING
|
||||
r_core_bin_load (core, input+1);
|
||||
//eprintf ("Map '%s' in 0x%08"PFMT64x" with size 0x%"PFMT64x"\n",
|
||||
// input+1, addr, file->size);
|
||||
} else eprintf ("Cannot open file '%s'\n", input+1);
|
||||
if (!isn)
|
||||
r_core_bin_load (core, file);
|
||||
} else eprintf ("Cannot open file '%s'\n", file);
|
||||
} else r_io_raise (core->io, num);
|
||||
r_core_block_read (core, 0);
|
||||
break;
|
||||
@ -152,6 +156,7 @@ static int cmd_open(void *data, const char *input) {
|
||||
" o /bin/ls open /bin/ls file in read-only\n"
|
||||
" o+/bin/ls open /bin/ls file in read-write mode\n"
|
||||
" o /bin/ls 0x4000 map file at 0x4000\n"
|
||||
" on /bin/ls 0x4000 map raw file at 0x4000 (no r_bin involved)\n"
|
||||
" om[?] create, list, remove IO maps\n");
|
||||
break;
|
||||
}
|
||||
|
@ -357,8 +357,8 @@ static int cmd_print(void *data, const char *input) {
|
||||
r_cons_printf ("%s.%s ", buf, buf+5);
|
||||
if (c==3) {
|
||||
const ut8 *b = core->block + i-3;
|
||||
#define B(x) (b[3-x]<<(8*x))
|
||||
n = B(0) | B(1) | B(2) | B(3);
|
||||
#define K(x) (b[3-x]<<(8*x))
|
||||
n = K(0) | K(1) | K(2) | K(3);
|
||||
r_cons_printf ("0x%08x %c%c%c%c\n",
|
||||
n, P(b[0]), P(b[1]), P(b[2]), P(b[3]));
|
||||
c = -1;
|
||||
|
@ -12,6 +12,12 @@ static const char *printfmt[] = {
|
||||
static int autoblocksize = 1;
|
||||
static int obs = 0;
|
||||
|
||||
static void showcursor(RCore *core, int x) {
|
||||
eprintf ("CURSOR %d\n", core && core->vmode);
|
||||
if (core && core->vmode)
|
||||
r_cons_show_cursor (x);
|
||||
}
|
||||
|
||||
// XXX: use core->print->cur_enabled instead of curset/cursor/ocursor
|
||||
static int curset = 0, cursor = 0, ocursor=-1;
|
||||
static int color = 1;
|
||||
@ -27,7 +33,7 @@ static int r_core_visual_hud(RCore *core) {
|
||||
char *res = NULL;
|
||||
char *p = 0;
|
||||
|
||||
r_cons_show_cursor (R_TRUE);
|
||||
showcursor (core, R_TRUE);
|
||||
if (homehud)
|
||||
res = r_cons_hud_file (homehud);
|
||||
if (!res) {
|
||||
@ -44,7 +50,7 @@ static int r_core_visual_hud(RCore *core) {
|
||||
if (p) r_core_cmd0 (core, p+1);
|
||||
free (res);
|
||||
}
|
||||
r_cons_show_cursor (R_FALSE);
|
||||
showcursor (core, R_FALSE);
|
||||
r_cons_flush ();
|
||||
return (int)(size_t)p;
|
||||
}
|
||||
@ -72,9 +78,9 @@ static void r_core_visual_mark(RCore *core, ut8 ch) {
|
||||
|
||||
static void prompt_read (const char *p, char *buf, int buflen) {
|
||||
r_line_set_prompt (p);
|
||||
r_cons_show_cursor (R_TRUE);
|
||||
showcursor (NULL, R_TRUE);
|
||||
r_cons_fgets (buf, buflen, 0, NULL);
|
||||
r_cons_show_cursor (R_FALSE);
|
||||
showcursor (NULL, R_FALSE);
|
||||
}
|
||||
|
||||
R_API void r_core_visual_prompt (RCore *core) {
|
||||
@ -85,13 +91,13 @@ R_API void r_core_visual_prompt (RCore *core) {
|
||||
#else
|
||||
r_line_set_prompt (":> ");
|
||||
#endif
|
||||
r_cons_show_cursor (R_TRUE);
|
||||
showcursor (core, R_TRUE);
|
||||
r_cons_fgets (buf, sizeof (buf), 0, NULL);
|
||||
r_line_hist_add (buf);
|
||||
r_core_cmd (core, buf, 0);
|
||||
r_cons_any_key ();
|
||||
r_cons_clear00 ();
|
||||
r_cons_show_cursor (R_FALSE);
|
||||
showcursor (core, R_FALSE);
|
||||
if (curset) r_core_seek (core, oseek, 1);
|
||||
}
|
||||
|
||||
@ -164,6 +170,7 @@ static void setcursor (RCore *core, int cur) {
|
||||
curset = cur;
|
||||
if (curset) flags |= R_PRINT_FLAGS_CURSOR;
|
||||
else flags &= ~(R_PRINT_FLAGS_CURSOR);
|
||||
core->print->cur_enabled = cur;
|
||||
r_print_set_flags (core->print, flags);
|
||||
core->print->col = curset? 1: 0;
|
||||
}
|
||||
@ -201,7 +208,7 @@ static void visual_search (RCore *core) {
|
||||
if (len>1) {
|
||||
ocursor = cursor+len-1;
|
||||
} else ocursor = -1;
|
||||
r_cons_show_cursor (R_TRUE);
|
||||
showcursor (core, R_TRUE);
|
||||
eprintf ("FOUND IN %d\n", cursor);
|
||||
r_cons_any_key ();
|
||||
} else {
|
||||
@ -253,7 +260,7 @@ R_API int r_core_visual_cmd(RCore *core, int ch) {
|
||||
return R_TRUE;
|
||||
}
|
||||
r_cons_printf ("Enter assembler opcodes separated with ';':\n");
|
||||
r_cons_show_cursor (R_TRUE);
|
||||
showcursor (core, R_TRUE);
|
||||
r_cons_flush ();
|
||||
r_cons_set_raw (R_FALSE);
|
||||
strcpy (buf, "wa ");
|
||||
@ -264,7 +271,7 @@ R_API int r_core_visual_cmd(RCore *core, int ch) {
|
||||
r_core_cmd (core, buf, R_TRUE);
|
||||
if (curset) r_core_seek (core, core->offset - cursor, 1);
|
||||
}
|
||||
r_cons_show_cursor (R_FALSE);
|
||||
showcursor (core, R_FALSE);
|
||||
r_cons_set_raw (R_TRUE);
|
||||
break;
|
||||
case 'A':
|
||||
@ -321,7 +328,7 @@ R_API int r_core_visual_cmd(RCore *core, int ch) {
|
||||
r_cons_any_key ();
|
||||
return R_TRUE;
|
||||
}
|
||||
r_cons_show_cursor (R_TRUE);
|
||||
showcursor (core, R_TRUE);
|
||||
r_cons_flush ();
|
||||
r_cons_set_raw (0);
|
||||
if (ch=='I') {
|
||||
@ -354,7 +361,7 @@ R_API int r_core_visual_cmd(RCore *core, int ch) {
|
||||
r_core_cmd (core, buf, 1);
|
||||
if (curset) r_core_seek (core, core->offset - cursor, 1);
|
||||
r_cons_set_raw (1);
|
||||
r_cons_show_cursor (R_FALSE);
|
||||
showcursor (core, R_FALSE);
|
||||
break;
|
||||
case 'R':
|
||||
r_core_cmd0 (core, "ecr");
|
||||
@ -722,7 +729,7 @@ R_API int r_core_visual_cmd(RCore *core, int ch) {
|
||||
break;
|
||||
case ';':
|
||||
r_cons_printf ("Enter a comment: ('-' to remove, '!' to use $EDITOR)\n");
|
||||
r_cons_show_cursor (R_TRUE);
|
||||
showcursor (core, R_TRUE);
|
||||
r_cons_flush ();
|
||||
r_cons_set_raw (R_FALSE);
|
||||
strcpy (buf, "CC ");
|
||||
@ -747,7 +754,7 @@ R_API int r_core_visual_cmd(RCore *core, int ch) {
|
||||
if (curset) r_core_seek (core, orig, 1);
|
||||
}
|
||||
r_cons_set_raw (R_TRUE);
|
||||
r_cons_show_cursor (R_FALSE);
|
||||
showcursor (core, R_FALSE);
|
||||
break;
|
||||
case 'b':
|
||||
{
|
||||
@ -955,17 +962,19 @@ R_API int r_core_visual(RCore *core, const char *input) {
|
||||
int flags, ch;
|
||||
|
||||
obs = core->blocksize;
|
||||
core->vmode = R_TRUE;
|
||||
core->cons->event_data = core;
|
||||
core->cons->event_resize = \
|
||||
(RConsEvent)r_core_visual_refresh;
|
||||
//r_cons_set_cup (R_TRUE);
|
||||
|
||||
core->vmode = R_FALSE;
|
||||
while (*input) {
|
||||
if (!r_core_visual_cmd (core, input[0]))
|
||||
return 0;
|
||||
input++;
|
||||
}
|
||||
core->vmode = R_TRUE;
|
||||
core->cons->event_data = core;
|
||||
core->cons->event_resize = \
|
||||
(RConsEvent)r_core_visual_refresh;
|
||||
r_cons_show_cursor (R_FALSE);
|
||||
|
||||
// disable tee in cons
|
||||
teefile = r_cons_singleton ()->teefile;
|
||||
@ -1004,5 +1013,6 @@ R_API int r_core_visual(RCore *core, const char *input) {
|
||||
core->vmode = R_FALSE;
|
||||
core->cons->event_resize = NULL;
|
||||
core->cons->event_data = NULL;
|
||||
r_cons_show_cursor (R_TRUE);
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user