作者cache.bbs@cpu.tfcis.org (Gphone實驗室) 看板: itoc
標題[功能] patch PTT 上的 pfterm (piaip's flat terminal, Perfect Term)
時間動力核心 (2009/10/29 Thu 21:15:55)
關於 pfterm 請詳見作者 piaip 長輩寫的說明
https://opensvn.csie.org/pttbbs/trunk/pttbbs/docs/pfterm.txt
這個 patch 可能還有一些未完善的地方
希望長輩們和板友可以指導 <(_"_)>
author: hrs113355.bbs <AT> xdbbs.twbbs.org
cache.bbs <AT> bbs.ee.ncku.edu.tw
感謝 dust.bbs <AT> bbs.tcfsh.tc.edu.tw 協助測試
首先請到 PTT 的 svn 下載 pfterm.c ( http://opensvn.csie.org/pttbbs )
或者是 https://opensvn.csie.org/NCKUEEBBS/bbs/src/maple/pfterm.c
並且將這個檔案放到 maple/ 底下
接著把 maple/maple.p 這個檔案備份起來
以下是要修改的地方:
game/bwboard.c main_board()
int sock, later;
{
+#ifdef M3_USE_PFTERM
+ screen_backup_t old_screen;
+#else
screenline sl[T_LINES];
+#endif
char c;
int ch;
KeyFunc *k;
+#ifdef M3_USE_PFTERM
+ scr_dump(&old_screen);
+#else
vs_save(sl);
+#endif
cfd = sock;
...
else
{
c = -1;
+#ifdef M3_USE_PFTERM
+ scr_restore(&old_screen); // restore foot
+#else
vs_restore(sl); /* lkchu.990428: 把 foot restore 回來 */
+#endif
}
/* transmit rule set */
if (send(cfd, &c, 1, 0) != 1)
...
/* receive rule set */
if (recv(cfd, &c, 1, 0) != 1)
return DISCONNECT;
+#ifdef M3_USE_PFTERM
+ scr_restore(&old_screen); // restore foot
+#else
vs_restore(sl); /* lkchu.990428: 把 foot restore 回來 */
+#endif
/* 被啟動遊戲者為紅(白)子 */
myColor = White; /* White == Red */
...
if (ch >= NOTHING) /* -1 for exit bwboard, -2 for exit talk */
continue;
+#ifdef M3_USE_PFTERM
+ scr_restore(&old_screen); // restore foot
+#else
vs_restore(sl);
+#endif
return ch;
}
#ifdef EVERY_Z
/* Thor: Chat 中按 ctrl-z */
...
screenline slt[T_LINES];
/* Thor.980731: 暫存 mateid, 因為出去時可能會用掉 mateid */
strcpy(buf, cutmp->mateid);
+#ifdef M3_USE_PFTERM
+ vio_save();
+ scr_dump(&old_screen);
+ every_Z(0);
+ scr_restore(&old_screen);
+ vio_restore();
+#else
vio_save(); /* Thor.980727: 暫存 vio_fd */
vs_save(slt);
every_Z(0);
vs_restore(slt);
vio_restore(); /* Thor.980727: 還原 vio_fd */
+#endif
/* Thor.980731: 還原 mateid, 因為出去時可能會用掉 mateid */
strcpy(cutmp->mateid, buf);
...
if ((ch = k->key ? (*k->func) () : (*k->func) (ch)) >= NOTHING)
continue;
+#ifdef M3_USE_PFTERM
+ scr_restore(&old_screen); // restore foot
+#else
vs_restore(sl);
+#endif
return ch;
}
}
#include <stdarg.h>
int
vaBWboard(pvar)
include/config.h
+#define M3_USE_PFTERM /* cache.091003: patch piaip's flat terminal system */
include/global.h
+/* ----------------------------------------------------- */
+/* Register Form Log */
+/* ----------------------------------------------------- */
+#define RFORM_PASS (0)
+#define RFORM_NOPASS (1)
+#define RFORM_DEL (2)
+#define RFORM_CANCELREG (3)
+
+/* ----------------------------------------------------- */
+/* Grayout Levels */
+/* ----------------------------------------------------- */
+#define GRAYOUT_COLORBOLD (-2)
+#define GRAYOUT_BOLD (-1)
+#define GRAYOUT_DARK (0)
+#define GRAYOUT_NORM (1)
+#define GRAYOUT_COLORNORM (+2)
include/struct.h
+/* ----------------------------------------------------- */
+/* M3_USE_PFTERM */
+/* ----------------------------------------------------- */
+
+typedef struct {
+ int row, col;
+ int y, x;
+ void *raw_memory;
+} screen_backup_t;
include/theme.h
+//for M3_USE_PFTERM
+#define FILEDFG (0)
+#define FILEDBG (7)
maple/Makefile
SRC = acct.c bbsd.c bmw.c board.c cache.c edit.c favor.c \
gem.c mail.c menu.c more.c pal.c post.c talk.c ulist.c \
! user.c visio.c window.c xover.c xpost.c pfterm.c
OBJ = acct.o bbsd.o bmw.o board.o cache.o edit.o favor.o \
gem.o mail.o menu.o more.o pal.o post.o talk.o ulist.o \
! user.o visio.o window.o xover.o xpost.o pfterm.o
maple/bbsd.c term_init()
char buf[64], *rcv;
struct timeval to;
+#ifdef M3_USE_PFTERM
+ initscr();
+#endif
/* 問對方 (telnet client) 有沒有支援不同的螢幕寬高 */
send(0, svr, 3, 0);
...
b_cols = 79;
}
+#ifdef M3_USE_PFTERM
+ resizeterm(b_lines + 1, b_cols + 1) ;
+#endif
d_cols = b_cols - 79;
}
maple/bmw.c bmw_edit()
char *hint;
BMW *bmw;
{
int recver;
+#ifdef M3_USE_PFTERM
+ screen_backup_t old_screen;
+#else
screenline slp[3];
+#endif
char *userid, fpath[64];
FILE *fp;
if (bbsmode != M_BMW_REPLY) /* 若是 reply 的話,會自行處理畫面重繪 */
+#ifdef M3_USE_PFTERM
+ scr_dump(&old_screen);
+#else
save_foot(slp);
+#endif
recver = up ? up->userno : 0;
bmw->msg[0] = '\0';
for (;;)
{
int ch;
BMW *benz;
ch = vget(0, 0, hint, bmw->msg, 62, GCARRY);
if (!ch) /* 沒輸入東西 */
{
if (bbsmode != M_BMW_REPLY)
+#ifdef M3_USE_PFTERM
+ scr_restore(&old_screen);
+#else
restore_foot(slp, 1);
+#endif
return;
}
if (ch != Ctrl('R') && ch != Ctrl('T')) /* 完成水球輸入 */
...
{
vmsg(MSG_USR_LEFT);
if (bbsmode != M_BMW_REPLY)
+#ifdef M3_USE_PFTERM
+ scr_restore(&old_screen);
+#else
restore_foot(slp, 2);
+#endif
return;
}
/* lkchu.990103: 若是自己送出的水球,存對方的 userid */
...
}
if (bbsmode != M_BMW_REPLY)
+#ifdef M3_USE_PFTERM
+ scr_dump(&old_screen);
+#else
restore_foot(slp, 2);
+#endif
}
maple/bmw.c bmw_reply_CtrlRT()
#ifdef BMW_DISPLAY
if (cuser.ufo & UFO_BMWDISPLAY)
{
+#ifdef M3_USE_PFTERM
+ attrsetfg(7);
+ attrsetbg(0);
+#endif
move(2 + max - pos, 0);
outc(' ');
maple/bmw.c bmw_reply()
void
bmw_reply()
{
int max, display, tmpmode;
char buf[128];
UTMP *up;
BMW bmw;
+#ifdef M3_USE_PFTERM
+ screen_backup_t old_screen;
+#else
#ifdef BMW_DISPLAY
screenline slt[T_LINES];
#else
screenline slt[3];
#endif
+#endif
cursor_save();
max = bmw_locus - 1;
+#ifdef M3_USE_PFTERM
+ if (!(up = bmw_lastslot(max)))
+ {
+ scr_dump(&old_screen);
+ vmsg("先前並無水球呼叫,或對方皆已下站");
+ scr_restore(&old_screen);
+ cursor_restore();
+ refresh();
+ return;
+ }
+#else
if (!(up = bmw_lastslot(max)))
{
save_foot(slt);
vmsg("先前並無水球呼叫,或對方皆已下站");
restore_foot(slt, 2);
cursor_restore();
refresh();
return;
}
+#endif
tmpmode = bbsmode; /* lkchu.981201: 儲存 bbsmode */
utmp_mode(M_BMW_REPLY);
#ifdef BMW_DISPLAY
display = cuser.ufo & UFO_BMWDISPLAY;
if (display)
{
+#ifdef M3_USE_PFTERM
+ scr_dump(&old_screen);
+#else
vs_save(slt); /* itoc.010313: 記錄 bmd_display 之前的 screen */
+#endif
bmw_display(max); /* itoc.010313: display 以前的水球 */
move(2 + max - bmw_pos, 0);
outc('>');
bmw_request = 0;
}
else
#endif
+#ifdef M3_USE_PFTERM
+ scr_dump(&old_screen);
+#else
save_foot(slt);
+#endif
bmw_outz();
sprintf(buf, "★[%s]", up->userid);
bmw_edit(up, buf, &bmw);
#ifdef BMW_DISPLAY
if (display)
{
cursor_restore();
+#ifdef M3_USE_PFTERM
+ scr_restore(&old_screen);
+#else
vs_restore(slt); /* itoc.010313: 還原 bmw_display 之前的 screen */
+#endif
}
else
#endif
{
+#ifdef M3_USE_PFTERM
+ scr_restore(&old_screen);
+#else
restore_foot(slt, 3); /* 已 bmw_outz,要還原三列 */
+#endif
cursor_restore();
refresh();
}
utmp_mode(tmpmode); /* lkchu.981201: 回復 bbsmode */
}
maple/bmw.c do_write()
void
do_write(up)
UTMP *up;
{
+#ifdef M3_USE_PFTERM
+ screen_backup_t old_screen;
+#endif
if (can_override(up))
{
BMW bmw;
char buf[20];
+#ifdef M3_USE_PFTERM
+ scr_dump(&old_screen);
+ sprintf(buf, "★[%s]", up->userid);
+ bmw_edit(up, buf, &bmw);
+ scr_restore(&old_screen);
+#else
sprintf(buf, "★[%s]", up->userid);
bmw_edit(up, buf, &bmw);
+#endif
}
}
maple/maple.p
/* visio.c */
int is_zhc_low(char *str, int pos);
void prints(char *fmt, ...);
void bell(void);
-void move(int x, int y);
-void refresh(void);
-void clear(void);
-void clrtoeol(void);
-void clrtobot(void);
-void outc(int ch);
-void outs(uschar *str);
+void outl(int line, uschar *msg);
void outx(uschar *str);
void outz(uschar *str);
void outf(uschar *str);
-void scroll(void);
-void rscroll(void);
+void outr(uschar *str);
void cursor_save(void);
void cursor_restore(void);
-void save_foot(screenline *slp);
-void restore_foot(screenline *slp, int line);
-int vs_save(screenline *slp);
-void vs_restore(screenline *slp);
int vmsg(char *msg);
void zmsg(char *msg)
...
+//M3_USE_PFTERM
+/* I/O base */
+void oflush();
+void ochar(int ch);
+
+/* pfterm.c */
+// initialization
+void initscr (void);
+int resizeterm (int rows, int cols);
+int endwin (void);
+
+// cursor
+void getyx (int *y, int *x);
+void getmaxyx (int *y, int *x);
+void move (int y, int x);
+
+// clear
+void clear (void); // clrscr + move(0,0)
+void clrtoeol (void); // end of line
+void clrtobot (void);
+
+// clear (non-ncurses)
+void clrtoln (int ln); // clear down to ln ( excluding ln, as [y,ln) )
+
+void clrcurln (void); // whole line
+void clrtobeg (void); // begin of line
+void clrtohome (void);
+void clrscr (void); // clear and keep cursor untouched
+void clrregion (int r1, int r2); // clear [r1,r2], bi-directional.
+
+// window control
+void newwin (int nlines, int ncols, int y, int x);
+
+// flushing
+void refresh (void); // optimized refresh
+void doupdate (void); // optimized refresh, ignore input queue
+void redrawwin (void); // invalidate whole screen
+int typeahead (int fd);// prevent refresh if input queue is not empty
+
+// scrolling
+void scroll (void); // scroll up
+void rscroll (void); // scroll down
+void scrl (int rows);
+
+// output (ncurses flavor)
+void addch (unsigned char c); // equivalent to outc()
+void addstr (const char *s); // equivalent to outs()
+void addnstr (const char *s, int n);
+
+// output (non-ncurses)
+void outc (unsigned char c);
+void outs (const char *s);
+
+// grayout advanced control
+void grayout (int y, int end, int level);
+
+#define _FTDTYPE
+typedef unsigned char ftchar; // primitive character type
+typedef unsigned char ftattr; // primitive attribute type
+
+// attributes
+ftattr attrget (void);
+void attrset (ftattr attr);
+void attrsetfg (ftattr attr);
+void attrsetbg (ftattr attr);
maple/more.c re_key:
shift = 0; /* 重繪 footer */
}
else if (key == 'h')
{
+#ifdef M3_USE_PFTERM
+ screen_backup_t old_screen;
+#else
screenline slt[T_LINES];
+#endif
uschar *tmp_fimage;
uschar *tmp_fend;
uschar *tmp_foff;
off_t tmp_block[MAXBLOCK];
/* itoc.060420: 會進入第二次 more(),要把所有 static 宣告的都記錄下來 */
tmp_fimage = fimage;
tmp_fend = fend;
tmp_foff = foff;
memcpy(tmp_block, block, sizeof(tmp_block));
+#ifdef M3_USE_PFTERM
+ scr_dump(&old_screen);
+ xo_help("post");
+ scr_restore(&old_screen);
+#else
vs_save(slt);
xo_help("post");
vs_restore(slt);
+#endif
fimage = tmp_fimage;
fend = tmp_fend;
maple/talk.c talk_speak()
#ifdef EVERY_Z
/* Thor.980725: talk中, ctrl-z */
if (ch == Ctrl('Z'))
{
char buf[IDLEN + 1];
+#ifdef M3_USE_PFTERM
+ screen_backup_t old_screen;
+#else
screenline slt[T_LINES];
+#endif
/* Thor.980731: 暫存 mateid, 因為出去時可能會用掉 mateid */
strcpy(buf, cutmp->mateid);
vio_save(); /* Thor.980727: 暫存 vio_fd */
+#ifdef M3_USE_PFTERM
+ scr_dump(&old_screen);
+ every_Z(0);
+ scr_restore(&old_screen);
+ vio_restore(); /* Thor.980727: AU-i vio_fd */
+#else
vs_save(slt);
every_Z(0);
vs_restore(slt);
vio_restore(); /* Thor.980727: 還原 vio_fd */
+#endif
/* Thor.980731: 還原 mateid, 因為出去時可能會用掉 mateid */
strcpy(cutmp->mateid, buf);
maple/talk.c talk_rqst()
void
talk_rqst()
{
UTMP *up;
int mode, sock, ans, len, port;
char buf[80];
struct sockaddr_in sin;
+#ifdef M3_USE_PFTERM
+ screen_backup_t old_screen;
+#else
screenline sl[T_LINES];
+#endif
#if defined(__OpenBSD__)
struct hostent *h;
#endif
up = cutmp->talker;
if (!up)
return;
port = up->sockport;
if (!port)
return;
mode = bbsmode;
utmp_mode(M_TRQST);
+#ifdef M3_USE_PFTERM
+ scr_dump(&old_screen);
+#else
vs_save(sl);
+#endif
clear();
sprintf(page_requestor, "%s (%s)", up->userid, up->username);
...
talk_speak(sock);
}
}
close(sock);
#ifdef LOG_TALK
if (ans == 'y') /* mat.991011: 防止Talk被拒絕時,產生聊天記錄的record */
talk_save(); /* lkchu.981201: talk 記錄處理 */
#endif
+#ifdef M3_USE_PFTERM
+ scr_restore(&old_screen);
+#else
vs_restore(sl);
+#endif
utmp_mode(mode);
}
maple/visio.c
#define INPUT_ACTIVE 0
#define INPUT_IDLE 1
+#ifdef M3_USE_PFTERM
+#define STANDOUT attrsetbg(FILEDBG); attrsetfg(FILEDFG);
+// filed color (defined in theme.h)
+#define STANDEND attrsetbg(0); attrsetfg(7);
+// default color (\033[37;40m)
+#else
static int cur_row, cur_col;
static int cur_pos; /* current position with ANSI codes */
+#endif
/* ----------------------------------------------------- */
/* 漢字 (zh-char) 判斷 */
/* ----------------------------------------------------- */
...
#define telnet_flush(data, size) send(0, data, size, 0)
#endif
+#ifdef M3_USE_PFTERM
+void
+#else
static void
+#endif
oflush()
{
int size;
if (size = vo_size)
{
telnet_flush(vo_pool, size);
vo_size = 0;
}
}
+#ifndef M3_USE_PFTERM
static void
output(str, len)
uschar *str;
...
}
vo_size = size;
}
#endif
+#ifdef M3_USE_PFTERM
+void
+#else
static void
+#endif
ochar(ch)
int ch;
...
/* ----------------------------------------------------- */
/* virtual screen */
/* ----------------------------------------------------- */
+#ifndef M3_USE_PFTERM
#define o_ansi(x) output(x, sizeof(x)-1)
...
}
}
#endif
+#endif// ifndef M3_USE_PFTERM
+#ifdef M3_USE_PFTERM
+vs_redraw()
+{
+ redrawwin(); refresh(); return;
+}
+#else
static void
vs_redraw()
{
screenline *slp;
...
str++;
}
}
+#endif // ifdef M3_USE_PFTERM
/* ----------------------------------------------------- */
/* eXtended output: 秀出 user 的 name 和 nick */
/* ----------------------------------------------------- */
...
outs(str);
}
+#ifdef M3_USE_PFTERM
void
outf(str)
uschar *str;
{
outz(str);
prints("%*s\033[m", d_cols, "");
}
+
+void outl (int line, uschar *msg) /* line output */
+{
+ move (line, 0);
+ clrtoeol();
+
+
+ if (msg != NULL)
+ outs(msg);
+}
+
+#define ANSI_COLOR_CODE "[m;0123456789"
+#define ANSI_COLOR_END "m"
+
+void outr (uschar *str)
+/* restricted output (strip the ansiscreen contolling code only) */
+{
+ uschar ch, buf[256], *p = NULL;
+ int ansi = 0;
+
+ while (ch = *str++)
+ {
+ if (ch == KEY_ESC)
+ {
+ ansi = 1;
+ p = buf;
+ *p++ = ch;
+ }
+ else if (ansi)
+ {
+ if (p)
+ *p++ = ch;
+
+ if (!strchr(ANSI_COLOR_CODE, ch))
+ {
+ ansi = 0;
+ buf[0] = '\0';
+ p = NULL;
+ }
+ else if (strchr(ANSI_COLOR_END, ch))
+ {
+ *p++ = '\0';
+ ansi = 0;
+ p = NULL;
+ outs(buf);
+
+ }
+ }
+ else
+ outc(ch);
+ }
+}
+#endif
void
prints(char *fmt, ...)
...
outc(cc);
}
+#ifdef M3_USE_PFTERM
+static int save_y, save_x;
+#else
void
scroll()
{
scrollcnt++;
if (++roll > b_lines)
roll = 0;
move(b_lines, 0);
clrtoeol();
}
void
rscroll()
{
scrollcnt--;
if (--roll < 0)
roll = b_lines;
move(0, 0);
clrtoeol();
}
+#endif
/* ----------------------------------------------------- */
+#ifdef M3_USE_PFTERM
+void
+cursor_save()
+{
+ getyx(&save_y, &save_x);
+}
+
+void
+cursor_restore()
+{
+ move(save_y, save_x);
+}
+#else
static int old_col, old_row, old_roll;
static int old_pos; /* Thor.990401: 多存一個 */
...
return i;
}
#endif /* VIEW_IMSG */
+#endif // M3_USE_PFTERM
+
+#ifdef M3_USE_PFTERM
+vmsg(msg)
+char *msg; /* length <= 54 */
+{
+ static int old_b_cols = 23;
+ static char foot[512] = VMSG_NULL;
+
+ move(b_lines, 0);
+ clrtoeol();
+ if (msg)
+ {
+ prints(COLOR1 " ◆ %-55s " COLOR2 " [請按任意鍵繼續] \033[m", msg);
+ }
+ else
+ {
+ move(b_lines, 0);
+ outs(VMSG_NULL);
+ move(b_lines, 0);
+ }
+ return vkey();
+}
+#else
+
#ifdef POPUP_MESSAGE
int
vmsg(msg)
...
return vkey();
}
#endif
+#endif // ifdef M3_USE_PFTERM
static inline void
zkey() /* press any key or timeout */
...
b_cols = 79;
d_cols = b_cols - 79;
+#ifdef M3_USE_PFTERM
+ resizeterm(b_lines + 1, b_cols + 1);
+#endif
}
for (;;)
...
STANDOUT;
+#ifdef M3_USE_PFTERM
+ getyx (&x, &y);
+#else
x = cur_row;
y = cur_col;
+#endif
if (echo & GCARRY)
...
/* Thor.990204:要求輸入任一字才代表自動 match, 否則算cancel */
{
ch = len;
len = vget_match(data, len, echo | MATCH_END);
+#ifdef M3_USE_PFTERM
+ STANDOUT;
+#endif
if (len > ch)
{
move(x, y);
outs(data);
}
else if (len == 0)
{
data[0] = '\0';
}
+#ifdef M3_USE_PFTERM
+ STANDEND;
+#endif
}
break;
}
if (isprint2(ch))
{
if (ch == ' ' && (echo & (GET_USER | GET_BRD | GET_LIST)))
{
ch = vget_match(data, len, echo);
+#ifdef M3_USE_PFTERM
+ STANDOUT;
+#endif
if (ch > len)
{
move(x, y);
outs(data);
col = len = ch;
}
+#ifdef M3_USE_PFTERM
+ STANDEND;
+#endif
continue;
}
if (len >= max)
continue;
/* ----------------------------------------------- */
/* insert data and display it */
/* ----------------------------------------------- */
prompt = &data[col];
i = col;
move(x, y + col);
+#ifdef M3_USE_PFTERM
+ STANDOUT;
+#endif
for (;;)
{
outc(echo ? ch : '*');
next = *prompt;
*prompt++ = ch;
if (i >= len)
break;
i++;
ch = next;
}
+#ifdef M3_USE_PFTERM
+ STANDEND;
+#endif
col++;
len++;
continue;
}
/* ----------------------------------------------- */
/* 輸入 password 時只能按 BackSpace */
/* ----------------------------------------------- */
if (!echo && ch != KEY_BKSP)
continue;
+#ifdef M3_USE_PFTERM
+ STANDOUT;
+#endif
switch (ch)
{
case Ctrl('D'):
...
break;
}
+#ifdef M3_USE_PFTERM
+ STANDEND;
+#endif
}
if (len >= 2 && echo)
{
for (line = MAXLASTCMD - 1; line; line--)
strcpy(lastcmd[line], lastcmd[line - 1]);
strcpy(lastcmd[0], data);
}
move(vlen, strlen(data) + hlen); /* itoc.010312: 固定移到列尾再印出'\n' */
outc('\n');
ch = data[0];
if ((echo & LCECHO) && (ch >= 'A' && ch <= 'Z'))
data[0] = (ch |= 0x20);
+#ifdef M3_USE_PFTERM
+ STANDEND;
+#endif
return ch;
}
maple/window.c
#include "bbs.h"
+#ifdef M3_USE_PFTERM
+/* ----------------------------------------------------- */
+/* M3_USE_PFTERM */
+/* ----------------------------------------------------- */
+
+static void
+draw_line(x, y, msg)
+ int x, y;
+ uschar *msg;
+{
+ /* hrs.090928: 讓 terminal 去處理 */
+ move(x, y);
+ outstr(msg);
+ return;
+}
+
+static screen_backup_t old_screen;
+
+#else
static screenline slt[T_LINES];
...
/* 印出 (x, y + strip_ansi_len(msg) + 1) 至 行尾 */
outs(str);
outs(str_ransi);
}
+#endif //M3_USE_PFTERM
#ifdef HAVE_POPUPMENU
#ifdef POPUP_ANSWER
...
int /* 傳回小寫字母或數字 */
pans(x, y, title, desc)
int x, y;
char *title;
char *desc[];
{
int cur, old_cur, max, ch;
char hotkey;
+#ifdef M3_USE_PFTERM
+ scr_dump(&old_screen);
+ grayout(0, b_lines, GRAYOUT_DARK);
+#else
x_roll = vs_save(slt);
+#endif
hotkey = desc[0][0];
/* 畫出整個選單 */
max = draw_menu(x, y, title, desc, hotkey, &cur);
x += 2;
/* 一進入,游標停在預設值 */
old_cur = cur;
while (1)
{
switch (ch = vkey())
{
case KEY_LEFT:
case KEY_RIGHT:
case '\n':
+#ifdef M3_USE_PFTERM
+ scr_restore(&old_screen);
+#else
vs_restore(slt);
+#endif
ch = (ch == KEY_LEFT) ? desc[0][1] : desc[cur][0];
if (ch >= 'A' && ch <= 'Z')
ch |= 0x20; /* 回傳小寫 */
...
int
pmsg(msg)
char *msg; /* 不可為 NULL */
{
int len, x, y, i;
char buf[80];
+#ifdef M3_USE_PFTERM
+ if (!msg)
+ return vmsg(NULL);
+
+ scr_dump(&old_screen);
+ grayout(0, b_lines, GRAYOUT_DARK);
+#else
x_roll = vs_save(slt);
+#endif
len = strlen(msg);
if (len < 16) /* 取 msg title 其中較長者為 len */
...
move(b_lines, 0);
x = vkey();
+#ifdef M3_USE_PFTERM
+ scr_restore(&old_screen);
+#else
vs_restore(slt);
+#endif
return x;
}
#endif /* POPUP_MESSAGE */
#endif /* HAVE_POPUPMENU */
maple/xover.c
int
every_Z(zone)
int zone; /* 傳入所在 XZ_ZONE,若傳入 0,表示不在 xover() 中 */
{
int cmd, tmpbno, tmpmode;
+#ifdef M3_USE_PFTERM
+ screen_backup_t old_screen;
+#endif
/* itoc.000319: 最多 every_Z 一層 */
if (z_status >= 1)
return XO_NONE;
else
z_status++;
+#ifdef M3_USE_PFTERM
+ scr_dump(&old_screen);
+#endif
cmd = zone;
so/chat.c
continue;
}
#ifdef EVERY_Z
+#ifdef M3_USE_PFTERM
+ if (ch == Ctrl('Z'))
+ {
+ char buf[IDLEN + 1];
+ screen_backup_t old_screen;
+
+ strcpy(buf, cutmp->mateid);
+
+ vio_save();
+ scr_dump(&old_screen);
+ every_Z(0);
+ scr_restore(&old_screen);
+ vio_restore();
+
+ strcpy(cutmp->mateid, buf);
+ continue;
+ }
+#else
/* Thor: Chat 中按 ctrl-z */
if (ch == Ctrl('Z'))
{
char buf[IDLEN + 1];
screenline slt[T_LINES];
/* Thor.980731: 暫存 mateid, 因為出去時可能會用掉 mateid */
strcpy(buf, cutmp->mateid);
vio_save(); /* Thor.980727: 暫存 vio_fd */
vs_save(slt);
every_Z(0);
vs_restore(slt);
vio_restore(); /* Thor.980727: 還原 vio_fd */
/* Thor.980731: 還原 mateid, 因為出去時可能會用掉 mateid */
strcpy(cutmp->mateid, buf);
continue;
}
+#endif
#endif
if (ch == KEY_DOWN)
--
=[﹎:�摃�◣��:﹎Origin ]|[ ���O���� cpu.tfcis.org ]|[�搟說�﹎:]=
=[﹊:�摃�╱��:﹊Author ]|[ cache.ee.ncku.edu.tw ]|[���插�﹊:]=
= ▊▌▎▎Modify ▎▌▋▊▊≡: Thu, 29 Oct 2009 21:17:29 CST :≡:]=