From a0f8ef1e2e04905908478088fc376435b770417c Mon Sep 17 00:00:00 2001 From: piaip Date: Wed, 8 Jun 2005 02:46:24 +0000 Subject: 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 --- include/ansi.h | 25 ++++++++++ include/bbs.h | 1 + include/chc.h | 10 ++-- include/common.h | 26 +++++------ include/config.h | 2 +- mbbsd/admin.c | 23 +++++---- mbbsd/announce.c | 26 +++++++---- mbbsd/bbs.c | 62 +++++++++++++----------- mbbsd/board.c | 82 ++++++++++++++++---------------- mbbsd/cal.c | 8 ++-- mbbsd/card.c | 54 ++++++++++----------- mbbsd/chat.c | 4 +- mbbsd/chc.c | 38 +++++++-------- mbbsd/chicken.c | 118 +++++++++++++++++++++++----------------------- mbbsd/dark.c | 72 ++++++++++++++-------------- mbbsd/dice.c | 140 +++++++++++++++++++++++++++---------------------------- mbbsd/edit.c | 48 +++++++++---------- mbbsd/file.c | 2 +- mbbsd/friend.c | 2 +- mbbsd/gamble.c | 22 ++++----- mbbsd/go.c | 28 +++++------ mbbsd/gomo.c | 78 +++++++++++++++---------------- mbbsd/guess.c | 12 ++--- mbbsd/indict.c | 24 +++++----- mbbsd/io.c | 2 +- mbbsd/kaede.c | 6 +-- mbbsd/mail.c | 24 +++++----- mbbsd/mbbsd.c | 14 +++--- mbbsd/menu.c | 54 ++++++++++----------- mbbsd/merge.c | 2 +- mbbsd/more.c | 30 ++++++------ mbbsd/page.c | 26 +++++------ mbbsd/pmore.c | 17 ++++++- mbbsd/read.c | 2 +- mbbsd/register.c | 4 +- mbbsd/screen.c | 4 +- mbbsd/stuff.c | 20 ++++---- mbbsd/syspost.c | 14 +++--- mbbsd/talk.c | 120 +++++++++++++++++++++++------------------------ mbbsd/topsong.c | 8 ++-- mbbsd/user.c | 46 +++++++++--------- mbbsd/var.c | 2 +- mbbsd/vote.c | 6 +-- mbbsd/xyz.c | 36 +++++++------- 44 files changed, 700 insertions(+), 644 deletions(-) create mode 100644 include/ansi.h diff --git a/include/ansi.h b/include/ansi.h new file mode 100644 index 00000000..1b0d9073 --- /dev/null +++ b/include/ansi.h @@ -0,0 +1,25 @@ +/* $Id */ +#ifndef INCLUDE_ANSI_H +#define INCLUDE_ANSI_H + +/* This is a more elegant style which is first introduced by pmore(piaip) + * and then promoted by Rong-en Fan (rafan). */ + +/* to help pmore know that we've already included this. */ +#define PMORE_STYLE_ANSI + +// Escapes. +#define ESC_NUM (0x1b) +#define ESC_STR "\x1b" +#define ESC_CHR '\x1b' + +// Common ANSI commands. +#define ANSI_RESET ESC_STR "[m" +#define ANSI_COLOR(x) ESC_STR "[" #x "m" +#define ANSI_MOVETO(x,y) ESC_STR "[" #x ";" #y "H" +#define ANSI_CLRTOEND ESC_STR "[K" + +#endif /* INCLUDE_ANSI_H */ + +/* vim:sw=4 + */ diff --git a/include/bbs.h b/include/bbs.h index 34a878b0..326fd49c 100644 --- a/include/bbs.h +++ b/include/bbs.h @@ -44,6 +44,7 @@ typedef uint32_t time4_t; #else typedef time_t time4_t; #endif +#include "ansi.h" #include "statistic.h" #include "pttstruct.h" #include "fav.h" diff --git a/include/chc.h b/include/chc.h index e3b16d38..6be0512c 100644 --- a/include/chc.h +++ b/include/chc.h @@ -26,11 +26,11 @@ #define LTR(x) ((x) * 2 + 3) #define CHE(a, b) ((a) | ((b) << 3)) -#define BLACK_COLOR "\033[1;36m" -#define RED_COLOR "\033[1;31m" -#define BLACK_REVERSE "\033[1;37;46m" -#define RED_REVERSE "\033[1;37;41m" -#define TURN_COLOR "\033[1;33m" +#define BLACK_COLOR ANSI_COLOR(1;36) +#define RED_COLOR ANSI_COLOR(1;31) +#define BLACK_REVERSE ANSI_COLOR(1;37;46) +#define RED_REVERSE ANSI_COLOR(1;37;41) +#define TURN_COLOR ANSI_COLOR(1;33) typedef struct chcusr_t{ char userid[IDLEN + 1]; diff --git a/include/common.h b/include/common.h index a17e7a15..5a29ca70 100644 --- a/include/common.h +++ b/include/common.h @@ -33,7 +33,7 @@ #define FN_BOARDHELP "etc/board.help" #define MSG_DEL_CANCEL "¨ú®ø§R°£" -#define MSG_SELECT_BOARD "\033[7m¡i ¿ï¾Ü¬ÝªO ¡j\033[m\n" \ +#define MSG_SELECT_BOARD ANSI_COLOR(7) "¡i ¿ï¾Ü¬ÝªO ¡j" ANSI_RESET "\n" \ "½Ð¿é¤J¬ÝªO¦WºÙ(«öªÅ¥ÕÁä¦Û°Ê·j´M)¡G" #define MSG_CLOAKED "«¢«¢¡I§ÚÁô§Î¤F¡I¬Ý¤£¨ì°Ç... :P" #define MSG_UNCLOAK "§Ú­n­«²{¦¿´ò¤F...." @@ -46,13 +46,13 @@ #define MSG_PLANT "´Óª«¤]¦³©Ê§O³á.." #define MSG_MIME "Äqª«Á`¨S©Ê§O¤F§a" #define MSG_PASSWD "½Ð¿é¤J±zªº±K½X: " -#define MSG_POSTER "\033[34;46m ¤å³¹¿ïŪ "\ - "\033[31;47m (y)\033[30m¦^«H "\ - "\033[31m(=[]<>)\033[30m¬ÛÃö¥DÃD "\ - "\033[31m(/?)\033[30m·j´M¼ÐÃD "\ - "\033[31m(aA)\033[30m·j´M§@ªÌ "\ - "\033[31m(x)\033[30mÂà¿ý "\ - "\033[31m(V)\033[30m§ë²¼ \033[m" +#define MSG_POSTER ANSI_COLOR(34;46) " ¤å³¹¿ïŪ "\ + ANSI_COLOR(31;47) " (y)" ANSI_COLOR(30) "¦^«H "\ + ANSI_COLOR(31) "(=[]<>)" ANSI_COLOR(30) "¬ÛÃö¥DÃD "\ + ANSI_COLOR(31) "(/?)" ANSI_COLOR(30) "·j´M¼ÐÃD "\ + ANSI_COLOR(31) "(aA)" ANSI_COLOR(30) "·j´M§@ªÌ "\ + ANSI_COLOR(31) "(x)" ANSI_COLOR(30) "Âà¿ý "\ + ANSI_COLOR(31) "(V)" ANSI_COLOR(30) "§ë²¼ " ANSI_RESET #define MSG_SEPERATOR "\ ¢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¢w¢w¢w¢w" @@ -99,11 +99,11 @@ #define ERR_PASSWD "±K½X¤£¹ï³á¡I§A¦³¨S¦³«_¥Î¤H®aªº¦W¦r°Ú¡H" #define ERR_FILENAME "ÀɦW¤£¦Xªk¡I" #define MSG_MAILER \ -"\033[34;46m ÂE¶­©¹ªð \033[31;47m(R)\033[30m¦^«H\033[31m(x)\033[30mÂà¹F\ -\033[31m(y)\033[30m¸s²Õ¦^«H\033[31m(D)\033[30m§R°£\ -\033[31m(c)\033[30m¦¬¤J«H¥ó§¨\033[31m(z)\033[30m«H¥ó§¨ \033[31m[G]\033[30mÄ~Äò?\033[0m" -#define MSG_SHORTULIST "\033[7m\ -¨Ï¥ÎªÌ¥N¸¹ ¥Ø«eª¬ºA ¢x¨Ï¥ÎªÌ¥N¸¹ ¥Ø«eª¬ºA ¢x¨Ï¥ÎªÌ¥N¸¹ ¥Ø«eª¬ºA \033[0m" +ANSI_COLOR(34;46) " ÂE¶­©¹ªð " ANSI_COLOR(31;47) "(R)" ANSI_COLOR(30) "¦^«H" ANSI_COLOR(31) "(x)" ANSI_COLOR(30) "Âà¹F\ +" ANSI_COLOR(31) "(y)" ANSI_COLOR(30) "¸s²Õ¦^«H" ANSI_COLOR(31) "(D)" ANSI_COLOR(30) "§R°£\ +" ANSI_COLOR(31) "(c)" ANSI_COLOR(30) "¦¬¤J«H¥ó§¨" ANSI_COLOR(31) "(z)" ANSI_COLOR(30) "«H¥ó§¨ " ANSI_COLOR(31) "[G]" ANSI_COLOR(30) "Ä~Äò?" ANSI_COLOR(0) "" +#define MSG_SHORTULIST ANSI_COLOR(7) "\ +¨Ï¥ÎªÌ¥N¸¹ ¥Ø«eª¬ºA ¢x¨Ï¥ÎªÌ¥N¸¹ ¥Ø«eª¬ºA ¢x¨Ï¥ÎªÌ¥N¸¹ ¥Ø«eª¬ºA " ANSI_COLOR(0) "" #define STR_AUTHOR1 "§@ªÌ:" diff --git a/include/config.h b/include/config.h index ec6b6f9c..e2b66931 100644 --- a/include/config.h +++ b/include/config.h @@ -74,7 +74,7 @@ #endif #ifndef TITLE_COLOR -#define TITLE_COLOR "\033[0;1;37;46m" +#define TITLE_COLOR ANSI_COLOR(0;1;37;46) #endif #ifndef SYSLOG_FACILITY 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" - " ¢~¢w¢s¢w¢s¢w¢s¢w¢s¢w¢s¢w¢s¢w¢s¢w¢¡\n" - " ¢x¡´¢x¡´¢x¡´¢x¡´¢x¡´¢x¡´¢x¡´¢x¡´¢x\n" - " ¢u¢w¢q¢w¢q¢w¢q¢w¢q¢w¢q¢w¢q¢w¢q¢w¢t\n" - " ¢x¡´¢x¡´¢x¡´¢x¡´¢x¡´¢x¡´¢x¡´¢x¡´¢x\n" - " ¢u¢w¢q¢w¢q¢w¢q¢w¢q¢w¢q¢w¢q¢w¢q¢w¢t\n" - " ¢x¡´¢x¡´¢x¡´¢x¡´¢x¡´¢x¡´¢x¡´¢x¡´¢x\n" - " ¢u¢w¢q¢w¢q¢w¢q¢w¢q¢w¢q¢w¢q¢w¢q¢w¢t\n" - " ¢x¡´¢x¡´¢x¡´¢x¡´¢x¡´¢x¡´¢x¡´¢x¡´¢x\n" - " ¢¢¢w¢r¢w¢r¢w¢r¢w¢r¢w¢r¢w¢r¢w¢r¢w¢£\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, " ¡»§A¬O¥ý¤â"); - mouts(22, 0, " ¡»½ü¨ì§A¤U¤F"); + 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, " ¡»§A¬O«á¤â"); + mouts(21, 0, " " ANSI_COLOR(1;33) "¡»" ANSI_COLOR(1;37) "§A¬O«á¤â" ANSI_RESET); } move(12, 3); - prints("%s[0³Ó0±Ñ]¢þ¢û.%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" - " ¢®¢¬¥\\¯àªí¢­¢®¢­¢¬¢®¢­\n" - " ¢¬ ¡ô¡ö¡õ¡÷: ²¾°Ê\n" - " ¢® ¢û:  ¿ï¤l,½¤l\n" - " ¢¬ enter:  ¦Y´Ñ,©ñ´Ñ\n" - "¡@¤w¸g¸Ñ¨Mªº:¡@¡@ ¢® ¢ø:  ¦X´Ñ\n" - " ¡@¡@ ¢¬ ¢ù:  »{¿é\n" - " ¢® ¢ë:  ´«Ãä"); + " " 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, " ¡»½ü¨ì§A¤U¤F"); + 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¡»§A«ù¬õ¦â´Ñ\033[m" : " \033[1;33m¡»§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¡»§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¡»§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¡»§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(" ¡»½ü¨ì%s¤U §O©È§O©È ¥LºâÔ£¦Ì", 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(" ¡»½ü¨ì%s¤U §O©È§O©È ¥LºâÔ£¦Ì", 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("§AŤF.. ¯u¬O®¥³ß~~"); + outs(ANSI_COLOR(1;31) "§AŤF.. ¯u¬O®¥³ß~~" ANSI_RESET); } else { move(22, 0); clrtoeol(); - outs("¿é±¼¤F°Õ.....¤U¦¸Åý¥L¦n¬Ý!!"); + outs(ANSI_COLOR(1;31) "¿é±¼¤F°Õ.....¤U¦¸Åý¥L¦n¬Ý!!" ANSI_RESET); } break; case -3: - mouts(22, 0, "¦X´Ñ­ò!! ¤U¦¸¦b¤À°ª¤U§a ^_^"); + 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" diff --git a/mbbsd/go.c b/mbbsd/go.c index 0f2274f0..9cf1e0ac 100644 --- a/mbbsd/go.c +++ b/mbbsd/go.c @@ -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(" ¥´ÃÐ  (¡ö¡ô¡õ¡÷)²¾°Ê (ªÅ¥ÕÁä/ENTER)¤U¤l (u)¦^¤W¤@¨B \033[31m(z)\033[30mÂ÷¶} "); + outmsg(" ¥´ÃÐ  (¡ö¡ô¡õ¡÷)²¾°Ê (ªÅ¥ÕÁä/ENTER)¤U¤l (u)¦^¤W¤@¨B " ANSI_COLOR(31) "(z)" ANSI_COLOR(30) "Â÷¶} "); 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\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; diff --git a/mbbsd/io.c b/mbbsd/io.c index 26201c7c..414ac3f7 100644 --- a/mbbsd/io.c +++ b/mbbsd/io.c @@ -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; // --------------------------------------------- // --------------------------- + +/* 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»Ä²¢­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) "»Ä²¢­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(); -- cgit v1.2.3