diff options
author | piaip <piaip@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2008-01-05 12:22:34 +0800 |
---|---|---|
committer | piaip <piaip@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2008-01-05 12:22:34 +0800 |
commit | 306ae489376906fe06e7abcfa119aeba3cf1095c (patch) | |
tree | 0c9abf8cb74894f18d205efd8ca76605aba12386 /mbbsd/io.c | |
parent | 17c4b2bd5db1169e22c9adca2d86559a1ed03f5c (diff) | |
download | pttbbs-306ae489376906fe06e7abcfa119aeba3cf1095c.tar pttbbs-306ae489376906fe06e7abcfa119aeba3cf1095c.tar.gz pttbbs-306ae489376906fe06e7abcfa119aeba3cf1095c.tar.bz2 pttbbs-306ae489376906fe06e7abcfa119aeba3cf1095c.tar.lz pttbbs-306ae489376906fe06e7abcfa119aeba3cf1095c.tar.xz pttbbs-306ae489376906fe06e7abcfa119aeba3cf1095c.tar.zst pttbbs-306ae489376906fe06e7abcfa119aeba3cf1095c.zip |
- io: add more control API
- bbslua: enable system break
git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@3788 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
Diffstat (limited to 'mbbsd/io.c')
-rw-r--r-- | mbbsd/io.c | 48 |
1 files changed, 48 insertions, 0 deletions
@@ -168,6 +168,12 @@ num_in_buf(void) return ibufsize - icurrchar; } +int +input_isfull(void) +{ + return ibufsize >= IBUFSIZE; +} + /* * dogetch() is not reentrant-safe. SIGUSR[12] might happen at any time, and * dogetch() might be called again, and then ibufsize/icurrchar/inbuf might @@ -236,6 +242,17 @@ dogetch(void) if(len > 0) len = input_wrapper(inbuf, len); #endif +#ifdef DBG_OUTRPT + // if (0) + { + static char xbuf[128]; + sprintf(xbuf, ESC_STR "[s" ESC_STR "[2;1H [%ld] " + ESC_STR "[u", len); + write(1, xbuf, strlen(xbuf)); + fsync(1); + } +#endif // DBG_OUTRPT + } while (len <= 0); ibufsize = len; @@ -669,6 +686,37 @@ wait_input(float f, int flDoRefresh) return 1; } +void +drop_input(void) +{ + icurrchar = ibufsize = 0; +} + +int +peek_input(float f, int c) +{ + int i = 0; + 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)) + { + int len = tty_read(inbuf + ibufsize, IBUFSIZE - ibufsize); +#ifdef CONVERT + if(len > 0) + len = input_wrapper(inbuf+ibufsize, len); +#endif + if (len > 0) + ibufsize += len; + } + for (i = icurrchar; i < ibufsize; i++) + { + if (inbuf[i] == c) + return 1; + } + return 0; +} + #ifdef DBCSAWARE |