mirror of
https://github.com/radareorg/radare2.git
synced 2024-11-27 07:00:30 +00:00
Add scr.timeout covering the ^C blocks ##shell
This commit is contained in:
parent
3803f33f6c
commit
6b0032fa68
@ -446,10 +446,14 @@ R_API void r_cons_context_break_pop(RConsContext *context, bool sig) {
|
||||
}
|
||||
|
||||
R_API void r_cons_break_push(RConsBreak cb, void *user) {
|
||||
if (r_stack_size (C->break_stack) > 0) {
|
||||
r_cons_break_timeout (I->otimeout);
|
||||
}
|
||||
r_cons_context_break_push (C, cb, user, true);
|
||||
}
|
||||
|
||||
R_API void r_cons_break_pop(void) {
|
||||
I->timeout = 0;
|
||||
r_cons_context_break_pop (C, true);
|
||||
}
|
||||
|
||||
@ -478,11 +482,12 @@ R_API bool r_cons_is_breaked(void) {
|
||||
I->cb_break (I->user);
|
||||
}
|
||||
if (R_UNLIKELY (I->timeout)) {
|
||||
if (r_time_now_mono () > I->timeout) {
|
||||
C->breaked = true;
|
||||
C->was_breaked = true;
|
||||
eprintf ("\nTimeout!\n");
|
||||
I->timeout = 0;
|
||||
if (r_stack_size (C->break_stack) > 0) {
|
||||
if (r_time_now_mono () > I->timeout) {
|
||||
C->breaked = true;
|
||||
C->was_breaked = true;
|
||||
r_cons_break_timeout (I->otimeout);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (R_UNLIKELY (!C->was_breaked)) {
|
||||
@ -539,8 +544,17 @@ R_API int r_cons_get_cur_line(void) {
|
||||
}
|
||||
|
||||
R_API void r_cons_break_timeout(int timeout) {
|
||||
if (timeout > 0) {
|
||||
I->timeout = r_time_now_mono () + (timeout * 1000);
|
||||
I->otimeout = timeout;
|
||||
} else {
|
||||
I->otimeout = 0;
|
||||
I->timeout = 0;
|
||||
}
|
||||
#if 0
|
||||
I->timeout = (timeout && !I->timeout)
|
||||
? r_time_now_mono () + ((ut64) timeout << 20) : 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
R_API void r_cons_break_end(void) {
|
||||
|
@ -2457,6 +2457,12 @@ static bool cb_scroptimize(void* user, void* data) {
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool cb_scrtimeout(void* user, void* data) {
|
||||
RConfigNode *node = (RConfigNode*) data;
|
||||
r_cons_break_timeout (node->i_value);
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool cb_scrcolumns(void* user, void* data) {
|
||||
RConfigNode *node = (RConfigNode*) data;
|
||||
RCore *core = (RCore*) user;
|
||||
@ -4287,6 +4293,7 @@ R_API int r_core_config_init(RCore *core) {
|
||||
SETCB ("scr.gadgets", "true", &cb_scr_gadgets, "run pg in prompt, visual and panels");
|
||||
SETBPREF ("scr.panelborder", "false", "specify panels border active area (0 by default)");
|
||||
SETCB ("scr.theme", "default", &cb_scrtheme, "specify the theme name to load on startup (See 'ec?')");
|
||||
SETICB ("scr.timeout", 0, &cb_scrtimeout, "check for timeout during the break.(push|pop) contexts");
|
||||
SETICB ("scr.cols", 0, &cb_scrcolumns, "force console column count (width)");
|
||||
SETICB ("scr.optimize", 0, &cb_scroptimize, "optimize the amount of ansi escapes and spaces (0, 1, 2 passes)");
|
||||
SETBPREF ("scr.dumpcols", "false", "prefer pC commands before p ones");
|
||||
|
@ -543,7 +543,8 @@ typedef struct r_cons_t {
|
||||
int maxpage;
|
||||
char *break_word;
|
||||
int break_word_len;
|
||||
ut64 timeout; // must come from r_time_now_mono()
|
||||
ut64 timeout;
|
||||
int otimeout;
|
||||
char* (*rgbstr)(char *str, size_t sz, ut64 addr);
|
||||
bool click_set;
|
||||
int click_x;
|
||||
|
Loading…
Reference in New Issue
Block a user