diff options
author | piaip <piaip@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2005-06-08 10:46:24 +0800 |
---|---|---|
committer | piaip <piaip@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2005-06-08 10:46:24 +0800 |
commit | a0f8ef1e2e04905908478088fc376435b770417c (patch) | |
tree | a96bd4096703e5d0bb0b9fe7c9499d0db7768070 /include | |
parent | f55eaef82ab265772418a545f32fa2780468603b (diff) | |
download | pttbbs-a0f8ef1e2e04905908478088fc376435b770417c.tar pttbbs-a0f8ef1e2e04905908478088fc376435b770417c.tar.gz pttbbs-a0f8ef1e2e04905908478088fc376435b770417c.tar.bz2 pttbbs-a0f8ef1e2e04905908478088fc376435b770417c.tar.lz pttbbs-a0f8ef1e2e04905908478088fc376435b770417c.tar.xz pttbbs-a0f8ef1e2e04905908478088fc376435b770417c.tar.zst pttbbs-a0f8ef1e2e04905908478088fc376435b770417c.zip |
New style to specify ANSI escape commands.
First introduced by pmore, but this hard work
(to transform all files to new style) is made by
Rong-en Fan (rafan). Thanks!
git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@2796 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
Diffstat (limited to 'include')
-rw-r--r-- | include/ansi.h | 25 | ||||
-rw-r--r-- | include/bbs.h | 1 | ||||
-rw-r--r-- | include/chc.h | 10 | ||||
-rw-r--r-- | include/common.h | 26 | ||||
-rw-r--r-- | include/config.h | 2 |
5 files changed, 45 insertions, 19 deletions
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 "取消刪除" -#define MSG_SELECT_BOARD "\033[7m【 選擇看板 】\033[m\n" \ +#define MSG_SELECT_BOARD ANSI_COLOR(7) "【 選擇看板 】" ANSI_RESET "\n" \ "請輸入看板名稱(按空白鍵自動搜尋):" #define MSG_CLOAKED "哈哈!我隱形了!看不到勒... :P" #define MSG_UNCLOAK "我要重現江湖了...." @@ -46,13 +46,13 @@ #define MSG_PLANT "植物也有性別喔.." #define MSG_MIME "礦物總沒性別了吧" #define MSG_PASSWD "請輸入您的密碼: " -#define MSG_POSTER "\033[34;46m 文章選讀 "\ - "\033[31;47m (y)\033[30m回信 "\ - "\033[31m(=[]<>)\033[30m相關主題 "\ - "\033[31m(/?)\033[30m搜尋標題 "\ - "\033[31m(aA)\033[30m搜尋作者 "\ - "\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) "回信 "\ + ANSI_COLOR(31) "(=[]<>)" ANSI_COLOR(30) "相關主題 "\ + ANSI_COLOR(31) "(/?)" ANSI_COLOR(30) "搜尋標題 "\ + ANSI_COLOR(31) "(aA)" ANSI_COLOR(30) "搜尋作者 "\ + ANSI_COLOR(31) "(x)" ANSI_COLOR(30) "轉錄 "\ + ANSI_COLOR(31) "(V)" ANSI_COLOR(30) "投票 " ANSI_RESET #define MSG_SEPERATOR "\ ───────────────────────────────────────" @@ -99,11 +99,11 @@ #define ERR_PASSWD "密碼不對喔!你有沒有冒用人家的名字啊?" #define ERR_FILENAME "檔名不合法!" #define MSG_MAILER \ -"\033[34;46m 鴻雁往返 \033[31;47m(R)\033[30m回信\033[31m(x)\033[30m轉達\ -\033[31m(y)\033[30m群組回信\033[31m(D)\033[30m刪除\ -\033[31m(c)\033[30m收入信件夾\033[31m(z)\033[30m信件夾 \033[31m[G]\033[30m繼續?\033[0m" -#define MSG_SHORTULIST "\033[7m\ -使用者代號 目前狀態 │使用者代號 目前狀態 │使用者代號 目前狀態 \033[0m" +ANSI_COLOR(34;46) " 鴻雁往返 " ANSI_COLOR(31;47) "(R)" ANSI_COLOR(30) "回信" ANSI_COLOR(31) "(x)" ANSI_COLOR(30) "轉達\ +" ANSI_COLOR(31) "(y)" ANSI_COLOR(30) "群組回信" ANSI_COLOR(31) "(D)" ANSI_COLOR(30) "刪除\ +" ANSI_COLOR(31) "(c)" ANSI_COLOR(30) "收入信件夾" ANSI_COLOR(31) "(z)" ANSI_COLOR(30) "信件夾 " ANSI_COLOR(31) "[G]" ANSI_COLOR(30) "繼續?" ANSI_COLOR(0) "" +#define MSG_SHORTULIST ANSI_COLOR(7) "\ +使用者代號 目前狀態 │使用者代號 目前狀態 │使用者代號 目前狀態 " 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 |