From 525ac36db85be7dd442b654f789582fa12dab91e Mon Sep 17 00:00:00 2001 From: piaip Date: Sun, 6 Jan 2008 11:03:14 +0000 Subject: - fixed: peek_input keeps waiting for new input. (due to buf control) git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@3799 63ad8ddf-47c3-0310-b6dd-a9e9d9715204 --- mbbsd/bbslua.c | 16 ++++++++++++---- mbbsd/io.c | 14 ++++++-------- mbbsd/user.c | 3 ++- 3 files changed, 20 insertions(+), 13 deletions(-) (limited to 'mbbsd') diff --git a/mbbsd/bbslua.c b/mbbsd/bbslua.c index 09c75dcc..98802b4a 100644 --- a/mbbsd/bbslua.c +++ b/mbbsd/bbslua.c @@ -33,8 +33,8 @@ ////////////////////////////////////////////////////////////////////////// #define BLAPI_PROTO int -#define BLCONF_EXEC_COUNT (1000) -#define BLCONF_PEEK_TIME (0.1) +#define BLCONF_EXEC_COUNT (5000) +#define BLCONF_PEEK_TIME (0.01) #define BLCONF_BREAK_KEY Ctrl('C') ////////////////////////////////////////////////////////////////////////// @@ -143,6 +143,14 @@ bl_addstr(lua_State* L) return 0; } +BLAPI_PROTO +bl_print(lua_State* L) +{ + bl_addstr(L); + outc('\n'); + return 0; +} + void bl_k2s(lua_State* L, int v) { @@ -343,8 +351,8 @@ static const struct luaL_reg lib_bbslua [] = { { "refresh", bl_refresh }, { "redrawwin", bl_redrawwin }, { "addstr", bl_addstr }, - { "print", bl_addstr }, { "outs", bl_addstr }, + { "print", bl_print }, /* input */ { "getch", bl_getch }, { "getdata", bl_getstr }, @@ -402,7 +410,7 @@ bbsluaRegConst(lua_State *L, const char *globName) lua_settable(L, -3); // global - lua_pushcfunction(L, bl_addstr); + lua_pushcfunction(L, bl_print); lua_setglobal(L, "print"); } diff --git a/mbbsd/io.c b/mbbsd/io.c index 030509e7..64d5b1a1 100644 --- a/mbbsd/io.c +++ b/mbbsd/io.c @@ -325,7 +325,8 @@ _debug_check_keyinput() } else { outs("Waiting for key input. 'q' to exit, 'd' to try dbcs-aware"); } - wait_input(-1, 1); + refresh(); + wait_input(-1, 0); switch(dogetch()) { case 'd': @@ -647,21 +648,18 @@ igetch(void) * Return 1 if anything available. */ int -wait_input(float f, int flDoRefresh) +wait_input(float f, int bIgnoreBuf) { int sel = 0; fd_set readfds; struct timeval tv, *ptv = &tv; - if(num_in_buf() > 0) // for EINTR + if(!bIgnoreBuf && num_in_buf() > 0) return 1; FD_ZERO(&readfds); FD_SET(0, &readfds); - if(flDoRefresh) - refresh(); - if(f > 0) { tv.tv_sec = (long) f; @@ -674,7 +672,7 @@ wait_input(float f, int flDoRefresh) #endif do { - if(num_in_buf() > 0) + if(!bIgnoreBuf && num_in_buf() > 0) return 1; sel = select(1, &readfds, NULL, NULL, ptv); } while (sel < 0 && errno == EINTR); @@ -699,7 +697,7 @@ peek_input(float f, int c) assert (c > 0 && c < ' '); // only ^x keys are safe to be detected. // other keys may fall into escape sequence. - if (wait_input(f, 0) && (IBUFSIZE > ibufsize)) + if (wait_input(f, 1) && (IBUFSIZE > ibufsize)) { int len = tty_read(inbuf + ibufsize, IBUFSIZE - ibufsize); #ifdef CONVERT diff --git a/mbbsd/user.c b/mbbsd/user.c index c68dc5b3..182f8610 100644 --- a/mbbsd/user.c +++ b/mbbsd/user.c @@ -2062,7 +2062,8 @@ int u_detectDBCSAwareEvilClient() * years) of num_in_buf forced me to write new wait_input. * Anyway it is fixed now. */ - if(wait_input(0.1, 1)) + refresh(); + if(wait_input(0.1, 0)) // if(igetch() == ch) // if (num_in_buf() > 0) { -- cgit v1.2.3