diff options
author | piaip <piaip@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2008-01-06 12:35:16 +0800 |
---|---|---|
committer | piaip <piaip@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2008-01-06 12:35:16 +0800 |
commit | ea71bde6b0addb910454451a969e2cfeca14eb4d (patch) | |
tree | 823a5287668cc1c0fd3fdbb23e5e205b48a6108d /mbbsd | |
parent | 312ac55f526f388f6154c9861f232659d348aae2 (diff) | |
download | pttbbs-ea71bde6b0addb910454451a969e2cfeca14eb4d.tar pttbbs-ea71bde6b0addb910454451a969e2cfeca14eb4d.tar.gz pttbbs-ea71bde6b0addb910454451a969e2cfeca14eb4d.tar.bz2 pttbbs-ea71bde6b0addb910454451a969e2cfeca14eb4d.tar.lz pttbbs-ea71bde6b0addb910454451a969e2cfeca14eb4d.tar.xz pttbbs-ea71bde6b0addb910454451a969e2cfeca14eb4d.tar.zst pttbbs-ea71bde6b0addb910454451a969e2cfeca14eb4d.zip |
- mail: prevent false alerts more carefully
- pfterm: add getmaxyx
- bbslua: change format detection and API refine
- var/mode: string fix
git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@3796 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
Diffstat (limited to 'mbbsd')
-rw-r--r-- | mbbsd/bbs.c | 12 | ||||
-rw-r--r-- | mbbsd/bbslua.c | 92 | ||||
-rw-r--r-- | mbbsd/mail.c | 1 | ||||
-rw-r--r-- | mbbsd/pfterm.c | 10 | ||||
-rw-r--r-- | mbbsd/var.c | 14 |
5 files changed, 96 insertions, 33 deletions
diff --git a/mbbsd/bbs.c b/mbbsd/bbs.c index 936267b8..0bc8f1fe 100644 --- a/mbbsd/bbs.c +++ b/mbbsd/bbs.c @@ -3690,18 +3690,18 @@ const onekey_t read_comms[] = { { 1, edit_post }, // 'E' { 0, NULL }, // 'F' { 0, NULL }, // 'G' - { 0, b_moved_to_config }, // 'H' + { 0, NULL }, // 'H' { 0, b_config }, // 'I' #ifdef USE_COOLDOWN { 0, change_cooldown }, // 'J' #else { 0, NULL }, // 'J' #endif - { 0, b_moved_to_config }, // 'K' + { 0, NULL }, // 'K' { 1, solve_post }, // 'L' { 0, b_vote_maintain }, // 'M' { 0, NULL }, // 'N' - { 0, b_moved_to_config }, // 'O' + { 0, NULL }, // 'O' { 0, NULL }, // 'P' { 1, view_postinfo }, // 'Q' { 0, b_results }, // 'R' @@ -3726,13 +3726,13 @@ const onekey_t read_comms[] = { #endif { 1, good_post }, // 'g' { 0, b_help }, // 'h' - { 0, b_moved_to_config }, // 'i' + { 0, b_config }, // 'i' { 0, NULL }, // 'j' { 0, NULL }, // 'k' { 0, NULL }, // 'l' { 1, mark_post }, // 'm' { 0, NULL }, // 'n' - { 0, b_moved_to_config }, // 'o' + { 0, NULL }, // 'o' { 0, NULL }, // 'p' { 0, NULL }, // 'q' { 1, read_post }, // 'r' @@ -3743,7 +3743,7 @@ const onekey_t read_comms[] = { #else { 0, NULL }, // 'u' #endif - { 0, b_moved_to_config }, // 'v' + { 0, NULL }, // 'v' { 1, b_call_in }, // 'w' { 1, cross_post }, // 'x' { 1, reply_post }, // 'y' diff --git a/mbbsd/bbslua.c b/mbbsd/bbslua.c index 2a1096fb..0fb4ac54 100644 --- a/mbbsd/bbslua.c +++ b/mbbsd/bbslua.c @@ -25,7 +25,7 @@ #define BBSLUA_VERSION_MAJOR (0) #define BBSLUA_VERSION_MINOR (1) #define BBSLUA_VERSION_STR "0.01" -#define BBSLUA_SIGNATURE "-- BBSLUA" +#define BBSLUA_SIGNATURE "--#BBSLUA" #define BBSLUA_EOFSIGNATURE "--\n" ////////////////////////////////////////////////////////////////////////// @@ -57,6 +57,14 @@ bl_getyx(lua_State* L) } BLAPI_PROTO +bl_getmaxyx(lua_State* L) +{ + lua_pushinteger(L, t_lines); + lua_pushinteger(L, t_columns); + return 2; +} + +BLAPI_PROTO bl_move(lua_State* L) { int n = lua_gettop(L); @@ -70,6 +78,23 @@ bl_move(lua_State* L) } BLAPI_PROTO +bl_moverel(lua_State* L) +{ + int n = lua_gettop(L); + int y = 0, x = 0; + getyx(&y, &x); + if (n > 0) + y += lua_tointeger(L, 1); + if (n > 1) + x += lua_tointeger(L, 2); + move(y, x); + getyx(&y, &x); + lua_pushinteger(L, y); + lua_pushinteger(L, x); + return 2; +} + +BLAPI_PROTO bl_clear(lua_State* L) { clear(); @@ -152,7 +177,7 @@ bl_k2s(lua_State* L, int v) } BLAPI_PROTO -bl_igetch(lua_State* L) +bl_getch(lua_State* L) { int c = igetch(); if (c == BLCONF_BREAK_KEY) @@ -166,7 +191,7 @@ bl_igetch(lua_State* L) BLAPI_PROTO -bl_getdata(lua_State* L) +bl_getstr(lua_State* L) { int y, x; char buf[PATHLEN] = ""; @@ -192,7 +217,7 @@ bl_getdata(lua_State* L) } BLAPI_PROTO -bl_vmsg(lua_State* L) +bl_pause(lua_State* L) { int n = lua_gettop(L); const char *s = NULL; @@ -210,7 +235,7 @@ bl_vmsg(lua_State* L) } BLAPI_PROTO -bl_stand_title(lua_State* L) +bl_title(lua_State* L) { int n = lua_gettop(L); const char *s = NULL; @@ -243,6 +268,21 @@ bl_ansi_color(lua_State *L) return 1; } +BLAPI_PROTO +bl_attrset(lua_State *L) +{ + char buf[PATHLEN] = ESC_STR "["; + char *p = buf + strlen(buf); + int i = 1; + int n = lua_gettop(L); + for (i = 1; i <= n; i++) + { + sprintf(p, "%dm",(int)lua_tointeger(L, i)); + outs(buf); + } + return 0; +} + ////////////////////////////////////////////////////////////////////////// // BBSLUA LIBRARY ////////////////////////////////////////////////////////////////////////// @@ -250,26 +290,29 @@ bl_ansi_color(lua_State *L) static const struct luaL_reg lib_bbslua [] = { /* curses output */ { "getyx", bl_getyx }, + { "getmaxyx", bl_getmaxyx }, { "move", bl_move }, + { "moverel", bl_moverel }, { "clear", bl_clear }, { "clrtoeol", bl_clrtoeol }, { "clrtobot", bl_clrtobot }, { "refresh", bl_refresh }, { "redrawwin", bl_redrawwin }, - { "addch", bl_addstr }, + // { "addch", bl_addstr }, { "addstr", bl_addstr }, - { "outc", bl_addstr }, + // { "outc", bl_addstr }, { "outs", bl_addstr }, /* input */ - { "getch", bl_igetch }, - { "igetch", bl_igetch }, - { "getdata", bl_getdata }, + { "getch", bl_getch }, + { "getdata", bl_getstr }, + { "getstr", bl_getstr }, /* BBS utilities */ - { "vmsg", bl_vmsg }, - { "pause", bl_vmsg }, - { "stand_title",bl_stand_title }, + { "pause", bl_pause }, + { "title", bl_title }, /* ANSI helpers */ { "ANSI_COLOR", bl_ansi_color }, + { "color", bl_attrset }, + { "attrset", bl_attrset }, { NULL, NULL}, }; @@ -319,7 +362,7 @@ bbsluaHook(lua_State *L, lua_Debug* ar) } static char * -bbslua_mmap(const char *fpath, int *plen) +bbslua_attach(const char *fpath, int *plen) { struct stat st; int fd = open(fpath, O_RDONLY, 0600); @@ -348,6 +391,12 @@ bbslua_mmap(const char *fpath, int *plen) return buf; } +static void +bbslua_detach(char *p, int len) +{ + munmap(p, len); +} + int bbslua_detect_range(char **pbs, char **pbe) { @@ -420,7 +469,7 @@ bbslua(const char *fpath) int sz = 0; // detect file - bs = bbslua_mmap(fpath, &sz); + bs = bbslua_attach(fpath, &sz); if (!bs) return 0; ps = bs; @@ -429,7 +478,7 @@ bbslua(const char *fpath) if(!bbslua_detect_range(&ps, &pe)) { // not detected - munmap(bs, sz); + bbslua_detach(bs, sz); return 0; } @@ -441,7 +490,7 @@ bbslua(const char *fpath) r = luaL_loadbuffer(L, ps, pe-ps, "BBS-Lua"); // unmap - munmap(bs, sz); + bbslua_detach(bs, sz); if (r != 0) { @@ -457,12 +506,13 @@ bbslua(const char *fpath) // prompt user grayout(0, b_lines, GRAYOUT_DARK); move(b_lines-2, 0); clrtobot(); - outs("\n"ANSI_COLOR(1;33;41) - "請按任意鍵開始執行 BBS-Lua 程式。 執行中您可隨時按下 Ctrl-C 強制中斷。" - ANSI_RESET); + prints("\n" ANSI_COLOR(1;33;41) "%-*s" ANSI_RESET, + t_columns-1, + "請按任意鍵開始執行 BBS-Lua 程式。執行中可隨時按下 Ctrl-C 強制中斷。" + ); setutmpmode(UMODE_BBSLUA); - vmsg(" BBS-Lua " BBSLUA_VERSION_STR ); + vmsg(" BBS-Lua v" BBSLUA_VERSION_STR " (" __DATE__ " " __TIME__")"); // ready for running clear(); diff --git a/mbbsd/mail.c b/mbbsd/mail.c index a9f4f9d7..972f37c3 100644 --- a/mbbsd/mail.c +++ b/mbbsd/mail.c @@ -1154,6 +1154,7 @@ mail_read_all(int ent, fileheader_t * fhdr, const char *direct) int fd = 0; fileheader_t xfhdr; + currutmp->alerts &= ~ALERT_NEW_MAIL; if ((fd = open(currmaildir, O_RDWR)) < 0) return DONOTHING; diff --git a/mbbsd/pfterm.c b/mbbsd/pfterm.c index 11a4d66c..df0ecb29 100644 --- a/mbbsd/pfterm.c +++ b/mbbsd/pfterm.c @@ -299,6 +299,7 @@ void attrsetbg (ftattr attr); // cursor void getyx (int *y, int *x); +void getmaxyx (int *y, int *x); void move (int y, int x); // clear @@ -888,6 +889,15 @@ getyx(int *y, int *x) } void +getmaxyx(int *y, int *x) +{ + if (y) + *y = ft.rows; + if (x) + *x = ft.cols; +} + +void move(int y, int x) { y = ranged(y, 0, ft.rows-1); diff --git a/mbbsd/var.c b/mbbsd/var.c index 17dd550b..cf0f22fa 100644 --- a/mbbsd/var.c +++ b/mbbsd/var.c @@ -183,7 +183,7 @@ char * const BBSName = BBSNAME; /* MAX_MODES is defined in common.h */ -char * const ModeTypeTable[MAX_MODES] = { +char * const ModeTypeTable[] = { "發呆", /* IDLE */ "主選單", /* MMENU */ "系統維護", /* ADMIN */ @@ -248,7 +248,7 @@ char * const ModeTypeTable[MAX_MODES] = { "玩彩券", /* TICKET */ "猜數字", /* GUESSNUM */ "遊樂場", /* AMUSE */ - "黑白棋", /* OTHELLO */ + "單人黑白棋", /* OTHELLO */ "玩骰子", /* DICE */ "發票對獎", /* VICE */ "逼逼摳ing", /* BBCALL */ @@ -270,12 +270,11 @@ char * const ModeTypeTable[MAX_MODES] = { "[系統錯誤]", /* DEBUGSLEEPING */ "連六棋", /* UMODE_CONN6 */ "黑白棋", /* REVERSI */ - "BBSLUA", /* UMODE_BBSLUA */ - "", - "", - "", + "BBS-Lua", /* UMODE_BBSLUA */ + "播放動畫", /* UMODE_ASCIIMOVIE */ "", "", + "", // 90 "", "", "", @@ -285,6 +284,7 @@ char * const ModeTypeTable[MAX_MODES] = { "", "", "", + "", // 100 "", "", "", @@ -294,6 +294,7 @@ char * const ModeTypeTable[MAX_MODES] = { "", "", "", + "", // 110 "", "", "", @@ -303,6 +304,7 @@ char * const ModeTypeTable[MAX_MODES] = { "", "", "", + "", // 120 "", "", "", |