diff options
author | piaip <piaip@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2008-04-21 19:18:44 +0800 |
---|---|---|
committer | piaip <piaip@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2008-04-21 19:18:44 +0800 |
commit | c431922490f08beb011af18f9ffb72a74b5d3a1c (patch) | |
tree | bf928a74c788a892dfc88965b0d866a33eb895a9 /mbbsd/io.c | |
parent | 08bea601fe829e23a80cd66a3809e49590a43e2f (diff) | |
download | pttbbs-c431922490f08beb011af18f9ffb72a74b5d3a1c.tar pttbbs-c431922490f08beb011af18f9ffb72a74b5d3a1c.tar.gz pttbbs-c431922490f08beb011af18f9ffb72a74b5d3a1c.tar.bz2 pttbbs-c431922490f08beb011af18f9ffb72a74b5d3a1c.tar.lz pttbbs-c431922490f08beb011af18f9ffb72a74b5d3a1c.tar.xz pttbbs-c431922490f08beb011af18f9ffb72a74b5d3a1c.tar.zst pttbbs-c431922490f08beb011af18f9ffb72a74b5d3a1c.zip |
- refine key processing of CR(C-M), LF(C-J), BS(C-H), BS2(0x7f)
git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@4223 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
Diffstat (limited to 'mbbsd/io.c')
-rw-r--r-- | mbbsd/io.c | 42 |
1 files changed, 31 insertions, 11 deletions
@@ -278,19 +278,39 @@ dogetch(void) lastact = now; } - // CR LF are treated as one. - if (inbuf[icurrchar] == Ctrl('M')) + // CRLF Handle: + // + // (UNIX) LF + // (WIN) CRLF + // (MAC) CR + // + // to work in a compatible way, (see KEY_ENTER definition) + // let KEY_ENTER = CR + { - if (++icurrchar < ibufsize && - inbuf[icurrchar] == Ctrl('J')) - icurrchar ++; - return Ctrl('M'); - } + unsigned char c = (unsigned char) inbuf[icurrchar++]; - // XXX also treat ^H and 127 (KEY_BS2) the same one? - // if (inbuf[icurrchar] == KEY_BS2) - // return Ctrl('H'); - return (unsigned char)inbuf[icurrchar++]; + // CR LF are treated as one. + if (c == KEY_CR) + { + // peak next character. + if (icurrchar < ibufsize && inbuf[icurrchar] == KEY_LF) + icurrchar ++; + return KEY_ENTER; + } + else if (c == KEY_LF) + { + return KEY_ENTER; + } + + // XXX also treat ^H and 127 (KEY_BS2) the same one? + // else if (c == KEY_BS2) + // { + // return KEY_BS; + // } + + return c; + } } #ifdef DEBUG |