diff options
author | piaip <piaip@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2005-06-08 10:46:24 +0800 |
---|---|---|
committer | piaip <piaip@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2005-06-08 10:46:24 +0800 |
commit | a0f8ef1e2e04905908478088fc376435b770417c (patch) | |
tree | a96bd4096703e5d0bb0b9fe7c9499d0db7768070 /mbbsd | |
parent | f55eaef82ab265772418a545f32fa2780468603b (diff) | |
download | pttbbs-a0f8ef1e2e04905908478088fc376435b770417c.tar pttbbs-a0f8ef1e2e04905908478088fc376435b770417c.tar.gz pttbbs-a0f8ef1e2e04905908478088fc376435b770417c.tar.bz2 pttbbs-a0f8ef1e2e04905908478088fc376435b770417c.tar.lz pttbbs-a0f8ef1e2e04905908478088fc376435b770417c.tar.xz pttbbs-a0f8ef1e2e04905908478088fc376435b770417c.tar.zst pttbbs-a0f8ef1e2e04905908478088fc376435b770417c.zip |
New style to specify ANSI escape commands.
First introduced by pmore, but this hard work
(to transform all files to new style) is made by
Rong-en Fan (rafan). Thanks!
git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@2796 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
Diffstat (limited to 'mbbsd')
-rw-r--r-- | mbbsd/admin.c | 23 | ||||
-rw-r--r-- | mbbsd/announce.c | 26 | ||||
-rw-r--r-- | mbbsd/bbs.c | 62 | ||||
-rw-r--r-- | mbbsd/board.c | 82 | ||||
-rw-r--r-- | mbbsd/cal.c | 8 | ||||
-rw-r--r-- | mbbsd/card.c | 54 | ||||
-rw-r--r-- | mbbsd/chat.c | 4 | ||||
-rw-r--r-- | mbbsd/chc.c | 38 | ||||
-rw-r--r-- | mbbsd/chicken.c | 118 | ||||
-rw-r--r-- | mbbsd/dark.c | 72 | ||||
-rw-r--r-- | mbbsd/dice.c | 140 | ||||
-rw-r--r-- | mbbsd/edit.c | 48 | ||||
-rw-r--r-- | mbbsd/file.c | 2 | ||||
-rw-r--r-- | mbbsd/friend.c | 2 | ||||
-rw-r--r-- | mbbsd/gamble.c | 22 | ||||
-rw-r--r-- | mbbsd/go.c | 28 | ||||
-rw-r--r-- | mbbsd/gomo.c | 78 | ||||
-rw-r--r-- | mbbsd/guess.c | 12 | ||||
-rw-r--r-- | mbbsd/indict.c | 24 | ||||
-rw-r--r-- | mbbsd/io.c | 2 | ||||
-rw-r--r-- | mbbsd/kaede.c | 6 | ||||
-rw-r--r-- | mbbsd/mail.c | 24 | ||||
-rw-r--r-- | mbbsd/mbbsd.c | 14 | ||||
-rw-r--r-- | mbbsd/menu.c | 54 | ||||
-rw-r--r-- | mbbsd/merge.c | 2 | ||||
-rw-r--r-- | mbbsd/more.c | 30 | ||||
-rw-r--r-- | mbbsd/page.c | 26 | ||||
-rw-r--r-- | mbbsd/pmore.c | 17 | ||||
-rw-r--r-- | mbbsd/read.c | 2 | ||||
-rw-r--r-- | mbbsd/register.c | 4 | ||||
-rw-r--r-- | mbbsd/screen.c | 4 | ||||
-rw-r--r-- | mbbsd/stuff.c | 20 | ||||
-rw-r--r-- | mbbsd/syspost.c | 14 | ||||
-rw-r--r-- | mbbsd/talk.c | 120 | ||||
-rw-r--r-- | mbbsd/topsong.c | 8 | ||||
-rw-r--r-- | mbbsd/user.c | 46 | ||||
-rw-r--r-- | mbbsd/var.c | 2 | ||||
-rw-r--r-- | mbbsd/vote.c | 6 | ||||
-rw-r--r-- | mbbsd/xyz.c | 36 |
39 files changed, 655 insertions, 625 deletions
diff --git a/mbbsd/admin.c b/mbbsd/admin.c index e2486ff8..77c75a27 100644 --- a/mbbsd/admin.c +++ b/mbbsd/admin.c @@ -103,11 +103,12 @@ search_key_user(const char *passwdfile, int mode) user_display(&user, 1); uinfo_query(&user, 1, coun); - outs("\033[44m �ť���\033[37m:�j�M�U�@��" - " \033[33m Q\033[37m: ���}"); + outs(ANSI_COLOR(44) " �ť���" \ + ANSI_COLOR(37) ":�j�M�U�@�� " \ + ANSI_COLOR(33)" Q" ANSI_COLOR(37)": ���}"); outs(mode ? - " A: add to namelist \033[m " : - " S: ���γƥ���� \033[m "); + " A: add to namelist " ANSI_RESET " " : + " S: ���γƥ���� " ANSI_RESET " "); while (1) { while ((ch = igetch()) == 0); if (ch == 'a' || ch=='A' ) @@ -190,10 +191,12 @@ search_user_bybakpwd(void) clear(); move(1, 1); outs("�п�J�A�n�ΨӴM��ƥ����ɮ� �Ϋ� 'q' ���}\n"); - outs(" [\033[1;31m1\033[m]�@�ѫe, [\033[1;31m2\033[m]��ѫe, " - "[\033[1;31m3\033[m]�T�ѫe\n"); - outs(" [\033[1;31m4\033[m]�|�ѫe, [\033[1;31m5\033[m]���ѫe, " - "[\033[1;31m6\033[m]���ѫe\n"); + outs(" [" ANSI_COLOR(1;31) "1" ANSI_RESET "]�@�ѫe," + " [" ANSI_COLOR(1;31) "2" ANSI_RESET "]��ѫe," + " [" ANSI_COLOR(1;31) "3" ANSI_RESET "]�T�ѫe\n"); + outs(" [" ANSI_COLOR(1;31) "4" ANSI_RESET "]�|�ѫe," + " [" ANSI_COLOR(1;31) "5" ANSI_RESET "]���ѫe," + " [" ANSI_COLOR(1;31) "6" ANSI_RESET "]���ѫe\n"); outs(" [7]�ƥ���\n"); do { move(5, 1); @@ -1130,7 +1133,9 @@ scan_register_form(const char *regfile, int automode, int neednum) prints("�b����m �G%d\n", unum); user_display(&muser, 1); move(14, 0); - prints("\033[1;32m------------- �Я����Y��f�֨ϥΪ̸�ơA�z�٦� %d ��---------------\033[m\n", neednum); + prints(ANSI_COLOR(1;32) "------------- " + "�Я����Y��f�֨ϥΪ̸�ơA�z�٦� %d ��" + "---------------" ANSI_RESET "\n", neednum); prints(" %-12s�G%s\n", finfo[0], fdata[0]); #ifdef FOREIGN_REG prints("0.%-12s�G%s%s\n", finfo[2], fdata[2], diff --git a/mbbsd/announce.c b/mbbsd/announce.c index bb605cd6..27dc373e 100644 --- a/mbbsd/announce.c +++ b/mbbsd/announce.c @@ -63,7 +63,7 @@ a_showmenu(const menu_t * pm) time4_t dtime; showtitle("��ؤ峹", pm->mtitle); - prints(" \033[1;36m�s�� �� �D%56s\033[0m", + prints(" " ANSI_COLOR(1;36) "�s�� �� �D%56s" ANSI_COLOR(0), "�s �� �� ��"); if (pm->num) { @@ -90,12 +90,18 @@ a_showmenu(const menu_t * pm) move(b_lines, 1); outs(pm->level ? - "\033[34;46m �i�O �D�j \033[31;47m (h)\033[30m���� " - "\033[31m(q/��)\033[30m���} \033[31m(n)\033[30m�s�W�峹 " - "\033[31m(g)\033[30m�s�W�ؿ� \033[31m(e)\033[30m�s���ɮ� \033[m" : - "\033[34;46m �i�\\����j \033[31;47m (h)\033[30m���� " - "\033[31m(q/��)\033[30m���} \033[31m(k��j��)\033[30m���ʴ�� " - "\033[31m(enter/��)\033[30mŪ����� \033[m"); + ANSI_COLOR(34;46) " �i�O �D�j " + ANSI_COLOR(31;47) " (h)" ANSI_COLOR(30) "���� " + ANSI_COLOR(31) "(q/��)" ANSI_COLOR(30) "���} " + ANSI_COLOR(31) "(n)" ANSI_COLOR(30) "�s�W�峹 " + ANSI_COLOR(31) "(g)" ANSI_COLOR(30) "�s�W�ؿ� " + ANSI_COLOR(31) "(e)" ANSI_COLOR(30) "�s���ɮ� " ANSI_RESET + : + ANSI_COLOR(34;46) " �i�\\����j " + ANSI_COLOR(31;47) " (h)" ANSI_COLOR(30) "���� " + ANSI_COLOR(31) "(q/��)" ANSI_COLOR(30) "���} " + ANSI_COLOR(31) "(k��j��)" ANSI_COLOR(30) "���ʴ�� " + ANSI_COLOR(31) "(enter/��)" ANSI_COLOR(30) "Ū����� " ANSI_RESET); } static int @@ -137,7 +143,7 @@ static void a_showhelp(int level) { clear(); - outs("\033[36m�i " BBSNAME "���G��ϥλ��� �j\033[m\n\n" + outs(ANSI_COLOR(36) "�i " BBSNAME "���G��ϥλ��� �j" ANSI_RESET "\n\n" "[��][q] ���}��W�@�h�ؿ�\n" "[��][k] �W�@�ӿﶵ\n" "[��][j] �U�@�ӿﶵ\n" @@ -148,7 +154,7 @@ a_showhelp(int level) "[F][U] �N�峹�H�^ Internet �l�c/" "�N�峹 uuencode ��H�^�l�c\n"); if (level >= MANAGER) { - outs("\n\033[36m�i �O�D�M���� �j\033[m\n" + outs("\n" ANSI_COLOR(36) "�i �O�D�M���� �j" ANSI_RESET "\n" "[H] ������ ���}/�|��/�O�D �~��\\Ū\n" "[n/g/G] ������ؤ峹/�}�P�ؿ�/�إ߳s�u\n" "[m/d/D] ����/�R���峹/�R���@�ӽd�峹\n" @@ -157,7 +163,7 @@ a_showhelp(int level) "[^P/^A] �߶K/���[�w��'t'�аO�峹\n"); } if (level >= SYSOP) { - outs("\n\033[36m�i �����M���� �j\033[m\n" + outs("\n" ANSI_COLOR(36) "�i �����M���� �j" ANSI_RESET "\n" "[l] �� symbolic link\n" "[N] �d���ɦW\n"); } diff --git a/mbbsd/bbs.c b/mbbsd/bbs.c index a95415b1..99b3d82a 100644 --- a/mbbsd/bbs.c +++ b/mbbsd/bbs.c @@ -16,7 +16,9 @@ void anticrosspost(void) { log_file("etc/illegal_money", LOG_CREAT | LOG_VF, - "\033[1;33;46m%s \033[37;45mcross post �峹 \033[37m %s\033[m\n", + ANSI_COLOR(1;33;46) "%s " + ANSI_COLOR(37;45) "cross post �峹 " + ANSI_COLOR(37) " %s" ANSI_RESET "\n", cuser.userid, ctime4(&now)); kick_all(cuser.userid); post_violatelaw(cuser.userid, "Ptt�t��ĵ��", "Cross-post", "�@��B��"); @@ -39,28 +41,29 @@ save_violatelaw(void) stand_title("ú�@�椤��"); if (!(cuser.userlevel & PERM_VIOLATELAW)) { - mouts(22, 0, "\033[1;31m�A�L���? �A�S�S���Q�}�@��~~\033[m"); + mouts(22, 0, ANSI_COLOR(1;31) "�A�L���? �A�S�S���Q�}�@��~~" ANSI_RESET); pressanykey(); return 0; } reload_money(); if (cuser.money < (int)cuser.vl_count * 1000) { - snprintf(buf, sizeof(buf), "\033[1;31m�o�O�A�� %d ���H�ϥ����k�W" - "����ú�X %d $Ptt ,�A�u�� %d ��, ��������!!\033[m", + snprintf(buf, sizeof(buf), + ANSI_COLOR(1;31) "�o�O�A�� %d ���H�ϥ����k�W" + "����ú�X %d $Ptt ,�A�u�� %d ��, ��������!!" ANSI_RESET, (int)cuser.vl_count, (int)cuser.vl_count * 1000, cuser.money); mouts(22, 0, buf); pressanykey(); return 0; } move(5, 0); - outs("\033[1;37m�A���D��? �]���A���H�k " - "�w�g�y���ܦh�H�����K\033[m\n"); - outs("\033[1;37m�A�O�_�T�w�H�ᤣ�|�A�ǤF�H\033[m\n"); + outs(ANSI_COLOR(1;37) "�A���D��? �]���A���H�k " + "�w�g�y���ܦh�H�����K" ANSI_RESET "\n"); + outs(ANSI_COLOR(1;37) "�A�O�_�T�w�H�ᤣ�|�A�ǤF�H" ANSI_RESET "\n"); if (!getdata(10, 0, "�T�w�ܡH[Y/n]:", ok, sizeof(ok), LCECHO) || ok[0] == 'n' || ok[0] == 'N') { - mouts(22, 0, "\033[1;31m���A�Q�q�F�A�ӧa!! " - "�ڬ۫H�A���|�������諸~~~\033[m"); + mouts(22, 0, ANSI_COLOR(1;31) "���A�Q�q�F�A�ӧa!! " + "�ڬ۫H�A���|�������諸~~~" ANSI_RESET); pressanykey(); return 0; } @@ -71,7 +74,7 @@ save_violatelaw(void) if (!getdata(10, 0, "�n�I��[Y/n]:", ok, sizeof(ok), LCECHO) || ok[0] == 'N' || ok[0] == 'n') { - mouts(22, 0, "\033[1;31m �� �s���� �A�ӧa!!!\033[m"); + mouts(22, 0, ANSI_COLOR(1;31) " �� �s���� �A�ӧa!!!" ANSI_RESET); pressanykey(); return 0; } @@ -153,13 +156,13 @@ readtitle(void) showtitle(currBM, brd_title); prints("[��]���} [��]�\\Ū [^P]�o���峹 [b]�Ƨѿ� [d]�R�� [z]��ذ� " - "[TAB]��K [h]elp\n\033[7m �s�� �� �� �@ �� �� �� �� �D"); + "[TAB]��K [h]elp\n" ANSI_COLOR(7) " �s�� �� �� �@ �� �� �� �� �D"); #ifdef USE_COOLDOWN if (bp->brdattr & BRD_COOLDOWN && !((currmode & MODE_BOARD) || HAS_PERM(PERM_SYSOP))) - prints(" \033[m"); + prints(" " ANSI_RESET); else #endif - prints(" �H��:%-5d \033[m", + prints(" �H��:%-5d " ANSI_RESET, SHM->bcache[currbid - 1].nuser); } @@ -224,15 +227,15 @@ readdoent(int num, fileheader_t * ent) else strcpy(recom,"0m "); if (ent->filemode & FILE_BOTTOM) - outs(" \033[1;33m �� \033[m"); + outs(" " ANSI_COLOR(1;33) " �� " ANSI_RESET); else prints("%6d", num); prints( #ifdef COLORDATE - " %c\033[1;3%4.4s\033[%dm%-6s\033[m\033[%dm%-13.12s", + " %c\033[1;3%4.4s" ANSI_COLOR(%d) "%-6s" ANSI_RESET ANSI_COLOR(%d) "%-13.12s", #else - " %c\033[1;3%4.4s\033[m%-6s\033[%dm%-13.12s", + " %c\033[1;3%4.4s" ANSI_RESET "%-6s" ANSI_COLOR(%d) "%-13.12s", #endif type, recom, #ifdef COLORDATE @@ -241,10 +244,10 @@ readdoent(int num, fileheader_t * ent) ent->date, isonline, ent->owner); if (strncmp(currtitle, title, TTLEN)) - prints("\033[m%s \033[1m%.*s\033[m%s\n", + prints(ANSI_RESET "%s " ANSI_COLOR(1) "%.*s" ANSI_RESET "%s\n", mark, special ? 6 : 0, title, special ? title + 6 : title); else - prints("\033[1;3%cm%s %s\033[m\n", + prints("\033[1;3%cm%s %s" ANSI_RESET "\n", color, mark, title); } @@ -556,7 +559,8 @@ do_general(int isbid) more("etc/" FN_POST_BID, NA); } move(19, 0); - prints("%s��i\033[33m %s\033[m �j \033[32m%s\033[m �ݪO\n", + prints("%s��i" ANSI_COLOR(33) " %s" ANSI_RESET " �j " + ANSI_COLOR(32) "%s" ANSI_RESET " �ݪO\n", isbid?"���}�ۼ�":"�o���峹", currboard, bp->title + 7); @@ -1614,7 +1618,9 @@ do_bid(int ent, fileheader_t * fhdr, const boardheader_t *bp, if( genbuf[0] != 'y' ) return FULLUPDATE; snprintf(genbuf, sizeof(genbuf), - "\033[1;31m�� \033[33m���%s��������\033[m%*s" + ANSI_COLOR(1;31) "�� " + ANSI_COLOR(33) "���%s��������" + ANSI_RESET "%*s" "��%15s %02d/%02d\n", cuser.userid, (int)(45 - strlen(cuser.userid) - strlen(money)), " ", fromhost, ptime->tm_mon + 1, ptime->tm_mday); @@ -1651,7 +1657,7 @@ do_bid(int ent, fileheader_t * fhdr, const boardheader_t *bp, } snprintf(genbuf, sizeof(genbuf), - "\033[1;31m�� \033[33m%s\033[m\033[33m:%s\033[m%*s" + ANSI_COLOR(1;31) "�� " ANSI_COLOR(33) "%s" ANSI_RESET ANSI_COLOR(33) ":%s" ANSI_RESET "%*s" "%s%-15d��%15s %02d/%02d\n", cuser.userid, say, (int)(31 - strlen(cuser.userid) - strlen(say)), " ", @@ -1672,8 +1678,8 @@ do_bid(int ent, fileheader_t * fhdr, const boardheader_t *bp, strcpy(bidinfo.userid, cuser.userid); snprintf(genbuf, sizeof(genbuf), - "\033[1;31m�� \033[33m�۰��v��%s�ӥX\033" - "[m\033[33m\033[m%*s%s%-15d�� %02d/%02d\n", + ANSI_COLOR(1;31) "�� " ANSI_COLOR(33) "�۰��v��%s�ӥX" ANSI_RESET + ANSI_COLOR(33) ANSI_RESET "%*s%s%-15d�� %02d/%02d\n", cuser.userid, (int)(20 - strlen(cuser.userid)), " ", money, bidinfo.high, @@ -1686,8 +1692,8 @@ do_bid(int ent, fileheader_t * fhdr, const boardheader_t *bp, else bidinfo.high=bidinfo.usermax; /*�o��ǩǪ�*/ snprintf(genbuf, sizeof(genbuf), - "\033[1;31m�� \033[33m�۰��v��%s�ӥX" - "\033[m\033[33m\033[m%*s%s%-15d�� %02d/%02d\n", + ANSI_COLOR(1;31) "�� " ANSI_COLOR(33) "�۰��v��%s�ӥX" + ANSI_RESET ANSI_COLOR(33) ANSI_RESET "%*s%s%-15d�� %02d/%02d\n", bidinfo.userid, (int)(20 - strlen(bidinfo.userid)), " ", money, bidinfo.high, @@ -1758,19 +1764,19 @@ recommend(int ent, fileheader_t * fhdr, const char *direct) #endif if (!getdata(b_lines - 2, 0, "�n������:", msg, maxlength, DOECHO) || - getans("�T�w�n\033[%s\033[m��? �ХJ�ӦҼ{(Y/N)?[n]", ctype[type]) != 'y') + getans("�T�w�n\033[%s" ANSI_RESET "��? �ХJ�ӦҼ{(Y/N)?[n]", ctype[type]) != 'y') return FULLUPDATE; STATINC(STAT_RECOMMEND); #ifdef OLDRECOMMEND snprintf(buf, sizeof(buf), - "\033[1;31m�� \033[33m%s\033[m\033[33m:%-*s\033[m" + ANSI_COLOR(1;31) "�� " ANSI_COLOR(33) "%s" ANSI_RESET ANSI_COLOR(33) ":%-*s" ANSI_RESET "��%15s %02d/%02d\n", cuser.userid, maxlength, msg, fromhost, ptime->tm_mon + 1, ptime->tm_mday); #else snprintf(buf, sizeof(buf), - "\033[1;%s \033[33m%s\033[m\033[33m:%-*s\033[m%15s %02d/%02d\n", + "\033[1;%s " ANSI_COLOR(33) "%s" ANSI_RESET ANSI_COLOR(33) ":%-*s" ANSI_RESET "%15s %02d/%02d\n", ctype[type], cuser.userid, maxlength, diff --git a/mbbsd/board.c b/mbbsd/board.c index 63b77752..55b1f450 100644 --- a/mbbsd/board.c +++ b/mbbsd/board.c @@ -444,9 +444,9 @@ get_fav_type(boardstat_t *ptr) static void brdlist_foot(void) { - prints("\033[34;46m ��ܬݪO \033[31;47m (c)\033[30m�s�峹�Ҧ� " - "\033[31m(v/V)\033[30m�аO�wŪ/��Ū \033[31m(y)\033[30m�z��%s" - " \033[31m(m)\033[30m�����̷R \033[m", + prints(ANSI_COLOR(34;46) " ��ܬݪO " ANSI_COLOR(31;47) " (c)" ANSI_COLOR(30) "�s�峹�Ҧ� " + ANSI_COLOR(31) "(v/V)" ANSI_COLOR(30) "�аO�wŪ/��Ū " ANSI_COLOR(31) "(y)" ANSI_COLOR(30) "�z��%s" + " " ANSI_COLOR(31) "(m)" ANSI_COLOR(30) "�����̷R " ANSI_RESET, IS_LISTING_FAV() ? "�̷R" : IS_LISTING_BRD() ? "����" : "����"); } @@ -454,16 +454,16 @@ brdlist_foot(void) static inline char * make_class_color(char *name) { - char *colorset[8] = {"", "\033[32m", - "\033[33m", "\033[36m", "\033[34m", "\033[1m", - "\033[1;32m", "\033[1;33m"}; + char *colorset[8] = {"", ANSI_COLOR(32), + ANSI_COLOR(33), ANSI_COLOR(36), ANSI_COLOR(34), ANSI_COLOR(1), + ANSI_COLOR(1;32), ANSI_COLOR(1;33)}; return colorset[(unsigned int) (name[0] + name[1] + name[2] + name[3]) & 07]; } -#define HILIGHT_COLOR "\033[1;36m" +#define HILIGHT_COLOR ANSI_COLOR(1;36) static void show_brdlist(int head, int clsflag, int newflag) @@ -477,22 +477,22 @@ show_brdlist(int head, int clsflag, int newflag) move(1, 0); outs( " " - "�� �~�X\033[33m��\n" - " ��X \033[m " - "���i\033[47m��\033[40m�i�i����\n" - " \033[44m �s�s�s�s�s�s�s�s " - "\033[33m��\033[m\033[44m �����i�i�i�������� \033[m\n" - " \033[44m " - "\033[33m \033[m\033[44m �����i�i�i������ ��\033[m\n" - " �s�s�s�s�s�s�s�s \033[33m" - "�x\033[m ���i�i�i�i�� ��\n" - " \033[33m��" - "�X�X\033[m �� �X��\033[m"); + "�� �~�X" ANSI_COLOR(33) "��\n" + " ��X " ANSI_RESET " " + "���i" ANSI_COLOR(47) "��" ANSI_COLOR(40) "�i�i����\n" + " " ANSI_COLOR(44) " �s�s�s�s�s�s�s�s " + ANSI_COLOR(33) "��" ANSI_RESET ANSI_COLOR(44) " �����i�i�i�������� " ANSI_RESET "\n" + " " ANSI_COLOR(44) " " + ANSI_COLOR(33) " " ANSI_RESET ANSI_COLOR(44) " �����i�i�i������ ��" ANSI_RESET "\n" + " �s�s�s�s�s�s�s�s " ANSI_COLOR(33) + "�x" ANSI_RESET " ���i�i�i�i�� ��\n" + " " ANSI_COLOR(33) "��" + "�X�X" ANSI_RESET " �� �X��" ANSI_RESET); } else if (clsflag) { showtitle("�ݪO�C��", BBSName); prints("[��]�D��� [��]�\\Ū [����]��� [y]���J [S]�Ƨ� [/]�j�M " "[TAB]��K�E�ݪO [h]�D�U\n" - "\033[7m%-20s ���O ��H%-31s�H�� �O �D \033[m", + ANSI_COLOR(7) "%-20s ���O ��H%-31s�H�� �O �D " ANSI_RESET, newflag ? "�`�� ��Ū �� �O" : " �s�� �� �O", " �� �� �� �z"); move(b_lines, 0); @@ -500,10 +500,10 @@ show_brdlist(int head, int clsflag, int newflag) } if (brdnum > 0) { boardstat_t *ptr; - char *color[8] = {"", "\033[32m", - "\033[33m", "\033[36m", "\033[34m", "\033[1m", - "\033[1;32m", "\033[1;33m"}; - char *unread[2] = {"\33[37m \033[m", "\033[1;31m��\033[m"}; + char *color[8] = {"", ANSI_COLOR(32), + ANSI_COLOR(33), ANSI_COLOR(36), ANSI_COLOR(34), ANSI_COLOR(1), + ANSI_COLOR(1;32), ANSI_COLOR(1;33)}; + char *unread[2] = {ANSI_COLOR(37) " " ANSI_RESET, ANSI_COLOR(1;31) "��" ANSI_RESET}; if (IS_LISTING_FAV() && get_data_number(get_current_fav()) == 0){ // brdnum > 0 ??? @@ -519,26 +519,26 @@ show_brdlist(int head, int clsflag, int newflag) ptr = &nbrd[head++]; if (ptr->myattr & NBRD_LINE){ if( !newflag ) - prints("%5d %c %s------------ ------------------------------------------\033[m", + prints("%5d %c %s------------ ------------------------------------------" ANSI_RESET, head, ptr->myattr & NBRD_TAG ? 'D' : ' ', - ptr->myattr & NBRD_FAV ? "" : "\033[1;30m"); + ptr->myattr & NBRD_FAV ? "" : ANSI_COLOR(1;30)); else - prints(" %s------------ ------------------------------------------\033[m", ptr->myattr & NBRD_FAV ? "" : "\033[1;30m"); + prints(" %s------------ ------------------------------------------" ANSI_RESET, ptr->myattr & NBRD_FAV ? "" : ANSI_COLOR(1;30)); continue; } else if (ptr->myattr & NBRD_FOLDER){ char *title = get_folder_title(ptr->bid); if( !newflag ) - prints("%5d %c %sMyFavFolder\033[m �ؿ� ��%-34s\033[m", + prints("%5d %c %sMyFavFolder" ANSI_RESET " �ؿ� ��%-34s" ANSI_RESET, head, ptr->myattr & NBRD_TAG ? 'D' : ' ', - !(cuser.uflag2 & FAVNOHILIGHT) ? "\033[1;36m" : "", + !(cuser.uflag2 & FAVNOHILIGHT) ? ANSI_COLOR(1;36) : "", title); else - prints("%6d %sMyFavFolder\033[m �ؿ� ��%-34s\033[m", + prints("%6d %sMyFavFolder" ANSI_RESET " �ؿ� ��%-34s" ANSI_RESET, get_data_number(get_fav_folder(getfolder(ptr->bid))), - !(cuser.uflag2 & FAVNOHILIGHT) ? "\033[1;36m" : "", + !(cuser.uflag2 & FAVNOHILIGHT) ? ANSI_COLOR(1;36) : "", title); continue; } @@ -567,10 +567,10 @@ show_brdlist(int head, int clsflag, int newflag) unread[ptr->myattr & NBRD_UNREAD ? 1 : 0]); } if (!IN_CLASSROOT()) { - prints("%s%-13s\033[m%s%5.5s\033[0;37m%2.2s\033[m" + prints("%s%-13s" ANSI_RESET "%s%5.5s" ANSI_COLOR(0;37) "%2.2s" ANSI_RESET "%-34.34s", ((!(cuser.uflag2 & FAVNOHILIGHT) && - getboard(ptr->bid) != NULL))? "\033[1;36m" : "", + getboard(ptr->bid) != NULL))? ANSI_COLOR(1;36) : "", B_BH(ptr)->brdname, color[(unsigned int) (B_BH(ptr)->title[1] + B_BH(ptr)->title[2] + @@ -591,19 +591,19 @@ show_brdlist(int head, int clsflag, int newflag) else if (B_BH(ptr)->nuser <= 10) prints("%2d ", B_BH(ptr)->nuser); else if (B_BH(ptr)->nuser <= 50) - prints("\033[1;33m%2d\033[m ", B_BH(ptr)->nuser); + prints(ANSI_COLOR(1;33) "%2d" ANSI_RESET " ", B_BH(ptr)->nuser); else if (B_BH(ptr)->nuser >= 5000) - outs("\033[1;34m�z!\033[m"); + outs(ANSI_COLOR(1;34) "�z!" ANSI_RESET); else if (B_BH(ptr)->nuser >= 2000) - outs("\033[1;31m�z!\033[m"); + outs(ANSI_COLOR(1;31) "�z!" ANSI_RESET); else if (B_BH(ptr)->nuser >= 1000) - outs("\033[1m�z!\033[m"); + outs(ANSI_COLOR(1) "�z!" ANSI_RESET); else if (B_BH(ptr)->nuser >= 100) - outs("\033[1mHOT\033[m"); + outs(ANSI_COLOR(1) "HOT" ANSI_RESET); else //if (B_BH(ptr)->nuser > 50) - prints("\033[1;31m%2d\033[m ", B_BH(ptr)->nuser); - prints("%.*s\033[K", t_columns - 67, B_BH(ptr)->BM); + prints(ANSI_COLOR(1;31) "%2d" ANSI_RESET " ", B_BH(ptr)->nuser); + prints("%.*s" ANSI_CLRTOEND, t_columns - 67, B_BH(ptr)->BM); } else { prints("%-40.40s %.*s", B_BH(ptr)->title + 7, t_columns - 67, B_BH(ptr)->BM); @@ -836,7 +836,7 @@ choose_board(int newflag) if(IS_LISTING_FAV()){ move(b_lines - 2, 0); outs("���s�ƧǬݪO " - "\033[1;33m(�`�N, �o�Ӱʧ@�|�мg��ӳ]�w)\033[m \n"); + ANSI_COLOR(1;33) "(�`�N, �o�Ӱʧ@�|�мg��ӳ]�w)" ANSI_RESET " \n"); tmp = getans("�ƧǤ覡 (1)���ӪO�W�Ƨ� (2)�������O�Ƨ� ==> [0]���� "); if( tmp == '1' ) fav_sort_by_name(); @@ -1098,7 +1098,7 @@ choose_board(int newflag) move(0, 0); clrtoeol(); /* use CompleteBoard or CompleteBoardAndGroup ? */ - CompleteBoard("\033[7m�i �W�[�ڪ��̷R �j\033[m\n" + CompleteBoard(ANSI_COLOR(7) "�i �W�[�ڪ��̷R �j" ANSI_RESET "\n" "�п�J���[�J���ݪO�W��(���ť���۰ʷj�M)�G", bname); diff --git a/mbbsd/cal.c b/mbbsd/cal.c index fd1f9b3e..56da1cb0 100644 --- a/mbbsd/cal.c +++ b/mbbsd/cal.c @@ -333,9 +333,9 @@ mail_redenvelop(const char *from, const char *to, int money, char mode) fprintf(fp, "�@��: %s\n" "���D: �۰]�i�_\n" "�ɶ�: %s\n" - "\033[1;33m�˷R�� %s �G\n\n\033[m" - "\033[1;31m �ڥ]���A�@�� %d �����j���]�� ^_^\n\n" - " §�����N���A�Я���...... ^_^\033[m\n", + ANSI_COLOR(1;33) "�˷R�� %s �G\n\n" ANSI_RESET + ANSI_COLOR(1;31) " �ڥ]���A�@�� %d �����j���]�� ^_^\n\n" + " §�����N���A�Я���...... ^_^" ANSI_RESET "\n", from, ctime4(&now), to, money); fclose(fp); snprintf(fhdr.title, sizeof(fhdr.title), "�۰]�i�_"); @@ -414,7 +414,7 @@ p_sysinfo(void) clear(); showtitle("�t�θ�T", BBSNAME); move(2, 0); - prints("�z�{�b��� " TITLE_COLOR BBSNAME "\033[m (" MYIP ")\n" + prints("�z�{�b��� " TITLE_COLOR BBSNAME ANSI_RESET " (" MYIP ")\n" "�t�έt�����p: %s\n" "�u�W�A�ȤH��: %d/%d\n" "�sĶ�ɶ�: %s\n" diff --git a/mbbsd/card.c b/mbbsd/card.c index 63567ddd..14b3cdf8 100644 --- a/mbbsd/card.c +++ b/mbbsd/card.c @@ -40,8 +40,8 @@ card_isblackjack(int card1, int card2) static int card_select(int *now) { - char *cc[2] = {"\033[44m \033[m", - "\033[1;33;41m �� \033[m"}; + char *cc[2] = {ANSI_COLOR(44) " " ANSI_RESET, + ANSI_COLOR(1;33;41) " �� " ANSI_RESET}; while (1) { move(20, 0); @@ -94,47 +94,47 @@ card_display(int cline, int number, enum CardSuit flower, int show) if (flower == 0 || flower == 3) color = 36; if ((show < 0) && (cline > 1 && cline < 8)) - outs("�x\033[1;33;42m��������\033[m�x"); + outs("�x" ANSI_COLOR(1;33;42) "��������" ANSI_RESET "�x"); else switch (cline) { case 1: outs("�~�w�w�w�w��"); break; case 2: - prints("�x\033[1;%dm%s\033[m �x", color, cn[number - 1]); + prints("�x" ANSI_COLOR(1;%d) "%s" ANSI_RESET " �x", color, cn[number - 1]); break; case 3: if (flower == 1) - prints("�x\033[1;%dm��������\033[m�x", color); + prints("�x" ANSI_COLOR(1;%d) "��������" ANSI_RESET "�x", color); else - prints("�x\033[1;%dm ���� \033[m�x", color); + prints("�x" ANSI_COLOR(1;%d) " ���� " ANSI_RESET "�x", color); break; case 4: if (flower == 1) - prints("�x\033[1;%dm�i�i�i�i\033[m�x", color); + prints("�x" ANSI_COLOR(1;%d) "�i�i�i�i" ANSI_RESET "�x", color); else if (flower == 3) - prints("�x\033[1;%dm���i�i��\033[m�x", color); + prints("�x" ANSI_COLOR(1;%d) "���i�i��" ANSI_RESET "�x", color); else - prints("�x\033[1;%dm���i�i��\033[m�x", color); + prints("�x" ANSI_COLOR(1;%d) "���i�i��" ANSI_RESET "�x", color); break; case 5: if (flower == 0) - prints("�x\033[1;%dm�i�i�i�i\033[m�x", color); + prints("�x" ANSI_COLOR(1;%d) "�i�i�i�i" ANSI_RESET "�x", color); else if (flower == 3) - prints("�x\033[1;%dm�i�����i\033[m�x", color); + prints("�x" ANSI_COLOR(1;%d) "�i�����i" ANSI_RESET "�x", color); else - prints("�x\033[1;%dm���i�i��\033[m�x", color); + prints("�x" ANSI_COLOR(1;%d) "���i�i��" ANSI_RESET "�x", color); break; case 6: if (flower == 0) - prints("�x\033[1;%dm ���� \033[m�x", color); + prints("�x" ANSI_COLOR(1;%d) " ���� " ANSI_RESET "�x", color); else if (flower == 3) - prints("�x\033[1;%dm��������\033[m�x", color); + prints("�x" ANSI_COLOR(1;%d) "��������" ANSI_RESET "�x", color); else - prints("�x\033[1;%dm ���� \033[m�x", color); + prints("�x" ANSI_COLOR(1;%d) " ���� " ANSI_RESET "�x", color); break; case 7: - prints("�x \033[1;%dm%s\033[m�x", color, cn[number - 1]); + prints("�x " ANSI_COLOR(1;%d) "%s" ANSI_RESET "�x", color, cn[number - 1]); break; case 8: outs("���w�w�w�w��"); @@ -192,12 +192,12 @@ card_start(char name[]) clear(); stand_title(name); move(1, 0); - outs(" \033[1;33;41m �q �� \033[m"); + outs(" " ANSI_COLOR(1;33;41) " �q �� " ANSI_RESET); move(10, 0); - outs("\033[1;34;44m���㡻�㡻�㡻�㡻�㡻�㡻�㡻�㡻�㡻�㡻�㡻��" - "���㡻�㡻�㡻�㡻�㡻�㡻�㡻\033[m"); + outs(ANSI_COLOR(1;34;44) "���㡻�㡻�㡻�㡻�㡻�㡻�㡻�㡻�㡻�㡻�㡻��" + "���㡻�㡻�㡻�㡻�㡻�㡻�㡻" ANSI_RESET); move(19, 0); - outs(" \033[1;37;42m �� �v \033[m"); + outs(" " ANSI_COLOR(1;37;42) " �� �v " ANSI_RESET); } static int @@ -279,8 +279,8 @@ card_99(void) int cpu[5], c[5], me[5], m[5]; int cards[52]; int count = 0; - char *ff[4] = {"\033[1;36m�®�", "\033[1;31m����", - "\033[1;31m���", "\033[1;36m�ª�"}; + char *ff[4] = {ANSI_COLOR(1;36) "�®�", ANSI_COLOR(1;31) "����", + ANSI_COLOR(1;31) "���", ANSI_COLOR(1;36) "�ª�"}; char *cn[13] = {"��", "��", "��", "��", "��", "��", "��", "��", "��", "10", "��", "��", "��"}; for (i = 0; i < 5; i++) @@ -307,7 +307,7 @@ card_99(void) count = card_99_add(card_number(me[j]), i, count); move(21 + (turn / 2) % 2, 0); clrtoeol(); - prints("[%d]�z�X %s%s\033[m �ثe \033[1;31m%d/\033[34m%d\033[m �I", + prints("[%d]�z�X %s%s" ANSI_RESET " �ثe " ANSI_COLOR(1;31) "%d/" ANSI_COLOR(34) "%d" ANSI_RESET " �I", turn, ff[card_flower(me[j])], cn[card_number(me[j]) - 1], count, 99 - count); me[j] = card_give(cards); @@ -319,14 +319,14 @@ card_99(void) if (count > 99) { move(22, 0); clrtoeol(); - prints("[%d]���G..YOU LOSS..�ثe \033[1;31m%d/\033[34m%d\033[m �I", + prints("[%d]���G..YOU LOSS..�ثe " ANSI_COLOR(1;31) "%d/" ANSI_COLOR(34) "%d" ANSI_RESET " �I", turn, count, 99 - count); pressanykey(); return 0; } i = card_99_cpu(cpu, &count); move(21 + (turn / 2 + 1) % 2, 40); - prints("[%d]�q���X %s%s\033[m �ثe \033[1;31m%d/\033[34m%d\033[m �I", + prints("[%d]�q���X %s%s" ANSI_RESET " �ثe " ANSI_COLOR(1;31) "%d/" ANSI_COLOR(34) "%d" ANSI_RESET " �I", turn, ff[card_flower(cpu[i])], cn[card_number(cpu[i]) - 1], count, 99 - count); cpu[i] = card_give(cards); @@ -336,7 +336,7 @@ card_99(void) if (count > 99) { move(22, 0); clrtoeol(); - prints("[%d]���G..YOU WIN!..�ثe \033[1;31m%d/\033[34m%d\033[m �I", + prints("[%d]���G..YOU WIN!..�ثe " ANSI_COLOR(1;31) "%d/" ANSI_COLOR(34) "%d" ANSI_RESET " �I", turn, count, 99 - count); pressanykey(); return 0; @@ -650,7 +650,7 @@ g_ten_helf(void) return 0; } getdata(b_lines - 1, 0, - "\033[1;37m�T�w�n���Q�I�b�� �@���Q����?(Y/N)?[N]\033[m", + ANSI_COLOR(1;37) "�T�w�n���Q�I�b�� �@���Q����?(Y/N)?[N]" ANSI_RESET, buf, 3, LCECHO); if (buf[0] != 'y' && buf[0] != 'Y') return 0; diff --git a/mbbsd/chat.c b/mbbsd/chat.c index f548775f..a837eab3 100644 --- a/mbbsd/chat.c +++ b/mbbsd/chat.c @@ -94,7 +94,7 @@ chat_recv(struct ChatBuf *cb, int fd, char *chatroom, char *chatid) case 't': move(0, 0); clrtoeol(); - prints("\033[1;37;46m �ͤѫ� [%-12s] \033[45m ���D�G%-48s\033[m", + prints(ANSI_COLOR(1;37;46) " �ͤѫ� [%-12s] " ANSI_COLOR(45) " ���D�G%-48s" ANSI_RESET, chatroom, bptr + 2); } } else @@ -531,7 +531,7 @@ t_chat(void) stampfile(genbuf, &mymail); mymail.filemode = FILE_READ ; strlcpy(mymail.owner, "[��.��.��]", sizeof(mymail.owner)); - strlcpy(mymail.title, "�|ij\033[1;33m�O��\033[m", sizeof(mymail.title)); + strlcpy(mymail.title, "�|ij" ANSI_COLOR(1;33) "�O��" ANSI_RESET, sizeof(mymail.title)); sethomedir(title, cuser.userid); append_record(title, &mymail, sizeof(mymail)); Rename(fpath, genbuf); diff --git a/mbbsd/chc.c b/mbbsd/chc.c index 1b664aea..18f7bceb 100644 --- a/mbbsd/chc.c +++ b/mbbsd/chc.c @@ -220,10 +220,10 @@ getstep(board_t board, const rc_t *from, const rc_t *to, char buf[]) num_str[turn][fc]); } /* �i�T */ - len+=sprintf(buf+len, "%s%s\033[m", dir, num_str[turn][tc]); + len+=sprintf(buf+len, "%s%s" ANSI_RESET, dir, num_str[turn][tc]); /* �G�H */ if(board[to->r][to->c]) { - len+=sprintf(buf+len,"�G%s%s\033[m", + len+=sprintf(buf+len,"�G%s%s" ANSI_RESET, turn_color[turn^1], chess_str[turn^1][CHE_P(board[to->r][to->c])]); } @@ -244,7 +244,7 @@ chc_drawline(board_t board, const chcusr_t *user1, const chcusr_t *user2, int li move(line, 0); clrtoeol(); if (line == 0) { - prints("\033[1;46m �H�ѹ�� \033[45m%30s VS %-20s%10s\033[m", + prints(ANSI_COLOR(1;46) " �H�ѹ�� " ANSI_COLOR(45) "%30s VS %-20s%10s" ANSI_RESET, user1->userid, user2->userid, chcd->mode & CHC_WATCH ? "[�[�ѼҦ�]" : ""); } else if (line >= 3 && line <= 21) { outs(" "); @@ -253,12 +253,12 @@ chc_drawline(board_t board, const chcusr_t *user1, const chcusr_t *user2, int li if ((line & 1) == 1 && j) { if (chcd->selected && chcd->select.r == RTL(line) && chcd->select.c == i) { - prints("%s%s\033[m", + prints("%s%s" ANSI_RESET, CHE_O(j) == BLK ? BLACK_REVERSE : RED_REVERSE, chess_str[CHE_O(j)][CHE_P(j)]); } else { - prints("%s%s\033[m", + prints("%s%s" ANSI_RESET, turn_color[CHE_O(j)], chess_str[CHE_O(j)][CHE_P(j)]); } @@ -274,11 +274,11 @@ chc_drawline(board_t board, const chcusr_t *user1, const chcusr_t *user2, int li if (line >= 3 && line < 3 + (int)dim(hint_str)) { outs(hint_str[line - 3]); } else if (line == SIDE_ROW) { - prints("\033[1m�A�O%s%s\033[m", + prints(ANSI_COLOR(1) "�A�O%s%s" ANSI_RESET, turn_color[chcd->my], turn_str[chcd->my]); } else if (line == TURN_ROW) { - prints("%s%s\033[m", + prints("%s%s" ANSI_RESET, TURN_COLOR, chcd->my == chcd->turn ? "����A�U�ѤF" : "���ݹ��U��"); } else if (line == STEP_ROW && !chcd->firststep) { @@ -288,17 +288,17 @@ chc_drawline(board_t board, const chcusr_t *user1, const chcusr_t *user2, int li } else if (line == WARN_ROW) { outs(chcd->warnmsg); } else if (line == MYWIN_ROW) { - prints("\033[1;33m%12.12s " - "\033[1;31m%2d\033[37m�� " - "\033[34m%2d\033[37m�� " - "\033[36m%2d\033[37m�M\033[m", + prints(ANSI_COLOR(1;33) "%12.12s " + ANSI_COLOR(1;31) "%2d" ANSI_COLOR(37) "�� " + ANSI_COLOR(34) "%2d" ANSI_COLOR(37) "�� " + ANSI_COLOR(36) "%2d" ANSI_COLOR(37) "�M" ANSI_RESET, user1->userid, user1->win, user1->lose - 1, user1->tie); } else if (line == HISWIN_ROW) { - prints("\033[1;33m%12.12s " - "\033[1;31m%2d\033[37m�� " - "\033[34m%2d\033[37m�� " - "\033[36m%2d\033[37m�M\033[m", + prints(ANSI_COLOR(1;33) "%12.12s " + ANSI_COLOR(1;31) "%2d" ANSI_COLOR(37) "�� " + ANSI_COLOR(34) "%2d" ANSI_COLOR(37) "�� " + ANSI_COLOR(36) "%2d" ANSI_COLOR(37) "�M" ANSI_RESET, user2->userid, user2->win, user2->lose - 1, user2->tie); } @@ -673,7 +673,7 @@ hisplay(int s, const chcusr_t *user1, const chcusr_t *user2, board_t board, boar } else { if (chcd->from.r == -1) { chcd->hepass = 1; - strlcpy(chcd->warnmsg, "\033[1;33m�n�D�M��!\033[m", sizeof(chcd->warnmsg)); + strlcpy(chcd->warnmsg, ANSI_COLOR(1;33) "�n�D�M��!" ANSI_RESET, sizeof(chcd->warnmsg)); chc_drawline(board, user1, user2, WARN_ROW); } else { /* �y���ܴ� @@ -767,7 +767,7 @@ myplay(int s, const chcusr_t *user1, const chcusr_t *user2, board_t board, board chcd->ipass = 1; chcd->from.r = -1; chc_broadcast_send(chcd->act_list, board); - strlcpy(chcd->warnmsg, "\033[1;33m�n�D�M��!\033[m", sizeof(chcd->warnmsg)); + strlcpy(chcd->warnmsg, ANSI_COLOR(1;33) "�n�D�M��!" ANSI_RESET, sizeof(chcd->warnmsg)); chc_drawline(board, user1, user2, WARN_ROW); bell(); break; @@ -799,7 +799,7 @@ myplay(int s, const chcusr_t *user1, const chcusr_t *user2, board_t board, board chc_drawline(board, user1, user2, LTR(chcd->to.r)); endturn = 1; } else { - strlcpy(chcd->warnmsg, "\033[1;33m���i�H������\033[m", sizeof(chcd->warnmsg)); + strlcpy(chcd->warnmsg, ANSI_COLOR(1;33) "���i�H������" ANSI_RESET, sizeof(chcd->warnmsg)); bell(); chc_drawline(board, user1, user2, WARN_ROW); } @@ -875,7 +875,7 @@ mainloop(int s, chcusr_t *user1, chcusr_t *user2, board_t board, play_func_t pla chcd->firststep = 0; chc_drawline(board, user1, user2, TURN_ROW); if (chc_ischeck(board, chcd->turn)) { - strlcpy(chcd->warnmsg, "\033[1;31m�N�x!\033[m", sizeof(chcd->warnmsg)); + strlcpy(chcd->warnmsg, ANSI_COLOR(1;31) "�N�x!" ANSI_RESET, sizeof(chcd->warnmsg)); bell(); } else chcd->warnmsg[0] = 0; diff --git a/mbbsd/chicken.c b/mbbsd/chicken.c index 9e21affc..9cf684d1 100644 --- a/mbbsd/chicken.c +++ b/mbbsd/chicken.c @@ -104,7 +104,7 @@ new_chicken(void) clear(); move(2, 0); - outs("�w����{ \033[33m��\033[37;44m Ptt�d������ \033[33;40m��\033[m.. " + outs("�w����{ " ANSI_COLOR(33) "��" ANSI_COLOR(37;44) " Ptt�d������ " ANSI_COLOR(33;40) "��" ANSI_RESET ".. " "�ثe�J���G\n" "(a)�p�� $5 (b)���֤k $25 (c)�i�h $30 (d)�j�� $40 " "(e)���s $80\n" @@ -133,8 +133,8 @@ new_chicken(void) sizeof(mychicken->name), DOECHO); log_file(CHICKENLOG, LOG_CREAT | LOG_VF, - "\033[31m%s \033[m�i�F�@���s\033[33m %s \033[m�� " - "\033[32m%s\033[m �� %s\n", cuser.userid, + ANSI_COLOR(31) "%s " ANSI_RESET "�i�F�@���s" ANSI_COLOR(33) " %s " ANSI_RESET "�� " + ANSI_COLOR(32) "%s" ANSI_RESET " �� %s\n", cuser.userid, mychicken->name, chicken_type[(int)mychicken->type], ctime4(&now)); mychicken->lastvisit = mychicken->birthday = mychicken->cbirth = now; mychicken->food = 0; @@ -161,18 +161,18 @@ show_chicken_stat(const chicken_t * thechicken, int age) struct tm *ptime; ptime = localtime4(&thechicken->birthday); - prints(" Name :\033[33m%s\033[m (\033[32m%s\033[m)%*s�ͤ� " - ":\033[31m%02d\033[m�~\033[31m%2d\033[m��\033[31m%2d\033[m�� " - "(\033[32m%s %d��\033[m)\n" - " ��:\033[33m%5d/%-5d\033[m �k:\033[33m%5d/%-5d\033[m �����O:" - "\033[33m%-7d\033[m �ӱ� :\033[33m%-7d\033[m ���� :\033[33m%-7d" - "\033[m \n" - " �ּ� :\033[33m%-7d\033[m ���N :\033[33m%-7d\033[m �h�� :" - "\033[33m%-7d\033[m ��� :\033[33m%-7d \033[m�魫 :" - "\033[33m%-5.2f\033[m \n" - " �f�� :\033[33m%-7d\033[m ���b :\033[33m%-7d\033[m ���� :" - "\033[33m%-7d\033[m �j�ɤY:\033[33m%-7d\033[m �ī~ :\033[33m%-7d" - "\033[m \n", + prints(" Name :" ANSI_COLOR(33) "%s" ANSI_RESET " (" ANSI_COLOR(32) "%s" ANSI_RESET ")%*s�ͤ� " + ":" ANSI_COLOR(31) "%02d" ANSI_RESET "�~" ANSI_COLOR(31) "%2d" ANSI_RESET "��" ANSI_COLOR(31) "%2d" ANSI_RESET "�� " + "(" ANSI_COLOR(32) "%s %d��" ANSI_RESET ")\n" + " ��:" ANSI_COLOR(33) "%5d/%-5d" ANSI_RESET " �k:" ANSI_COLOR(33) "%5d/%-5d" ANSI_RESET " �����O:" + ANSI_COLOR(33) "%-7d" ANSI_RESET " �ӱ� :" ANSI_COLOR(33) "%-7d" ANSI_RESET " ���� :" ANSI_COLOR(33) "%-7d" + ANSI_RESET " \n" + " �ּ� :" ANSI_COLOR(33) "%-7d" ANSI_RESET " ���N :" ANSI_COLOR(33) "%-7d" ANSI_RESET " �h�� :" + ANSI_COLOR(33) "%-7d" ANSI_RESET " ��� :" ANSI_COLOR(33) "%-7d " ANSI_RESET "�魫 :" + ANSI_COLOR(33) "%-5.2f" ANSI_RESET " \n" + " �f�� :" ANSI_COLOR(33) "%-7d" ANSI_RESET " ���b :" ANSI_COLOR(33) "%-7d" ANSI_RESET " ���� :" + ANSI_COLOR(33) "%-7d" ANSI_RESET " �j�ɤY:" ANSI_COLOR(33) "%-7d" ANSI_RESET " �ī~ :" ANSI_COLOR(33) "%-7d" + ANSI_RESET " \n", thechicken->name, chicken_type[(int)thechicken->type], (int)(15 - strlen(thechicken->name)), "", ptime->tm_year % 100, ptime->tm_mon + 1, ptime->tm_mday, @@ -214,39 +214,39 @@ show_chicken_data(chicken_t * thechicken, chicken_t * pkchicken) if (thechicken->sick) outs("�ͯf�F..."); if (thechicken->sick > thechicken->hp / 5) - outs("\033[5;31m���...�f��!!\033[m"); + outs(ANSI_COLOR(5;31) "���...�f��!!" ANSI_RESET); if (thechicken->clean > 150) - outs("\033[31m�S��Sż��..\033[m"); + outs(ANSI_COLOR(31) "�S��Sż��.." ANSI_RESET); else if (thechicken->clean > 80) outs("���Iż.."); else if (thechicken->clean < 20) - outs("\033[32m�ܰ��b..\033[m"); + outs(ANSI_COLOR(32) "�ܰ��b.." ANSI_RESET); if (thechicken->weight > thechicken->hp_max * 4) - outs("\033[31m�ֹ����F!.\033[m"); + outs(ANSI_COLOR(31) "�ֹ����F!." ANSI_RESET); else if (thechicken->weight > thechicken->hp_max * 3) - outs("\033[32m���ʹ�..\033[m"); + outs(ANSI_COLOR(32) "���ʹ�.." ANSI_RESET); else if (thechicken->weight < (thechicken->hp_max / 4)) - outs("\033[31m�־j���F!..\033[m"); + outs(ANSI_COLOR(31) "�־j���F!.." ANSI_RESET); else if (thechicken->weight < (thechicken->hp_max / 2)) outs("�j�F.."); if (thechicken->tiredstrong > thechicken->hp * 1.7) - outs("\033[31m�ֱo���g�F...\033[m"); + outs(ANSI_COLOR(31) "�ֱo���g�F..." ANSI_RESET); else if (thechicken->tiredstrong > thechicken->hp) outs("�֤F.."); else if (thechicken->tiredstrong < thechicken->hp / 4) - outs("\033[32m��O����...\033[m"); + outs(ANSI_COLOR(32) "��O����..." ANSI_RESET); if (thechicken->hp < thechicken->hp_max / 4) - outs("\033[31m��O�κ�..�a�a�@��..\033[m"); + outs(ANSI_COLOR(31) "��O�κ�..�a�a�@��.." ANSI_RESET); if (thechicken->happy > 500) - outs("\033[32m�ܧּ�..\033[m"); + outs(ANSI_COLOR(32) "�ܧּ�.." ANSI_RESET); else if (thechicken->happy < 100) outs("���ּ�.."); if (thechicken->satis > 500) - outs("\033[32m�ܺ���..\033[m"); + outs(ANSI_COLOR(32) "�ܺ���.." ANSI_RESET); else if (thechicken->satis < 50) outs("������.."); @@ -300,8 +300,8 @@ ch_guess(void) mychicken->attack += time_change[(int)mychicken->type][ATTACK] / 4; move(20, 0); clrtobot(); - outs("�A�n�X[\033[32m1\033[m]\033[33m�ŤM\033[m(\033[32m2\033[m)" - "\033[33m���Y\033[m(\033[32m3\033[m)\033[33m��\033[m:\n"); + outs("�A�n�X[" ANSI_COLOR(32) "1" ANSI_RESET "]" ANSI_COLOR(33) "�ŤM" ANSI_RESET "(" ANSI_COLOR(32) "2" ANSI_RESET ")" + ANSI_COLOR(33) "���Y" ANSI_RESET "(" ANSI_COLOR(32) "3" ANSI_RESET ")" ANSI_COLOR(33) "��" ANSI_RESET ":\n"); me = igetch(); me -= '1'; if (me > 2 || me < 0) @@ -427,8 +427,8 @@ ch_kill(void) vice(100, "��i�d���O"); more(CHICKEN_PIC "/deadth", YEA); log_file(CHICKENLOG, LOG_CREAT | LOG_VF, - "\033[31m%s \033[m�� \033[33m%s\033[m\033[32m %s " - "\033[m�_�F �� %s\n", cuser.userid, mychicken->name, + ANSI_COLOR(31) "%s " ANSI_RESET "�� " ANSI_COLOR(33) "%s" ANSI_RESET ANSI_COLOR(32) " %s " + ANSI_RESET "�_�F �� %s\n", cuser.userid, mychicken->name, chicken_type[(int)mychicken->type], ctime4(&now)); mychicken->name[0] = 0; } @@ -466,7 +466,7 @@ ch_sell(int age) money = MAX_CHICKEN_MONEY; //������� if (mychicken->type == 1 || mychicken->type == 7) { - outs("\n\033[31m ��..�˷R��..�c��H�f�O�|�Ǫk����..\033[m"); + outs("\n" ANSI_COLOR(31) " ��..�˷R��..�c��H�f�O�|�Ǫk����.." ANSI_RESET); pressanykey(); return 0; } @@ -476,7 +476,7 @@ ch_sell(int age) return 0; } if (age > 30) { - outs("\n\033[31m �o..�ӦѨS�H�n�F\033[m"); + outs("\n" ANSI_COLOR(31) " �o..�ӦѨS�H�n�F" ANSI_RESET); pressanykey(); return 0; } @@ -484,8 +484,8 @@ ch_sell(int age) chicken_type[(int)mychicken->type], money); if (ans == 'y') { log_file(CHICKENLOG, LOG_CREAT | LOG_VF, - "\033[31m%s\033[m �� \033[33m%s\033[m " - "\033[32m%s\033[m �� \033[36m%d\033[m ��F �� %s\n", + ANSI_COLOR(31) "%s" ANSI_RESET " �� " ANSI_COLOR(33) "%s" ANSI_RESET " " + ANSI_COLOR(32) "%s" ANSI_RESET " �� " ANSI_COLOR(36) "%d" ANSI_RESET " ��F �� %s\n", cuser.userid, mychicken->name, chicken_type[(int)mychicken->type], money, ctime4(&now)); mychicken->lastvisit = mychicken->name[0] = 0; @@ -641,8 +641,8 @@ deadtype(const chicken_t * thechicken) if (thechicken == mychicken) { log_file(CHICKENLOG, LOG_CREAT | LOG_VF, - "\033[31m%s\033[m �үk�R��\033[33m %s\033[32m %s " - "\033[m���F �� %s\n", cuser.userid, thechicken->name, + ANSI_COLOR(31) "%s" ANSI_RESET " �үk�R��" ANSI_COLOR(33) " %s" ANSI_COLOR(32) " %s " + ANSI_RESET "���F �� %s\n", cuser.userid, thechicken->name, chicken_type[(int)thechicken->type], ctime4(&now)); mychicken->name[0] = 0; passwd_update(usernum, &cuser); @@ -698,8 +698,8 @@ ch_changename(void) if (strlen(newname) >= 3 && strcmp(newname, mychicken->name)) { strlcpy(mychicken->name, newname, sizeof(mychicken->name)); log_file(CHICKENLOG, LOG_CREAT | LOG_VF, - "\033[31m%s\033[m ��k�R��\033[33m %s\033[32m %s " - "\033[m��W��\033[33m %s\033[m �� %s\n", + ANSI_COLOR(31) "%s" ANSI_RESET " ��k�R��" ANSI_COLOR(33) " %s" ANSI_COLOR(32) " %s " + ANSI_RESET "��W��" ANSI_COLOR(33) " %s" ANSI_RESET " �� %s\n", cuser.userid, mychicken->name, chicken_type[(int)mychicken->type], newname, ctime4(&now)); } @@ -713,16 +713,16 @@ select_menu(int age) reload_money(); move(19, 0); - prints("\033[44;37m �� :\033[33m %-10d " - " \033[m\n" - "\033[33m(\033[37m1\033[33m)�M�z (\033[37m2\033[33m)�Y�� " - "(\033[37m3\033[33m)�q�� (\033[37m4\033[33m)��� " - "(\033[37m5\033[33m)�˥L (\033[37m6\033[33m)���L " - "(\033[37m7\033[33m)�R%s$%d (\033[37m8\033[33m)�Y�ɤY\n" - "(\033[37m9\033[33m)�Y�f�� (\033[37mo\033[33m)�R�j�ɤY$100 " - "(\033[37mm\033[33m)�R��$10 (\033[37mk\033[33m)��i " - "(\033[37ms\033[33m)�汼 (\033[37mn\033[33m)��W " - "(\033[37mq\033[33m)���}:\033[m", + prints(ANSI_COLOR(44;37) " �� :" ANSI_COLOR(33) " %-10d " + " " ANSI_RESET "\n" + ANSI_COLOR(33) "(" ANSI_COLOR(37) "1" ANSI_COLOR(33) ")�M�z (" ANSI_COLOR(37) "2" ANSI_COLOR(33) ")�Y�� " + "(" ANSI_COLOR(37) "3" ANSI_COLOR(33) ")�q�� (" ANSI_COLOR(37) "4" ANSI_COLOR(33) ")��� " + "(" ANSI_COLOR(37) "5" ANSI_COLOR(33) ")�˥L (" ANSI_COLOR(37) "6" ANSI_COLOR(33) ")���L " + "(" ANSI_COLOR(37) "7" ANSI_COLOR(33) ")�R%s$%d (" ANSI_COLOR(37) "8" ANSI_COLOR(33) ")�Y�ɤY\n" + "(" ANSI_COLOR(37) "9" ANSI_COLOR(33) ")�Y�f�� (" ANSI_COLOR(37) "o" ANSI_COLOR(33) ")�R�j�ɤY$100 " + "(" ANSI_COLOR(37) "m" ANSI_COLOR(33) ")�R��$10 (" ANSI_COLOR(37) "k" ANSI_COLOR(33) ")��i " + "(" ANSI_COLOR(37) "s" ANSI_COLOR(33) ")�汼 (" ANSI_COLOR(37) "n" ANSI_COLOR(33) ")��W " + "(" ANSI_COLOR(37) "q" ANSI_COLOR(33) ")���}:" ANSI_RESET, cuser.money, /* * chicken_food[(int)mychicken->type], @@ -802,15 +802,15 @@ recover_chicken(chicken_t * thechicken) if (now - thechicken->lastvisit > (60 * 60 * 24 * 7)) return 0; - outmsg("\033[33;44m���F�ɦu��\033[37;45m �O�`�� �ڬO�����A�� \033[m"); + outmsg(ANSI_COLOR(33;44) "���F�ɦu��" ANSI_COLOR(37;45) " �O�`�� �ڬO�����A�� " ANSI_RESET); bell(); igetch(); - outmsg("\033[33;44m���F�ɦu��\033[37;45m �A�L�k���ڤ��y �]���ڬO�t�F, " - "�̪�ʿ��Q�ȥ~�� \033[m"); + outmsg(ANSI_COLOR(33;44) "���F�ɦu��" ANSI_COLOR(37;45) " �A�L�k���ڤ��y �]���ڬO�t�F, " + "�̪�ʿ��Q�ȥ~�� " ANSI_RESET); bell(); igetch(); - snprintf(buf, sizeof(buf), "\033[33;44m���F�ɦu��\033[37;45m " - "�A���@�ӭ訫���[��%s�n�۴��^�Ӷ�? �u�n%d���� \033[m", + snprintf(buf, sizeof(buf), ANSI_COLOR(33;44) "���F�ɦu��" ANSI_COLOR(37;45) " " + "�A���@�ӭ訫���[��%s�n�۴��^�Ӷ�? �u�n%d���� " ANSI_RESET, chicken_type[(int)thechicken->type], price * 2); outmsg(buf); bell(); @@ -818,8 +818,8 @@ recover_chicken(chicken_t * thechicken) if (buf[0] == 'y' || buf[0] == 'Y') { reload_money(); if (cuser.money < price * 2) { - outmsg("\033[33;44m���F�ɦu��\033[37;45m ���� ���S�a�� " - "�S�����p�� �֥h�w���a \033[m"); + outmsg(ANSI_COLOR(33;44) "���F�ɦu��" ANSI_COLOR(37;45) " ���� ���S�a�� " + "�S�����p�� �֥h�w���a " ANSI_RESET); bell(); igetch(); return 0; @@ -830,15 +830,15 @@ recover_chicken(chicken_t * thechicken) thechicken->satis = 2; vice(money, "�F�ɦu��"); snprintf(buf, sizeof(buf), - "\033[33;44m���F�ɦu��\033[37;45m OK�F �O�o���L�I�F�� " - "���M�i�ॢ�� ���b�ڤ]����Ptt ���A%d�N�n \033[m", money); + ANSI_COLOR(33;44) "���F�ɦu��" ANSI_COLOR(37;45) " OK�F �O�o���L�I�F�� " + "���M�i�ॢ�� ���b�ڤ]����Ptt ���A%d�N�n " ANSI_RESET, money); outmsg(buf); bell(); igetch(); return 1; } - outmsg("\033[33;44m���F�ɦu��\033[37;45m ���M���ڧ|�H! �o�~�Y�R�u���ȿ� " - "���D�ڦA�ӧ�A �A�A�]�S���|�F \033[m"); + outmsg(ANSI_COLOR(33;44) "���F�ɦu��" ANSI_COLOR(37;45) " ���M���ڧ|�H! �o�~�Y�R�u���ȿ� " + "���D�ڦA�ӧ�A �A�A�]�S���|�F " ANSI_RESET); bell(); igetch(); thechicken->lastvisit = 0; diff --git a/mbbsd/dark.c b/mbbsd/dark.c index 9fe17eb8..475fc302 100644 --- a/mbbsd/dark.c +++ b/mbbsd/dark.c @@ -129,15 +129,15 @@ brd_prints(void) clear(); move(1, 0); outs("\n" - " [43;30m�~�w�s�w�s�w�s�w�s�w�s�w�s�w�s�w��[m\n" - " [43;30m�x���x���x���x���x���x���x���x���x[m\n" - " [43;30m�u�w�q�w�q�w�q�w�q�w�q�w�q�w�q�w�t[m\n" - " [43;30m�x���x���x���x���x���x���x���x���x[m\n" - " [43;30m�u�w�q�w�q�w�q�w�q�w�q�w�q�w�q�w�t[m\n" - " [43;30m�x���x���x���x���x���x���x���x���x[m\n" - " [43;30m�u�w�q�w�q�w�q�w�q�w�q�w�q�w�q�w�t[m\n" - " [43;30m�x���x���x���x���x���x���x���x���x[m\n" - " [43;30m���w�r�w�r�w�r�w�r�w�r�w�r�w�r�w��[m\n" + " " ANSI_COLOR(43;30) "�~�w�s�w�s�w�s�w�s�w�s�w�s�w�s�w��" ANSI_RESET "\n" + " " ANSI_COLOR(43;30) "�x���x���x���x���x���x���x���x���x" ANSI_RESET "\n" + " " ANSI_COLOR(43;30) "�u�w�q�w�q�w�q�w�q�w�q�w�q�w�q�w�t" ANSI_RESET "\n" + " " ANSI_COLOR(43;30) "�x���x���x���x���x���x���x���x���x" ANSI_RESET "\n" + " " ANSI_COLOR(43;30) "�u�w�q�w�q�w�q�w�q�w�q�w�q�w�q�w�t" ANSI_RESET "\n" + " " ANSI_COLOR(43;30) "�x���x���x���x���x���x���x���x���x" ANSI_RESET "\n" + " " ANSI_COLOR(43;30) "�u�w�q�w�q�w�q�w�q�w�q�w�q�w�q�w�t" ANSI_RESET "\n" + " " ANSI_COLOR(43;30) "�x���x���x���x���x���x���x���x���x" ANSI_RESET "\n" + " " ANSI_COLOR(43;30) "���w�r�w�r�w�r�w�r�w�r�w�r�w�r�w��" ANSI_RESET "\n" " "); } @@ -149,21 +149,21 @@ draw_line(struct DarkData *dd, sint y, sint f) *buf = 0; *tmp = 0; - strlcpy(buf, "\033[43;30m", sizeof(buf)); + strlcpy(buf, ANSI_COLOR(43;30), sizeof(buf)); for (i = 0; i < 8; i++) { if (dd->brd[y][i].die == 1) snprintf(tmp, sizeof(tmp), "�x "); else if (dd->brd[y][i].out == 0) snprintf(tmp, sizeof(tmp), "�x��"); else { - snprintf(tmp, sizeof(tmp), "�x\033[%s1;%dm%s\033[m\033[43;30m", + snprintf(tmp, sizeof(tmp), "�x" ANSI_COLOR(%s1;%d) "%s" ANSI_RESET ANSI_COLOR(43;30) "", (f == i) ? "1;47;" : "", (dd->brd[y][i].color) ? 31 : 34, (dd->brd[y][i].color) ? rname[dd->brd[y][i].value] : bname[dd->brd[y][i].value]); } strcat(buf, tmp); } - strcat(buf, "�x\033[m"); + strcat(buf, "�x" ANSI_RESET); move(cury[y], 3); clrtoeol(); @@ -379,22 +379,22 @@ main_dark(int fd, userinfo_t * uin) if (currutmp->turn) { brd_rand(&dd); send(fd, &dd.brd, sizeof(dd.brd), 0); - mouts(21, 0, " [1;37m[1;33m��[1;37m�A�O����[m"); - mouts(22, 0, " [1;33m��[5;35m����A�U�F[m"); + mouts(21, 0, " " ANSI_COLOR(1;37) ANSI_COLOR(1;33) "��" ANSI_COLOR(1;37) "�A�O����" ANSI_RESET); + mouts(22, 0, " " ANSI_COLOR(1;33) "��" ANSI_COLOR(5;35) "����A�U�F" ANSI_RESET); } else { recv(fd, &dd.brd, sizeof(dd.brd), 0); - mouts(21, 0, " [1;33m��[1;37m�A�O���[m"); + mouts(21, 0, " " ANSI_COLOR(1;33) "��" ANSI_COLOR(1;37) "�A�O���" ANSI_RESET); } move(12, 3); - prints("%s[0��0��][5;31m����[1;37m.[m%s[0��0��]", currutmp->userid, currutmp->mateid); + prints("%s[0��0��]" ANSI_COLOR(5;31) "����" ANSI_COLOR(1;37) "." ANSI_RESET "%s[0��0��]", currutmp->userid, currutmp->mateid); outs("\n" - " [1;36m����[1;31m�\\���[1;36m������������[m\n" - " [1;36m��[1;33m ��������[1;37m: [1;35m����[m\n" - " [1;36m��[1;33m ��[1;37m: [1;35m ��l,½�l[m\n" - " [1;36m��[1;33m enter[1;37m: [1;35m �Y��,���[m\n" - "�@[1;33m�w�g�ѨM��[1;37m:[1;36m�@�@ ��[1;33m ��[1;37m: [1;35m �X��[m\n" - " �@�@ [1;36m��[1;33m ��[1;37m: [1;35m �{��[m\n" - " [1;36m��[1;33m ��[1;37m: [1;35m ����[m"); + " " ANSI_COLOR(1;36) "����" ANSI_COLOR(1;31) "�\\���" ANSI_COLOR(1;36) "������������" ANSI_RESET "\n" + " " ANSI_COLOR(1;36) "��" ANSI_COLOR(1;33) " ��������" ANSI_COLOR(1;37) ": " ANSI_COLOR(1;35) "����" ANSI_RESET "\n" + " " ANSI_COLOR(1;36) "��" ANSI_COLOR(1;33) " ��" ANSI_COLOR(1;37) ": " ANSI_COLOR(1;35) " ��l,½�l" ANSI_RESET "\n" + " " ANSI_COLOR(1;36) "��" ANSI_COLOR(1;33) " enter" ANSI_COLOR(1;37) ": " ANSI_COLOR(1;35) " �Y��,���" ANSI_RESET "\n" + "�@" ANSI_COLOR(1;33) "�w�g�ѨM��" ANSI_COLOR(1;37) ":" ANSI_COLOR(1;36) "�@�@ ��" ANSI_COLOR(1;33) " ��" ANSI_COLOR(1;37) ": " ANSI_COLOR(1;35) " �X��" ANSI_RESET "\n" + " �@�@ " ANSI_COLOR(1;36) "��" ANSI_COLOR(1;33) " ��" ANSI_COLOR(1;37) ": " ANSI_COLOR(1;35) " �{��" ANSI_RESET "\n" + " " ANSI_COLOR(1;36) "��" ANSI_COLOR(1;33) " ��" ANSI_COLOR(1;37) ": " ANSI_COLOR(1;35) " ����" ANSI_RESET); if (currutmp->turn) move(cury[0], curx[0]); @@ -421,11 +421,11 @@ main_dark(int fd, userinfo_t * uin) break; } if (dd.curr.end == -3) - mouts(23, 30, "\033[33m�n�D�X��\033[m"); + mouts(23, 30, ANSI_COLOR(33) "�n�D�X��" ANSI_RESET); else if (dd.curr.end == -4) - mouts(23, 30, "\033[33m�n�D����\033[m"); + mouts(23, 30, ANSI_COLOR(33) "�n�D����" ANSI_RESET); else if (dd.curr.end == -5) - mouts(23, 30, "\033[33m�n�D�s�Y\033[m"); + mouts(23, 30, ANSI_COLOR(33) "�n�D�s�Y" ANSI_RESET); else mouts(23, 30, ""); @@ -434,7 +434,7 @@ main_dark(int fd, userinfo_t * uin) dd.mx = dd.curr.x; redraw(&dd); if (dd.curr.end) - mouts(22, 0, " [1;33m��[5;35m����A�U�F[m"); + mouts(22, 0, " " ANSI_COLOR(1;33) "��" ANSI_COLOR(5;35) "����A�U�F" ANSI_RESET); move(cury[dd.my], curx[dd.mx]); } else { if (currutmp->turn == 'p') { @@ -451,7 +451,7 @@ main_dark(int fd, userinfo_t * uin) if (ch == 'y') { currutmp->color = (currutmp->color == '1') ? '0' : '1'; uin->color = (uin->color == '1') ? '0' : '1'; - mouts(21, 0, (currutmp->color == '1') ? " \033[1;33m��[1;31m�A�������\033[m" : " \033[1;33m��[1;36m�A���¦��\033[m"); + mouts(21, 0, (currutmp->color == '1') ? " " ANSI_COLOR(1;33) "��" ANSI_COLOR(1;31) "�A�������" ANSI_RESET : " " ANSI_COLOR(1;33) "��" ANSI_COLOR(1;36) "�A���¦��" ANSI_RESET); } else { mouts(23, 30, ""); currutmp->turn = (uin->turn) ? 0 : 1; @@ -459,7 +459,7 @@ main_dark(int fd, userinfo_t * uin) } else if (currutmp->turn == 'g') { if (ch == 'y') { dd.cont = 1; - mouts(21, 0, " \033[1;33m��[1;31m�A�������\033[m �i�s�Y"); + mouts(21, 0, " " ANSI_COLOR(1;33) "��" ANSI_COLOR(1;31) "�A�������" ANSI_RESET " �i�s�Y"); } else { mouts(23, 30, ""); currutmp->turn = (uin->turn) ? 0 : 1; @@ -503,12 +503,12 @@ main_dark(int fd, userinfo_t * uin) continue; } if (!i && currutmp->color == '1') { - mouts(21, 0, " \033[1;33m��[1;31m�A�������\033[m"); + mouts(21, 0, " " ANSI_COLOR(1;33) "��" ANSI_COLOR(1;31) "�A�������" ANSI_RESET); i++; move(cury[dd.my], curx[dd.mx]); } if (!i && currutmp->color == '0') { - mouts(21, 0, " \033[1;33m��[1;36m�A���¦��\033[m"); + mouts(21, 0, " " ANSI_COLOR(1;33) "��" ANSI_COLOR(1;36) "�A���¦��" ANSI_RESET); i++; move(cury[dd.my], curx[dd.mx]); } @@ -521,7 +521,7 @@ main_dark(int fd, userinfo_t * uin) move(22, 0); clrtoeol(); - prints(" [1;33m��[1;37m����%s�U �O�ȧO�� �L��ԣ��[m", currutmp->mateid); + prints(" " ANSI_COLOR(1;33) "��" ANSI_COLOR(1;37) "����%s�U �O�ȧO�� �L��ԣ��" ANSI_RESET, currutmp->mateid); currutmp->turn = 0; uin->turn = 1; } else { @@ -531,7 +531,7 @@ main_dark(int fd, userinfo_t * uin) } move(22, 0); clrtoeol(); - prints(" [1;33m��[1;37m����%s�U �O�ȧO�� �L��ԣ��[m", currutmp->mateid); + prints(" " ANSI_COLOR(1;33) "��" ANSI_COLOR(1;37) "����%s�U �O�ȧO�� �L��ԣ��" ANSI_RESET, currutmp->mateid); } } } @@ -542,15 +542,15 @@ main_dark(int fd, userinfo_t * uin) if (currutmp->turn == 'w') { move(22, 0); clrtoeol(); - outs("[1;31m�AĹ�F.. �u�O����~~[m"); + outs(ANSI_COLOR(1;31) "�AĹ�F.. �u�O����~~" ANSI_RESET); } else { move(22, 0); clrtoeol(); - outs("[1;31m�鱼�F��.....�U�����L�n��!![m"); + outs(ANSI_COLOR(1;31) "�鱼�F��.....�U�����L�n��!!" ANSI_RESET); } break; case -3: - mouts(22, 0, "[1;31m�X�ѭ�!! �U���b�����U�a ^_^[m"); + mouts(22, 0, ANSI_COLOR(1;31) "�X�ѭ�!! �U���b�����U�a ^_^" ANSI_RESET); break; default: add_io(0, 0); diff --git a/mbbsd/dice.c b/mbbsd/dice.c index f7cf6537..b44f1744 100644 --- a/mbbsd/dice.c +++ b/mbbsd/dice.c @@ -97,30 +97,30 @@ static void show_data(void) { move(0, 0); - outs("\033[31m �z�w�w�w�w�w�w�w�w�w�w�w�w�w�w�w�w�w�w�w�w�w�w�w" - "�w�w�w�w�w�w�w�w�w�w�{\033[m\n"); - outs("\033[45;37m���v�@\033[m\033[31m �x \033[33m[1]��@�I [2]��G�I " - "[3]��T�I [4]��|�I [5]�㤭�I [6]�㤻�I \033[31m �x\033[m\n"); - outs("\033[31m �x \033[33m[7]��p [8]��j " - " \033[31m �x\033[m\n"); - outs("\033[31m �x " - " �x\033[m\n"); - outs("\033[45;37m�߲v�T\033[m\033[31m �x \033[33m[11]�㤤(�`�I�Ƶ���11" - "��10) \033[31m �x\033[m\n"); - outs("\033[31m �x " - " �x\033[m\n"); - outs("\033[45;37m�߲v��\033[m\033[31m �x \033[33m[74]��p�B�|�I [83]��" - "�j�B�T�I [66]��s�� \033[31m �x\033[m\n"); - outs("\033[31m �x " - " �x\033[m\n"); - outs("\033[31m �x \033[33m[12]��@�G�I [13]��@�T�I [14]��@�|�I" - " [15]��@���I [16]��@���I\033[31m �x\033[m\n"); - outs("\033[31m �x \033[33m[23]��G�T�I [24]��G�|�I [25]��G���I" - " [26]��G���I [34]��T�|�I\033[31m �x\033[m\n"); - outs("\033[31m �x \033[33m[35]��T���I [36]��T���I [45]��|���I" - " [46]��|���I [56]�㤭���I\033[31m �x\033[m\n"); - outs("\033[31m �|�w�w�w�w�w�w�w�w�w�w�w�w�w�w�w�w�w�w�w�w�w�w�w�w" - "�w�w�w�w�w�w�w�w�w�}\033[m\n"); + outs(ANSI_COLOR(31) " �z�w�w�w�w�w�w�w�w�w�w�w�w�w�w�w�w�w�w�w�w�w�w�w" + "�w�w�w�w�w�w�w�w�w�w�{" ANSI_RESET "\n"); + outs(ANSI_COLOR(45;37) "���v�@" ANSI_RESET ANSI_COLOR(31) " �x " ANSI_COLOR(33) "[1]��@�I [2]��G�I " + "[3]��T�I [4]��|�I [5]�㤭�I [6]�㤻�I " ANSI_COLOR(31) " �x" ANSI_RESET "\n"); + outs(ANSI_COLOR(31) " �x " ANSI_COLOR(33) "[7]��p [8]��j " + " " ANSI_COLOR(31) " �x" ANSI_RESET "\n"); + outs(ANSI_COLOR(31) " �x " + " �x" ANSI_RESET "\n"); + outs(ANSI_COLOR(45;37) "�߲v�T" ANSI_RESET ANSI_COLOR(31) " �x " ANSI_COLOR(33) "[11]�㤤(�`�I�Ƶ���11" + "��10) " ANSI_COLOR(31) " �x" ANSI_RESET "\n"); + outs(ANSI_COLOR(31) " �x " + " �x" ANSI_RESET "\n"); + outs(ANSI_COLOR(45;37) "�߲v��" ANSI_RESET ANSI_COLOR(31) " �x " ANSI_COLOR(33) "[74]��p�B�|�I [83]��" + "�j�B�T�I [66]��s�� " ANSI_COLOR(31) " �x" ANSI_RESET "\n"); + outs(ANSI_COLOR(31) " �x " + " �x" ANSI_RESET "\n"); + outs(ANSI_COLOR(31) " �x " ANSI_COLOR(33) "[12]��@�G�I [13]��@�T�I [14]��@�|�I" + " [15]��@���I [16]��@���I" ANSI_COLOR(31) " �x" ANSI_RESET "\n"); + outs(ANSI_COLOR(31) " �x " ANSI_COLOR(33) "[23]��G�T�I [24]��G�|�I [25]��G���I" + " [26]��G���I [34]��T�|�I" ANSI_COLOR(31) " �x" ANSI_RESET "\n"); + outs(ANSI_COLOR(31) " �x " ANSI_COLOR(33) "[35]��T���I [36]��T���I [45]��|���I" + " [46]��|���I [56]�㤭���I" ANSI_COLOR(31) " �x" ANSI_RESET "\n"); + outs(ANSI_COLOR(31) " �|�w�w�w�w�w�w�w�w�w�w�w�w�w�w�w�w�w�w�w�w�w�w�w�w" + "�w�w�w�w�w�w�w�w�w�}" ANSI_RESET "\n"); } static void @@ -243,83 +243,83 @@ show_output(int bet[]) outs(" "); } move(12, 0); - outs("\033[1;31m �z�w�w�w�w�w�w�w�w�w�w�w�w�w�w�w�w�w�w�w�w�w�w" - "�w�{\033[m\n\n\n\n\n\n"); - outs("\033[1;31m �|�w�w�w�w�w�w�w�w�w�w�w�w�w�w�w�w�w�w�w�w�w�w" - "�w�}\033[m"); + outs(ANSI_COLOR(1;31) " �z�w�w�w�w�w�w�w�w�w�w�w�w�w�w�w�w�w�w�w�w�w�w" + "�w�{" ANSI_RESET "\n\n\n\n\n\n"); + outs(ANSI_COLOR(1;31) " �|�w�w�w�w�w�w�w�w�w�w�w�w�w�w�w�w�w�w�w�w�w�w" + "�w�}" ANSI_RESET); for (i = 0; i < 3; i++, j += 25) { switch (bet[i]) { case 1: move(13, j); - outs("\033[37m�~�w�w�w�w��\033[m"); + outs(ANSI_COLOR(37) "�~�w�w�w�w��" ANSI_RESET); move(14, j); - outs("\033[37m�x �x\033[m"); + outs(ANSI_COLOR(37) "�x �x" ANSI_RESET); move(15, j); - outs("\033[37m�x �� �x\033[m"); + outs(ANSI_COLOR(37) "�x �� �x" ANSI_RESET); move(16, j); - outs("\033[37m�x �x\033[m"); + outs(ANSI_COLOR(37) "�x �x" ANSI_RESET); move(17, j); - outs("\033[37m���w�w�w�w��\033[m"); + outs(ANSI_COLOR(37) "���w�w�w�w��" ANSI_RESET); break; case 2: move(13, j); - outs("\033[37m�~�w�w�w�w��\033[m"); + outs(ANSI_COLOR(37) "�~�w�w�w�w��" ANSI_RESET); move(14, j); - outs("\033[37m�x ���x\033[m"); + outs(ANSI_COLOR(37) "�x ���x" ANSI_RESET); move(15, j); - outs("\033[37m�x �x\033[m"); + outs(ANSI_COLOR(37) "�x �x" ANSI_RESET); move(16, j); - outs("\033[37m�x�� �x\033[m"); + outs(ANSI_COLOR(37) "�x�� �x" ANSI_RESET); move(17, j); - outs("\033[37m���w�w�w�w��\033[m"); + outs(ANSI_COLOR(37) "���w�w�w�w��" ANSI_RESET); break; case 3: move(13, j); - outs("\033[37m�~�w�w�w�w��\033[m"); + outs(ANSI_COLOR(37) "�~�w�w�w�w��" ANSI_RESET); move(14, j); - outs("\033[37m�x ���x\033[m"); + outs(ANSI_COLOR(37) "�x ���x" ANSI_RESET); move(15, j); - outs("\033[37m�x �� �x\033[m"); + outs(ANSI_COLOR(37) "�x �� �x" ANSI_RESET); move(16, j); - outs("\033[37m�x�� �x\033[m"); + outs(ANSI_COLOR(37) "�x�� �x" ANSI_RESET); move(17, j); - outs("\033[37m���w�w�w�w��\033[m"); + outs(ANSI_COLOR(37) "���w�w�w�w��" ANSI_RESET); break; case 4: move(13, j); - outs("\033[37m�~�w�w�w�w��\033[m"); + outs(ANSI_COLOR(37) "�~�w�w�w�w��" ANSI_RESET); move(14, j); - outs("\033[37m�x�� ���x\033[m"); + outs(ANSI_COLOR(37) "�x�� ���x" ANSI_RESET); move(15, j); - outs("\033[37m�x �x\033[m"); + outs(ANSI_COLOR(37) "�x �x" ANSI_RESET); move(16, j); - outs("\033[37m�x�� ���x\033[m"); + outs(ANSI_COLOR(37) "�x�� ���x" ANSI_RESET); move(17, j); - outs("\033[37m���w�w�w�w��\033[m"); + outs(ANSI_COLOR(37) "���w�w�w�w��" ANSI_RESET); break; case 5: move(13, j); - outs("\033[37m�~�w�w�w�w��\033[m"); + outs(ANSI_COLOR(37) "�~�w�w�w�w��" ANSI_RESET); move(14, j); - outs("\033[37m�x�� ���x\033[m"); + outs(ANSI_COLOR(37) "�x�� ���x" ANSI_RESET); move(15, j); - outs("\033[37m�x �� �x\033[m"); + outs(ANSI_COLOR(37) "�x �� �x" ANSI_RESET); move(16, j); - outs("\033[37m�x�� ���x\033[m"); + outs(ANSI_COLOR(37) "�x�� ���x" ANSI_RESET); move(17, j); - outs("\033[37m���w�w�w�w��\033[m"); + outs(ANSI_COLOR(37) "���w�w�w�w��" ANSI_RESET); break; case 6: move(13, j); - outs("\033[37m�~�w�w�w�w��\033[m"); + outs(ANSI_COLOR(37) "�~�w�w�w�w��" ANSI_RESET); move(14, j); - outs("\033[37m�x�� ���x\033[m"); + outs(ANSI_COLOR(37) "�x�� ���x" ANSI_RESET); move(15, j); - outs("\033[37m�x�� ���x\033[m"); + outs(ANSI_COLOR(37) "�x�� ���x" ANSI_RESET); move(16, j); - outs("\033[37m�x�� ���x\033[m"); + outs(ANSI_COLOR(37) "�x�� ���x" ANSI_RESET); move(17, j); - outs("\033[37m���w�w�w�w��\033[m"); + outs(ANSI_COLOR(37) "���w�w�w�w��" ANSI_RESET); break; } } @@ -340,7 +340,7 @@ dice_main(void) reload_money(); if (cuser.money < 10) { move(19, 0); - outs("\033[1;37m�W�L�Q���A�Ӫ��a~~\033[m"); + outs(ANSI_COLOR(1;37) "�W�L�Q���A�Ӫ��a~~" ANSI_RESET); pressanykey(); return 0; } @@ -363,15 +363,15 @@ dice_main(void) while (1) { move(19, 0); - prints("\033[1;32m�A�{�b��\033[1;31m %u \033[1;32mPtt$��\033[m", + prints(ANSI_COLOR(1;32) "�A�{�b��" ANSI_COLOR(1;31) " %u " ANSI_COLOR(1;32) "Ptt$��" ANSI_RESET, cuser.money); - getdata(20, 0, "\033[1;37m�Ʀr:�[�� d:�h�� s:�}�l�����}\033[m: ", + getdata(20, 0, ANSI_COLOR(1;37) "�Ʀr:�[�� d:�h�� s:�}�l�����}" ANSI_RESET ": ", input, 5, LCECHO); reload_money(); if (input[0] != 's' && input[0] != 'd' && cuser.money < 10) { move(21, 0); clrtoeol(); - outs("\033[1;37m�W�L�Q���~���~\033[m"); + outs(ANSI_COLOR(1;37) "�W�L�Q���~���~" ANSI_RESET); continue; } if (input[0] == 'd' || input[0] == 'D') { @@ -391,8 +391,8 @@ dice_main(void) while (1) { if (cuser.money < 10) break; - getdata(21, 0, "\033[1;32m��h�ֿ��O\033[1;37m(�j��10 �p��500)" - "\033[m: ", input, sizeof(input), LCECHO); + getdata(21, 0, ANSI_COLOR(1;32) "��h�ֿ��O" ANSI_COLOR(1;37) "(�j��10 �p��500)" + ANSI_RESET ": ", input, sizeof(input), LCECHO); if (!(money = IsLegal(input)) || input[0] == '0') continue; reload_money(); @@ -426,7 +426,7 @@ dice_main(void) } reload_money(); move(19, 0); - prints("\033[1;32m�A�{�b�� \033[1;31m%u\033[1;32m Ptt$��", + prints(ANSI_COLOR(1;32) "�A�{�b�� " ANSI_COLOR(1;31) "%u" ANSI_COLOR(1;32) " Ptt$��", cuser.money); if (sig != 2) show_count(value,index, money); @@ -461,20 +461,20 @@ dice_main(void) if (total > 0) { move(21, 0); - prints("\033[1;32m�AĹ�F \033[1;31m%d\033[1;32m Ptt$ ��~~" - " \033[m", total); + prints(ANSI_COLOR(1;32) "�AĹ�F " ANSI_COLOR(1;31) "%d" ANSI_COLOR(1;32) " Ptt$ ��~~" + " " ANSI_RESET, total); } else { move(21, 0); clrtoeol(); - outs("\033[1;32m�u�i�� �U���A�ӸI�I�B��a\033[m"); + outs(ANSI_COLOR(1;32) "�u�i�� �U���A�ӸI�I�B��a" ANSI_RESET); } move(19, 0); clrtoeol(); - prints("\033[1;32m�A�{�b�� \033[1;31m%u\033[1;32m Ptt$��\033[m", + prints(ANSI_COLOR(1;32) "�A�{�b�� " ANSI_COLOR(1;31) "%u" ANSI_COLOR(1;32) " Ptt$��" ANSI_RESET, cuser.money); - getdata(23, 0, "\033[1;32m�~��İ�[\033[1;37my/n\033[1;32m]\033[m: ", + getdata(23, 0, ANSI_COLOR(1;32) "�~��İ�[" ANSI_COLOR(1;37) "y/n" ANSI_COLOR(1;32) "]" ANSI_RESET ": ", input, 2, LCECHO); } while (input[0] != 'n' && input[0] != 'N'); fclose(winfp); diff --git a/mbbsd/edit.c b/mbbsd/edit.c index 47fcece7..990155cc 100644 --- a/mbbsd/edit.c +++ b/mbbsd/edit.c @@ -369,23 +369,23 @@ show_phone_mode_panel(void) if (curr_buf->last_phone_mode < 20) { int len; - prints("\033[1;46m�i%s��J�j ", BIG_mode[curr_buf->last_phone_mode - 1]); + prints(ANSI_COLOR(1;46) "�i%s��J�j ", BIG_mode[curr_buf->last_phone_mode - 1]); len = strlen(BIG5[curr_buf->last_phone_mode - 1]) / 2; for (i = 0; i < len; i++) - prints("\033[37m%c\033[34m%2.2s", + prints(ANSI_COLOR(37) "%c" ANSI_COLOR(34) "%2.2s", i + 'A', BIG5[curr_buf->last_phone_mode - 1] + i * 2); for (i = 0; i < 16 - len; i++) outs(" "); - outs("\033[37m `1~9-=���� Z����\033[m"); + outs(ANSI_COLOR(37) " `1~9-=���� Z����" ANSI_RESET); } else { - prints("\033[1;46m�i����ø�s�j /=%s *=%s�� ", + prints(ANSI_COLOR(1;46) "�i����ø�s�j /=%s *=%s�� ", table_mode[(curr_buf->last_phone_mode - 20) / 4], table_mode[(curr_buf->last_phone_mode - 20) % 4 + 2]); for (i = 0;i < 11;i++) - prints("\033[37m%c\033[34m%2.2s", i ? i + '/' : '.', + prints(ANSI_COLOR(37) "%c" ANSI_COLOR(34) "%2.2s", i ? i + '/' : '.', table[curr_buf->last_phone_mode - 20] + i * 2); - outs("\033[37m Z���X \033[m"); + outs(ANSI_COLOR(37) " Z���X " ANSI_RESET); } } @@ -405,10 +405,10 @@ edit_msg(void) move(b_lines, 0); clrtoeol(); - prints("\033[37;44m �s��峹 \033[31;47m (^Z)\033[30m���� " - "\033[31;47m(^P)\033[30m�Ÿ� " - "\033[31;47m(^G)\033[30m���J�Ϥ�w \033[31m(^X,^Q)" - "\033[30m���}��%s�x%c%c%c%c�� %3d:%3d \033[m", + prints(ANSI_COLOR(37;44) " �s��峹 " ANSI_COLOR(31;47) " (^Z)" ANSI_COLOR(30) "���� " + ANSI_COLOR(31;47) "(^P)" ANSI_COLOR(30) "�Ÿ� " + ANSI_COLOR(31;47) "(^G)" ANSI_COLOR(30) "���J�Ϥ�w " ANSI_COLOR(31) "(^X,^Q)" + ANSI_COLOR(30) "���}��%s�x%c%c%c%c�� %3d:%3d " ANSI_RESET, curr_buf->insert_mode ? "���J" : "���N", curr_buf->ansimode ? 'A' : 'a', curr_buf->indent_mode ? 'I' : 'i', @@ -887,7 +887,7 @@ insert_tab(void) /** * Insert a string. * - * All printable and '\033' will be directly printed out. + * All printable and ESC_CHR will be directly printed out. * '\t' will be printed to align every 8 byte. * '\n' will split the line. * The other character will be ignore. @@ -898,7 +898,7 @@ insert_string(const char *str) char ch; while ((ch = *str++)) { - if (isprint2(ch) || ch == '\033') + if (isprint2(ch) || ch == ESC_CHR) insert_char(ch); else if (ch == '\t') insert_tab(); @@ -1289,7 +1289,7 @@ check_quote(void) if ((included_line >> 2) > post_line) { move(4, 0); outs("���g�峹���ި���ҶW�L 80%�A�бz���ǷL���ץ��G\n\n" - "\033[1;33m1) �W�[�@�Ǥ峹 �� 2) �R�������n���ި�\033[m"); + ANSI_COLOR(1;33) "1) �W�[�@�Ǥ峹 �� 2) �R�������n���ި�" ANSI_RESET); { char ans[4]; @@ -1489,7 +1489,7 @@ write_file(char *fpath, int saveheader, int *islocal) switch (ans[0]) { case 'a': - outs("�峹\033[1m �S�� \033[m�s�J"); + outs("�峹" ANSI_COLOR(1) " �S�� " ANSI_RESET "�s�J"); aborted = -1; break; case 'r': @@ -1868,17 +1868,17 @@ display_textline_internal(textline_t *p, int i, int min, int max) (curr_buf->blockln <= curr_buf->currln && curr_buf->blockln <= tmp && tmp <= curr_buf->currln) || (curr_buf->currln <= tmp && tmp <= curr_buf->blockln)) ) { - outs("\033[7m"); + outs(ANSI_COLOR(7)); inblock = 1; } else inblock = 0; if (curr_buf->currln == curr_buf->blockln && p == curr_buf->currline && max > min) { - outs("\033[m"); + outs(ANSI_RESET); (*output_n)(p->data, min); - outs("\033[7m"); + outs(ANSI_COLOR(7)); (*output_n)(p->data + min, max - min); - outs("\033[m"); + outs(ANSI_RESET); (*output)(p->data + max); } else @@ -1906,7 +1906,7 @@ display_textline_internal(textline_t *p, int i, int min, int max) (*output)((curr_buf->edit_margin < p->len) ? &p->data[curr_buf->edit_margin] : ""); if (inblock) - outs("\033[m"); + outs(ANSI_RESET); } /** * given a textline_t 'text' and the line number 'n' in the content, @@ -2305,8 +2305,8 @@ insert_ansi_code(void) else { char ans[4]; move(b_lines - 2, 55); - outs("\033[1;33;40mB\033[41mR\033[42mG\033[43mY\033[44mL" - "\033[45mP\033[46mC\033[47mW\033[m"); + outs(ANSI_COLOR(1;33;40) "B" ANSI_COLOR(41) "R" ANSI_COLOR(42) "G" ANSI_COLOR(43) "Y" ANSI_COLOR(44) "L" + ANSI_COLOR(45) "P" ANSI_COLOR(46) "C" ANSI_COLOR(47) "W" ANSI_RESET); if (getdata(b_lines - 1, 0, "�п�J �G��/�e��/�I��[���`�զr�©�][0wb]�G", ans, sizeof(ans), LCECHO)) @@ -2316,7 +2316,7 @@ insert_ansi_code(void) char *tmp, *apos = ans; int fg, bg; - strcpy(color, "\033["); + strcpy(color, ESC_STR "["); if (isdigit((int)*apos)) { sprintf(color,"%s%c", color, *(apos++)); if (*apos) @@ -2543,7 +2543,7 @@ vedit(char *fpath, int saveheader, int *islocal) count = 0; /* log_file("etc/illegal_money", LOG_CREAT | LOG_VF, - "\033[1;33;46m%s \033[37;45m �ξ����H�o���峹 \033[37m %s\033[m\n", + ANSI_COLOR(1;33;46) "%s " ANSI_COLOR(37;45) " �ξ����H�o���峹 " ANSI_COLOR(37) " %s" ANSI_RESET "\n", cuser.userid, ctime4(&now)); post_violatelaw(cuser.userid, "Ptt�t��ĵ��", "�ξ����H�o���峹", "�j������"); @@ -2758,7 +2758,7 @@ vedit(char *fpath, int saveheader, int *islocal) search_str(0); break; case Ctrl('U'): - insert_char('\033'); + insert_char(ESC_CHR); break; case Ctrl('V'): /* Toggle ANSI color */ curr_buf->ansimode ^= 1; diff --git a/mbbsd/file.c b/mbbsd/file.c index cf13fb36..b0fd501e 100644 --- a/mbbsd/file.c +++ b/mbbsd/file.c @@ -1,4 +1,4 @@ -/* $Id: file.c 2191 2004-09-10 00:49:47Z victor $ */ +/* $Id$ */ #include "bbs.h" diff --git a/mbbsd/friend.c b/mbbsd/friend.c index 855056be..3d2898b4 100644 --- a/mbbsd/friend.c +++ b/mbbsd/friend.c @@ -97,7 +97,7 @@ friend_special(void) FILE *fp; friend_file[FRIEND_SPECIAL] = special_list; for (i = 0; i <= 9; i++) { - snprintf(genbuf, sizeof(genbuf), " (\033[36m%d\033[m) .. ", i); + snprintf(genbuf, sizeof(genbuf), " (" ANSI_COLOR(36) "%d" ANSI_RESET ") .. ", i); special_des[5] = i + '0'; setuserfile(fname, special_des); if( (fp = fopen(fname, "r")) != NULL ){ diff --git a/mbbsd/gamble.c b/mbbsd/gamble.c index 3889577a..b66428e2 100644 --- a/mbbsd/gamble.c +++ b/mbbsd/gamble.c @@ -53,11 +53,11 @@ show_ticket_data(char betname[MAX_ITEM][MAX_ITEM_LEN],const char *direct, int *p strtok(betname[count], "\r\n"); fclose(fp); - prints("\033[32m���W:\033[m 1.�i�ʶR�H�U���P�������m���C�C�i�n�� \033[32m%d\033[m ���C\n" + prints(ANSI_COLOR(32) "���W:" ANSI_RESET " 1.�i�ʶR�H�U���P�������m���C�C�i�n�� " ANSI_COLOR(32) "%d" ANSI_RESET " ���C\n" " 2.%s\n" " 3.�}���ɥu���@�رm������, ���ʶR�ӱm����, �h�i���ʶR���i�Ƨ����`����C\n" " 4.�C�������Ѩt�Ω�� 5%% ���|��%s�C\n\n" - "\033[32m%s:\033[m", *price, + ANSI_COLOR(32) "%s:" ANSI_RESET, *price, bh ? "����L�ѪO�D�t�d�|��åB�M�w�}���ɶ����G, ��������, �@��A��C" : "�t�ΨC�� 2:00 11:00 16:00 21:00 �}���C", bh ? ", �䤤 2% �����}���O�D" : "", @@ -71,17 +71,17 @@ show_ticket_data(char betname[MAX_ITEM][MAX_ITEM_LEN],const char *direct, int *p } show_file(genbuf, 8, -1, NO_RELOAD); move(15, 0); - outs("\033[1;32m�ثe�U�`���p:\033[m\n"); + outs(ANSI_COLOR(1;32) "�ثe�U�`���p:" ANSI_RESET "\n"); total = load_ticket_record(direct, ticket); - outs("\033[33m"); + outs(ANSI_COLOR(33)); for (i = 0; i < count; i++) { prints("%d.%-8s: %-7d", i + 1, betname[i], ticket[i]); if (i == 3) outc('\n'); } - prints("\033[m\n\033[42m �U�`�`���B:\033[31m %d �� \033[m", total * (*price)); + prints(ANSI_RESET "\n" ANSI_COLOR(42) " �U�`�`���B:" ANSI_COLOR(31) " %d �� " ANSI_RESET, total * (*price)); if (end) { outs("\n��L�w�g����U�`\n"); return -count; @@ -161,8 +161,8 @@ ticket(int bid) } move(20, 0); reload_money(); - prints("\033[44m��: %-10d \033[m\n\033[1m�п�ܭn�ʶR������(1~%d)" - "[Q:���}]\033[m:", cuser.money, count); + prints(ANSI_COLOR(44) "��: %-10d " ANSI_RESET "\n" ANSI_COLOR(1) "�п�ܭn�ʶR������(1~%d)" + "[Q:���}]" ANSI_RESET ":", cuser.money, count); ch = igetch(); /*-- Tim011127 @@ -221,7 +221,7 @@ openticket(int bid) do { do { getdata(20, 0, - "\033[1m��ܤ��������X(0:���}�� 99:�����h��)\033[m:", buf, 3, LCECHO); + ANSI_COLOR(1) "��ܤ��������X(0:���}�� 99:�����h��)" ANSI_RESET ":", buf, 3, LCECHO); bet = atoi(buf); move(0, 0); clrtoeol(); @@ -230,7 +230,7 @@ openticket(int bid) unlockutmpmode(); return 0; } - getdata(21, 0, "\033[1m�A���T�{��J���X\033[m:", buf, 3, LCECHO); + getdata(21, 0, ANSI_COLOR(1) "�A���T�{��J���X" ANSI_RESET ":", buf, 3, LCECHO); } while (bet != atoi(buf)); if (fork()) { @@ -280,13 +280,13 @@ openticket(int bid) } fprintf(fp, "�U�`���p\n"); - fprintf(fp, "\033[33m"); + fprintf(fp, ANSI_COLOR(33)); for (i = 0; i < count; i++) { fprintf(fp, "%d.%-8s: %-7d", i + 1, betname[i], ticket[i]); if (i == 3) fprintf(fp, "\n"); } - fprintf(fp, "\033[m\n"); + fprintf(fp, ANSI_RESET "\n"); if (bet != 98) { fprintf(fp, "\n\n�}���ɶ��G %s \n\n" @@ -435,7 +435,7 @@ GO_log(struct GOData *gd, char *userid) } else snprintf(mymail.title, sizeof(mymail.title), - "\033[37;41m����\033[m %s VS %s", cuser.userid, userid); + ANSI_COLOR(37;41) "����" ANSI_RESET " %s VS %s", cuser.userid, userid); sethomedir(title, cuser.userid); append_record(title, &mymail, sizeof(mymail)); @@ -702,7 +702,7 @@ gochess(int fd) } */ - prints("\033[1;46m ��ѹ�� \033[45m%31s VS %-31s\033[m", + prints(ANSI_COLOR(1;46) " ��ѹ�� " ANSI_COLOR(45) "%31s VS %-31s" ANSI_RESET, cuser.userid, my->mateid); GO_cleantable(); @@ -756,24 +756,24 @@ gochess(int fd) if (v == pool) { if (gd.me == BWHITE && gd.win != 0) - outs("\033[1;33m�� x ���l y ������ Ctrl-C ����ѧ�\033[m"); + outs(ANSI_COLOR(1;33) "�� x ���l y ������ Ctrl-C ����ѧ�" ANSI_RESET); else - outs("\033[1;33m�� Ctrl-C ����ѧ�\033[m"); + outs(ANSI_COLOR(1;33) "�� Ctrl-C ����ѧ�" ANSI_RESET); } else if (passflag && my->turn) { if (endflag) - outs("\033[1;33m��� DONE�A�v�� DONE �N�p��G\033[m"); + outs(ANSI_COLOR(1;33) "��� DONE�A�v�� DONE �N�p��G" ANSI_RESET); else - outs("\033[1;33m��� PASS�A�v�� PASS �N�����ѧ�\033[m"); + outs(ANSI_COLOR(1;33) "��� PASS�A�v�� PASS �N�����ѧ�" ANSI_RESET); } else if (v > pool) clrtoeol(); if (endflag) - outmsg("\033[1;33;42m �U�� \033[;31;47m (��������)\033[30m���� \033[31m(�ť���/ENTER)\033[30m�U�l \033[31m(v)\033[30m�ǰT \033[31m(z)\033[30m�뭰 \033[31m(w)\033[30mDONE \033[31m(u)\033[30m�^�_ \033[m"); + outmsg(ANSI_COLOR(1;33;42) " �U�� " ANSI_COLOR(;31;47) " (��������)" ANSI_COLOR(30) "���� " ANSI_COLOR(31) "(�ť���/ENTER)" ANSI_COLOR(30) "�U�l " ANSI_COLOR(31) "(v)" ANSI_COLOR(30) "�ǰT " ANSI_COLOR(31) "(z)" ANSI_COLOR(30) "�뭰 " ANSI_COLOR(31) "(w)" ANSI_COLOR(30) "DONE " ANSI_COLOR(31) "(u)" ANSI_COLOR(30) "�^�_ " ANSI_RESET); else - outmsg("\033[1;33;42m �U�� \033[;31;47m (��������)\033[30m���� \033[31m(�ť���/ENTER)\033[30m�U�l \033[31m(v)\033[30m�ǰT \033[31m(z)\033[30m�뭰 \033[31m(w)\033[30mPASS \033[m"); + outmsg(ANSI_COLOR(1;33;42) " �U�� " ANSI_COLOR(;31;47) " (��������)" ANSI_COLOR(30) "���� " ANSI_COLOR(31) "(�ť���/ENTER)" ANSI_COLOR(30) "�U�l " ANSI_COLOR(31) "(v)" ANSI_COLOR(30) "�ǰT " ANSI_COLOR(31) "(z)" ANSI_COLOR(30) "�뭰 " ANSI_COLOR(31) "(w)" ANSI_COLOR(30) "PASS " ANSI_RESET); redoscr(); scr_need_redraw = 0; @@ -784,10 +784,10 @@ gochess(int fd) char buf[128]; int n; //move(5, 46); - n = sprintf(buf, "\033[6;47H%s ��ɶ��G----- --", bw_chess[gd.me - 1]); + n = sprintf(buf, ANSI_MOVETO(6,47) "%s ��ɶ��G----- --", bw_chess[gd.me - 1]); output(buf, n); //move(6, 46); - n = sprintf(buf, "\033[7;47H%s ��ɶ��G----- --", bw_chess[gd.he - 1]); + n = sprintf(buf, ANSI_MOVETO(7,47) "%s ��ɶ��G----- --", bw_chess[gd.he - 1]); output(buf, n); } else @@ -836,13 +836,13 @@ gochess(int fd) char buf[128]; int n; //move(5, 46); - n = sprintf(buf, "\033[6;47H%s ��ɶ��G%02d:%02d ", + n = sprintf(buf, ANSI_MOVETO(6,47) "%s ��ɶ��G%02d:%02d ", bw_chess[gd.me - 1], mtime / 60, mtime % 60); if (mhand <= 25) n += sprintf(buf + n, "%2d ��", 25 - mhand); output(buf, n); //move(6, 46); - n = sprintf(buf, "\033[7;47H%s ��ɶ��G%02d:%02d ", + n = sprintf(buf, ANSI_MOVETO(7,47) "%s ��ɶ��G%02d:%02d ", bw_chess[gd.he - 1], htime / 60, htime % 60); if (hhand <= 25) n += sprintf(buf + n, "%2d ��", 25 - hhand); @@ -1339,7 +1339,7 @@ GoBot(void) clear(); - prints("\033[1;46m ��ѥ��� \033[45m%66s\033[m", " "); + prints(ANSI_COLOR(1;46) " ��ѥ��� " ANSI_COLOR(45) "%66s" ANSI_RESET, " "); GO_cleantable(); /* film_out(FILM_GO, 1); */ @@ -1373,7 +1373,7 @@ GoBot(void) prints("%s #%-3d %.1s%-2d ", bw_chess[(i - 1) & 1], i, locE + pool[i - 1].x, pool[i - 1].y + 1); } - outmsg("[1;33;42m ���� [;31;47m (��������)[30m���� [31m(�ť���/ENTER)[30m�U�l [30m[31m(u)[30m�^�W�@�B \033[31m(z)\033[30m���} [m"); + outmsg("[1;33;42m ���� [;31;47m (��������)[30m���� [31m(�ť���/ENTER)[30m�U�l [30m[31m(u)[30m�^�W�@�B " ANSI_COLOR(31) "(z)" ANSI_COLOR(30) "���} [m"); redoscr(); scr_need_redraw = 0; } diff --git a/mbbsd/gomo.c b/mbbsd/gomo.c index 3d2539e6..52d7bbf3 100644 --- a/mbbsd/gomo.c +++ b/mbbsd/gomo.c @@ -221,7 +221,7 @@ HO_log_user(Horder_t* pool, char *mate) mail_header.filemode = FILE_READ; strlcpy(mail_header.owner, "[��.��.��]", sizeof(mail_header.owner)); snprintf(mail_header.title, sizeof(mail_header.title), - "\033[37;41m����\033[m %s VS %s", cuser.userid, mate); + ANSI_COLOR(37;41) "����" ANSI_RESET " %s VS %s", cuser.userid, mate); sethomedir(buf, cuser.userid); append_record(buf, &mail_header, sizeof(mail_header)); @@ -250,7 +250,7 @@ HO_log_board(Horder_t* pool, char *mate) strlcpy(log_header.owner, "[���о����H]", sizeof(log_header.owner)); snprintf(log_header.title, sizeof(log_header.title), - "\033[37;41m����\033[m %s VS %s", cuser.userid, mate); + ANSI_COLOR(37;41) "����" ANSI_RESET " %s VS %s", cuser.userid, mate); setbdir(buf, GLOBAL_FIVECHESS_LOG); append_record(buf, &log_header, sizeof(log_header)); @@ -269,12 +269,12 @@ countgomo(Horder_t *pool) static int chkmv(char ku[][BRDSIZ], Horder_t * mv, int color, int limit) { - char *xtype[] = {"\033[1;31m���T\033[m", "\033[1;31m���T\033[m", - "\033[1;31m���|\033[m", "\033[1;31m���|\033[m", - "\033[1;31m���|\033[m", "\033[1;31m�|�T\033[m", - "\033[1;31m���T\033[m", "\033[1;31m���|\033[m", - "\033[1;31m���|\033[m", "\033[1;31m�s��\033[m", - "\033[1;31m�s��\033[m"}; + char *xtype[] = {ANSI_COLOR(1;31) "���T" ANSI_RESET, ANSI_COLOR(1;31) "���T" ANSI_RESET, + ANSI_COLOR(1;31) "���|" ANSI_RESET, ANSI_COLOR(1;31) "���|" ANSI_RESET, + ANSI_COLOR(1;31) "���|" ANSI_RESET, ANSI_COLOR(1;31) "�|�T" ANSI_RESET, + ANSI_COLOR(1;31) "���T" ANSI_RESET, ANSI_COLOR(1;31) "���|" ANSI_RESET, + ANSI_COLOR(1;31) "���|" ANSI_RESET, ANSI_COLOR(1;31) "�s��" ANSI_RESET, + ANSI_COLOR(1;31) "�s��" ANSI_RESET}; int rule = getstyle(ku, mv->x, mv->y, color, limit); if (rule > 1 && rule < 13) { move(draw_photo ? 19 : 15, 40); @@ -360,27 +360,27 @@ gomoku(int fd) setutmpmode(M_FIVE); clear(); - prints("\033[1;46m ���l�ѹ�� \033[45m%30s VS %-30s\033[m", + prints(ANSI_COLOR(1;46) " ���l�ѹ�� " ANSI_COLOR(45) "%30s VS %-30s" ANSI_RESET, cuser.userid, my->mateid); //show_file("etc/@five", 1, -1, ONLY_COLOR); move(1, 0); outs( " A B C D E F G H I J K L M N\n" - " 15\033[30;43m�z�s�s�s�s�s�s�s�s�s�s�s�s�s�{\033[m\n" - " 14\033[30;43m�u�q�q�q�q�q�q�q�q�q�q�q�q�q�t\033[m\n" - " 13\033[30;43m�u�q�q�q�q�q�q�q�q�q�q�q�q�q�t\033[m\n" - " 12\033[30;43m�u�q�q�q�q�q�q�q�q�q�q�q�q�q�t\033[m\n" - " 11\033[30;43m�u�q�q�q�q�q�q�q�q�q�q�q�q�q�t\033[m\n" - " 10\033[30;43m�u�q�q�q�q�q�q�q�q�q�q�q�q�q�t\033[m\n" - " 9\033[30;43m�u�q�q�q�q�q�q�q�q�q�q�q�q�q�t\033[m\n" - " 8\033[30;43m�u�q�q�q�q�q�q�q�q�q�q�q�q�q�t\033[m\n" - " 7\033[30;43m�u�q�q�q�q�q�q�q�q�q�q�q�q�q�t\033[m\n" - " 6\033[30;43m�u�q�q�q�q�q�q�q�q�q�q�q�q�q�t\033[m\n" - " 5\033[30;43m�u�q�q�q�q�q�q�q�q�q�q�q�q�q�t\033[m\n" - " 4\033[30;43m�u�q�q�q�q�q�q�q�q�q�q�q�q�q�t\033[m\n" - " 3\033[30;43m�u�q�q�q�q�q�q�q�q�q�q�q�q�q�t\033[m\n" - " 2\033[30;43m�u�q�q�q�q�q�q�q�q�q�q�q�q�q�t\033[m\n" - " 1\033[30;43m�|�r�r�r�r�r�r�r�r�r�r�r�r�r�}\033[m\n" + " 15" ANSI_COLOR(30;43) "�z�s�s�s�s�s�s�s�s�s�s�s�s�s�{" ANSI_RESET "\n" + " 14" ANSI_COLOR(30;43) "�u�q�q�q�q�q�q�q�q�q�q�q�q�q�t" ANSI_RESET "\n" + " 13" ANSI_COLOR(30;43) "�u�q�q�q�q�q�q�q�q�q�q�q�q�q�t" ANSI_RESET "\n" + " 12" ANSI_COLOR(30;43) "�u�q�q�q�q�q�q�q�q�q�q�q�q�q�t" ANSI_RESET "\n" + " 11" ANSI_COLOR(30;43) "�u�q�q�q�q�q�q�q�q�q�q�q�q�q�t" ANSI_RESET "\n" + " 10" ANSI_COLOR(30;43) "�u�q�q�q�q�q�q�q�q�q�q�q�q�q�t" ANSI_RESET "\n" + " 9" ANSI_COLOR(30;43) "�u�q�q�q�q�q�q�q�q�q�q�q�q�q�t" ANSI_RESET "\n" + " 8" ANSI_COLOR(30;43) "�u�q�q�q�q�q�q�q�q�q�q�q�q�q�t" ANSI_RESET "\n" + " 7" ANSI_COLOR(30;43) "�u�q�q�q�q�q�q�q�q�q�q�q�q�q�t" ANSI_RESET "\n" + " 6" ANSI_COLOR(30;43) "�u�q�q�q�q�q�q�q�q�q�q�q�q�q�t" ANSI_RESET "\n" + " 5" ANSI_COLOR(30;43) "�u�q�q�q�q�q�q�q�q�q�q�q�q�q�t" ANSI_RESET "\n" + " 4" ANSI_COLOR(30;43) "�u�q�q�q�q�q�q�q�q�q�q�q�q�q�t" ANSI_RESET "\n" + " 3" ANSI_COLOR(30;43) "�u�q�q�q�q�q�q�q�q�q�q�q�q�q�t" ANSI_RESET "\n" + " 2" ANSI_COLOR(30;43) "�u�q�q�q�q�q�q�q�q�q�q�q�q�q�t" ANSI_RESET "\n" + " 1" ANSI_COLOR(30;43) "�|�r�r�r�r�r�r�r�r�r�r�r�r�r�}" ANSI_RESET "\n" ); draw_photo = 0; @@ -457,11 +457,11 @@ gomoku(int fd) fclose(fp); move(8, 43); - prints("\033[7m%s\033[m", me == BBLACK ? "�´�" : "�մ�"); + prints(ANSI_COLOR(7) "%s" ANSI_RESET, me == BBLACK ? "�´�" : "�մ�"); move(9, 43); outs(" ��.�� "); move(10, 68); - prints("\033[7m%s\033[m", me == BBLACK ? "�մ�" : "�´�"); + prints(ANSI_COLOR(7) "%s" ANSI_RESET, me == BBLACK ? "�մ�" : "�´�"); sethomefile(genbuf, my->mateid, "photo_fivechess"); fp = fopen(genbuf, "r"); @@ -523,17 +523,17 @@ gomoku(int fd) move(11, 40); prints("�ڬO %s", me == BBLACK ? "���� ��, ���T��" : "��� ��"); move(16, 40); - prints("\033[1;33m%s", cuser.userid); + prints(ANSI_COLOR(1;33) "%s", cuser.userid); move(17, 40); - prints("\033[1;33m%s", my->mateid); + prints(ANSI_COLOR(1;33) "%s", my->mateid); move(16, 60); - prints("\033[1;31m%d\033[37m�� \033[34m%d\033[37m�� \033[36m%d\033[37m�M" - "\033[m", cuser.five_win, cuser.five_lose, cuser.five_tie); + prints(ANSI_COLOR(1;31) "%d" ANSI_COLOR(37) "�� " ANSI_COLOR(34) "%d" ANSI_COLOR(37) "�� " ANSI_COLOR(36) "%d" ANSI_COLOR(37) "�M" + ANSI_RESET, cuser.five_win, cuser.five_lose, cuser.five_tie); move(17, 60); - prints("\033[1;31m%d\033[37m�� \033[34m%d\033[37m�� \033[36m%d\033[37m" - "�M\033[m", xuser.five_win, xuser.five_lose, xuser.five_tie); + prints(ANSI_COLOR(1;31) "%d" ANSI_COLOR(37) "�� " ANSI_COLOR(34) "%d" ANSI_COLOR(37) "�� " ANSI_COLOR(36) "%d" ANSI_COLOR(37) "" + "�M" ANSI_RESET, xuser.five_win, xuser.five_lose, xuser.five_tie); move(18, 40); prints("%s�ɶ��ٳ�%d:%02d\n", my->turn ? "�A��" : "���", @@ -559,7 +559,7 @@ gomoku(int fd) outs(my->turn ? "����ۤv�U�F!" : "���ݹ��U�l.."); redoln(); - outmsg("\033[1;33;42m �U���l�� \033[;31;47m (��������)\033[30m���� \033[31m(�ť���/ENTER)\033[30m�U�l \033[31m(q)\033[30m�뭰 \033[31m(p)\033[30m�M�� \033[31m(u)\033[30m���� \033[m"); + outmsg(ANSI_COLOR(1;33;42) " �U���l�� " ANSI_COLOR(;31;47) " (��������)" ANSI_COLOR(30) "���� " ANSI_COLOR(31) "(�ť���/ENTER)" ANSI_COLOR(30) "�U�l " ANSI_COLOR(31) "(q)" ANSI_COLOR(30) "�뭰 " ANSI_COLOR(31) "(p)" ANSI_COLOR(30) "�M�� " ANSI_COLOR(31) "(u)" ANSI_COLOR(30) "���� " ANSI_RESET); scr_need_redraw = 0; } if (lastcount != tick - now) { @@ -590,20 +590,20 @@ gomoku(int fd) move(draw_photo ? 20 : 14, 40); clrtoeol(); if (hewantpass) { - outs("\033[1;32m�M�ѭn�D!\033[m"); + outs(ANSI_COLOR(1;32) "�M�ѭn�D!" ANSI_RESET); bell(); } else if (iwantpass) - outs("\033[1;32m���X�M�ѭn�D!\033[m"); + outs(ANSI_COLOR(1;32) "���X�M�ѭn�D!" ANSI_RESET); else if (passrejected) { - outs("\033[1;32m�n�D�Q��!\033[m"); + outs(ANSI_COLOR(1;32) "�n�D�Q��!" ANSI_RESET); passrejected = 0; } else if (hewantundo) { - outs("\033[1;33m���ѭn�D! (�� u ����, ���N��ڵ�)\033[m"); + outs(ANSI_COLOR(1;33) "���ѭn�D! (�� u ����, ���N��ڵ�)" ANSI_RESET); bell(); } else if (iwantundo) - outs("\033[1;33m���X���ѭn�D!\033[m"); + outs(ANSI_COLOR(1;33) "���X���ѭn�D!" ANSI_RESET); else if (undorejected) { - outs("\033[1;33m�n�D�Q��!\033[m"); + outs(ANSI_COLOR(1;33) "�n�D�Q��!" ANSI_RESET); undorejected = 0; } BGOTOCUR(mv.x, mv.y); diff --git a/mbbsd/guess.c b/mbbsd/guess.c index a6bd7ddb..766cbd16 100644 --- a/mbbsd/guess.c +++ b/mbbsd/guess.c @@ -8,10 +8,10 @@ show_table(char TABLE[], char ifcomputer) int i; move(0, 35); - outs("\033[1;44;33m �i �q�Ʀr �j \033[m"); + outs(ANSI_COLOR(1;44;33) " �i �q�Ʀr �j " ANSI_RESET); move(8, 1); - outs("\033[1;44;36m�� �e �� �v\033[m\n"); - outs("\033[1;33m=================\033[m\n"); + outs(ANSI_COLOR(1;44;36) "�� �e �� �v" ANSI_RESET "\n"); + outs(ANSI_COLOR(1;33) "=================" ANSI_RESET "\n"); if (ifcomputer) { outs("Ĺ�q��: 2 ��\n"); outs("��q��: 0 ��\n"); @@ -19,7 +19,7 @@ show_table(char TABLE[], char ifcomputer) for (i = 1; i <= 6; i++) prints("��%d��, %02d��\n", i, TABLE[i]); } - outs("\033[33m=================\033[m"); + outs(ANSI_COLOR(33) "=================" ANSI_RESET); } static int @@ -105,7 +105,7 @@ guess_play(const char *data, const char *answer, int count) if (A_num == 4) return 1; move(count + 8, 55); - prints("%s => \033[1;32m%dA %dB\033[m", data, A_num, B_num); + prints("%s => " ANSI_COLOR(1;32) "%dA %dB" ANSI_RESET, data, A_num, B_num); return 0; } @@ -178,7 +178,7 @@ computer(int correct, int total, char flag[], int n[]) } else { move(total + 8, 25); snprintf(data, sizeof(data), "%04d", guess); - prints("%s => \033[1;32m%dA %dB\033[m", data, k / 10, k % 10); + prints("%s => " ANSI_COLOR(1;32) "%dA %dB" ANSI_RESET, data, k / 10, k % 10); } j = 0; for (i = 0; i < 10000; i++) diff --git a/mbbsd/indict.c b/mbbsd/indict.c index 8b87e0e3..e8af6075 100644 --- a/mbbsd/indict.c +++ b/mbbsd/indict.c @@ -18,8 +18,8 @@ addword(const char *database,char word[]) if (HAVE_PERM(PERM_LOGINOK)) { clear(); move(4, 0); - outs(" \033[31mĵ�i\033[m:�Y�W�N��g����ƱN\033[36m��id\033[m�B��\n"); - prints("\n��J�d��\n:\033[33m%s\033[m", buf); + outs(" " ANSI_COLOR(31) "ĵ�i" ANSI_RESET ":�Y�W�N��g����ƱN" ANSI_COLOR(36) "��id" ANSI_RESET "�B��\n"); + prints("\n��J�d��\n:" ANSI_COLOR(33) "%s" ANSI_RESET, buf); outs("\n�Ш̤W�C�d�ҿ�J�@����(����enter���)\n"); getdata(10, 0, ":", buf, 65, DOECHO); if (buf[0]) { @@ -43,12 +43,12 @@ choose_dict(char *dict,int dictlen,char *database,int databaselen) move(12, 0); clrtobot(); outs(" " - "�� \033[45;33m�r��� �� �n�d���@���H\033[m ��"); + "�� " ANSI_COLOR(45;33) "�r��� �� �n�d���@���H" ANSI_RESET " ��"); if ((fp = fopen(REFER, "r"))) { for(n=0; n<MAX_DICT && fscanf(fp,"%s %s",buf[n],data[n])==2; n++) { // XXX check buffer size prints("\n " - "(\033[36m%d\033[m) %-20s�j�r��", n + 1, buf[n]); + "(" ANSI_COLOR(36) "%d" ANSI_RESET ") %-20s�j�r��", n + 1, buf[n]); } fclose(fp); @@ -70,7 +70,7 @@ use_dict(char *dict,char *database) { FILE *fp; char lang[150], word[80] = ""; - char j, f, buf[120], sys[] = "|\033[31me\033[m:�s��r��"; + char j, f, buf[120], sys[] = "|" ANSI_COLOR(31) "e" ANSI_RESET ":�s��r��"; int i = 0; setutmpmode(DICT); @@ -80,14 +80,14 @@ use_dict(char *dict,char *database) clear(); snprintf(buf, sizeof(buf), - "\033[45m ��\033[1;44;33m" - " %-14s\033[3;45m �� ", dict); - strlcpy(&buf[100], "\033[m\n", sizeof(buf) - 100); + ANSI_COLOR(45) " ��" ANSI_COLOR(1;44;33) "" + " %-14s" ANSI_COLOR(3;45) " �� ", dict); + strlcpy(&buf[100], ANSI_RESET "\n", sizeof(buf) - 100); for (;;) { move(0, 0); prints(" �п�J����r��(%s) �Ϋ��O(h,t,a)\n", dict); - prints("[\033[32m<����r>\033[m|\033[32mh\033[m:help|\033[32m" - "t\033[m:�Ҧ����|\033[32ma\033[m:�s�W���%s]\n:", sys); + prints("[" ANSI_COLOR(32) "<����r>" ANSI_RESET "|" ANSI_COLOR(32) "h" ANSI_RESET ":help|" ANSI_COLOR(32) "" + "t" ANSI_RESET ":�Ҧ����|" ANSI_COLOR(32) "a" ANSI_RESET ":�s�W���%s]\n:", sys); getdata(2, 0, ":", word, 18, DOECHO); outs("��Ʒj�M���еy��...."); str_lower(word, word); @@ -133,9 +133,9 @@ use_dict(char *dict,char *database) i++; if (!((i + 1) % 17)) { move(23, 0); - outs("\033[45m " + outs(ANSI_COLOR(45) " " "���N���~�� Q:���} " - "\033[m "); + ANSI_RESET " "); j = igetch(); if (j == 'q') break; @@ -472,7 +472,7 @@ strip_ansi(char *buf, const char *str, int mode) #define isEscapeCommand(X) (EscapeFlag[(int)(X)] & 2) for(; *str; ++str) - if( *str != '\033' ){ + if( *str != ESC_CHR ){ if( buf ) *buf++ = *str; ++count; diff --git a/mbbsd/kaede.c b/mbbsd/kaede.c index 43da0653..c0b1ed23 100644 --- a/mbbsd/kaede.c +++ b/mbbsd/kaede.c @@ -7,11 +7,11 @@ Ptt_prints(char *str, int mode) char strbuf[256]; int r, w; for( r = w = 0 ; str[r] != 0 && w < (sizeof(strbuf) - 1) ; ++r ) - if( str[r] != '\033' ) + if( str[r] != ESC_CHR ) strbuf[w++] = str[r]; else{ if( str[++r] != '*' ){ - strbuf[w++] = '\033'; + strbuf[w++] = ESC_CHR; strbuf[w++] = str[r]; } else{ @@ -51,7 +51,7 @@ Ptt_prints(char *str, int mode) break; /* It's saver not to send these undefined escape string. default: - strbuf[w++] = '\033'; + strbuf[w++] = ESC_CHR; strbuf[w++] = '*'; strbuf[w++] = str[r]; */ diff --git a/mbbsd/mail.c b/mbbsd/mail.c index d10fb115..32b9da2e 100644 --- a/mbbsd/mail.c +++ b/mbbsd/mail.c @@ -1,7 +1,7 @@ /* $Id$ */ #include "bbs.h" static char currmaildir[32]; -static char msg_cc[] = "\033[32m[�s�զW��]\033[m\n"; +static char msg_cc[] = ANSI_COLOR(32) "[�s�զW��]" ANSI_RESET "\n"; static char listfile[] = "list.0"; static int mailkeep = 0, mailsum = 0; static int mailsumlimit = 0, mailmaxkeep = 0; @@ -41,9 +41,9 @@ built_mail_index(void) char genbuf[128]; move(b_lines - 4, 0); - outs("���\\��u�b�H�c�ɷ��l�ɨϥΡA\033[1;33m�L�k\033[m�Ϧ^�Q�R�����H��C\n" - "���D�z�M���o�ӥ\\��@�ΡA�_�h\033[1;33m�Ф��n�ϥ�\033[m�C\n" - "ĵ�i�G���N���ϥαN�ɭP\033[1;33m���i�w�������G\033[m�I\n"); + outs("���\\��u�b�H�c�ɷ��l�ɨϥΡA" ANSI_COLOR(1;33) "�L�k" ANSI_RESET "�Ϧ^�Q�R�����H��C\n" + "���D�z�M���o�ӥ\\��@�ΡA�_�h" ANSI_COLOR(1;33) "�Ф��n�ϥ�" ANSI_RESET "�C\n" + "ĵ�i�G���N���ϥαN�ɭP" ANSI_COLOR(1;33) "���i�w�������G" ANSI_RESET "�I\n"); getdata(b_lines - 1, 0, "�T�w���ثH�c?(y/N)", genbuf, 3, LCECHO); @@ -54,7 +54,7 @@ built_mail_index(void) BBSHOME "/bin/buildir " BBSHOME "/home/%c/%s", cuser.userid[0], cuser.userid); move(22, 0); - outs("\033[1;31m�w�g�B�z����!! �Ѧh���K �q�Э��~\033[m"); + outs(ANSI_COLOR(1;31) "�w�g�B�z����!! �Ѧh���K �q�Э��~" ANSI_RESET); pressanykey(); system(genbuf); return 0; @@ -563,12 +563,12 @@ mail_all(void) setutmpmode(SMAIL); getdata(2, 0, "�D�D�G", fpath, sizeof(fpath), DOECHO); snprintf(save_title, sizeof(save_title), - "[�t�γq�i]\033[1;32m %s\033[m", fpath); + "[�t�γq�i]" ANSI_COLOR(1;32) " %s" ANSI_RESET, fpath); setuserfile(fpath, fn_notes); if ((fp = fopen(fpath, "w"))) { - fprintf(fp, "�� [\033[1m�t�γq�i\033[m] �o�O�ʵ��Ҧ��ϥΪ̪��H\n"); + fprintf(fp, "�� [" ANSI_COLOR(1) "�t�γq�i" ANSI_RESET "] �o�O�ʵ��Ҧ��ϥΪ̪��H\n"); fprintf(fp, "-----------------------------------------------------" "----------------------\n"); fclose(fp); @@ -799,16 +799,16 @@ mailtitle(void) showtitle("\0�l����", BBSName); prints("[��]���}[����]���[��]�\\Ū�H�� [R]�^�H [x]��F " - "[y]�s�զ^�H [O]���~�H:%s [h]�D�U\n\033[7m" - "�s�� �� �� �@ �� �H �� �� �D \033[32m", - REJECT_OUTTAMAIL ? "\033[31m��\033[m" : "�}"); + "[y]�s�զ^�H [O]���~�H:%s [h]�D�U\n" ANSI_COLOR(7) "" + "�s�� �� �� �@ �� �H �� �� �D " ANSI_COLOR(32) "", + REJECT_OUTTAMAIL ? ANSI_COLOR(31) "��" ANSI_RESET : "�}"); buf[0] = 0; if (mailsumlimit) { snprintf(buf, sizeof(buf), "(�e�q:%d/%dk %d/%d�g)", mailsum, mailsumlimit, mailkeep, mailmaxkeep); } - prints("%-29s\033[m", buf); + prints("%-29s" ANSI_RESET, buf); } static void @@ -832,7 +832,7 @@ maildoent(int num, fileheader_t * ent) prints("%5d %c %-7s%-15.14s%s %.46s\n", num, type, ent->date, ent->owner, mark, title); else - prints("%5d %c %-7s%-15.14s\033[1;3%cm%s %.46s\033[0m\n", num, type, + prints("%5d %c %-7s%-15.14s" ANSI_COLOR(1;3%c) "%s %.46s" ANSI_COLOR(0) "\n", num, type, ent->date, ent->owner, color, mark, title); } diff --git a/mbbsd/mbbsd.c b/mbbsd/mbbsd.c index c99468c5..4b915a36 100644 --- a/mbbsd/mbbsd.c +++ b/mbbsd/mbbsd.c @@ -219,7 +219,7 @@ abort_bbs_debug(int sig) case SIGBUS: STATINC(STAT_SIGBUS); break; case SIGSEGV: STATINC(STAT_SIGSEGV); break; } -#define CRASH_MSG "\033[0m\r\n�{�����`, �ߨ��_�u. �Ь� PttBug �O�ԭz�A�o�ͪ����D.\n" +#define CRASH_MSG ANSI_COLOR(0) "\r\n�{�����`, �ߨ��_�u. �Ь� PttBug �O�ԭz�A�o�ͪ����D.\n" /* NOTE: It's better to use signal-safe functions. Avoid to call * functions with global/static variable -- data may be corrupted */ write(1, CRASH_MSG, sizeof(CRASH_MSG)); @@ -260,7 +260,7 @@ talk_request(int sig) move(0, 0); clrtoeol(); - prints("\033[33;41m��%s\033[34;47m [%s] %s \033[0m", + prints(ANSI_COLOR(33;41) "��%s" ANSI_COLOR(34;47) " [%s] %s " ANSI_COLOR(0) "", SHM->uinfo[currutmp->destuip].userid, my_ctime(&now,timebuf,sizeof(timebuf)), (currutmp->sig == 2) ? "���n�����s���I(��Ctrl-U,l�d�ݼ��T�O��)" : "�I�s�B�I�s�Ať��Ц^��"); @@ -289,11 +289,11 @@ show_call_in(int save, int which) char buf[200]; #ifdef PLAY_ANGEL if (currutmp->msgs[which].msgmode == MSGMODE_TOANGEL) - snprintf(buf, sizeof(buf), "\033[1;37;46m��%s\033[37;45m %s \033[m", + snprintf(buf, sizeof(buf), ANSI_COLOR(1;37;46) "��%s" ANSI_COLOR(37;45) " %s " ANSI_RESET, currutmp->msgs[which].userid, currutmp->msgs[which].last_call_in); else #endif - snprintf(buf, sizeof(buf), "\033[1;33;46m��%s\033[37;45m %s \033[m", + snprintf(buf, sizeof(buf), ANSI_COLOR(1;33;46) "��%s" ANSI_COLOR(37;45) " %s " ANSI_RESET, currutmp->msgs[which].userid, currutmp->msgs[which].last_call_in); outmsg(buf); @@ -831,9 +831,9 @@ setup_utmp(int mode) inline static void welcome_msg(void) { - prints("\033[m �w��z�� \033[1;33m%d\033[0;37m ���X�����A" - "�W���z�O�q \033[1;33m%s\033[0;37m �s�������A\n" - " �ڰO�o���ѬO \033[1;33m%s\033[0;37m�C\n", + prints(ANSI_RESET " �w��z�� " ANSI_COLOR(1;33) "%d" ANSI_COLOR(0;37) " ���X�����A" + "�W���z�O�q " ANSI_COLOR(1;33) "%s" ANSI_COLOR(0;37) " �s�������A\n" + " �ڰO�o���ѬO " ANSI_COLOR(1;33) "%s" ANSI_COLOR(0;37) "�C\n", ++cuser.numlogins, cuser.lasthost, Cdate(&(cuser.lastlogin))); pressanykey(); } diff --git a/mbbsd/menu.c b/mbbsd/menu.c index 2718d0c0..2d524374 100644 --- a/mbbsd/menu.c +++ b/mbbsd/menu.c @@ -23,19 +23,19 @@ showtitle(const char *title, const char *mid) #ifdef DEBUG else { snprintf(numreg, sizeof(numreg), - "\033[41;5m current pid: %6d " TITLE_COLOR, + ANSI_COLOR(41;5) " current pid: %6d " TITLE_COLOR, getpid()); mid = numreg; spc = 22; } #else else if (currutmp->mailalert) { - mid = "\033[41;5m �l�t�ӫ��a�o " TITLE_COLOR; + mid = ANSI_COLOR(41;5) " �l�t�ӫ��a�o " TITLE_COLOR; spc = 22; } else if ( HAS_PERM(PERM_ACCTREG) && (nreg = dashs((char *)fn_register) / 163) > 100 ) { snprintf(numreg, sizeof(numreg), - "\033[41;5m �� %03d ���f�� " TITLE_COLOR, + ANSI_COLOR(41;5) " �� %03d ���f�� " TITLE_COLOR, nreg); mid = numreg; spc = 22; @@ -49,10 +49,10 @@ showtitle(const char *title, const char *mid) buf[spc] = '\0'; clear(); - prints(TITLE_COLOR "�i%s�j%s\033[33m%s%s%s\033[3%s�m", + prints(TITLE_COLOR "�i%s�j%s" ANSI_COLOR(33) "%s%s%s%s�m", title, buf, mid, buf, " " + pad, - currmode & MODE_SELECT ? "6m�t�C" : - currmode & MODE_DIGEST ? "2m��K" : "7m�ݪO"); + currmode & MODE_SELECT ? ANSI_COLOR(36) "�t�C" : + currmode & MODE_DIGEST ? ANSI_COLOR(32) "��K" : ANSI_COLOR(37) "�ݪO"); if (strcmp(currboard, lastboard)) { /* change board */ if (currboard[0] != 0 && @@ -64,9 +64,9 @@ showtitle(const char *title, const char *mid) } } if (board_hidden_status) - outs("\033[32m"); + outs(ANSI_COLOR(32)); outs(currboard); - prints("\033[3%dm�n\033[0m\n", currmode & MODE_SELECT ? 6 : + prints(ANSI_COLOR(3%d) "�n" ANSI_COLOR(0) "\n", currmode & MODE_SELECT ? 6 : currmode & MODE_DIGEST ? 2 : 7); } @@ -86,9 +86,9 @@ show_status(void) i = ptime->tm_wday << 1; snprintf(mystatus, sizeof(mystatus), - "\033[34;46m[%d/%d �P��%c%c %d:%02d]\033[1;33;45m%-14s" - "\033[30;47m �ثe�{�̦�\033[31m%d\033[30m�H, �ڬO\033[31m%-12s" - "\033[30m[����]\033[31m%s\033[0m", + ANSI_COLOR(34;46) "[%d/%d �P��%c%c %d:%02d]" ANSI_COLOR(1;33;45) "%-14s" + ANSI_COLOR(30;47) " �ثe�{�̦�" ANSI_COLOR(31) "%d" ANSI_COLOR(30) "�H, �ڬO" ANSI_COLOR(31) "%-12s" + ANSI_COLOR(30) "[����]" ANSI_COLOR(31) "%s" ANSI_COLOR(0) "", ptime->tm_mon + 1, ptime->tm_mday, myweek[i], myweek[i + 1], ptime->tm_hour, ptime->tm_min, currutmp->birth ? "�ͤ�n�Ыȭ�" : SHM->today_is, @@ -147,7 +147,7 @@ show_menu(const commands_t * p) move(menu_row, 0); while ((s = p[n].desc)) { if (HAS_PERM(p[n].level)) { - prints("%*s (\033[1;36m%c\033[0m)%s\n", menu_column, "", s[1], + prints("%*s (" ANSI_COLOR(1;36) "%c" ANSI_COLOR(0) ")%s\n", menu_column, "", s[1], s+2); } n++; @@ -328,9 +328,9 @@ static const commands_t maillist[] = { {m_new, PERM_READMAIL, "RNew �\\Ū�s�i�l��"}, {m_read, PERM_READMAIL, "RRead �h�\\��Ū�H���"}, {m_send, PERM_LOGINOK, "RSend �����H�H"}, - {x_love, PERM_LOGINOK, "PPaper \033[1;32m���Ѳ��;�\033[m "}, + {x_love, PERM_LOGINOK, "PPaper " ANSI_COLOR(1;32) "���Ѳ��;�" ANSI_RESET " "}, {mail_list, PERM_LOGINOK, "RMail List �s�ձH�H"}, - {setforward, PERM_LOGINOK, "FForward \033[32m�]�w�H�c�۰���H\033[m"}, + {setforward, PERM_LOGINOK, "FForward " ANSI_COLOR(32) "�]�w�H�c�۰���H" ANSI_RESET}, {m_sysop, 0, "YYes, sir! �ԴA����"}, {m_internet, PERM_INTERNET, "RInternet �H�H�� Internet"}, {mail_mbox, PERM_INTERNET, "RZip UserHome ��Ҧ��p�H��ƥ��]�^�h"}, @@ -483,21 +483,21 @@ static const commands_t playlist[] = { /* {x_weather,0 , "WWeather �i ��H�w�� �j"}, */ /* XXX �a���F */ /* {x_stock,0 , "SStock �i �ѥ��污 �j"},*/ - {forsearch,PERM_LOGINOK, "SSearchEngine�i\033[1;35m ��tt�j�M�� \033[m�j"}, - {topsong,PERM_LOGINOK, "TTop Songs �i\033[1;32m�ڮ��I�q�Ʀ�]\033[m�j"}, - {p_money,PERM_LOGINOK, "PPay �i\033[1;31m ��tt�q�c�� \033[m�j"}, + {forsearch,PERM_LOGINOK, "SSearchEngine�i" ANSI_COLOR(1;35) " ��tt�j�M�� " ANSI_RESET "�j"}, + {topsong,PERM_LOGINOK, "TTop Songs �i" ANSI_COLOR(1;32) "�ڮ��I�q�Ʀ�]" ANSI_RESET "�j"}, + {p_money,PERM_LOGINOK, "PPay �i" ANSI_COLOR(1;31) " ��tt�q�c�� " ANSI_RESET "�j"}, {chicken_main,PERM_LOGINOK, "CChicken " - "�i\033[1;34m ��tt�i���� \033[m�j"}, - {playground,PERM_LOGINOK, "AAmusement �i\033[1;33m ��tt�C�ֳ� \033[m�j"}, - {chessroom, PERM_LOGINOK, "BBhineseChess�i\033[1;34m ��tt�Ѱ| \033[m�j"}, + "�i" ANSI_COLOR(1;34) " ��tt�i���� " ANSI_RESET "�j"}, + {playground,PERM_LOGINOK, "AAmusement �i" ANSI_COLOR(1;33) " ��tt�C�ֳ� " ANSI_RESET "�j"}, + {chessroom, PERM_LOGINOK, "BBhineseChess�i" ANSI_COLOR(1;34) " ��tt�Ѱ| " ANSI_RESET "�j"}, {NULL, 0, NULL} }; static const commands_t chesslist[] = { - {chc_main, PERM_LOGINOK, "11ChessFight �i\033[1;33m �H���ܧ� \033[m�j"}, - {chc_personal, PERM_LOGINOK, "22SelfPlay �i\033[1;34m �H�ѥ��� \033[m�j"}, - {chc_watch, PERM_LOGINOK, "33ChessWatch �i\033[1;35m �H���[�� \033[m�j"}, - {GoBot, PERM_LOGINOK, "44GoBot �i\033[1;36m ��ѥ��� \033[m�j"}, + {chc_main, PERM_LOGINOK, "11ChessFight �i" ANSI_COLOR(1;33) " �H���ܧ� " ANSI_RESET "�j"}, + {chc_personal, PERM_LOGINOK, "22SelfPlay �i" ANSI_COLOR(1;34) " �H�ѥ��� " ANSI_RESET "�j"}, + {chc_watch, PERM_LOGINOK, "33ChessWatch �i" ANSI_COLOR(1;35) " �H���[�� " ANSI_RESET "�j"}, + {GoBot, PERM_LOGINOK, "44GoBot �i" ANSI_COLOR(1;36) " ��ѥ��� " ANSI_RESET "�j"}, {NULL, 0, NULL} }; @@ -529,11 +529,11 @@ static int playground() { static const commands_t slist[] = { {x_dict,0, "11Dictionary " - "�i\033[1;33m ����j�r�� \033[m�j"}, + "�i" ANSI_COLOR(1;33) " ����j�r�� " ANSI_RESET "�j"}, {x_mrtmap, 0, "22MRTmap " - "�i\033[1;34m ���B�a�� \033[m�j"}, + "�i" ANSI_COLOR(1;34) " ���B�a�� " ANSI_RESET "�j"}, {main_railway, PERM_LOGINOK, "33Railway " - "�i\033[1;32m �������d�� \033[m�j"}, + "�i" ANSI_COLOR(1;32) " �������d�� " ANSI_RESET "�j"}, {NULL, 0, NULL} }; diff --git a/mbbsd/merge.c b/mbbsd/merge.c index 720bb506..da91ad09 100644 --- a/mbbsd/merge.c +++ b/mbbsd/merge.c @@ -1,4 +1,4 @@ -/* $Id: merge.c 2060 2004-06-11 17:18:06Z Ptt $ */ +/* $Id$ */ #define _XOPEN_SOURCE #define _ISOC99_SOURCE /* this is a interface provided when we merge BBS */ diff --git a/mbbsd/more.c b/mbbsd/more.c index 04d2baff..56ccdb7f 100644 --- a/mbbsd/more.c +++ b/mbbsd/more.c @@ -96,7 +96,7 @@ more_readln(int fd, struct MorePool *mp, unsigned char *buf) *buf++ = ' '; } while ((++len & 7) && len < t_columns); - } else if (ch == '\033') { + } else if (ch == ESC_CHR) { if (atoi((char *)(data + 1)) > 47) { if ((cc = (unsigned char *)strchr((char *)(data + 1), 'm')) != NULL) { ch = cc - data + 1; @@ -206,12 +206,12 @@ more(char *fpath, int promptend) if (!pos && ((ptr = strstr(word, str_post1)) || (ptr = strstr(word, str_post2)))) { ptr[-1] = '\0'; - prints("\033[47;34m %s \033[44;37m%-53.53s" - "\033[47;34m %.4s \033[44;37m%-13s\033[m\n", + prints(ANSI_COLOR(47;34) " %s " ANSI_COLOR(44;37) "%-53.53s" + ANSI_COLOR(47;34) " %.4s " ANSI_COLOR(44;37) "%-13s" ANSI_RESET "\n", head[0], word, ptr, ptr + 5); } else if (pos < line) - prints("\033[47;34m %s \033[44;37m%-72.72s" - "\033[m\n", head[pos], word); + prints(ANSI_COLOR(47;34) " %s " ANSI_COLOR(44;37) "%-72.72s" + ANSI_RESET "\n", head[pos], word); viewed += numbytes; numbytes = more_readln(fd, &mp, (unsigned char *)buf); @@ -230,7 +230,7 @@ more(char *fpath, int promptend) if (pos) { header = 1; - prints("\033[36m%s\033[m\n", msg_seperator); + prints(ANSI_COLOR(36) "%s" ANSI_RESET "\n", msg_seperator); ++line; ++pos; } @@ -239,9 +239,9 @@ more(char *fpath, int promptend) } /* ���B�z�ޥΪ� & �ި� */ if ((buf[0] == ':' || buf[0] == '>') && (buf[1] == ' ')) - word = "\033[36m"; + word = ANSI_COLOR(36); else if (!strncmp(buf, "��", 2) || !strncmp(buf, "==>", 3)) - word = "\033[32m"; + word = ANSI_COLOR(32); if (word) outs(word); @@ -256,12 +256,12 @@ more(char *fpath, int promptend) strlcpy(SearchStr, pos, search_str_len + 1); searching = 0; snprintf(msg, sizeof(msg), - "%.*s\033[7m%s\033[m", (int)(pos - buf), buf, + "%.*s" ANSI_COLOR(7) "%s" ANSI_RESET, (int)(pos - buf), buf, SearchStr); while ((pos = (*fptr)(pos1 = pos + search_str_len, search_str))) { snprintf(buf1, sizeof(buf1), - "%.*s\033[7m%s\033[m", (int)(pos - pos1), + "%.*s" ANSI_COLOR(7) "%s" ANSI_RESET, (int)(pos - pos1), pos1, SearchStr); strlcat(msg, buf1, sizeof(msg)); } @@ -271,7 +271,7 @@ more(char *fpath, int promptend) outs(Ptt_prints(buf, NO_RELOAD)); } if (word) { - outs("\033[m"); + outs(ANSI_RESET); word = NULL; } outc('\n'); @@ -333,13 +333,13 @@ more(char *fpath, int promptend) } else color = 2; - prints("\033[m\033[%sm �s�� P.%d(%d%%) %s %-30.30s%s", + prints(ANSI_RESET ANSI_COLOR(%s) " �s�� P.%d(%d%%) %s %-30.30s%s", printcolor[(int)color], pageno, (int)((viewed * 100) / fsize), - "\033[31;47m", - "(h)\033[30m�D�U \033[31m����[PgUp][", - "PgDn][Home][End]\033[30m��в��� \033[31m��[q]\033[30m���� \033[m"); + ANSI_COLOR(31;47), + "(h)" ANSI_COLOR(30) "�D�U " ANSI_COLOR(31) "����[PgUp][", + "PgDn][Home][End]" ANSI_COLOR(30) "��в��� " ANSI_COLOR(31) "��[q]" ANSI_COLOR(30) "���� " ANSI_RESET); while (line == b_lines || (line > 0 && viewed == fsize)) { diff --git a/mbbsd/page.c b/mbbsd/page.c index 25cdfd81..16b707d4 100644 --- a/mbbsd/page.c +++ b/mbbsd/page.c @@ -2,7 +2,7 @@ #include "bbs.h" #define hpressanykey(a) {move(22, 0); outs(a); pressanykey();} -#define TITLE "\033[1;37;45m �����d�ߨt�� \033[1;44;33m��@��:Heat\033[m" +#define TITLE ANSI_COLOR(1;37;45) " �����d�ߨt�� " ANSI_COLOR(1;44;33) "��@��:Heat" ANSI_RESET static void print_station(const char * const addr[6][100], int path, int *line, int *num) @@ -82,13 +82,13 @@ main_railway(void) outs(TITLE); move(1, 0); - getdata(3, 0, "\033[1;35m�A�T�w�n�j�M��?[y/n]:\033[m", buf, 2, LCECHO); + getdata(3, 0, ANSI_COLOR(1;35) "�A�T�w�n�j�M��?[y/n]:" ANSI_RESET, buf, 2, LCECHO); if (buf[0] != 'y' && buf[0] != 'Y') return 0; - outs("\033[1;33m1.�賡�F�u(�t�x���u) 2.�F���F�u(�t�_�j�u)\n"); - outs("\033[1;33m3.�n�j�u 4.���˽u 5.���W�u 6.�����u\n"); + outs(ANSI_COLOR(1;33) "1.�賡�F�u(�t�x���u) 2.�F���F�u(�t�_�j�u)\n"); + outs(ANSI_COLOR(1;33) "3.�n�j�u 4.���˽u 5.���W�u 6.�����u\n"); while (1) - if (getdata(7, 0, "\033[1;35m�п�ܸ��u(1-6):\033[m", buf, 2, LCECHO) && + if (getdata(7, 0, ANSI_COLOR(1;35) "�п�ܸ��u(1-6):" ANSI_RESET, buf, 2, LCECHO) && (path = atoi(buf)) >= 1 && path <= 6) break; @@ -97,41 +97,41 @@ main_railway(void) outs(TITLE); line = 3; print_station(addr, path, &line, &station_num); - sprintf(genbuf, "\033[1;35m�п�J�_��(1-%d):\033[m", station_num); + sprintf(genbuf, ANSI_COLOR(1;35) "�п�J�_��(1-%d):" ANSI_RESET, station_num); while (1) if (getdata(line, 0, genbuf, buf, 3, LCECHO) && (from = atoi(buf)) >= 1 && from <= station_num) break; - sprintf(genbuf, "\033[1;35m�п�J�ׯ�(1-%d):\033[m", station_num); + sprintf(genbuf, ANSI_COLOR(1;35) "�п�J�ׯ�(1-%d):" ANSI_RESET, station_num); while (1) if (getdata(line, 40, genbuf, buf, 3, LCECHO) && (to = atoi(buf)) >= 1 && to <= station_num) break; line++; while (1) - if (getdata(line, 0, "\033[1;35m�п�J�ɶ��Ϭq(0-23) ��:\033[m", + if (getdata(line, 0, ANSI_COLOR(1;35) "�п�J�ɶ��Ϭq(0-23) ��:" ANSI_RESET, buf, 3, LCECHO) && (time_go = atoi(buf)) >= 0 && time_go <= 23) break; while (1) - if (getdata(line, 40, "\033[1;35m��:\033[m", buf, 3, LCECHO) && + if (getdata(line, 40, ANSI_COLOR(1;35) "��:" ANSI_RESET, buf, 3, LCECHO) && (time_reach = atoi(buf)) >= 0 && time_reach <= 23) break; line++; if (path<=3){ while (1) - if (getdata(line, 0, "\033[1;35m�Q�d�� 1:�︹�֨� 2:���q����\033[m", + if (getdata(line, 0, ANSI_COLOR(1;35) "�Q�d�� 1:�︹�֨� 2:���q����" ANSI_RESET, type, 2, LCECHO) && (type[0] == '1' || type[0] == '2')) break; line++; } while (1) - if (getdata(line, 0, "\033[1;35m���d�� 1:�X�o�ɶ� 2:��F�ɶ�\033[m", + if (getdata(line, 0, ANSI_COLOR(1;35) "���d�� 1:�X�o�ɶ� 2:��F�ɶ�" ANSI_RESET, tt, sizeof(tt), LCECHO) && (tt[0] == '1' || tt[0] == '2')) break; line++; while (1) - if (getdata(line, 0, "\033[1;35m�п�J���d�ߤ��(0-29)�ѫ�\033[m", + if (getdata(line, 0, ANSI_COLOR(1;35) "�п�J���d�ߤ��(0-29)�ѫ�" ANSI_RESET, buf, 3, LCECHO) && (date = atoi(buf))>=0 && date<=29) break; line++; @@ -151,6 +151,6 @@ main_railway(void) sethomedir(genbuf, cuser.userid); if (append_record(genbuf, &mhdr, sizeof(mhdr)) == -1) return -1; - hpressanykey("\033[1;31m�ڭ̷|��j�M���G�ܧ֦a�H���A�� ^_^\033[m"); + hpressanykey(ANSI_COLOR(1;31) "�ڭ̷|��j�M���G�ܧ֦a�H���A�� ^_^" ANSI_RESET); return 0; } diff --git a/mbbsd/pmore.c b/mbbsd/pmore.c index aaf7e1b4..02006ecb 100644 --- a/mbbsd/pmore.c +++ b/mbbsd/pmore.c @@ -129,6 +129,16 @@ int debug = 0; // --------------------------------------------- <Defines and constants> // --------------------------- <Display> + +/* ANSI COMMAND SYSTEM */ +#define STR_ANSICODE "[0123456789;," + +/* On some systems with pmore style ANSI system applied, + * we don't have to define these again. + */ +#ifndef PMORE_STYLE_ANSI +#define PMORE_STYLE_ANSI + // Escapes. I don't like \033 everywhere. #define ESC_NUM (0x1b) #define ESC_STR "\x1b" @@ -137,14 +147,17 @@ int debug = 0; // Common ANSI commands. #define ANSI_RESET ESC_STR "[m" #define ANSI_COLOR(x) ESC_STR "[" #x "m" -#define STR_ANSICODE "[0123456789;," +#define ANSI_MOVETO(x,y) ESC_STR "[" #x ";" #y "H" +#define ANSI_CLRTOEND ESC_STR "[K" + +#endif /* PMORE_STYLE_ANSI */ // Poor BBS terminal system Workarounds // - Most BBS implements clrtoeol() as fake command // and usually messed up when output ANSI quoted string. // - A workaround is suggested by kcwu: // https://opensvn.csie.org/traccgi/pttbbs/trac.cgi/changeset/519 -#define FORCE_CLRTOEOL() outs(ESC_STR "[K") +#define FORCE_CLRTOEOL() outs(ANSI_CLRTOEND) /* Again, if you have a BBS system which optimized out* without recognizing * ANSI escapes, scrolling with ANSI text may result in melformed text (because diff --git a/mbbsd/read.c b/mbbsd/read.c index 3c779f48..029f2421 100644 --- a/mbbsd/read.c +++ b/mbbsd/read.c @@ -893,7 +893,7 @@ i_read(int cmdmode, const char *direct, void (*dotitle) (), (*doentry) (locmem->top_ln + i, &headers[i]); case READ_REDRAW: outmsg(curredit & EDIT_ITEM ? - "\033[44m �p�H���� \033[30;47m �~��? \033[m" : + ANSI_COLOR(44) " �p�H���� " ANSI_COLOR(30;47) " �~��? " ANSI_RESET : curredit & EDIT_MAIL ? msg_mailer : MSG_POSTER); break; case TITLE_REDRAW: diff --git a/mbbsd/register.c b/mbbsd/register.c index 8bf88202..d29466e0 100644 --- a/mbbsd/register.c +++ b/mbbsd/register.c @@ -238,7 +238,7 @@ new_register(void) exit(1); } move(18, 0); - outs("\033[1;33m���קK�Q���ݡA�z���K�X�ä��|��ܦb�e���W�A������J����� Enter ��Y�i�C\033[m"); + outs(ANSI_COLOR(1;33) "���קK�Q���ݡA�z���K�X�ä��|��ܦb�e���W�A������J����� Enter ��Y�i�C" ANSI_RESET); if ((getdata(19, 0, "�г]�w�K�X�G", passbuf, sizeof(passbuf), NOECHO) < 3) || !strcmp(passbuf, newuser.userid)) { @@ -319,7 +319,7 @@ check_register(void) /* �^�йL�����{�ҫH��A�δ��g E-mail post �L */ clear(); move(9, 3); - outs("�иԶ�g\033[32m���U�ӽг�\033[m�A" + outs("�иԶ�g" ANSI_COLOR(32) "���U�ӽг�" ANSI_RESET "�A" "�q�i�����H��o�i���ϥ��v�O�C\n\n\n\n"); u_register(); diff --git a/mbbsd/screen.c b/mbbsd/screen.c index aee1319d..951cc1fc 100644 --- a/mbbsd/screen.c +++ b/mbbsd/screen.c @@ -222,7 +222,7 @@ refresh(void) } if (bp->oldlen > len) { /* XXX len/oldlen also count the length of escape sequence, - * before we fix it, we must print \033[K everywhere */ + * before we fix it, we must print ANSI_CLRTOEND everywhere */ rel_move(tc_col, tc_line, len, i); o_cleol(); } @@ -319,7 +319,7 @@ outc(unsigned char c) return; } /* - * else if(c != '\033' && !isprint2(c)) { c = '*'; //substitute a '*' for + * else if(c != ESC_CHR && !isprint2(c)) { c = '*'; //substitute a '*' for * non-printable } */ if (cur_col >= slp->len) { diff --git a/mbbsd/stuff.c b/mbbsd/stuff.c index 2a42fd5e..cd0b3471 100644 --- a/mbbsd/stuff.c +++ b/mbbsd/stuff.c @@ -556,8 +556,8 @@ vmsg_lines(const int lines, const char msg[]) if (msg) outs((char *)msg); else - outs("\033[1;34;44m �e�e�e�e�e�e�e�e�e�e�e�e�e�e�e\033[1;37;44m �Ы� " -"\033[36m���N�� \033[37m�~�� \033[1;34m�e�e�e�e�e\033[36m^T �����Ȧs��\033[34m�e�e�e \033[m"); + outs(ANSI_COLOR(1;34;44) " �e�e�e�e�e�e�e�e�e�e�e�e�e�e�e" ANSI_COLOR(1;37;44) " �Ы� " +ANSI_COLOR(36) "���N�� " ANSI_COLOR(37) "�~�� " ANSI_COLOR(1;34) "�e�e�e�e�e" ANSI_COLOR(36) "^T �����Ȧs��" ANSI_COLOR(34) "�e�e�e " ANSI_RESET); do { if( (ch = igetch()) == Ctrl('T') ) @@ -575,8 +575,8 @@ pressanykey_or_callangel(){ int ch; outmsg( -"\033[1;34;44m �e�e�e�e \033[32mH \033[36m�I�s�p�Ѩ�\033[34m �e�e�e�e\033[1;37;44m �Ы� " -"\033[36m���N�� \033[37m�~�� \033[1;34m�e�e�e�e�e\033[36m^T �����Ȧs��\033[34m�e�e�e \033[m"); +ANSI_COLOR(1;34;44) " �e�e�e�e " ANSI_COLOR(32) "H " ANSI_COLOR(36) "�I�s�p�Ѩ�" ANSI_COLOR(34) " �e�e�e�e" ANSI_COLOR(1;37;44) " �Ы� " +ANSI_COLOR(36) "���N�� " ANSI_COLOR(37) "�~�� " ANSI_COLOR(1;34) "�e�e�e�e�e" ANSI_COLOR(36) "^T �����Ȧs��" ANSI_COLOR(34) "�e�e�e " ANSI_RESET); do { ch = igetch(); @@ -627,7 +627,7 @@ getkey(const char *fmt,...) int vmsg(const char *fmt,...) { - char msg[256] = "\033[1;36;44m �� "; + char msg[256] = ANSI_COLOR(1;36;44) " �� "; int i=14; // 14=strlen(msg) va_list ap; va_start(ap, fmt); @@ -636,7 +636,7 @@ vmsg(const char *fmt,...) for(; i < 71; i++) msg[i] = ' '; strcat(msg + 71, - "\033[33;46m \033[200m\033[1431m\033[506m[�����N���~��]\033[201m \033[m"); + ANSI_COLOR(33;46) " " ANSI_COLOR(200) ANSI_COLOR(1431) ANSI_COLOR(506) "[�����N���~��]" ANSI_COLOR(201) " " ANSI_RESET); return vmsg_lines(b_lines, msg); } @@ -683,7 +683,7 @@ search_num(int ch, int max) int x, y; char genbuf[10]; - outmsg("\033[7m ���ܲĴX���G\033[m"); + outmsg(ANSI_COLOR(7) " ���ܲĴX���G" ANSI_RESET); outc(ch); genbuf[0] = ch; getyx(&y, &x); @@ -736,7 +736,7 @@ void stand_title(const char *title) { clear(); - prints("\033[1;37;46m�i %s �j\033[m\n", title); + prints(ANSI_COLOR(1;37;46) "�i %s �j" ANSI_RESET "\n", title); } void @@ -841,9 +841,9 @@ show_help(const char * const helptext[]) clear(); for (i = 0; (str = helptext[i]); i++) { if (*str == '\0') - prints("\033[1m�i %s �j\033[0m\n", str + 1); + prints(ANSI_COLOR(1) "�i %s �j" ANSI_COLOR(0) "\n", str + 1); else if (*str == '\01') - prints("\n\033[36m�i %s �j\033[m\n", str + 1); + prints("\n" ANSI_COLOR(36) "�i %s �j" ANSI_RESET "\n", str + 1); else prints(" %s\n", str); } diff --git a/mbbsd/syspost.c b/mbbsd/syspost.c index 741fc122..a5780eec 100644 --- a/mbbsd/syspost.c +++ b/mbbsd/syspost.c @@ -72,9 +72,9 @@ post_change_perm(int oldperm, int newperm, const char *sysopid, const char *user "�ɶ�: %s\n", ctime4(&now)); for (i = 5; i < NUMPERMS; i++) { if (((oldperm >> i) & 1) != ((newperm >> i) & 1)) { - fprintf(fp, " ����\033[1;32m%s%s%s%s\033[m���v��\n", + fprintf(fp, " ����" ANSI_COLOR(1;32) "%s%s%s%s" ANSI_RESET "���v��\n", sysopid, - (((oldperm >> i) & 1) ? "\033[1;33m����" : "\033[1;33m�}��"), + (((oldperm >> i) & 1) ? ANSI_COLOR(1;33) "����" : ANSI_COLOR(1;33) "�}��"), userid, str_permid[i]); flag++; } @@ -85,7 +85,7 @@ post_change_perm(int oldperm, int newperm, const char *sysopid, const char *user clear(); while (!getdata_str(5, 0, "�п�J�z�ѥH�ܭt�d�G", reason, sizeof(reason), DOECHO, "�ݪO�O�D:")); - fprintf(fp, "\n \033[1;37m����%s�ק��v���z�ѬO�G%s\033[m", + fprintf(fp, "\n " ANSI_COLOR(1;37) "����%s�ק��v���z�ѬO�G%s" ANSI_RESET, cuser.userid, reason); fclose(fp); @@ -108,9 +108,9 @@ post_violatelaw(const char *crime, const char *police, const char *reason, const "[���i] %s:%-*s �P�M", crime, (int)(37 - strlen(reason) - strlen(crime)), reason); snprintf(msg, sizeof(msg), - "\033[1;32m%s\033[m�P�M�G\n" - " \033[1;32m%s\033[m�]\033[1;35m%s\033[m�欰�A\n" - "�H�ϥ������W�A�B�H\033[1;35m%s\033[m�A�S�����i\n", + ANSI_COLOR(1;32) "%s" ANSI_RESET "�P�M�G\n" + " " ANSI_COLOR(1;32) "%s" ANSI_RESET "�]" ANSI_COLOR(1;35) "%s" ANSI_RESET "�欰�A\n" + "�H�ϥ������W�A�B�H" ANSI_COLOR(1;35) "%s" ANSI_RESET "�A�S�����i\n", police, crime, reason, result); post_msg("ViolateLaw",title,msg,"[Ptt�k�|]"); @@ -136,7 +136,7 @@ give_money_post(const char *userid, int money) char msg[128]; snprintf(title, sizeof(title), "[���w���i] ����%s�ϥά��]�����i", cuser.userid); - snprintf(msg, sizeof(msg), "\n ����\033[1;32m%s\033[m��\033[1;33m%s %d ��\033[m", + snprintf(msg, sizeof(msg), "\n ����" ANSI_COLOR(1;32) "%s" ANSI_RESET "��" ANSI_COLOR(1;33) "%s %d ��" ANSI_RESET, cuser.userid, userid, money); post_msg("Security", title, msg, "[�t�Φw����]"); diff --git a/mbbsd/talk.c b/mbbsd/talk.c index e986b3a1..a57827fe 100644 --- a/mbbsd/talk.c +++ b/mbbsd/talk.c @@ -34,9 +34,9 @@ typedef struct pickup_t { #define PICKUP_WAYS 7 static char * const fcolor[11] = { - "", "\033[36m", "\033[32m", "\033[1;32m", - "\033[33m", "\033[1;33m", "\033[1;37m", "\033[1;37m", - "\033[31m", "\033[1;35m", "\033[1;36m" + "", ANSI_COLOR(36), ANSI_COLOR(32), ANSI_COLOR(1;32), + ANSI_COLOR(33), ANSI_COLOR(1;33), ANSI_COLOR(1;37), ANSI_COLOR(1;37), + ANSI_COLOR(31), ANSI_COLOR(1;35), ANSI_COLOR(1;36) }; static char save_page_requestor[40]; static char page_requestor[40]; @@ -419,7 +419,7 @@ my_query(const char *uident) prints("�m�峹�g�ơn%d�g\n", muser.numposts); #endif - prints("\033[1;33m�m�ثe�ʺA�n%-28.28s\033[m", + prints(ANSI_COLOR(1;33) "�m�ثe�ʺA�n%-28.28s" ANSI_RESET, (uentp && isvisible_stat(currutmp, uentp, fri_stat)) ? modestring(uentp, 0) : "���b���W"); @@ -458,7 +458,7 @@ water_scr(const water_t * tw, int which, char type) move(8 + which, 28); outc(' '); move(8 + which, 28); - prints("\033[1;37;45m %c %-14s \033[0m", + prints(ANSI_COLOR(1;37;45) " %c %-14s " ANSI_COLOR(0) "", tw->uin ? ' ' : 'x', tw->userid); for (i = 0; i < 5; ++i) { @@ -466,17 +466,17 @@ water_scr(const water_t * tw, int which, char type) outc(' '); move(16 + i, 4); if (tw->msg[(tw->top - i + 4) % 5].last_call_in[0] != 0) - prints("\033[0m \033[1;%d;44m��%-64s\033[0m \n", + prints(ANSI_COLOR(0) " " ANSI_COLOR(1;%d;44) "��%-64s" ANSI_COLOR(0) " \n", colors[i], tw->msg[(tw->top - i + 4) % 5].last_call_in); else - outs("\033[0m�@\n"); + outs(ANSI_COLOR(0) "�@\n"); } move(21, 4); outc(' '); move(21, 4); - prints("\033[0m \033[1;37;46m%-66s\033[0m \n", + prints(ANSI_COLOR(0) " " ANSI_COLOR(1;37;46) "%-66s" ANSI_COLOR(0) " \n", tw->msg[5].last_call_in); move(0, 0); @@ -484,17 +484,17 @@ water_scr(const water_t * tw, int which, char type) move(0, 0); #ifdef PLAY_ANGEL if (tw->msg[0].msgmode == MSGMODE_TOANGEL) - outs("\033[0m�^���p�D�H:"); + outs(ANSI_COLOR(0) "�^���p�D�H:"); else #endif - prints("\033[0m���� %s:", tw->userid); + prints(ANSI_COLOR(0) "���� %s:", tw->userid); clrtoeol(); move(0, strlen(tw->userid) + 6); } else { move(8 + which, 28); outs("123456789012345678901234567890"); move(8 + which, 28); - prints("\033[1;37;44m %c %-13s�@\033[0m", + prints(ANSI_COLOR(1;37;44) " %c %-13s�@" ANSI_COLOR(0) "", tw->uin ? ' ' : 'x', tw->userid); } @@ -520,7 +520,7 @@ my_write2(void) //init screen move(WB_OFO_USER_TOP, WB_OFO_USER_LEFT); - outs("\033[1;33;46m �� ���y������H ��\033[0m"); + outs(ANSI_COLOR(1;33;46) " �� ���y������H ��" ANSI_COLOR(0) ""); for (i = 0; i < WB_OFO_USER_HEIGHT;++i) if (swater[i] == NULL || swater[i]->pid == 0) break; @@ -532,11 +532,11 @@ my_write2(void) water_scr(swater[i], i, 0); } move(WB_OFO_MSG_TOP, WB_OFO_MSG_LEFT); - outs("\033[0m \033[1;35m��\033[1;36m�w�w�w�w�w�w�w�w�w�w�w�w�w�w�w�w" - "�w�w�w�w�w�w�w�w�w�w�w�w�w�w�w�w�w\033[1;35m��\033[0m "); + outs(ANSI_COLOR(0) " " ANSI_COLOR(1;35) "��" ANSI_COLOR(1;36) "�w�w�w�w�w�w�w�w�w�w�w�w�w�w�w�w" + "�w�w�w�w�w�w�w�w�w�w�w�w�w�w�w�w�w" ANSI_COLOR(1;35) "��" ANSI_COLOR(0) " "); move(WB_OFO_MSG_BOTTOM, WB_OFO_MSG_LEFT); - outs(" \033[1;35m��\033[1;36m�w�w�w�w�w�w�w�w�w�w�w�w�w�w�w�w" - "�w�w�w�w�w�w�w�w�w�w�w�w�w�w�w�w�w\033[1;35m��\033[0m "); + outs(" " ANSI_COLOR(1;35) "��" ANSI_COLOR(1;36) "�w�w�w�w�w�w�w�w�w�w�w�w�w�w�w�w" + "�w�w�w�w�w�w�w�w�w�w�w�w�w�w�w�w�w" ANSI_COLOR(1;35) "��" ANSI_COLOR(0) " "); water_scr(swater[0], 0, 1); refresh(); @@ -579,7 +579,7 @@ my_write2(void) } else msg[0] = 0; move(0, 0); - outs("\033[m"); + outs(ANSI_RESET); clrtoeol(); #ifndef PLAY_ANGEL snprintf(genbuf, sizeof(genbuf), "���� %s:", tw->userid); @@ -769,7 +769,7 @@ my_write(pid_t pid, const char *prompt, const char *id, int flag, userinfo_t * p && he_reject_me(uin)) #endif ) { - outmsg("\033[1;33;41m�V�|! ��訾���F! \033[37m~>_<~\033[m"); + outmsg(ANSI_COLOR(1;33;41) "�V�|! ��訾���F! " ANSI_COLOR(37) "~>_<~" ANSI_RESET); } else { int write_pos = uin->msgcount; /* try to avoid race */ if ( write_pos < (MAX_MSGS - 1) ) { /* race here */ @@ -806,7 +806,7 @@ my_write(pid_t pid, const char *prompt, const char *id, int flag, userinfo_t * p #endif uin->pager = pager0; } else if (flag != WATERBALL_ALOHA) - outmsg("\033[1;33;41m�V�|! ��褣��F! (����Ӧh���y) \033[37m@_@\033[m"); + outmsg(ANSI_COLOR(1;33;41) "�V�|! ��褣��F! (����Ӧh���y) " ANSI_COLOR(37) "@_@" ANSI_RESET); if (uin->msgcount >= 1 && #ifdef NOKILLWATERBALL @@ -815,12 +815,12 @@ my_write(pid_t pid, const char *prompt, const char *id, int flag, userinfo_t * p (uin->pid <= 0 || kill(uin->pid, SIGUSR2) == -1) #endif && flag != WATERBALL_ALOHA) - outmsg("\033[1;33;41m�V�|! �S����! \033[37m~>_<~\033[m"); + outmsg(ANSI_COLOR(1;33;41) "�V�|! �S����! " ANSI_COLOR(37) "~>_<~" ANSI_RESET); else if (uin->msgcount == 1 && flag != WATERBALL_ALOHA) - outmsg("\033[1;33;44m���y�{�L�h�F! \033[37m*^o^*\033[m"); + outmsg(ANSI_COLOR(1;33;44) "���y�{�L�h�F! " ANSI_COLOR(37) "*^o^*" ANSI_RESET); else if (uin->msgcount > 1 && uin->msgcount < MAX_MSGS && flag != WATERBALL_ALOHA) - outmsg("\033[1;33;44m�A�ɤW�@��! \033[37m*^o^*\033[m"); + outmsg(ANSI_COLOR(1;33;44) "�A�ɤW�@��! " ANSI_COLOR(37) "*^o^*" ANSI_RESET); #if defined(NOKILLWATERBALL) && defined(PLAY_ANGEL) /* Questioning and answering should better deliver immediately. */ @@ -884,17 +884,17 @@ t_display_new(void) (swater[i - 1]->pid != swater[i - 1]->uin->pid || swater[i - 1]->userid[0] != swater[i - 1]->uin->userid[0])) swater[i - 1]->uin = (userinfo_t *) search_ulist_pid(swater[i - 1]->pid); - prints("%s%c%-13.13s\033[m", + prints("%s%c%-13.13s" ANSI_RESET, swater[i - 1] != water_which ? "" : - swater[i - 1]->uin ? "\033[1;33;47m" : - "\033[1;33;45m", + swater[i - 1]->uin ? ANSI_COLOR(1;33;47) : + ANSI_COLOR(1;33;45), !swater[i - 1]->uin ? '#' : ' ', swater[i - 1]->userid); } else outs(" "); else - prints("%s ���� \033[m", - water_which == &water[0] ? "\033[1;33;47m " : + prints("%s ���� " ANSI_RESET, + water_which == &water[0] ? ANSI_COLOR(1;33;47) " " : " " ); } @@ -909,13 +909,13 @@ t_display_new(void) move(i + (WATERMODE(WATER_ORIG) ? 2 : 3), 0); clrtoeol(); if (watermode - 1 != i) - prints("\033[1;33;46m %s \033[37;45m %s \033[m%*s", + prints(ANSI_COLOR(1;33;46) " %s " ANSI_COLOR(37;45) " %s " ANSI_RESET "%*s", water_which->msg[a].userid, water_which->msg[a].last_call_in, len, ""); else - prints("\033[1;44m>\033[1;33;47m%s " - "\033[37;45m %s \033[m%*s", + prints(ANSI_COLOR(1;44) ">" ANSI_COLOR(1;33;47) "%s " + ANSI_COLOR(37;45) " %s " ANSI_RESET "%*s", water_which->msg[a].userid, water_which->msg[a].last_call_in, len, ""); @@ -951,7 +951,7 @@ t_display(void) if (more(genbuf, YEA) != -1) { move(b_lines - 4, 0); clrtobot(); - outs("\033[1;33;45m���{�b Ptt���ѳзs�����y��z�{����\033[m\n" + outs(ANSI_COLOR(1;33;45) "���{�b Ptt���ѳзs�����y��z�{����" ANSI_RESET "\n" "�z�N���y�s�ܫH�c��, �b�i�l����j�ӫH��e�� u,\n" "�t�ΧY�|�N�z�����y�������s��z��H�e���z��! \n"); getdata(b_lines - 1, 0, "�M��(C) ���ܳƧѿ�(M) �O�d(R) (C/M/R)?[R]", @@ -1114,10 +1114,10 @@ do_talk_char(talkwin_t * twin, int ch, FILE *flog) trim(buf); if (*buf) fprintf(flog, "%s%s: %s%s\n", - (twin->eline == b_lines - 1) ? "\033[1;35m" : "", + (twin->eline == b_lines - 1) ? ANSI_COLOR(1;35) : "", (twin->eline == b_lines - 1) ? getuserid(currutmp->destuid) : cuser.userid, buf, - (ch == Ctrl('P')) ? "\033[37;45m(Up)\033[m" : "\033[m"); + (ch == Ctrl('P')) ? ANSI_COLOR(37;45) "(Up)" ANSI_RESET : ANSI_RESET); } static void @@ -1158,8 +1158,8 @@ do_talk(int fd) data[i] = '\0'; snprintf(mid_line, sizeof(mid_line), - "\033[1;46;37m �ͤѻ��a \033[45m%s%s�j" - " �P %s%s\033[0m", data, genbuf, save_page_requestor, data); + ANSI_COLOR(1;46;37) " �ͤѻ��a " ANSI_COLOR(45) "%s%s�j" + " �P %s%s" ANSI_COLOR(0) "", data, genbuf, save_page_requestor, data); memset(&mywin, 0, sizeof(mywin)); memset(&itswin, 0, sizeof(itswin)); @@ -1231,7 +1231,7 @@ do_talk(int fd) char ans[4]; int i; - fprintf(flog, "\n\033[33;44m���O�e�� [%s] ... \033[m\n", + fprintf(flog, "\n" ANSI_COLOR(33;44) "���O�e�� [%s] ... " ANSI_RESET "\n", Cdatelite(&now)); for (i = 0; i < scr_lns; i++) fprintf(flog, "%.*s\n", big_picture[i].len, big_picture[i].data); @@ -1248,7 +1248,7 @@ do_talk(int fd) mymail.filemode = FILE_READ ; strlcpy(mymail.owner, "[��.��.��]", sizeof(mymail.owner)); snprintf(mymail.title, sizeof(mymail.title), - "��ܰO�� \033[1;36m(%s)\033[m", + "��ܰO�� " ANSI_COLOR(1;36) "(%s)" ANSI_RESET, getuserid(currutmp->destuid)); sethomedir(title, cuser.userid); Rename(fpath, genbuf); @@ -1576,7 +1576,7 @@ t_showhelp(void) { clear(); - outs("\033[36m�i ��Ѩϥλ��� �j\033[m\n\n" + outs(ANSI_COLOR(36) "�i ��Ѩϥλ��� �j" ANSI_RESET "\n\n" "(��)(e) �������} (h) �ݨϥλ���\n" "(��)/(��)(n) �W�U���� (TAB) �����ƧǤ覡\n" "(PgUp)(^B) �W����� ( )(PgDn)(^F) �U�����\n" @@ -1589,7 +1589,7 @@ t_showhelp(void) "(N) �ק�ʺ� (y) �ڷQ��H��ѡB�U�ѡK\n"); if (HAS_PERM(PERM_PAGE)) { - outs("\n\033[36m�i ��ͱM���� �j\033[m\n" + outs("\n" ANSI_COLOR(36) "�i ��ͱM���� �j" ANSI_RESET "\n" "(��)(t)(Enter) ��L���o���\n" "(w) ���u Call in\n" "(^W)�������y�覡 �@�� / �i�� / ����\n" @@ -1597,7 +1597,7 @@ t_showhelp(void) "(^R) �Y�ɦ^�� (���H Call in �A��)\n"); } if (HAS_PERM(PERM_SYSOP)) { - outs("\n\033[36m�i �����M���� �j\033[m\n\n"); + outs("\n" ANSI_COLOR(36) "�i �����M���� �j" ANSI_RESET "\n\n"); outs("(u)/(H) �]�w�ϥΪ̸��/�������μҦ�\n"); outs("(K) ���a�J��X�h\n"); #if defined(SHOWBOARD) && defined(DEBUG) @@ -1938,7 +1938,7 @@ draw_pickup(int drawall, pickup_t * pickup, int pickup_way, showtitle((cuser.uflag & FRIEND_FLAG) ? "�n�ͦC��" : "���", BBSName); prints("\n" - "\033[7m %s P%c�N�� %-17s%-17s%-13s%-10s\033[m\n", + ANSI_COLOR(7) " %s P%c�N�� %-17s%-17s%-13s%-10s" ANSI_RESET "\n", show_uid ? "UID" : "No.", (HAS_PERM(PERM_SEECLOAK) || HAS_PERM(PERM_SYSOP)) ? 'C' : ' ', "�ʺ�", @@ -1947,15 +1947,15 @@ draw_pickup(int drawall, pickup_t * pickup, int pickup_way, show_pid ? " PID" : "�߱� �o�b" ); move(b_lines, 0); - outs("\033[31;47m(TAB/f)\033[30m�Ƨ�/�n�� \033[31m(t)\033[30m��� " - "\033[31m(a/d/o)\033[30m��� \033[31m(q)\033[30m�d�� " - "\033[31m(w)\033[30m���y \033[31m(m)\033[30m�H�H \033[31m(h)" - "\033[30m�u�W���U \033[m"); + outs(ANSI_COLOR(31;47) "(TAB/f)" ANSI_COLOR(30) "�Ƨ�/�n�� " ANSI_COLOR(31) "(t)" ANSI_COLOR(30) "��� " + ANSI_COLOR(31) "(a/d/o)" ANSI_COLOR(30) "��� " ANSI_COLOR(31) "(q)" ANSI_COLOR(30) "�d�� " + ANSI_COLOR(31) "(w)" ANSI_COLOR(30) "���y " ANSI_COLOR(31) "(m)" ANSI_COLOR(30) "�H�H " ANSI_COLOR(31) "(h)" + ANSI_COLOR(30) "�u�W���U " ANSI_RESET); } move(1, 0); - prints(" �ƧǡG[%s] �W���H�ơG%-4d\033[1;32m�ڪ��B�͡G%-3d" - "\033[33m�P�ڬ��͡G%-3d\033[36m�O�͡G%-4d\033[31m�a�H�G" - "%-2d\033[m\n", + prints(" �ƧǡG[%s] �W���H�ơG%-4d" ANSI_COLOR(1;32) "�ڪ��B�͡G%-3d" + ANSI_COLOR(33) "�P�ڬ��͡G%-3d" ANSI_COLOR(36) "�O�͡G%-4d" ANSI_COLOR(31) "�a�H�G" + "%-2d" 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) { @@ -2002,7 +2002,7 @@ draw_pickup(int drawall, pickup_t * pickup, int pickup_way, else memcpy(mind, uentp->mind, 4); mind[4] = 0; - prints("%5d %c%c%s%-13s%-17.16s\033[m%-17.16s%-13.13s" + prints("%5d %c%c%s%-13s%-17.16s" ANSI_RESET "%-17.16s%-13.13s" "\33[33m%-4.4s\33[m%s\n", /* list number or uid */ @@ -2584,7 +2584,7 @@ userlist(void) reload_money(); if (ch > cuser.money) { - outs("\033[41m �{������~~\033[m"); + outs(ANSI_COLOR(41) " �{������~~" ANSI_RESET); } else { deumoney(uentp->uid, ch - give_tax(ch)); log_file(FN_MONEY, LOG_CREAT | LOG_VF, @@ -2906,7 +2906,7 @@ talkreply(void) prints(" (C) �Ф��n�n�ڦn�ܡH" " (D) �ڭn�����o..�U���A��a.......\n"); prints(" (E) ���ƶܡH�Х��ӫH" - " (F) \033[1;33m�ڦۤv��J�z�Ѧn�F...\033[m\n"); + " (F) " ANSI_COLOR(1;33) "�ڦۤv��J�z�Ѧn�F..." ANSI_RESET "\n"); prints(" (1) %s�H����100�Ȩ��" " (2) %s�H����1000�Ȩ��..\n\n", sig_des[sig], sig_des[sig]); @@ -3102,18 +3102,18 @@ AngelNotOnline(){ clrtobot(); outs(not_online_message); outs("\n͢�d�����A�G\n"); - outs("\033[1;31;44m��s�w�w�w�w�w�w�w�w�w�w�w�w�w�w�t\033[37m" - "�p�Ѩϯd��\033[31m�u�w�w�w�w�w�w�w�w�w�w�w�w�w�w�s��\033[m\n"); - outs("\033[1;31m�~�t\033[32m �p�Ѩ� " - " \033[31m�u��\033[m\n"); + outs(ANSI_COLOR(1;31;44) "��s�w�w�w�w�w�w�w�w�w�w�w�w�w�w�t" ANSI_COLOR(37) "" + "�p�Ѩϯd��" ANSI_COLOR(31) "�u�w�w�w�w�w�w�w�w�w�w�w�w�w�w�s��" ANSI_RESET "\n"); + outs(ANSI_COLOR(1;31) "�~�t" ANSI_COLOR(32) " �p�Ѩ� " + " " ANSI_COLOR(31) "�u��" ANSI_RESET "\n"); while (fgets(buf, sizeof(buf), fp)) { chomp(buf); - prints("\033[1;31m�x\033[m%-74.74s\033[1;31m�x\033[m\n", buf); + prints(ANSI_COLOR(1;31) "�x" ANSI_RESET "%-74.74s" ANSI_COLOR(1;31) "�x" ANSI_RESET "\n", buf); } - outs("\033[1;31m���s�w�w�w�w�w�w�w�w�w�w�w�w�w�w�w�w�w�w�w�w�w�w" - "�w�w�w�w�w�w�w�w�w�w�w�w�w�s��\033[m\n"); - outs("\033[1;31;44m��r�w�w�w�w�w�w�w�w�w�w�w�w�w�w�w�w�w�w�w�w�w" - "�w�w�w�w�w�w�w�w�w�w�w�w�w�w�r��\033[m\n"); + outs(ANSI_COLOR(1;31) "���s�w�w�w�w�w�w�w�w�w�w�w�w�w�w�w�w�w�w�w�w�w�w" + "�w�w�w�w�w�w�w�w�w�w�w�w�w�s��" ANSI_RESET "\n"); + outs(ANSI_COLOR(1;31;44) "��r�w�w�w�w�w�w�w�w�w�w�w�w�w�w�w�w�w�w�w�w�w" + "�w�w�w�w�w�w�w�w�w�w�w�w�w�w�r��" ANSI_RESET "\n"); move(b_lines - 1, 0); outs("�Х��b�s��O�W�M�䵪�שΫ� Ctrl-P �o��"); diff --git a/mbbsd/topsong.c b/mbbsd/topsong.c index 41adc53f..72e3d3d5 100644 --- a/mbbsd/topsong.c +++ b/mbbsd/topsong.c @@ -68,11 +68,11 @@ sortsong(void) } qsort(songs, MAX_SONGS, sizeof(songcmp_t), (QCAST) count_cmp); fprintf(fo, - " \033[36m�w�w\033[37m�W��\033[36m�w�w�w�w�w�w\033[37m�q" - " �W\033[36m�w�w�w�w�w�w�w�w�w�w�w\033[37m����\033[36m" - "�w�w\033[32m�@%d��\033[36m�w�w\033[m\n", totalcount); + " " ANSI_COLOR(36) "�w�w" ANSI_COLOR(37) "�W��" ANSI_COLOR(36) "�w�w�w�w�w�w" ANSI_COLOR(37) "�q" + " �W" ANSI_COLOR(36) "�w�w�w�w�w�w�w�w�w�w�w" ANSI_COLOR(37) "����" ANSI_COLOR(36) "" + "�w�w" ANSI_COLOR(32) "�@%d��" ANSI_COLOR(36) "�w�w" ANSI_RESET "\n", totalcount); for (n = 0; n < 100 && songs[n].name[0]; n++) { - fprintf(fo, " %5d. %-38.38s %4d \033[32m[%.2f]\033[m\n", n + 1, + fprintf(fo, " %5d. %-38.38s %4d " ANSI_COLOR(32) "[%.2f]" ANSI_RESET "\n", n + 1, songs[n].name, songs[n].count, (float)songs[n].count / totalcount); } diff --git a/mbbsd/user.c b/mbbsd/user.c index d8816c6e..26c22abd 100644 --- a/mbbsd/user.c +++ b/mbbsd/user.c @@ -66,9 +66,9 @@ user_display(const userec_t * u, int real) clrtobot(); prints( - " \033[30;41m�r�s�r�s�r�s\033[m \033[1;30;45m �� �� ��" + " " ANSI_COLOR(30;41) "�r�s�r�s�r�s" ANSI_RESET " " ANSI_COLOR(1;30;45) " �� �� ��" " �� �� " - " \033[m \033[30;41m�r�s�r�s�r�s\033[m\n"); + " " ANSI_RESET " " ANSI_COLOR(30;41) "�r�s�r�s�r�s" ANSI_RESET "\n"); prints(" �N���ʺ�: %s(%s)\n" " �u��m�W: %s" #if FOREIGN_REG_DAY > 0 @@ -158,8 +158,8 @@ user_display(const userec_t * u, int real) } outc('\n'); } - outs(" \033[30;41m�r�s�r�s�r�s�r�s�r�s�r�s�r�s�r�s�r�s�r�s�r�s�r" - "�s�r�s�r�s�r�s\033[m"); + outs(" " ANSI_COLOR(30;41) "�r�s�r�s�r�s�r�s�r�s�r�s�r�s�r�s�r�s�r�s�r�s�r" + "�s�r�s�r�s�r�s" ANSI_RESET); outs((u->userlevel & PERM_LOGINOK) ? "\n�z�����U�{�Ǥw�g�����A�w��[�J����" : @@ -185,8 +185,8 @@ mail_violatelaw(const char *crime, const char *police, const char *reason, const fprintf(fp, "�@��: [Ptt�k�|]\n" "���D: [���i] �H�k�P�M���i\n" "�ɶ�: %s\n" - "\033[1;32m%s\033[m�P�M�G\n \033[1;32m%s\033[m" - "�]\033[1;35m%s\033[m�欰�A\n�H�ϥ������W�A�B�H\033[1;35m%s\033[m�A�S���q��" + ANSI_COLOR(1;32) "%s" ANSI_RESET "�P�M�G\n " ANSI_COLOR(1;32) "%s" ANSI_RESET + "�]" ANSI_COLOR(1;35) "%s" ANSI_RESET "�欰�A\n�H�ϥ������W�A�B�H" ANSI_COLOR(1;35) "%s" ANSI_RESET "�A�S���q��" "\n�Ш� PttLaw �d�߬����k�W��T�A�è� Play-Pay-ViolateLaw ú��@��", ctime4(&now), police, crime, reason, result); fclose(fp); @@ -777,9 +777,9 @@ uinfo_query(userec_t * u, int real, int unum) reason, sizeof(reason), DOECHO)); snprintf(msg, sizeof(msg), - " ����\033[1;32m%s\033[m��\033[1;32m%s\033[m����" - "�q\033[1;35m%d\033[m�令\033[1;35m%d\033[m\n" - " \033[1;37m����%s�ק���z�ѬO�G%s\033[m", + " ����" ANSI_COLOR(1;32) "%s" ANSI_RESET "��" ANSI_COLOR(1;32) "%s" ANSI_RESET "����" + "�q" ANSI_COLOR(1;35) "%d" ANSI_RESET "�令" ANSI_COLOR(1;35) "%d" ANSI_RESET "\n" + " " ANSI_COLOR(1;37) "����%s�ק���z�ѬO�G%s" ANSI_RESET, cuser.userid, x.userid, money, x.money, cuser.userid, reason); snprintf(title, sizeof(title), @@ -880,7 +880,7 @@ showsignature(char *fname, int *j) for (ch = '1'; ch <= '9'; ch++) { fname[*j] = ch; if ((fp = fopen(fname, "r"))) { - prints("\033[36m�i ñ�W��.%c �j\033[m\n", ch); + prints(ANSI_COLOR(36) "�i ñ�W��.%c �j" ANSI_RESET "\n", ch); for (i = 0; i < MAX_SIGLINES && fgets(buf, sizeof(buf), fp); i++) outs(buf); num++; @@ -1460,10 +1460,10 @@ u_register(void) move(11, 0); outs(" �кɶq�ԲӪ���g�z���A�ȳ��A�j�M�|�սг·�" - "�[\033[1;33m�t��\033[m�A���q���Х[\033[1;33m¾��\033[m�A\n" - " �ȵL�u�@�г·ж�g\033[1;33m���~�Ǯ�\033[m�C\n"); + "�[" ANSI_COLOR(1;33) "�t��" ANSI_RESET "�A���q���Х[" ANSI_COLOR(1;33) "¾��" ANSI_RESET "�A\n" + " �ȵL�u�@�г·ж�g" ANSI_COLOR(1;33) "���~�Ǯ�" ANSI_RESET "�C\n"); while (1) { - getfield(9, "(���~)�Ǯ�(�t\033[1;33m�t�Ҧ~��\033[m)�γ��¾��", + getfield(9, "(���~)�Ǯ�(�t" ANSI_COLOR(1;33) "�t�Ҧ~��" ANSI_RESET ")�γ��¾��", "�A�ȳ��", career, 40); if( (errcode = isvalidcareer(career)) == NULL ) break; @@ -1471,8 +1471,8 @@ u_register(void) vmsg(errcode); } while (1) { - getfield(11, "�t\033[1;33m����\033[m�Ϊ��츹�X" - "(�x�_�Х[\033[1;33m��F��\033[m)", + getfield(11, "�t" ANSI_COLOR(1;33) "����" ANSI_RESET "�Ϊ��츹�X" + "(�x�_�Х[" ANSI_COLOR(1;33) "��F��" ANSI_RESET ")", "�ثe���}", addr, sizeof(addr)); if( (errcode = isvalidaddr(addr)) == NULL #ifdef FOREIGN_REG @@ -1548,8 +1548,8 @@ u_register(void) clear(); move(9, 3); - outs("�̫�Post�@�g\033[32m�ۧڤ��Ф峹\033[m���j�a�a�A" - "�i�D�Ҧ��Ѱ��Y\033[31m�ڨӰ�^$�C\\n\n\n\n"); + outs("�̫�Post�@�g" ANSI_COLOR(32) "�ۧڤ��Ф峹" ANSI_RESET "���j�a�a�A" + "�i�D�Ҧ��Ѱ��Y" ANSI_COLOR(31) "�ڨӰ�^$�C\\n\n\n\n"); pressanykey(); cuser.userlevel |= PERM_POST; brc_initial_board("WhoAmI"); @@ -1573,8 +1573,8 @@ u_list_CB(int num, userec_t * uentp) if (uentp == NULL) { move(2, 0); clrtoeol(); - prints("\033[7m �ϥΪ̥N�� %-25s �W�� �峹 %s " - "�̪���{��� \033[0m\n", + prints(ANSI_COLOR(7) " �ϥΪ̥N�� %-25s �W�� �峹 %s " + "�̪���{��� " ANSI_COLOR(0) "\n", "�︹�ʺ�", HAS_PERM(PERM_SEEULEVELS) ? "����" : ""); i = 3; @@ -1587,8 +1587,8 @@ u_list_CB(int num, userec_t * uentp) return 0; if (i == b_lines) { - prints("\033[34;46m �w��� %d/%d �H(%d%%) \033[31;47m " - "(Space)\033[30m �ݤU�@�� \033[31m(Q)\033[30m ���} \033[m", + prints(ANSI_COLOR(34;46) " �w��� %d/%d �H(%d%%) " ANSI_COLOR(31;47) " " + "(Space)" ANSI_COLOR(30) " �ݤU�@�� " ANSI_COLOR(31) "(Q)" ANSI_COLOR(30) " ���} " ANSI_RESET, usercounter, totalusers, usercounter * 100 / totalusers); i = igetch(); if (i == 'q' || i == 'Q') @@ -1654,8 +1654,8 @@ u_list(void) } move(b_lines, 0); clrtoeol(); - prints("\033[34;46m �w��� %d/%d ���ϥΪ�(�t�ήe�q�L�W��) " - "\033[31;47m (�Ы����N���~��) \033[m", usercounter, totalusers); + prints(ANSI_COLOR(34;46) " �w��� %d/%d ���ϥΪ�(�t�ήe�q�L�W��) " + ANSI_COLOR(31;47) " (�Ы����N���~��) " ANSI_RESET, usercounter, totalusers); igetch(); return 0; } diff --git a/mbbsd/var.c b/mbbsd/var.c index 81dd207c..baee68d0 100644 --- a/mbbsd/var.c +++ b/mbbsd/var.c @@ -87,7 +87,7 @@ char currtitle[TTLEN + 1] = "\0"; char currauthor[IDLEN + 2] = "\0"; const char *currboard = "\0"; char currBM[IDLEN * 3 + 10]; -const char reset_color[4] = "\033[m"; +const char reset_color[4] = ANSI_RESET; char margs[64] = "\0"; /* main argv list */ pid_t currpid; /* current process ID */ time4_t login_start_time; diff --git a/mbbsd/vote.c b/mbbsd/vote.c index cf52228f..c6c27576 100644 --- a/mbbsd/vote.c +++ b/mbbsd/vote.c @@ -726,7 +726,7 @@ vote_maintain(const char *bname) if( num % 15 == 0 ){ for( i = num ; i < num + 15 ; ++i ){ move((i % 15) + 2, (i / 15) * 40); - prints("\033[1;30m%c)\033[m ", i + 'A'); + prints(ANSI_COLOR(1;30) "%c)" ANSI_RESET " ", i + 'A'); } } snprintf(buf, sizeof(buf), "%c) ", num + 'A'); @@ -982,8 +982,8 @@ user_vote_one(vote_buffer_t *vbuf, const char *bname, int ind) if (mycomments[0]) if ((fcm = fopen(b_comments, "a"))) { fprintf(fcm, - "\033[36m���ϥΪ�\033[1;36m %s " - "\033[;36m����ij�G\033[m\n", + ANSI_COLOR(36) "���ϥΪ�" ANSI_COLOR(1;36) " %s " + ANSI_COLOR(;36) "����ij�G" ANSI_RESET "\n", cuser.userid); for (i = 0; i < 3; i++) fprintf(fcm, " %s\n", mycomments[i]); diff --git a/mbbsd/xyz.c b/mbbsd/xyz.c index 1837c508..490febd8 100644 --- a/mbbsd/xyz.c +++ b/mbbsd/xyz.c @@ -180,7 +180,7 @@ note(void) notedata_t myitem; if (cuser.money < 5) { - vmsg("\033[1;41m �u�r! �n�뤭�Ȥ~��d��...�S���C..\033[m"); + vmsg(ANSI_COLOR(1;41) " �u�r! �n�뤭�Ȥ~��d��...�S���C.." ANSI_RESET); return 0; } setutmpmode(EDNOTE); @@ -226,37 +226,37 @@ note(void) if (total > MAX_NOTE) total = MAX_NOTE; } - fputs("\033[1;31;44m��s�w�w�w�w�w�w�w�w�w�w�w�w�w�w�t" - "\033[37m�IJ��W���O\033[31m�u�w�w�w�w�w�w�w�w�w�w�w�w�w�w�s��" - "\033[m\n", fp); + fputs(ANSI_COLOR(1;31;44) "��s�w�w�w�w�w�w�w�w�w�w�w�w�w�w�t" + ANSI_COLOR(37) "�IJ��W���O" ANSI_COLOR(31) "�u�w�w�w�w�w�w�w�w�w�w�w�w�w�w�s��" + ANSI_RESET "\n", fp); collect = 1; while (total) { - snprintf(buf, sizeof(buf), "\033[1;31m�ݢt\033[32m %s \033[37m(%s)", + snprintf(buf, sizeof(buf), ANSI_COLOR(1;31) "�ݢt" ANSI_COLOR(32) " %s " ANSI_COLOR(37) "(%s)", myitem.userid, myitem.username); len = strlen(buf); for (i = len; i < 71; i++) strcat(buf, " "); - snprintf(buf2, sizeof(buf2), " \033[1;36m%.16s\033[31m �u��\033[m\n", + snprintf(buf2, sizeof(buf2), " " ANSI_COLOR(1;36) "%.16s" ANSI_COLOR(31) " �u��" ANSI_RESET "\n", Cdate(&(myitem.date))); strcat(buf, buf2); fputs(buf, fp); if (collect) fputs(buf, foo); for (i = 0; i < 3 && *myitem.buf[i]; i++) { - fprintf(fp, "\033[1;31m�x\033[m%-74.74s\033[1;31m�x\033[m\n", + fprintf(fp, ANSI_COLOR(1;31) "�x" ANSI_RESET "%-74.74s" ANSI_COLOR(1;31) "�x" ANSI_RESET "\n", myitem.buf[i]); if (collect) - fprintf(foo, "\033[1;31m�x\033[m%-74.74s\033[1;31m�x\033[m\n", + fprintf(foo, ANSI_COLOR(1;31) "�x" ANSI_RESET "%-74.74s" ANSI_COLOR(1;31) "�x" ANSI_RESET "\n", myitem.buf[i]); } - fputs("\033[1;31m��s�w�w�w�w�w�w�w�w�w�w�w�w�w�w�w�w�w�w�w�w�w�w�w" - "�w�w�w�w�w�w�w�w�w�w�w�w�s��\033[m\n", fp); + fputs(ANSI_COLOR(1;31) "��s�w�w�w�w�w�w�w�w�w�w�w�w�w�w�w�w�w�w�w�w�w�w�w" + "�w�w�w�w�w�w�w�w�w�w�w�w�s��" ANSI_RESET "\n", fp); if (collect) { - fputs("\033[1;31m��s�w�w�w�w�w�w�w�w�w�w�w�w�w�w�w�w�w�w�w�w�w" - "�w�w�w�w�w�w�w�w�w�w�w�w�w�w�s��\033[m\n", foo); + fputs(ANSI_COLOR(1;31) "��s�w�w�w�w�w�w�w�w�w�w�w�w�w�w�w�w�w�w�w�w�w" + "�w�w�w�w�w�w�w�w�w�w�w�w�w�w�s��" ANSI_RESET "\n", foo); fclose(foo); collect = 0; } @@ -265,8 +265,8 @@ note(void) if (--total) read(fd, (char *)&myitem, sizeof(myitem)); } - fputs("\033[1;31;44m��r�w�w�w�w�w�w�w�w�w�w�w�w�w�w�w�w�w�w�w�w�w�w�w" - "�w�w�w�w�w�w�w�w�w�w�w�w�r��\033[m\n", fp); + fputs(ANSI_COLOR(1;31;44) "��r�w�w�w�w�w�w�w�w�w�w�w�w�w�w�w�w�w�w�w�w�w�w�w" + "�w�w�w�w�w�w�w�w�w�w�w�w�r��" ANSI_RESET "\n", fp); fclose(fp); close(fd); close(fx); @@ -314,9 +314,9 @@ mail_sysop(void) outs(" �s�� ���� ID �v�d����\n\n"); for (i = 0; i < j; i++) - prints("%15d. \033[1;%dm%-16s%s\033[0m\n", + prints("%15d. " ANSI_COLOR(1;%d) "%-16s%s" ANSI_COLOR(0) "\n", i + 1, 31 + i % 7, sysoplist[i].userid, sysoplist[i].duty); - prints("%-14s0. \033[1;%dm���}\033[0m", "", 31 + j % 7); + prints("%-14s0. " ANSI_COLOR(1;%d) "���}" ANSI_COLOR(0) "", "", 31 + j % 7); getdata(b_lines - 1, 0, " �п�J�N�X[0]�G", genbuf, 4, DOECHO); i = genbuf[0] - '0' - 1; @@ -357,8 +357,8 @@ Goodbye(void) note(); } clear(); - prints("\033[1;36m�˷R�� \033[33m%s(%s)\033[36m�A�O�ѤF�A�ץ��{\033[45;33m" - " %s \033[40;36m�I\n�H�U�O�z�b���������U���:\033[0m\n", + prints(ANSI_COLOR(1;36) "�˷R�� " ANSI_COLOR(33) "%s(%s)" ANSI_COLOR(36) "�A�O�ѤF�A�ץ��{" ANSI_COLOR(45;33) "" + " %s " ANSI_COLOR(40;36) "�I\n�H�U�O�z�b���������U���:" ANSI_COLOR(0) "\n", cuser.userid, cuser.username, BBSName); user_display(&cuser, 0); pressanykey(); |