summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpiaip <piaip@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2007-12-21 18:36:17 +0800
committerpiaip <piaip@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2007-12-21 18:36:17 +0800
commitfbcab98509f954bfebaef37085e34ea9ecf1dfb8 (patch)
tree66885a0f7d62f634ca716aa74400615d8fc8bb14
parent12a7296bac13fc1d7d3540ef0b474002ae023234 (diff)
downloadpttbbs-fbcab98509f954bfebaef37085e34ea9ecf1dfb8.tar
pttbbs-fbcab98509f954bfebaef37085e34ea9ecf1dfb8.tar.gz
pttbbs-fbcab98509f954bfebaef37085e34ea9ecf1dfb8.tar.bz2
pttbbs-fbcab98509f954bfebaef37085e34ea9ecf1dfb8.tar.lz
pttbbs-fbcab98509f954bfebaef37085e34ea9ecf1dfb8.tar.xz
pttbbs-fbcab98509f954bfebaef37085e34ea9ecf1dfb8.tar.zst
pttbbs-fbcab98509f954bfebaef37085e34ea9ecf1dfb8.zip
- change screen APIs to ncurses-like names
git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@3717 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
-rw-r--r--include/proto.h39
-rw-r--r--mbbsd/bbs.c2
-rw-r--r--mbbsd/chat.c4
-rw-r--r--mbbsd/chess.c4
-rw-r--r--mbbsd/dice.c6
-rw-r--r--mbbsd/io.c14
-rw-r--r--mbbsd/mbbsd.c18
-rw-r--r--mbbsd/menu.c2
-rw-r--r--mbbsd/pmore.c2
-rw-r--r--mbbsd/read.c2
-rw-r--r--mbbsd/screen.c57
-rw-r--r--mbbsd/stuff.c3
-rw-r--r--mbbsd/talk.c8
-rw-r--r--mbbsd/term.c2
-rw-r--r--mbbsd/user.c2
15 files changed, 101 insertions, 64 deletions
diff --git a/include/proto.h b/include/proto.h
index b56690cf..c0e5a134 100644
--- a/include/proto.h
+++ b/include/proto.h
@@ -560,27 +560,32 @@ int reversi_personal(void);
int reversi_watch(void);
ChessInfo* reversi_replay(FILE* fp);
-/* screen/pfterm */
-void initscr(void);
-int resizescr(int rows, int cols);
-void getyx(int *y, int *x);
-void move(int y, int x);
-void move_ansi(int y, int x);
+/* screen/pfterm (ncurses-like) */
+void initscr (void);
+int resizeterm (int rows, int cols);
+void getyx (int *y, int *x);
+void move (int y, int x);
+void clear (void);
+void clrtoeol (void);
+void clrtobot (void);
+void clrtoln (int ln);
+void refresh (void);
+void redrawwin (void);
+void scroll (void);
+void rscroll (void);
+int instr (char *str);
+int innstr (char *str, int n);
+void scr_dump (screen_backup_t *buf);
+void scr_restore(const screen_backup_t *buf);
+// non-curses
void outc(unsigned char ch);
void outs(const char *str);
-void clear(void);
-void clrtoeol(void);
-void clrtobot(void);
-void clrtoline(int line);
-void refresh(void);
-void redoscr(void);
+int inansistr(char *str, int n);
+void move_ansi(int y, int x);
+void region_scroll_up(int top, int bottom);
+// deprecated
void standout(void);
void standend(void);
-void scroll(void);
-void rscroll(void);
-void region_scroll_up(int top, int bottom);
-void screen_backup(screen_backup_t *buf);
-void screen_restore(const screen_backup_t *buf);
#define HAVE_GRAYOUT
void grayout(int start, int end, int level);
diff --git a/mbbsd/bbs.c b/mbbsd/bbs.c
index d0a722f5..59a6fc45 100644
--- a/mbbsd/bbs.c
+++ b/mbbsd/bbs.c
@@ -3143,7 +3143,7 @@ view_postinfo(int ent, const fileheader_t * fhdr, const char *direct, int crs_ln
clrtoeol();
move(area_l, 0);
- clrtoline(area_l + area_lines);
+ clrtoln(area_l + area_lines);
if(area_l > l)
prints(" ↖\n");
diff --git a/mbbsd/chat.c b/mbbsd/chat.c
index 9d729969..85834a67 100644
--- a/mbbsd/chat.c
+++ b/mbbsd/chat.c
@@ -490,10 +490,10 @@ t_chat(void)
} else if (ch == Ctrl('I')) {
screen_backup_t old_screen;
- screen_backup(&old_screen);
+ scr_dump(&old_screen);
add_io(0, 0);
t_idle();
- screen_restore(&old_screen);
+ scr_restore(&old_screen);
add_io(cfd, 0);
} else if (ch == Ctrl('Q')) {
print_chatid(chatid);
diff --git a/mbbsd/chess.c b/mbbsd/chess.c
index afe6dcd8..6d28e603 100644
--- a/mbbsd/chess.c
+++ b/mbbsd/chess.c
@@ -1299,9 +1299,9 @@ ChessReplayGame(const char* fname)
fclose(fp);
if (info) {
- screen_backup(&oldscreen);
+ scr_dump(&oldscreen);
ChessPlay(info);
- screen_restore(&oldscreen);
+ scr_restore(&oldscreen);
DeleteChessInfo(info);
}
diff --git a/mbbsd/dice.c b/mbbsd/dice.c
index e353bec4..4e627e69 100644
--- a/mbbsd/dice.c
+++ b/mbbsd/dice.c
@@ -117,7 +117,7 @@ show_count(int value[100],int index, int money)
value[index] += money;
move(14, 0);
- clrtoline(18);
+ clrtoln(18);
for (i = 1, j = 13; i <= 8; i++, count += 12) {
if (i == 6) {
j = 14;
@@ -223,8 +223,8 @@ show_output(int bet[])
int i, j = 10;
move(12, 0);
- clrtoline(17);
- /* 暫時降啦 因為那各clrtoline怪怪的 */ // XXX 哪裡怪?
+ clrtoln(17);
+ /* 暫時降啦 因為那各clrtoln怪怪的 */ // XXX 哪裡怪?
for (i = 13; i <= 18; i++) {
move(i, 0);
outs(" ");
diff --git a/mbbsd/io.c b/mbbsd/io.c
index 7b343b29..6916322a 100644
--- a/mbbsd/io.c
+++ b/mbbsd/io.c
@@ -431,7 +431,7 @@ igetch(void)
continue;
#endif
case Ctrl('L'):
- redoscr();
+ redrawwin();
continue;
case Ctrl('U'):
if (currutmp != NULL && currutmp->mode != EDITING
@@ -441,7 +441,7 @@ igetch(void)
int oldroll = roll;
int my_newfd;
- screen_backup(&old_screen);
+ scr_dump(&old_screen);
my_newfd = i_newfd;
i_newfd = 0;
@@ -449,7 +449,7 @@ igetch(void)
i_newfd = my_newfd;
roll = oldroll;
- screen_restore(&old_screen);
+ scr_restore(&old_screen);
continue;
}
return ch;
@@ -473,12 +473,12 @@ igetch(void)
int my_newfd;
screen_backup_t old_screen;
- screen_backup(&old_screen);
+ scr_dump(&old_screen);
my_newfd = i_newfd;
i_newfd = 0;
my_write2();
- screen_restore(&old_screen);
+ scr_restore(&old_screen);
i_newfd = my_newfd;
continue;
} else if (!WATERMODE(WATER_OFO)) {
@@ -499,7 +499,7 @@ igetch(void)
/* 第一次按 Ctrl-R (必須先被丟過水球) */
screen_backup_t old_screen;
int my_newfd;
- screen_backup(&old_screen);
+ scr_dump(&old_screen);
/* 如果正在talk的話先不處理對方送過來的封包 (不去select) */
my_newfd = i_newfd;
@@ -529,7 +529,7 @@ igetch(void)
i_newfd = my_newfd;
/* 還原螢幕 */
- screen_restore(&old_screen);
+ scr_restore(&old_screen);
continue;
}
}
diff --git a/mbbsd/mbbsd.c b/mbbsd/mbbsd.c
index 499d0421..0aefee21 100644
--- a/mbbsd/mbbsd.c
+++ b/mbbsd/mbbsd.c
@@ -321,12 +321,8 @@ talk_request(int sig)
bell();
if (currutmp->msgcount) {
char timebuf[100];
-#ifdef OUTTA_TIMER
- now = SHM->GV2.e.now;
-#else
- now = time(0);
-#endif
+ syncnow();
move(0, 0);
clrtoeol();
prints(ANSI_COLOR(33;41) "★%s" ANSI_COLOR(34;47) " [%s] %s " ANSI_COLOR(0) "",
@@ -341,11 +337,11 @@ talk_request(int sig)
currutmp->mode = 0;
currutmp->chatid[0] = 1;
- screen_backup(&old_screen);
+ scr_dump(&old_screen);
talkreply();
currutmp->mode = mode0;
currutmp->chatid[0] = c0;
- screen_restore(&old_screen);
+ scr_restore(&old_screen);
}
}
@@ -450,11 +446,7 @@ write_request(int sig)
return;
reentrant_write_request = 1;
#endif
-#ifdef OUTTA_TIMER
- now = SHM->GV2.e.now;
-#else
- now = time(0);
-#endif
+ syncnow();
check_water_init();
if (WATERMODE(WATER_OFO)) {
/* 如果目前正在回水球模式的話, 就不能進行 add_history() ,
@@ -585,7 +577,7 @@ multi_user_check(void)
if(ui == NULL)
return;
- getdata(b_lines - 1, 0, "您想刪除其他重複的 login (Y/N)嗎?[Y] ",
+ getdata(b_lines - 1, 0, "您想刪除其他重複的 login 嗎?[Y/n] ",
genbuf, 3, LCECHO);
usleep(random()%1000000);
diff --git a/mbbsd/menu.c b/mbbsd/menu.c
index a6a7af96..69add9c1 100644
--- a/mbbsd/menu.c
+++ b/mbbsd/menu.c
@@ -188,7 +188,7 @@ movie(int cmdmode)
#undef N_SYSMOVIE
move(1, 0);
- clrtoline(1 + FILMROW); /* 清掉上次的 */
+ clrtoln(1 + FILMROW); /* 清掉上次的 */
out_lines(SHM->notes[i], 11); /* 只印11行就好 */
outs(reset_color);
}
diff --git a/mbbsd/pmore.c b/mbbsd/pmore.c
index 8275290c..7640d2e8 100644
--- a/mbbsd/pmore.c
+++ b/mbbsd/pmore.c
@@ -15,7 +15,7 @@
* All Rights Reserved.
* You are free to use, modify, redistribute this program
* in any BBS style systems, or any other non-commercial usage.
- * You must keep these copyright infomration.
+ * You must keep these copyright information.
*
* MAJOR IMPROVEMENTS:
* - Clean source code, and more readable for mortal
diff --git a/mbbsd/read.c b/mbbsd/read.c
index 8cbd81b4..29401afb 100644
--- a/mbbsd/read.c
+++ b/mbbsd/read.c
@@ -850,7 +850,7 @@ i_read_key(const onekey_t * rcmdlist, keeploc_t * locmem,
}
break;
case Ctrl('L'):
- redoscr();
+ redrawwin();
break;
case Ctrl('H'):
diff --git a/mbbsd/screen.c b/mbbsd/screen.c
index 03f825c1..74d434e1 100644
--- a/mbbsd/screen.c
+++ b/mbbsd/screen.c
@@ -27,7 +27,7 @@ initscr(void)
}
int
-resizescr(int w, int h)
+resizeterm(int w, int h)
{
screenline_t *new_picture;
@@ -147,7 +147,7 @@ standoutput(const char *buf, int ds, int de, int sso, int eso)
}
void
-redoscr(void)
+redrawwin(void)
{
register screenline_t *bp;
register int i, j;
@@ -207,12 +207,12 @@ refresh(void)
return;
if ((docls) || (abs(scrollcnt) >= (scr_lns - 3))) {
- redoscr();
+ redrawwin();
return;
}
if (scrollcnt < 0) {
if (!scrollrevlen) {
- redoscr();
+ redrawwin();
return;
}
rel_move(tc_col, tc_line, 0, 0);
@@ -355,7 +355,7 @@ clrtoeol(void)
* 從目前的行數(scr_ln) clear 到第 line 行
*/
void
-clrtoline(int line)
+clrtoln(int line)
{
register screenline_t *slp;
register int i, j;
@@ -376,7 +376,7 @@ clrtoline(int line)
inline void
clrtobot(void)
{
- clrtoline(scr_lns);
+ clrtoln(scr_lns);
}
void
@@ -517,6 +517,45 @@ standend(void)
}
}
+// readback
+int
+instr(char *str)
+{
+ register screenline_t *slp = GetCurrentLine();
+ *str = 0;
+ if (!slp)
+ return 0;
+ slp->data[slp->len] = 0;
+ strip_ansi(str, (char*)slp->data, STRIP_ALL);
+ return strlen(str);
+}
+
+int
+innstr(char *str, int n)
+{
+ register screenline_t *slp = GetCurrentLine();
+ char buf[ANSILINELEN];
+ *str = 0;
+ if (!slp)
+ return 0;
+ slp->data[slp->len] = 0;
+ strip_ansi(buf, (char*)slp->data, STRIP_ALL);
+ buf[ANSILINELEN] = 0;
+ strncpy(str, buf, n);
+ return strlen(str);
+}
+
+int
+inansistr(char *str, int n)
+{
+ register screenline_t *slp = GetCurrentLine();
+ *str = 0;
+ if (!slp)
+ return 0;
+ strncpy(str, (char*)slp->data, n);
+ return strlen(str);
+}
+
// level:
// -1 - bold out
// 0 - dark text
@@ -603,7 +642,7 @@ static size_t screen_backupsize(int len, const screenline_t *bp)
return sum;
}
-void screen_backup(screen_backup_t *old)
+void scr_dump(screen_backup_t *old)
{
int i;
size_t offset = 0;
@@ -627,7 +666,7 @@ void screen_backup(screen_backup_t *old)
}
}
-void screen_restore(const screen_backup_t *old)
+void scr_restore(const screen_backup_t *old)
{
int i;
size_t offset=0;
@@ -647,7 +686,7 @@ void screen_restore(const screen_backup_t *old)
free(old->raw_memory);
move(old->y, old->x);
- redoscr();
+ redrawwin();
}
#endif // !defined(EXP_PFTERM) && !defined(HAVE_PFTERM)
diff --git a/mbbsd/stuff.c b/mbbsd/stuff.c
index 312b523f..958e34f7 100644
--- a/mbbsd/stuff.c
+++ b/mbbsd/stuff.c
@@ -359,6 +359,7 @@ vmsg(const char *msg)
if (i == pad-1)
outc(' ');
}
+ outs(ANSI_RESET);
} else {
/* msg_pressanykey_trail */
outs(ANSI_COLOR(1;36;44) " ◆ ");
@@ -410,7 +411,7 @@ show_file(const char *filename, int y, int lines, int mode)
if (y >= 0)
move(y, 0);
- clrtoline(lines + y);
+ clrtoln(lines + y);
if ((fp = fopen(filename, "r"))) {
while (fgets(buf, sizeof(buf), fp) && lines--)
outs(Ptt_prints(buf, sizeof(buf), mode));
diff --git a/mbbsd/talk.c b/mbbsd/talk.c
index b0e6f4d0..e431f43a 100644
--- a/mbbsd/talk.c
+++ b/mbbsd/talk.c
@@ -1467,7 +1467,7 @@ do_talk(int fd)
if (itswin.big_picture[i].len)
fprintf(flog, "%.*s\n", itswin.big_picture[i].len, itswin.big_picture[i].data);
- redoscr();
+ redrawwin();
fclose(flog);
more(fpath, NA);
@@ -1494,7 +1494,7 @@ do_talk(int fd)
free(mywin.big_picture);
free(itswin.big_picture);
setutmpmode(XINFO);
- redoscr();
+ redrawwin();
}
#define lockreturn(unmode, state) if(lockutmpmode(unmode, state)) return
@@ -3601,11 +3601,11 @@ CallAngel(){
return;
entered = 1;
- screen_backup(&old_screen);
+ scr_dump(&old_screen);
TalkToAngel();
- screen_restore(&old_screen);
+ scr_restore(&old_screen);
entered = 0;
}
diff --git a/mbbsd/term.c b/mbbsd/term.c
index 202ea582..bea4ec33 100644
--- a/mbbsd/term.c
+++ b/mbbsd/term.c
@@ -47,7 +47,7 @@ void term_resize(int w, int h)
w = MAX(80, MIN(200, w));
// invoke terminal system resize
- resizescr(h, w);
+ resizeterm(h, w);
t_lines = h;
t_columns = w;
diff --git a/mbbsd/user.c b/mbbsd/user.c
index 92c423f2..dde0ee0f 100644
--- a/mbbsd/user.c
+++ b/mbbsd/user.c
@@ -1341,7 +1341,7 @@ u_editcalendar(void)
vmsg("行事曆刪除完畢");
} else if (genbuf[0] == 'h') {
move(1, 0);
- clrtoline(b_lines);
+ clrtoln(b_lines);
move(3, 0);
prints("行事曆格式說明:\n編輯時以一行為單位,如:\n\n# 井號開頭的是註解\n2006/05/04 red 上批踢踢!\n\n其中的 red 是指表示的顏色。");
pressanykey();