summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpiaip <piaip@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2008-03-12 01:52:35 +0800
committerpiaip <piaip@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2008-03-12 01:52:35 +0800
commitfc02f02dde9445c8d6d1eb938bf9c63a2be698a5 (patch)
treeeabadf410e9e2ff16113fc1e6e6f9e57758baedf
parent0312ef782e11700862f8f1e4d601706cdb8e0874 (diff)
downloadpttbbs-fc02f02dde9445c8d6d1eb938bf9c63a2be698a5.tar
pttbbs-fc02f02dde9445c8d6d1eb938bf9c63a2be698a5.tar.gz
pttbbs-fc02f02dde9445c8d6d1eb938bf9c63a2be698a5.tar.bz2
pttbbs-fc02f02dde9445c8d6d1eb938bf9c63a2be698a5.tar.lz
pttbbs-fc02f02dde9445c8d6d1eb938bf9c63a2be698a5.tar.xz
pttbbs-fc02f02dde9445c8d6d1eb938bf9c63a2be698a5.tar.zst
pttbbs-fc02f02dde9445c8d6d1eb938bf9c63a2be698a5.zip
- vt100/200 key conversion: improve error handling (may cause endless loop) for HOME/INS family.
git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@3993 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
-rw-r--r--mbbsd/io.c32
1 files changed, 22 insertions, 10 deletions
diff --git a/mbbsd/io.c b/mbbsd/io.c
index 66418259..ae78bbcd 100644
--- a/mbbsd/io.c
+++ b/mbbsd/io.c
@@ -452,29 +452,41 @@ igetch(void)
/* ~: Ins Del Home End PgUp PgDn */
if(ch == '~')
- return KEY_HOME + (last - '1');
+ {
+ // vt220 style
+ if (last >= '1' && last <= '6')
+ return KEY_HOME + (last - '1');
+ // else, unknown.
+ return KEY_UNKNOWN;
+ }
else if (last == '1')
{
if (ch >= '1' && ch <= '6')
{
- dogetch(); /* must be '~' */
- return KEY_F1 + ch - '1';
+ // use num_in_buf() to prevent waiting keys
+ if (num_in_buf() && dogetch() == '~') /* must be '~' */
+ return KEY_F1 + ch - '1';
}
else if (ch >= '7' && ch <= '9')
{
- dogetch(); /* must be '~' */
- return KEY_F6 + ch - '7';
+ // use num_in_buf() to prevent waiting keys
+ if (num_in_buf() && dogetch() == '~') /* must be '~' */
+ return KEY_F6 + ch - '7';
}
- else return KEY_UNKNOWN;
- } else if (last == '2')
+ return KEY_UNKNOWN;
+ }
+ else if (last == '2')
{
if (ch >= '0' && ch <= '4')
{
- dogetch(); /* hope you are '~' */
- return KEY_F9 + ch - '0';
+ // use inbuf() to prevent waiting keys
+ if (num_in_buf() && dogetch() == '~') /* hope you are '~' */
+ return KEY_F9 + ch - '0';
}
- else return KEY_UNKNOWN;
+ return KEY_UNKNOWN;
}
+ // if fall here, then escape sequence is broken.
+ return KEY_UNKNOWN;
}
else // here is switch for default keys
switch (ch) { // XXX: indent error