From 1b48c6b5e274d2744286e70300a36e758763aa7e Mon Sep 17 00:00:00 2001 From: piaip Date: Wed, 8 Jun 2005 16:44:52 +0000 Subject: debug mode: raw key escape codes checker git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@2809 63ad8ddf-47c3-0310-b6dd-a9e9d9715204 --- mbbsd/io.c | 92 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++---- mbbsd/menu.c | 11 ++++++++ 2 files changed, 98 insertions(+), 5 deletions(-) diff --git a/mbbsd/io.c b/mbbsd/io.c index a57d005c..620bec77 100644 --- a/mbbsd/io.c +++ b/mbbsd/io.c @@ -220,6 +220,80 @@ dogetch(void) return (unsigned char)inbuf[icurrchar++]; } +#ifdef DEBUG +/* + * These are for terminal keys debug + */ +void +_debug_print_ibuffer() +{ + static int y = 0; + int i = 0; + + move(y % b_lines, 0); + for (i = 0; i < t_columns; i++) + outc(' '); + move(y % b_lines, 0); + prints("%d. Current Buffer: %d/%d, ", y+1, icurrchar, ibufsize); + outs(ANSI_COLOR(1) "[" ANSI_RESET); + for (i = 0; i < ibufsize; i++) + { + int c = (unsigned char)inbuf[i]; + if(c < ' ') + { + prints(ANSI_COLOR(1;33) "0x%02x" ANSI_RESET, c); + } else { + outc(c); + } + } + outs(ANSI_COLOR(1) "]" ANSI_RESET); + y++; + move(y % b_lines, 0); + for (i = 0; i < t_columns; i++) + outc(' '); +} + +int +_debug_check_keyinput() +{ + int dbcsaware = 0; + int flExit = 0; + + clear(); + while(!flExit) + { + int i = 0; + move(b_lines, 0); + for(i=0; i 0) + dogetch(); + } + return 0; +} + +#endif + static int water_which_flag = 0; int @@ -516,6 +590,7 @@ igetch(void) /* * wait user input anything for f seconds. + * if f < 0, then wait forever. * Return 1 if anything available. */ int @@ -523,9 +598,9 @@ wait_input(float f, int flDoRefresh) { int sel = 0; fd_set readfds; - struct timeval tv; + struct timeval tv, *ptv = &tv; - if(num_in_buf() > 0) + if(num_in_buf() > 0) // for EINTR return 1; FD_ZERO(&readfds); @@ -533,15 +608,22 @@ wait_input(float f, int flDoRefresh) if(flDoRefresh) refresh(); - tv.tv_sec = (long) f; - tv.tv_usec = (f - (long)f) * 1000000L; + + if(f > 0) + { + tv.tv_sec = (long) f; + tv.tv_usec = (f - (long)f) * 1000000L; + } else + ptv = NULL; #ifdef STATINC STATINC(STAT_SYSSELECT); #endif do { - sel = select(1, &readfds, NULL, NULL, &tv); + if(num_in_buf() > 0) + return 1; + sel = select(1, &readfds, NULL, NULL, ptv); } while (sel < 0 && errno == EINTR); /* EINTR, interrupted. I don't care! */ diff --git a/mbbsd/menu.c b/mbbsd/menu.c index 2d524374..ad11a72a 100644 --- a/mbbsd/menu.c +++ b/mbbsd/menu.c @@ -411,8 +411,14 @@ static const commands_t userlist[] = { {NULL, 0, NULL} }; +#ifdef DEBUG +int _debug_check_keyinput(); +#endif + /* XYZ tool menu */ static const commands_t xyzlist[] = { +#ifndef DEBUG + /* All these are useless in debug mode. */ #ifdef HAVE_LICENSE {x_gpl, 0, "LLicense GNU 使用執照"}, #endif @@ -429,6 +435,11 @@ static const commands_t xyzlist[] = { {x_today, 0, "TToday 《今日上線人次統計》"}, {x_yesterday, 0, "YYesterday 《昨日上線人次統計》"}, {x_user100 ,0, "UUsers 《使用者百大排行榜》"}, +#else + {_debug_check_keyinput, 0, + "MMKeycode 檢查按鍵控制碼工具"}, +#endif + {p_sysinfo, 0, "XXinfo 《查看系統資訊》"}, {NULL, 0, NULL} }; -- cgit v1.2.3