diff options
author | piaip <piaip@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2008-03-12 01:52:35 +0800 |
---|---|---|
committer | piaip <piaip@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2008-03-12 01:52:35 +0800 |
commit | fc02f02dde9445c8d6d1eb938bf9c63a2be698a5 (patch) | |
tree | eabadf410e9e2ff16113fc1e6e6f9e57758baedf /mbbsd | |
parent | 0312ef782e11700862f8f1e4d601706cdb8e0874 (diff) | |
download | pttbbs-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
Diffstat (limited to 'mbbsd')
-rw-r--r-- | mbbsd/io.c | 32 |
1 files changed, 22 insertions, 10 deletions
@@ -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 |