Implement r_cons_readpush() new api and fix the V... automation

This commit is contained in:
pancake 2018-02-28 00:26:41 +01:00
parent 19bdc6f41a
commit 2497fb6f51
4 changed files with 17 additions and 2 deletions

View file

@ -233,3 +233,4 @@ Don't trust what can't be compiled
Coffee time!
Can you you challenge a perfect immortal machine?
Add more blockchains to your life.
Congratulations! You got the segfault 1.000.000! Click [here] to win a prize!

View file

@ -275,7 +275,7 @@ R_API int r_cons_any_key(const char *msg) {
#if __WINDOWS__ && !__CYGWIN__
static int readchar_win(ut32 usec) {
int ch=0;
int ch = 0;
BOOL ret;
BOOL bCtrl = FALSE;
DWORD mode, out;
@ -458,9 +458,21 @@ R_API int r_cons_readchar_timeout(ut32 usec) {
#endif
}
// TODO: support binary? buf+len
static char *readbuffer = NULL;
R_API void r_cons_readpush(const char *str) {
readbuffer = r_str_append (readbuffer, str);
}
R_API int r_cons_readchar() {
char buf[2];
buf[0] = -1;
if (readbuffer && *readbuffer) {
int ch = *readbuffer;
memmove (readbuffer, readbuffer + 1, strlen (readbuffer));
return ch;
}
#if __WINDOWS__ && !__CYGWIN__ //&& !MINGW32
#if 1 // if something goes wrong set this to 0. skuater.....
return readchar_win(0);

View file

@ -1173,7 +1173,8 @@ static int cmd_visual(void *data, const char *input) {
if (!r_config_get_i (core->config, "scr.interactive")) {
return false;
}
return r_core_visual ((RCore *)data, input);
r_cons_readpush (input);
return r_core_visual ((RCore *)data, ""); //NULL); //input);
}
static int task_finished(void *user, void *data) {

View file

@ -698,6 +698,7 @@ R_API void r_cons_cmd_help(const char * help[], bool use_color);
//R_API int r_cons_fgets(char *buf, int len, int argc, const char **argv);
R_API int r_cons_controlz(int ch);
R_API int r_cons_readchar(void);
R_API void r_cons_readpush(const char *str);
R_API int r_cons_readchar_timeout(ut32 usec);
R_API int r_cons_any_key(const char *msg);
R_API int r_cons_eof(void);