summaryrefslogtreecommitdiffstatshomepage
path: root/3rdparty
diff options
context:
space:
mode:
author cracyc <cracyc@users.noreply.github.com>2017-07-23 20:41:08 -0500
committer cracyc <cracyc@users.noreply.github.com>2017-07-23 20:41:08 -0500
commit81079946a4e1308ec4c02f69e9aebc27ec4bb3d1 (patch)
tree3e1d9906808ace432f82536a46e3352e37bd0b4e /3rdparty
parent90abd22229b3567c6c836c0bc40fa5facfbabd33 (diff)
luaengine: debugger_manager support [Carl]
Diffstat (limited to '3rdparty')
-rw-r--r--3rdparty/linenoise/linenoise.c34
-rw-r--r--3rdparty/linenoise/linenoise.h2
-rw-r--r--3rdparty/lua-linenoise/linenoise.c7
3 files changed, 42 insertions, 1 deletions
diff --git a/3rdparty/linenoise/linenoise.c b/3rdparty/linenoise/linenoise.c
index 1291d08d9ed..3c63ffe4a96 100644
--- a/3rdparty/linenoise/linenoise.c
+++ b/3rdparty/linenoise/linenoise.c
@@ -160,6 +160,7 @@ static int history_len = 0;
static char **history = NULL;
static char preload_buf[LINENOISE_MAX_LINE];
static int preload = 0;
+static int refresh = 0;
/* Structure to contain the status of the current (being edited) line */
struct current {
@@ -184,6 +185,7 @@ struct current {
static int fd_read(struct current *current);
static int getWindowSize(struct current *current);
+static void refreshLine(const char *prompt, struct current *current);
void linenoiseHistoryFree(void) {
if (history) {
@@ -408,6 +410,23 @@ static int fd_read_char(int fd, int timeout)
*/
static int fd_read(struct current *current)
{
+ struct pollfd p;
+ int ret;
+ p.fd = current->fd;
+ p.events = POLLIN;
+ while(1) {
+ ret = poll(&p, 1, 100);
+ if (ret == -1)
+ return -1;
+ else if (!ret) {
+ if (!refresh)
+ continue;
+ refresh = 0;
+ refreshLine(current->prompt, current);
+ }
+ else
+ break;
+ }
#ifdef USE_UTF8
char buf[4];
int n;
@@ -799,7 +818,15 @@ static int fd_read(struct current *current)
while (1) {
INPUT_RECORD irec;
DWORD n;
- if (WaitForSingleObject(current->inh, INFINITE) != WAIT_OBJECT_0) {
+ DWORD ret = WaitForSingleObject(current->inh, 100);
+ if (ret == WAIT_TIMEOUT) {
+ if (!refresh)
+ continue;
+ refresh = 0;
+ refreshLine(current->prompt, current);
+ continue;
+ }
+ else if (ret != WAIT_OBJECT_0) {
break;
}
if (!ReadConsoleInput (current->inh, &irec, 1, &n)) {
@@ -1580,6 +1607,11 @@ void linenoisePreloadBuffer(const char* preloadText)
strcpy(preload_buf, preloadText);
}
+void linenoiseRefresh(void)
+{
+ refresh = 1;
+}
+
char *linenoise(const char *prompt)
{
int count;
diff --git a/3rdparty/linenoise/linenoise.h b/3rdparty/linenoise/linenoise.h
index d6688099c42..aa1f77ec819 100644
--- a/3rdparty/linenoise/linenoise.h
+++ b/3rdparty/linenoise/linenoise.h
@@ -125,4 +125,6 @@ int linenoiseColumns(void);
void linenoisePreloadBuffer(const char* preloadText);
+void linenoiseRefresh(void);
+
#endif /* __LINENOISE_H */
diff --git a/3rdparty/lua-linenoise/linenoise.c b/3rdparty/lua-linenoise/linenoise.c
index f7a8a60d1de..768d455729d 100644
--- a/3rdparty/lua-linenoise/linenoise.c
+++ b/3rdparty/lua-linenoise/linenoise.c
@@ -169,6 +169,12 @@ static int l_addcompletion(lua_State *L)
return handle_ln_ok(L);
}
+static int l_refresh(lua_State *L)
+{
+ linenoiseRefresh();
+ return handle_ln_ok(L);
+}
+
luaL_Reg linenoise_funcs[] = {
{ "linenoise", l_linenoise },
{ "historyadd", l_historyadd },
@@ -179,6 +185,7 @@ luaL_Reg linenoise_funcs[] = {
{ "setcompletion", l_setcompletion},
{ "addcompletion", l_addcompletion },
{ "preload", l_preloadbuffer },
+ { "refresh", l_refresh },
/* Aliases for more consistent function names */
{ "addhistory", l_historyadd },