From 4c520550cca32522e89fe01e2e0d3d172ed6b86d Mon Sep 17 00:00:00 2001 From: piaip Date: Tue, 15 Apr 2008 02:04:38 +0000 Subject: - bbs: fix utmp_brcid out-of-sync on 's' select. - visio: change unified handle (VSOREF) to typed ref, and utilize new APIs git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@4165 63ad8ddf-47c3-0310-b6dd-a9e9d9715204 --- mbbsd/visio.c | 43 +++++++++++++++++++++++++++++-------------- 1 file changed, 29 insertions(+), 14 deletions(-) (limited to 'mbbsd/visio.c') diff --git a/mbbsd/visio.c b/mbbsd/visio.c index 59a69c2e..b4845f59 100644 --- a/mbbsd/visio.c +++ b/mbbsd/visio.c @@ -27,6 +27,11 @@ #define SAFE_MAX_COL (MAX_COL-1) #define VBUFLEN (ANSILINELEN) +// this is a special strlen to speed up processing. +// warning: x MUST be #define x "msg". +// otherwise you need to use real strlen. +#define MACROSTRLEN(x) (sizeof(x)-1) + // ---- UTILITIES ---------------------------------------------------- inline void outnc(int n, unsigned char c) @@ -41,17 +46,12 @@ nblank(int n) outnc(n, ' '); } -// this is a special strlen to speed up processing. -// warning: x MUST be #define x "msg". -// otherwise you need to use real strlen. -#define MACROSTRLEN(x) (sizeof(x)-1) - -// ---- VSOREF API -------------------------------------------------- +// ---- VREF API -------------------------------------------------- /** * vscr_save(): 傳回目前畫面的備份物件。 */ -VSOREF +VREFSCR vscr_save(void) { // TODO optimize memory allocation someday. @@ -65,9 +65,9 @@ vscr_save(void) * vscr_restore(obj): 使用並刪除畫面的備份物件。 */ void -vscr_restore(VSOREF obj) +vscr_restore(VREFSCR obj) { - screen_backup_t *o = (screen_backup_t*)o; + screen_backup_t *o = (screen_backup_t*)obj; if (o) { scr_restore(o); @@ -79,24 +79,25 @@ vscr_restore(VSOREF obj) /** * vcur_save(): 傳回目前游標的備份物件。 */ -VSOREF +VREFCUR vcur_save(void) { // XXX 偷懶不 new object 了, pointer 夠大 int y, x; + VREFCUR v; getyx(&y, &x); - y = ((unsigned short)y << 16) | (unsigned short)x; - return (VSOREF)NULL + y; + v = ((unsigned short)y << 16) | (unsigned short)x; + return v; } /** * vcur_restore(obj): 使用並刪除游標的備份物件。 */ void -vcur_restore(VSOREF o) +vcur_restore(VREFCUR o) { int y, x; - y = (unsigned int)(o - NULL); + y = (unsigned int)(o); x = (unsigned short)(y & 0xFFFF); y = (unsigned short)(y >> 16); move(y, x); @@ -124,6 +125,20 @@ vpad(int n, const char *pattern) if (n) nblank(n); } +/** + * vgety(): 取得目前所在位置的行數 + * + * 考慮到 ANSI 系統,getyx() 較為少用且危險。 + * vgety() 安全而明確。 + */ +inline int +vgety(void) +{ + int y, x; + getyx(&y, &x); + return y; +} + // ---- HIGH LEVEL API ----------------------------------------------- /** -- cgit v1.2.3