diff options
author | piaip <piaip@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2008-04-20 22:58:30 +0800 |
---|---|---|
committer | piaip <piaip@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2008-04-20 22:58:30 +0800 |
commit | 457fd9457edb48999f2a238f6f93ea0b2cbe254e (patch) | |
tree | cfbf9eaa2314d1d7afff0d104eae8cd21fff7f62 /mbbsd | |
parent | 45fd0b8bbba0062c3b815e5a09b27aec378ee3a1 (diff) | |
download | pttbbs-457fd9457edb48999f2a238f6f93ea0b2cbe254e.tar pttbbs-457fd9457edb48999f2a238f6f93ea0b2cbe254e.tar.gz pttbbs-457fd9457edb48999f2a238f6f93ea0b2cbe254e.tar.bz2 pttbbs-457fd9457edb48999f2a238f6f93ea0b2cbe254e.tar.lz pttbbs-457fd9457edb48999f2a238f6f93ea0b2cbe254e.tar.xz pttbbs-457fd9457edb48999f2a238f6f93ea0b2cbe254e.tar.zst pttbbs-457fd9457edb48999f2a238f6f93ea0b2cbe254e.zip |
- bbs: fixed: push_bottom nofitication not refreshed if abort.
- io: drop traditional getdata code
- read: prevent non-BM seeing ZA alert messages
- visio: change license to 2-clause BSD because I don't want to maintain compatible code...
git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@4219 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
Diffstat (limited to 'mbbsd')
-rw-r--r-- | mbbsd/bbs.c | 4 | ||||
-rw-r--r-- | mbbsd/io.c | 280 | ||||
-rw-r--r-- | mbbsd/read.c | 3 | ||||
-rw-r--r-- | mbbsd/visio.c | 37 |
4 files changed, 12 insertions, 312 deletions
diff --git a/mbbsd/bbs.c b/mbbsd/bbs.c index d843afdb..598d5106 100644 --- a/mbbsd/bbs.c +++ b/mbbsd/bbs.c @@ -3706,12 +3706,12 @@ push_bottom(int ent, fileheader_t *fhdr, const char *direct) if( vans(fhdr->filemode & FILE_BOTTOM ? "取消置底公告?(y/N)": "加入置底公告?(y/N)") != 'y' ) - return READ_REDRAW; + return FULLUPDATE; if(!(fhdr->filemode & FILE_BOTTOM) ){ snprintf(buf, sizeof(buf), "%s.bottom", direct); if(num >= 5){ vmsg("不得超過 5 篇重要公告 請精簡!"); - return READ_REDRAW; + return FULLUPDATE; } fhdr->filemode ^= FILE_BOTTOM; fhdr->multi.refer.flag = 1; @@ -741,256 +741,6 @@ peek_input(float f, int c) return 0; } -#ifndef TRY_VGETS - -#define MAXLASTCMD 12 -static int -getdata_raw(int line, int col, const char *prompt, char *buf, int len, int echo) -{ - register int ch, i; - int clen, lprompt = 0; - int cx = col, cy = line; - static char lastcmd[MAXLASTCMD][80]; - unsigned char occupy_msg = 0; - -#ifdef DBCSAWARE - unsigned int dbcsincomplete = 0; -#endif - - strip_ansi(buf, buf, STRIP_ALL); - if (prompt) - { - lprompt = strlen_noansi(prompt); - cx += lprompt; - } - - if(line == b_lines-msg_occupied) - occupy_msg=1, msg_occupied ++; - - // workaround poor terminal - move_ansi(line, col); - getyx(&line, &col); - clrtoeol(); - - // (line, col) are real starting address - - if (!echo) { - if (prompt) outs(prompt); - len--; - clen = 0; - while ((ch = igetch()) != '\r') { - if (ch == Ctrl('C')) - { - // abort - clen = 0; - if (len > 1) - buf[1] = ch; // workaround for BBS-Lua - break; - } - if (ch == KEY_BS2 || ch == Ctrl('H')) { - if (!clen) { - bell(); - continue; - } - clen--; - continue; - } - if (ch>=0x100 || !isprint(ch)) { - bell(); - continue; - } - if (clen >= len) { - bell(); - continue; - } - buf[clen++] = ch; - } - buf[clen] = '\0'; - outc('\n'); - oflush(); - } else { - int cmdpos = 0; - int currchar = 0; - - len--; - buf[len] = '\0'; - clen = currchar = strlen(buf); - - while (1) { - // refresh from prompt - move(line, col); outc(' '); move(line, col); clrtoeol(); - if (prompt) outs(prompt); - - outs(ANSI_COLOR(7)); - outs(buf); - for(i=clen; i<=len; i++) - outc(' '); - outs(ANSI_RESET); - move(cy, cx + currchar); - - if ((ch = igetch()) == '\r') - break; - - if (ch == Ctrl('C')) - { - // abort - clen = currchar = 0; - if (len > 1) - buf[1] = ch; // workaround for BBS-Lua - break; - } - - switch (ch) { - case Ctrl('A'): - case KEY_HOME: - currchar = 0; - break; - - case Ctrl('E'): - case KEY_END: - currchar = clen; - break; - - case KEY_UNKNOWN: - break; - - case KEY_LEFT: - if (currchar <= 0) - break; - --currchar; -#ifdef DBCSAWARE - if(currchar > 0 && ISDBCSAWARE() && - DBCS_Status(buf, currchar) == DBCS_TRAILING) - currchar --; -#endif - break; - - case KEY_RIGHT: - if (!buf[currchar]) - break; - ++currchar; -#ifdef DBCSAWARE - if(buf[currchar] && ISDBCSAWARE() && - DBCS_Status(buf, currchar) == DBCS_TRAILING) - currchar++; -#endif - break; - - case Ctrl('Y'): - currchar = 0; - case Ctrl('K'): - /* we shoud be able to avoid DBCS issues in ^K mode */ - buf[currchar] = '\0'; - clen = currchar; - break; - - case KEY_DOWN: case Ctrl('N'): - case KEY_UP: case Ctrl('P'): - strlcpy(lastcmd[cmdpos], buf, sizeof(lastcmd[0])); - if (ch == KEY_UP || ch == Ctrl('P')) - cmdpos++; - else - cmdpos += MAXLASTCMD - 1; - cmdpos %= MAXLASTCMD; - strlcpy(buf, lastcmd[cmdpos], len+1); - clen = currchar = strlen(buf); - break; - - case KEY_BS2: - case Ctrl('H'): - if (!currchar) - break; -#ifdef DBCSAWARE - if (ISDBCSAWARE() && DBCS_Status(buf, - currchar-1) == DBCS_TRAILING) - { - memmove(buf+currchar-1, buf+currchar, clen-currchar+1); - currchar--, clen--; - } -#endif - memmove(buf+currchar-1, buf+currchar, clen-currchar+1); - currchar--, clen--; - break; - - case Ctrl('D'): - case KEY_DEL: - if (!buf[currchar]) - break; -#ifdef DBCSAWARE - if (ISDBCSAWARE() && buf[currchar+1] && DBCS_Status( - buf, currchar+1) == DBCS_TRAILING) - { - memmove(buf+currchar, buf+currchar+1, clen-currchar); - clen --; - } -#endif - memmove(buf+currchar, buf+currchar+1, clen-currchar); - clen --; - break; - - default: - if (echo == NUMECHO && !isdigit(ch)) - { - bell(); - break; - } - if (isprint2(ch) && clen < len && cx + clen < scr_cols) { -#ifdef DBCSAWARE - if(ISDBCSAWARE()) - { - /* to prevent single byte input */ - if(dbcsincomplete) - { - dbcsincomplete = 0; - } - else if (ch >= 0x80) - { - dbcsincomplete = 1; - if(clen + 2 > len) - { - /* we can't print this. ignore and eat key. */ - igetch(); - dbcsincomplete = 0; - break; - } - } else { - /* nothing, normal key. */ - } - } -#endif - for (i = clen + 1; i > currchar; i--) - buf[i] = buf[i - 1]; - buf[currchar] = ch; - currchar++; - clen++; - } - break; - } /* end case */ - assert(0<=clen); - } /* end while */ - buf[clen] = '\0'; - - if (clen > 1) { - strlcpy(lastcmd[0], buf, sizeof(lastcmd[0])); - memmove(lastcmd+1, lastcmd, (MAXLASTCMD-1)*sizeof(lastcmd[0])); - } - /* why return here? because some code then outs.*/ - // outc('\n'); - move(line+1, 0); - refresh(); - - assert(0<=currchar && currchar<=clen); - assert(0<=clen && clen<=len); - } - - if ((echo == LCECHO) && isupper((int)buf[0])) - buf[0] = tolower(buf[0]); - - if(occupy_msg) msg_occupied --; - return clen; -} -#else // TRY_VGETS - static int getdata2vgetflag(int echo) { @@ -1007,62 +757,32 @@ getdata2vgetflag(int echo) return echo; } -#endif // TRY_VGETS /* Ptt */ int getdata_buf(int line, int col, const char *prompt, char *buf, int len, int echo) { -#ifdef TRY_VGETS move(line, col); if(prompt && *prompt) outs(prompt); return vgetstr(buf, len, getdata2vgetflag(echo), buf); -#else - return getdata_raw(line, col, prompt, buf, len, echo); -#endif } int getdata_str(int line, int col, const char *prompt, char *buf, int len, int echo, const char *defaultstr) { -#ifdef TRY_VGETS move(line, col); if(prompt && *prompt) outs(prompt); return vgetstr(buf, len, getdata2vgetflag(echo), defaultstr); -#else - // if pointer is the same, ignore copy. - if (defaultstr != buf) - strlcpy(buf, defaultstr, len); - return getdata_raw(line, col, prompt, buf, len, echo); -#endif } int getdata(int line, int col, const char *prompt, char *buf, int len, int echo) { -#ifdef TRY_VGETS move(line, col); if(prompt && *prompt) outs(prompt); return vgets(buf, len, getdata2vgetflag(echo)); -#else - buf[0] = 0; - return getdata_raw(line, col, prompt, buf, len, echo); -#endif } -#if 0 -int -vget(int line, int col, const char *prompt, char *buf, int len, int mode) -{ - if (mode & GCARRY) - return getdata_raw(line, col, prompt, buf, len, (mode & ~GCARRY)); - else { - buf[0] = 0; - return getdata_raw(line, col, prompt, buf, len, mode); - } -} -#endif - /* vim:sw=4 */ diff --git a/mbbsd/read.c b/mbbsd/read.c index 25722c39..0140b1a5 100644 --- a/mbbsd/read.c +++ b/mbbsd/read.c @@ -666,7 +666,8 @@ i_read_key(const onekey_t * rcmdlist, keeploc_t * locmem, switch (ch) { case Ctrl('Z'): // notify new usage - if (currstat != RMAIL) + // only BM will need this information. + if ((currstat != RMAIL) && (currmode & MODE_BOARD)) { move(b_lines-2, 0); clrtobot(); outs(ANSI_COLOR(1;33) "置底的功\能鍵已改為 _ (shift-) 或 Ctrl-X。\n" diff --git a/mbbsd/visio.c b/mbbsd/visio.c index 2893bf01..b4b17fd1 100644 --- a/mbbsd/visio.c +++ b/mbbsd/visio.c @@ -18,40 +18,19 @@ * * Author: Hung-Te Lin (piaip), April 2008. * - * Copyright (c) 2005-2008 Hung-Te Lin <piaip@csie.ntu.edu.tw> + * Copyright (c) 2008 Hung-Te Lin <piaip@csie.ntu.edu.tw> * All rights reserved. * - * Distributed under a Non-Commercial 4clause-BSD alike license. + * Distributed under BSD license (GPL compatible). * * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display appropriate acknowledgement, like: - * This product includes software developed by Hung-Te Lin (piaip). - * The acknowledgement can be localized with the name unchanged. - * 4. You may not exercise any of the rights granted to you above in any - * manner that is primarily intended for or directed toward commercial - * advantage or private monetary compensation. For avoidance of doubt, - * using in a program providing commercial network service is also - * prohibited. + * modification, are permitted provided that the following conditions are met: * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS - * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A - * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER - * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. * * To add API here, please... * (1) name the API in prefix of 'v'. |