From ef72c801c2d2166a64a02cc76abe76ec3da260f9 Mon Sep 17 00:00:00 2001 From: kcwu Date: Fri, 25 Jan 2008 19:17:09 +0000 Subject: - revise menu.c code. git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@3868 63ad8ddf-47c3-0310-b6dd-a9e9d9715204 --- include/pttstruct.h | 6 ---- mbbsd/board.c | 4 --- mbbsd/menu.c | 96 +++++++++++++++++++++++++++++++++++------------------ mbbsd/var.c | 27 --------------- 4 files changed, 63 insertions(+), 70 deletions(-) diff --git a/include/pttstruct.h b/include/pttstruct.h index 1e4074f2..6b9a4090 100644 --- a/include/pttstruct.h +++ b/include/pttstruct.h @@ -615,12 +615,6 @@ struct NameList { char (*base)[IDLEN+1]; }; -typedef struct commands_t { - int (*cmdfunc)(); - int level; - char *desc; /* next/key/description */ -} commands_t; - typedef struct MailQueue { char filepath[FNLEN]; char subject[STRLEN]; diff --git a/mbbsd/board.c b/mbbsd/board.c index adbefaa1..0faef5f6 100644 --- a/mbbsd/board.c +++ b/mbbsd/board.c @@ -267,8 +267,6 @@ b_posttype() return FULLUPDATE; } -char board_hidden_status; - // integrated board config int b_config(void) @@ -516,12 +514,10 @@ b_config(void) { bp->brdattr &= ~BRD_HIDE; bp->brdattr &= ~BRD_POSTMASK; - board_hidden_status = 0; hbflreload(currbid); } else { bp->brdattr |= BRD_HIDE; bp->brdattr |= BRD_POSTMASK; - board_hidden_status = 1; } touched = 1; break; diff --git a/mbbsd/menu.c b/mbbsd/menu.c index 31d0798f..a35a1915 100644 --- a/mbbsd/menu.c +++ b/mbbsd/menu.c @@ -10,7 +10,6 @@ static int refscreen = NA; extern char *boardprefix; extern struct utmpfile_t *utmpshm; -extern char board_hidden_status; static const char *title_tail_msgs[] = { "看板", @@ -36,44 +35,25 @@ showtitle(const char *title, const char *mid) * - display mid message, cannot truncate * - display tail (board info), if possible. */ - int llen = -1, rlen = -1, mlen = -1, mpos = 0; + int llen, rlen, mlen, mpos = 0; int pos = 0; - int tail_type = TITLE_TAIL_BOARD; + int tail_type; const char *mid_attr = ANSI_COLOR(33); - - static char lastboard[16] = {0}; + int is_currboard_special = 0; char buf[64]; - if (currmode & MODE_SELECT) - tail_type = TITLE_TAIL_SELECT; - else if (currmode & MODE_DIGEST) - tail_type = TITLE_TAIL_DIGEST; - - /* check if board was changed. */ - if (strcmp(currboard, lastboard) != 0 && currboard[0]) { - int bid = getbnum(currboard); - if(bid > 0) - { - assert(0<=bid-1 && bid-1brdattr & BRD_HIDE) && - (getbcache(bid)->brdattr & BRD_POSTMASK)); - strlcpy(lastboard, currboard, sizeof(lastboard)); - } - } - /* next, determine if title was overrided. */ + /* prepare mid */ #ifdef DEBUG { sprintf(buf, " current pid: %6d ", getpid()); mid = buf; mid_attr = ANSI_COLOR(41;5); - mlen = strlen(mid); } #else if (ISNEWMAIL(currutmp)) { mid = " 郵差來按鈴囉 "; mid_attr = ANSI_COLOR(41;5); - mlen = strlen(mid); } else if ( HasUserPerm(PERM_ACCTREG) ) { int nreg = dashs((char *)fn_register) / 163; if(nreg > 100) @@ -81,13 +61,29 @@ showtitle(const char *title, const char *mid) sprintf(buf, " 有 %03d 未審核 ", nreg); mid_attr = ANSI_COLOR(41;5); mid = buf; - mlen = strlen(mid); } } #endif + + /* prepare tail */ + if (currmode & MODE_SELECT) + tail_type = TITLE_TAIL_SELECT; + else if (currmode & MODE_DIGEST) + tail_type = TITLE_TAIL_DIGEST; + else + tail_type = TITLE_TAIL_BOARD; + + if(currbid > 0) + { + assert(0<=currbid-1 && currbid-1brdattr & BRD_HIDE) && + (getbcache(currbid)->brdattr & BRD_POSTMASK)); + } + /* now, calculate real positioning info */ - if(llen < 0) llen = strlen(title); - if(mlen < 0) mlen = strlen(mid); + llen = strlen(title); + mlen = strlen(mid); mpos = (t_columns -1 - mlen)/2; /* first, print left. */ @@ -96,12 +92,15 @@ showtitle(const char *title, const char *mid) outs(title); outs("】"); pos = llen + 4; - /* prepare for mid */ - while(pos < mpos) - outc(' '), pos++; + + /* print mid */ + while(pos++ < mpos) + outc(' '); outs(mid_attr); - outs(mid), pos+=mlen; + outs(mid); + pos += mlen; outs(TITLE_COLOR); + /* try to locate right */ rlen = strlen(currboard) + 4 + 4; if(currboard[0] && pos+rlen < t_columns) @@ -112,7 +111,8 @@ showtitle(const char *title, const char *mid) outs(title_tail_attrs[tail_type]); outs(title_tail_msgs[tail_type]); outs("《"); - if (board_hidden_status) + + if (is_currboard_special) outs(ANSI_COLOR(32)); outs(currboard); outs(title_tail_attrs[tail_type]); @@ -160,7 +160,7 @@ show_status(void) } /* - * current callee of movie: + * current caller of movie: * board.c: movie(0); // called when IN_CLASSROOT() * // with currstat = CLASS -> don't show movies * xyz.c: movie(999999); // logout @@ -199,6 +199,12 @@ movie(int cmdmode) refresh(); } +typedef struct commands_t { + int (*cmdfunc)(); + int level; + char *desc; /* next/key/description */ +} commands_t; + static int show_menu(int moviemode, const commands_t * p) { @@ -545,6 +551,30 @@ static const commands_t moneylist[] = { {NULL, 0, NULL} }; +static const commands_t cmdlist[] = { + {admin, PERM_SYSOP|PERM_ACCOUNTS|PERM_BOARD|PERM_VIEWSYSOP|PERM_ACCTREG|PERM_POLICE_MAN, + "00Admin 【 系統維護區 】"}, + {Announce, 0, "AAnnounce 【 精華公佈欄 】"}, +#ifdef DEBUG + {Favorite, 0, "FFavorite 【 我的最不愛 】"}, +#else + {Favorite, 0, "FFavorite 【 我 的 最愛 】"}, +#endif + {Class, 0, "CClass 【 分組討論區 】"}, + {Mail, PERM_BASIC, "MMail 【 私人信件區 】"}, + {Talk, 0, "TTalk 【 休閒聊天區 】"}, + {User, PERM_BASIC, "UUser 【 個人設定區 】"}, + {Xyz, 0, "XXyz 【 系統工具區 】"}, + {Play_Play, PERM_LOGINOK, "PPlay 【 娛樂與休閒 】"}, + {Name_Menu, PERM_LOGINOK, "NNamelist 【 編特別名單 】"}, +#ifdef DEBUG + {Goodbye, 0, "GGoodbye 再見再見再見再見"}, +#else + {Goodbye, 0, "GGoodbye 離開,再見… "}, +#endif + {NULL, 0, NULL} +}; + int main_menu(void) { domenu(M_MMENU, "主功\能表", (ISNEWMAIL(currutmp) ? 'M' : 'C'), cmdlist); return 0; diff --git a/mbbsd/var.c b/mbbsd/var.c index 12a4fabe..ca50824c 100644 --- a/mbbsd/var.c +++ b/mbbsd/var.c @@ -600,33 +600,6 @@ const unsigned char * const adv_gomoku /* [978] */ = (unsigned char*) /* name.c */ word_t *toplev; -#ifndef _BBS_UTIL_C_ -/* menu.c */ -const commands_t cmdlist[] = { - {admin, PERM_SYSOP|PERM_ACCOUNTS|PERM_BOARD|PERM_VIEWSYSOP|PERM_ACCTREG|PERM_POLICE_MAN, - "00Admin 【 系統維護區 】"}, - {Announce, 0, "AAnnounce 【 精華公佈欄 】"}, -#ifdef DEBUG - {Favorite, 0, "FFavorite 【 我的最不愛 】"}, -#else - {Favorite, 0, "FFavorite 【 我 的 最愛 】"}, -#endif - {Class, 0, "CClass 【 分組討論區 】"}, - {Mail, PERM_BASIC, "MMail 【 私人信件區 】"}, - {Talk, 0, "TTalk 【 休閒聊天區 】"}, - {User, PERM_BASIC, "UUser 【 個人設定區 】"}, - {Xyz, 0, "XXyz 【 系統工具區 】"}, - {Play_Play, PERM_LOGINOK, "PPlay 【 娛樂與休閒 】"}, - {Name_Menu, PERM_LOGINOK, "NNamelist 【 編特別名單 】"}, -#ifdef DEBUG - {Goodbye, 0, "GGoodbye 再見再見再見再見"}, -#else - {Goodbye, 0, "GGoodbye 離開,再見… "}, -#endif - {NULL, 0, NULL} -}; -#endif - /* friend.c */ /* Ptt 各種特別名單的檔名 */ char *friend_file[8] = { -- cgit v1.2.3