mirror of
https://github.com/radareorg/radare2.git
synced 2024-11-27 23:20:40 +00:00
Implement scr.linesleep and scr.pagesize for fancier demo output
This commit is contained in:
parent
2d0b00222a
commit
22e024d5de
@ -246,6 +246,7 @@ R_API RCons *r_cons_new() {
|
||||
I.event_data = NULL;
|
||||
I.is_interactive = true;
|
||||
I.noflush = false;
|
||||
I.linesleep = 0;
|
||||
I.fdin = stdin;
|
||||
I.fdout = 1;
|
||||
I.breaked = false;
|
||||
@ -253,7 +254,7 @@ R_API RCons *r_cons_new() {
|
||||
I.buffer = NULL;
|
||||
I.buffer_sz = 0;
|
||||
I.buffer_len = 0;
|
||||
r_cons_get_size (NULL);
|
||||
r_cons_get_size (&I.pagesize);
|
||||
I.num = NULL;
|
||||
I.null = 0;
|
||||
#if __WINDOWS__ && !__CYGWIN__
|
||||
@ -538,7 +539,27 @@ R_API void r_cons_flush() {
|
||||
if (I.is_html) {
|
||||
r_cons_html_print (I.buffer);
|
||||
} else {
|
||||
r_cons_write (I.buffer, I.buffer_len);
|
||||
if (I.linesleep > 0 && I.linesleep < 1000) {
|
||||
int i = 0;
|
||||
char *ptr = I.buffer;
|
||||
char *nl = strchr (ptr, '\n');
|
||||
int len = I.buffer_len;
|
||||
I.buffer[I.buffer_len] = 0;
|
||||
r_cons_break (NULL, NULL);
|
||||
while (nl && !r_cons_is_breaked ()) {
|
||||
r_cons_write (ptr, nl - ptr + 1);
|
||||
if (!(i % I.pagesize)) {
|
||||
r_sys_usleep (I.linesleep * 1000);
|
||||
}
|
||||
ptr = nl + 1;
|
||||
nl = strchr (ptr, '\n');
|
||||
i++;
|
||||
}
|
||||
r_cons_write (ptr, I.buffer + len - ptr);
|
||||
r_cons_break_end ();
|
||||
} else {
|
||||
r_cons_write (I.buffer, I.buffer_len);
|
||||
}
|
||||
}
|
||||
|
||||
r_cons_reset ();
|
||||
|
@ -446,7 +446,7 @@ static int cb_asmfeatures(void *user, void *data) {
|
||||
static int cb_asmcpu(void *user, void *data) {
|
||||
RCore *core = (RCore *) user;
|
||||
RConfigNode *node = (RConfigNode *) data;
|
||||
if (*node->value=='?') {
|
||||
if (*node->value == '?') {
|
||||
rasm2_list (core, r_config_get (core->config, "asm.arch"), node->value[1]);
|
||||
return 0;
|
||||
}
|
||||
@ -1142,6 +1142,18 @@ static int cb_screcho(void *user, void *data) {
|
||||
return true;
|
||||
}
|
||||
|
||||
static int cb_scrlinesleep(void *user, void *data) {
|
||||
RConfigNode *node = (RConfigNode *) data;
|
||||
r_cons_singleton()->linesleep = node->i_value;
|
||||
return true;
|
||||
}
|
||||
|
||||
static int cb_scrpagesize(void *user, void *data) {
|
||||
RConfigNode *node = (RConfigNode *) data;
|
||||
r_cons_singleton()->pagesize= node->i_value;
|
||||
return true;
|
||||
}
|
||||
|
||||
static int cb_scrflush(void *user, void *data) {
|
||||
RConfigNode *node = (RConfigNode *) data;
|
||||
r_cons_singleton()->flush = node->i_value;
|
||||
@ -1980,6 +1992,8 @@ R_API int r_core_config_init(RCore *core) {
|
||||
#endif
|
||||
r_config_desc (cfg, "scr.fgets", "Use fgets() instead of dietline for prompt input");
|
||||
SETCB("scr.echo", "false", &cb_screcho, "Show rcons output in realtime to stderr and buffer");
|
||||
SETICB("scr.linesleep", 0, &cb_scrlinesleep, "Flush sleeping some ms in every line");
|
||||
SETICB("scr.pagesize", 1, &cb_scrpagesize, "Flush in pages when scr.linesleep is != 0");
|
||||
SETCB("scr.flush", "false", &cb_scrflush, "Force flush to console in realtime (breaks scripting)");
|
||||
/* TODO: rename to asm.color.ops ? */
|
||||
SETPREF("scr.zoneflags", "true", "Show zoneflags in visual mode before the title (see fz?)");
|
||||
|
@ -265,6 +265,8 @@ typedef struct r_cons_t {
|
||||
#endif
|
||||
bool flush;
|
||||
bool use_utf8; // use utf8 features
|
||||
int linesleep;
|
||||
int pagesize;
|
||||
} RCons;
|
||||
|
||||
// XXX THIS MUST BE A SINGLETON AND WRAPPED INTO RCons */
|
||||
|
Loading…
Reference in New Issue
Block a user