Skip to content

Commit

Permalink
Add scr.maxpage to remove the CONS_MAX_USER constant ##cons
Browse files Browse the repository at this point in the history
  • Loading branch information
trufae committed May 26, 2022
1 parent 9a6c7a0 commit eca58ce
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
3 changes: 2 additions & 1 deletion libr/cons/cons.c
Expand Up @@ -653,6 +653,7 @@ R_API RCons *r_cons_new(void) {
I->fdout = 1;
I->break_lines = false;
I->lines = 0;
I->maxpage = 102400;

r_cons_context_reset ();
cons_context_init (C, NULL);
Expand Down Expand Up @@ -1090,7 +1091,7 @@ R_API void r_cons_flush(void) {
r_sys_cmd_str_full (I->pager, C->buffer, -1, NULL, NULL, NULL);
r_cons_reset ();
}
} else if (C->buffer_len > CONS_MAX_USER) {
} else if (I->maxpage > 0 && C->buffer_len > I->maxpage) {
#if COUNT_LINES
int i, lines = 0;
for (i = 0; C->buffer[i]; i++) {
Expand Down
9 changes: 8 additions & 1 deletion libr/core/cconfig.c
Expand Up @@ -2496,9 +2496,15 @@ static bool cb_scrlinesleep(void *user, void *data) {
return true;
}

static bool cb_scr_maxpage(void *user, void *data) {
RConfigNode *node = (RConfigNode *) data;
r_cons_singleton ()->maxpage = node->i_value;
return true;
}

static bool cb_scrpagesize(void *user, void *data) {
RConfigNode *node = (RConfigNode *) data;
r_cons_singleton ()->pagesize= node->i_value;
r_cons_singleton ()->pagesize = node->i_value;
return true;
}

Expand Down Expand Up @@ -4046,6 +4052,7 @@ R_API int r_core_config_init(RCore *core) {
SETPREF ("scr.loopnl", "false", "add a newline after every command executed in @@ loops");
SETICB ("scr.linesleep", 0, &cb_scrlinesleep, "flush sleeping some ms in every line");
SETICB ("scr.maxtab", 4096, &cb_completion_maxtab, "change max number of auto completion suggestions");
SETICB ("scr.maxpage", 102400, &cb_scr_maxpage, "change max chars to print before prompting the user");
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)");
SETBPREF ("scr.slow", "true", "do slow stuff on visual mode like RFlag.get_at(true)");
Expand Down
2 changes: 1 addition & 1 deletion libr/include/r_cons.h
Expand Up @@ -50,7 +50,6 @@ extern "C" {
#endif

/* constants */
#define CONS_MAX_USER 102400
#define CONS_BUFSZ 0x4f00
#define STR_IS_NULL(x) (!x || !x[0])

Expand Down Expand Up @@ -497,6 +496,7 @@ typedef struct r_cons_t {
bool dotted_lines;
int linesleep;
int pagesize;
int maxpage;
char *break_word;
int break_word_len;
ut64 timeout; // must come from r_time_now_mono()
Expand Down

0 comments on commit eca58ce

Please sign in to comment.