diff options
author | piaip <piaip@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2005-09-08 00:03:08 +0800 |
---|---|---|
committer | piaip <piaip@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2005-09-08 00:03:08 +0800 |
commit | 4aab81aad26f5619e514dbb97419521fa96cc37f (patch) | |
tree | c874f8c6f9202e5c7353eeceb04038051bb447d8 | |
parent | 092c2f44d463699a7e9b2965f1a354a225081516 (diff) | |
download | pttbbs-4aab81aad26f5619e514dbb97419521fa96cc37f.tar pttbbs-4aab81aad26f5619e514dbb97419521fa96cc37f.tar.gz pttbbs-4aab81aad26f5619e514dbb97419521fa96cc37f.tar.bz2 pttbbs-4aab81aad26f5619e514dbb97419521fa96cc37f.tar.lz pttbbs-4aab81aad26f5619e514dbb97419521fa96cc37f.tar.xz pttbbs-4aab81aad26f5619e514dbb97419521fa96cc37f.tar.zst pttbbs-4aab81aad26f5619e514dbb97419521fa96cc37f.zip |
Wide terminal rules.
This time we have userlist and mailbox support.
git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@3136 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
-rw-r--r-- | mbbsd/Makefile | 2 | ||||
-rw-r--r-- | mbbsd/bbs.c | 2 | ||||
-rw-r--r-- | mbbsd/mail.c | 53 | ||||
-rw-r--r-- | mbbsd/talk.c | 64 |
4 files changed, 85 insertions, 36 deletions
diff --git a/mbbsd/Makefile b/mbbsd/Makefile index 2e5637ab..3be108ad 100644 --- a/mbbsd/Makefile +++ b/mbbsd/Makefile @@ -21,7 +21,7 @@ OBJS= admin.o announce.o args.o assess.o bbs.o board.o cache.o cal.o card.o\ OBJS+= random.o time.o DIETCC= diet -Os .endif -#CFLAGS+=-g +CFLAGS+=-std=c99 # reduce .bss align overhead .if !defined(DEBUG) diff --git a/mbbsd/bbs.c b/mbbsd/bbs.c index dad56f0a..fac9c21a 100644 --- a/mbbsd/bbs.c +++ b/mbbsd/bbs.c @@ -1173,6 +1173,8 @@ edit_post(int ent, fileheader_t * fhdr, const char *direct) fp = fopen(fpath, "at"); src = fopen(genbuf, "rt"); + FILE *xp = NULL; + if(!fp) { vmsg("抱歉,檔案已損毀。"); diff --git a/mbbsd/mail.c b/mbbsd/mail.c index c9e2011e..7acc84fe 100644 --- a/mbbsd/mail.c +++ b/mbbsd/mail.c @@ -893,28 +893,40 @@ m_new(void) static void mailtitle(void) { - char buf[256]; + char buf[STRLEN]; + int msglen = 0; showtitle("郵件選單", BBSName); prints("[←]離開[↑↓]選擇[→]閱\讀信件 [R]回信 [x]轉達 " - "[y]群組回信 [O]站外信:%s [h]求助\n" ANSI_COLOR(7) "" - " 編號 %s 作 者 信 件 標 題 " - ANSI_COLOR(32) "", + "[y]群組回信 [O]站外信:%s [h]求助\n" + ANSI_COLOR(7) " 編號 %s 作 者 信 件 標 題" + "", REJECT_OUTTAMAIL ? ANSI_COLOR(31) "關" ANSI_RESET : "開", (showmail_mode == SHOWMAIL_SUM) ? "大 小":"日 期"); + + /* 43 columns in length, used later. */ buf[0] = 0; - if (mailsumlimit) { - snprintf(buf, sizeof(buf), - "(容量:%d/%dk %d/%d篇)", mailsum, mailsumlimit, + + if (mailsumlimit) + { + /* warning: snprintf returns length "if not limited". + * however if this case, they should be the same. */ + + msglen = snprintf(buf, sizeof(buf), + ANSI_COLOR(32) + " (容量:%d/%dk %d/%d篇) ", + mailsum, mailsumlimit, mailkeep, mailmaxkeep); + msglen -= strlen(ANSI_COLOR(32)); } - prints("%-29s" ANSI_RESET, buf); + outslr("", 44, buf, msglen); + outs(ANSI_RESET); } static void maildoent(int num, fileheader_t * ent) { - char *title, *mark, color, type = "+ Mm"[(ent->filemode & 3)]; + char *title, *mark, *color = NULL, type = "+ Mm"[(ent->filemode & 3)]; char datepart[6]; if (TagNum && !Tagger(atoi(ent->filename + 2), 0, TAG_NIN)) @@ -922,10 +934,10 @@ maildoent(int num, fileheader_t * ent) title = subject(mark = ent->title); if (title == mark) { - color = '1'; + color = ANSI_COLOR(1;31); mark = "◇"; } else { - color = '3'; + color = ANSI_COLOR(1;33); mark = "R:"; } @@ -966,13 +978,18 @@ maildoent(int num, fileheader_t * ent) break; } - if (strncmp(currtitle, title, TTLEN)) - prints("%6d %c %-6s%-15.14s%s %.46s\n", num, type, - datepart, ent->owner, mark, title); - else - prints("%6d %c %-6s%-15.14s" ANSI_COLOR(1;3%c) - "%s %.46s" ANSI_COLOR(0) "\n", num, type, - datepart, ent->owner, color, mark, title); + /* print out */ + if (strncmp(currtitle, title, TTLEN) != 0) + { + /* is title. */ + color = ""; + } + + prints("%6d %c %-6s%-15.14s%s %s%-*.*s%s\n", + num, type, datepart, ent->owner, mark, color, + t_columns - 34, t_columns - 34, + title, + *color ? ANSI_RESET : ""); } diff --git a/mbbsd/talk.c b/mbbsd/talk.c index 3cdf126f..316739a2 100644 --- a/mbbsd/talk.c +++ b/mbbsd/talk.c @@ -122,8 +122,8 @@ modestring(const userinfo_t * uentp, int simple) ) if (uentp->msgcount < 10) { const char *cnum[10] = - {"", "一", "兩", "三", "四", "五", "六", "七", - "八", "九"}; + {"", "一", "兩", "三", "四", "五", + "六", "七", "八", "九"}; snprintf(modestr, sizeof(modestr), "中%s顆水球", cnum[(int)(uentp->msgcount)]); } else @@ -2035,38 +2035,63 @@ draw_pickup(int drawall, pickup_t * pickup, int pickup_way, userinfo_t *uentp; int i, ch, state, friend; char mind[5]; + #ifdef SHOW_IDLE_TIME char idlestr[32]; int idletime; #endif + /* wide screen support */ + int wNick = 17, wMode = 12; //13; , one byte give number for ptt always > 10000 online. + + if (t_columns > 80) + { + int d = t_columns - 80; + + /* rule: try to give extra space to both nick and mode, + * because nick is smaller, try nick first then mode. */ + if (d >= sizeof(cuser.nickname) - wNick) + { + d -= (sizeof(cuser.nickname) - wNick); + wNick = sizeof(cuser.nickname); + wMode += d; + } else { + wNick += d; + } + } + if (drawall) { showtitle((cuser.uflag & FRIEND_FLAG) ? "好友列表" : "休閒聊天", BBSName); prints("\n" - ANSI_COLOR(7) " %s P%c代號 %-17s%-17s%-13s%-10s" ANSI_RESET "\n", + ANSI_COLOR(7) " %s P%c代號 %-*s%-17s%-*s%10s" + ANSI_RESET "\n", show_uid ? "UID " : "編號", - (HasUserPerm(PERM_SEECLOAK) || HasUserPerm(PERM_SYSOP)) ? 'C' : ' ', - "暱稱", + (HasUserPerm(PERM_SEECLOAK) || HasUserPerm(PERM_SYSOP)) ? + 'C' : ' ', + wNick, "暱稱", MODE_STRING[show_mode], - show_board ? "Board" : "動態", - show_pid ? " PID" : "心情 發呆" + wMode, show_board ? "Board" : "動態", + show_pid ? " PID" : "心情 " +#ifdef SHOW_IDLE_TIME + "發呆" +#else + " " +#endif ); move(b_lines, 0); outslr( ANSI_COLOR(34;46) " 休閒聊天 " ANSI_COLOR(31;47) " (TAB/f)" ANSI_COLOR(30) "排序/好友 " - ANSI_COLOR(31) "(t)" ANSI_COLOR(30) "聊天 " - ANSI_COLOR(31) "(a/d/o)" ANSI_COLOR(30) "交友 " - ANSI_COLOR(31) "(q)" ANSI_COLOR(30) "查詢 " - ANSI_COLOR(31) "(w)" ANSI_COLOR(30) "水球 " - ANSI_COLOR(31) "(m)" ANSI_COLOR(30) "寄信 ", - 80-8, + ANSI_COLOR(31) "(a/o)" ANSI_COLOR(30) "交友 " + ANSI_COLOR(31) "(q/w)" ANSI_COLOR(30) "查詢/丟水球 " + ANSI_COLOR(31) "(t/m)" ANSI_COLOR(30) "聊天/寫信 ", + 80-10, ANSI_COLOR(31) "(h)" ANSI_COLOR(30) "說明 " ANSI_RESET, 8); } move(1, 0); - prints(" 排序:[%s] 上站人數:%-4d " + prints(" 排序:[%s] 上站人數:%-4d " ANSI_COLOR(1;32) "我的朋友:%-3d " ANSI_COLOR(33) "與我為友:%-3d " ANSI_COLOR(36) "板友:%-4d " @@ -2074,6 +2099,7 @@ draw_pickup(int drawall, pickup_t * pickup, int pickup_way, ANSI_RESET "\n", msg_pickup_way[pickup_way], SHM->UTMPnumber, myfriend, friendme, currutmp->brc_id ? bfriend : 0, badfriend); + for (i = 0, ch = page * nPickups + 1; i < nPickups; ++i, ++ch) { move(i + 3, 0); outc('a'); @@ -2118,7 +2144,11 @@ draw_pickup(int drawall, pickup_t * pickup, int pickup_way, else memcpy(mind, uentp->mind, 4); mind[4] = 0; - prints("%6d %c%c%s%-13s%-17.16s" ANSI_RESET "%-17.16s%-13.13s" + + /* TODO + * will this be faster if we use pure outc/outs? + */ + prints("%7d %c%c%s%-13s%-*.*s " ANSI_RESET "%-16.16s %-*.*s" ANSI_COLOR(33) "%-4.4s" ANSI_RESET "%s\n", /* list number or uid */ @@ -2137,18 +2167,18 @@ draw_pickup(int drawall, pickup_t * pickup, int pickup_way, fcolor[state], uentp->userid, /* nickname */ - uentp->nickname, + wNick-1, wNick-1, uentp->nickname, /* from */ descript(show_mode, uentp, uentp->pager & !(friend & HRM)), /* board or mode */ + wMode, wMode, #if defined(SHOWBOARD) && defined(DEBUG) show_board ? (uentp->brc_id == 0 ? "" : getbcache(uentp->brc_id)->brdname) : #endif - /* %-13.13s */ modestring(uentp, 0), /* memo */ |