From f665f13b5bdcb87f19a0681481f6044cbcc109b9 Mon Sep 17 00:00:00 2001 From: piaip Date: Mon, 17 Dec 2007 03:26:22 +0000 Subject: - general message update and optimization - change search_num() to getdata(), allow unified control git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@3698 63ad8ddf-47c3-0310-b6dd-a9e9d9715204 --- include/common.h | 1 + mbbsd/bbs.c | 8 ++++++-- mbbsd/board.c | 2 +- mbbsd/io.c | 13 +++++++++++-- mbbsd/menu.c | 2 +- mbbsd/pmore.c | 7 +++---- mbbsd/screen.c | 14 +++++++++----- mbbsd/stuff.c | 46 ++++++++-------------------------------------- mbbsd/talk.c | 2 +- mbbsd/user.c | 9 ++++++++- mbbsd/vote.c | 6 +++--- 11 files changed, 52 insertions(+), 58 deletions(-) diff --git a/include/common.h b/include/common.h index a6fb23ec..6bd4bb98 100644 --- a/include/common.h +++ b/include/common.h @@ -124,6 +124,7 @@ #define NOECHO 0 #define DOECHO 1 #define LCECHO 2 +#define NUMECHO 4 #define YEA 1 /* Booleans (Yep, for true and false) */ #define NA 0 diff --git a/mbbsd/bbs.c b/mbbsd/bbs.c index e58e3909..d5775d12 100644 --- a/mbbsd/bbs.c +++ b/mbbsd/bbs.c @@ -3495,8 +3495,12 @@ change_cooldown(void) static int b_moved_to_config() { - vmsg("這個功\能已移入看板設定 (大寫 I) 去了!"); - return FULLUPDATE; + if ((currmode & MODE_BOARD) || HasUserPerm(PERM_SYSOP)) + { + vmsg("這個功\能已移入看板設定 (大寫 I) 去了!"); + return FULLUPDATE; + } + return DONOTHING; } /* ----------------------------------------------------- */ diff --git a/mbbsd/board.c b/mbbsd/board.c index 74ba0e59..3febb2e7 100644 --- a/mbbsd/board.c +++ b/mbbsd/board.c @@ -441,7 +441,7 @@ b_config(void) ); } - // if (isBM) + if (isBM) { ipostres ++; move_ansi(ipostres++, COLPOSTRES-2); diff --git a/mbbsd/io.c b/mbbsd/io.c index 1c3f9e7a..bd4c89df 100644 --- a/mbbsd/io.c +++ b/mbbsd/io.c @@ -61,12 +61,16 @@ oflush(void) } } +// deprecated? +#if 0 void init_buf(void) { - memset(inbuf, 0, IBUFSIZE); + ibufsize = icurrchar = 0; } +#endif + void output(const char *s, int len) { @@ -260,7 +264,7 @@ _debug_check_keyinput() move(b_lines, 0); if(dbcsaware) { - prints( ANSI_COLOR(7) "游標在此" ANSI_RESET + outs( ANSI_COLOR(7) "游標在此" ANSI_RESET " 測試中文模式會不會亂送鍵。 'q' 離開, 'd' 回英文模式 "); move(b_lines, 4); } else { @@ -870,6 +874,11 @@ oldgetdata(int line, int col, const char *prompt, char *buf, int len, int echo) case KEY_UNKNOWN: break; default: + if (echo == NUMECHO && !isdigit(ch)) + { + bell(); + break; + } if (isprint2(ch) && clen < len && x + clen < scr_cols) { #ifdef DBCSAWARE if(ISDBCSAWARE()) diff --git a/mbbsd/menu.c b/mbbsd/menu.c index a4d1e1d8..710494ab 100644 --- a/mbbsd/menu.c +++ b/mbbsd/menu.c @@ -688,7 +688,7 @@ Talk(void) int User(void) { - domenu(M_UMENU, "個人設定", 'I', userlist); + domenu(M_UMENU, "個人設定", 'U', userlist); return 0; } diff --git a/mbbsd/pmore.c b/mbbsd/pmore.c index eac18ac1..600535d7 100644 --- a/mbbsd/pmore.c +++ b/mbbsd/pmore.c @@ -233,11 +233,10 @@ pmore_clrtoeol(int y, int x) for (i = x; i < t_columns; i++) outc(' '); clrtoeol(); - move(y, x); + move(y, x); // this is required, due to outc(). #else move(y, x); clrtoeol(); - move(y, x); #endif } @@ -1989,7 +1988,7 @@ pmore(char *fpath, int promptend) postfix1len = 12; // check msg below postfix2len = 10; - if(mf_viewedAll()) postfix1len = 15; + if(mf_viewedAll()) postfix1len = 16; if (prefixlen + postfix1len + postfix2len + 1 > t_columns) { @@ -2006,7 +2005,7 @@ pmore(char *fpath, int promptend) outs( mf_viewedAll() ? ANSI_COLOR(0;31;47)"(y)" ANSI_COLOR(30) "回信" - ANSI_COLOR(31) "(X)" ANSI_COLOR(30) "推文 " + ANSI_COLOR(31) "(X%)" ANSI_COLOR(30) "推文 " : ANSI_COLOR(0;31;47) "(h)" ANSI_COLOR(30) "按鍵說明 " diff --git a/mbbsd/screen.c b/mbbsd/screen.c index 9a8f74e5..853d3110 100644 --- a/mbbsd/screen.c +++ b/mbbsd/screen.c @@ -45,6 +45,9 @@ move_ansi(int y, int x) return; slp = &big_picture[y]; + if (slp->len < 1) + return; + slp->data[slp->len] = 0; x += (strlen((char*)slp->data) - strlen_noansi((char*)slp->data)); cur_col = x; @@ -246,9 +249,9 @@ refresh(void) #endif // DBCSAWARE #if 0 - // disable now, bugs: - // (1) pmore scrolling failed - // (2) input number (goto) in bbs list (search_num) + // disabled now, bugs: + // (1) input number (goto) in bbs list (search_num) + // (2) some empty lines becomes weird (eg, b_config) // // more effort to determine ANSI smod if (bp->smod > 0) @@ -258,12 +261,13 @@ refresh(void) { if (bp->data[iesc] == ESC_CHR) { - bp->smod = iesc; + bp->smod = 0;// iesc; + bp->emod =len -1; break; } } } -#endif +#endif if (bp->emod >= len) bp->emod = len - 1; diff --git a/mbbsd/stuff.c b/mbbsd/stuff.c index e7cbaf34..fa4c424a 100644 --- a/mbbsd/stuff.c +++ b/mbbsd/stuff.c @@ -453,45 +453,15 @@ bell(void) int search_num(int ch, int max) { - int clen = 1; - int x, y; - char genbuf[10]; - - outmsg(ANSI_COLOR(7) " 跳至第幾項:" ANSI_RESET); - outc(ch); - genbuf[0] = ch; - getyx(&y, &x); - x--; - while ((ch = igetch()) != '\r') { - if (ch == 'q' || ch == 'e') - return -1; - if (ch == '\n') - break; - if (ch == '\177' || ch == Ctrl('H')) { - if (clen == 0) { - bell(); - continue; - } - clen--; - move(y, x + clen); - outc(' '); - move(y, x + clen); - continue; - } - if (!isdigit(ch)) { - bell(); - continue; - } - if (x + clen >= scr_cols || clen >= 6) { - bell(); - continue; - } - genbuf[clen++] = ch; - outc(ch); - } + int clen = 1, y = b_lines - msg_occupied; + char genbuf[10]; + + genbuf[0] = ch; genbuf[1] = 0; + clen = getdata_buf(y, 0, + " 跳至第幾項: ", genbuf, sizeof(genbuf)-1, NUMECHO); + + move(y, 0); clrtoeol(); genbuf[clen] = '\0'; - move(b_lines, 0); - clrtoeol(); if (genbuf[0] == '\0') return -1; clen = atoi(genbuf); diff --git a/mbbsd/talk.c b/mbbsd/talk.c index 29532d82..5a82e5bb 100644 --- a/mbbsd/talk.c +++ b/mbbsd/talk.c @@ -2929,7 +2929,7 @@ userlist(void) move(b_lines - 4, 0); clrtobot(); move(b_lines - 3, 0); - prints("系統提供 一般 進階 未來 三種模式\n" + outs("系統提供 一般 進階 未來 三種模式\n" "在切換後請正常下線再重新登入, 以確保結構正確\n"); vmsgf( "目前切換到 %s 水球模式", wm[tmp]); redrawall = redraw = 1; diff --git a/mbbsd/user.c b/mbbsd/user.c index cf676f88..0b912c05 100644 --- a/mbbsd/user.c +++ b/mbbsd/user.c @@ -502,10 +502,17 @@ void Customize(void) } + grayout_lines(1, b_lines, 0); + move(b_lines-1, 0); clrtoeol(); + if(dirty) + { passwd_update(usernum, &cuser); + outs("設定已儲存。\n"); + } else { + outs("結束設定。\n"); + } - grayout_lines(0, b_lines, 0); vmsg("設定完成"); } diff --git a/mbbsd/vote.c b/mbbsd/vote.c index 9c3259cb..7562a7b8 100644 --- a/mbbsd/vote.c +++ b/mbbsd/vote.c @@ -834,9 +834,9 @@ user_vote_one(vote_buffer_t *vbuf, const char *bname, int ind) memset(choices, 0, sizeof(choices)); max_page = (item_num - 1)/ ITEM_PER_PAGE + 1; - prints("投票方式:確定好您的選擇後,輸入其代碼(A, B, C...)即可。\n" - "此次投票你可以投 %1hd 票。按 0 取消投票, 1 完成投票, > 下一頁, < 上一頁\n" - "此次投票將結束於:%s \n", + outs("投票方式:確定好您的選擇後,輸入其代碼(A, B, C...)即可。\n"); + prints("此次投票你可以投 %1hd 票。按 0 取消投票, 1 完成投票, " + "> 下一頁, < 上一頁\n此次投票將結束於:%s \n", tickets, ctime4(&closetime)); #define REDO_DRAW 1 -- cgit v1.2.3