summaryrefslogtreecommitdiffstats
path: root/mbbsd
diff options
context:
space:
mode:
Diffstat (limited to 'mbbsd')
-rw-r--r--mbbsd/chat.c2
-rw-r--r--mbbsd/chc.c6
-rw-r--r--mbbsd/chicken.c2
-rw-r--r--mbbsd/dark.c4
-rw-r--r--mbbsd/edit.c4
-rw-r--r--mbbsd/gomo.c2
-rw-r--r--mbbsd/io.c95
-rw-r--r--mbbsd/mbbsd.c2
-rw-r--r--mbbsd/othello.c4
-rw-r--r--mbbsd/stuff.c11
-rw-r--r--mbbsd/talk.c4
11 files changed, 55 insertions, 81 deletions
diff --git a/mbbsd/chat.c b/mbbsd/chat.c
index f94cfc5f..06f706c3 100644
--- a/mbbsd/chat.c
+++ b/mbbsd/chat.c
@@ -386,7 +386,7 @@ t_chat()
while (chatting) {
move(b_lines - 1, currchar + chatid_len);
- ch = igetkey();
+ ch = igetch();
switch (ch) {
case KEY_DOWN:
diff --git a/mbbsd/chc.c b/mbbsd/chc.c
index 12aed0ad..d80cf276 100644
--- a/mbbsd/chc.c
+++ b/mbbsd/chc.c
@@ -575,14 +575,14 @@ hisplay(int s, chcusr_t *user1, chcusr_t *user2, board_t board, board_t tmpbrd)
if (chc_lefttime < 0) {
chc_lefttime = 0;
- /* to make him break out igetkey() */
+ /* to make him break out igetch() */
chc_from.r = -2;
chc_broadcast_send(act_list, board);
}
chc_drawline(board, user1, user2, TIME_ROW);
move(1, 0);
oflush();
- switch (igetkey()) {
+ switch (igetch()) {
case 'q':
endgame = 2;
endturn = 1;
@@ -653,7 +653,7 @@ myplay(int s, chcusr_t *user1, chcusr_t *user2, board_t board, board_t tmpbrd)
chc_drawline(board, user1, user2, TIME_ROW);
chc_movecur(chc_cursor.r, chc_cursor.c);
oflush();
- ch = igetkey();
+ ch = igetch();
chc_lefttime = CHC_TIMEOUT - (now - start_time);
if (chc_lefttime < 0)
ch = 'q';
diff --git a/mbbsd/chicken.c b/mbbsd/chicken.c
index 1685d842..bc97cc58 100644
--- a/mbbsd/chicken.c
+++ b/mbbsd/chicken.c
@@ -941,7 +941,7 @@ chickenpk(int fd)
add_io(fd, 3); /* 把fd加到igetch監視 */
while (1) {
r = rand();
- ch = igetkey();
+ ch = igetch();
getuser(mateid);
memcpy(&ouser, &xuser, sizeof(userec_t));
reload_chicken();
diff --git a/mbbsd/dark.c b/mbbsd/dark.c
index 4c9c6486..60f64dbd 100644
--- a/mbbsd/dark.c
+++ b/mbbsd/dark.c
@@ -1,4 +1,4 @@
-/* $Id: dark.c,v 1.8 2002/07/22 19:02:00 in2 Exp $ */
+/* $Id$ */
#include "bbs.h"
#define RED 1
@@ -396,7 +396,7 @@ main_dark(int fd, userinfo_t * uin)
end = -1;
break;
}
- ch = igetkey();
+ ch = igetch();
if (ch == I_OTHERDATA) {
ch = recv(fd, &curr, sizeof(curr), 0);
if (ch != sizeof(curr)) {
diff --git a/mbbsd/edit.c b/mbbsd/edit.c
index acc7bac0..897c7178 100644
--- a/mbbsd/edit.c
+++ b/mbbsd/edit.c
@@ -258,7 +258,7 @@ ask(char *prompt)
standout();
prints("%s", prompt);
standend();
- ch = igetkey();
+ ch = igetch();
move(0, 0);
clrtoeol();
return (ch);
@@ -1682,7 +1682,7 @@ vedit(char *fpath, int saveheader, int *islocal)
move(curr_window_line, ch);
if (!line_dirty && strcmp(line, currline->data))
strcpy(line, currline->data);
- ch = igetkey();
+ ch = igetch();
/* jochang debug */
if ((interval = (now - th))) {
th = now;
diff --git a/mbbsd/gomo.c b/mbbsd/gomo.c
index 55060b67..82e9af8f 100644
--- a/mbbsd/gomo.c
+++ b/mbbsd/gomo.c
@@ -371,7 +371,7 @@ gomoku(int fd)
} else
clrtoeol();
BGOTOCUR(mv.x, mv.y);
- ch = igetkey();
+ ch = igetch();
if (ch != I_OTHERDATA)
iwantpass = 0;
if (ch == 'q') {
diff --git a/mbbsd/io.c b/mbbsd/io.c
index c0f5d721..3429a3c3 100644
--- a/mbbsd/io.c
+++ b/mbbsd/io.c
@@ -174,6 +174,7 @@ dogetch()
if (len == 0 || errno != EINTR)
abort_bbs(0);
/* raise(SIGHUP); */
+
}
#ifdef SKIP_TELNET_CONTROL_SIGNAL
} while( inbuf[0] == -1 );
@@ -198,9 +199,34 @@ static int water_which_flag = 0;
int
igetch()
{
- register int ch;
- while ((ch = dogetch())) {
+ register int ch, mode =0, last;
+ while ((ch = dogetch())) {
+ if (mode == 0 && ch == KEY_ESC) // here is state machine for 2 bytes key
+ mode = 1;
+ else if (mode == 1) { /* Escape sequence */
+ if (ch == '[' || ch == 'O')
+ mode = 2;
+ else if (ch == '1' || ch == '4')
+ { mode = 3; last = ch; }
+ else
+ {
+ KEY_ESC_arg = ch;
+ return KEY_ESC;
+ }
+ } else if (mode == 2) { /* Cursor key */
+ if (ch >= 'A' && ch <= 'D')
+ return KEY_UP + (ch - 'A');
+ else if (ch >= '1' && ch <= '6')
+ { mode = 3; last = ch; }
+ } else if (mode == 3) { /* Ins Del Home End PgUp PgDn */
+ if (ch == '~')
+ return KEY_HOME + (last - '1');
+ }
+ else // here is switch for default keys
switch (ch) {
+ case IAC:
+ case '\n': /* filters */
+ continue;
#ifdef DEBUG
case Ctrl('Q'):{
struct rusage ru;
@@ -234,8 +260,8 @@ igetch()
free(screen0);
redoscr();
continue;
- } else
- return (ch);
+ }
+ return ch;
case KEY_TAB:
if (WATERMODE(WATER_ORIG) || WATERMODE(WATER_NEW))
if (currutmp != NULL && watermode > 0) {
@@ -244,8 +270,7 @@ igetch()
t_display_new();
continue;
}
- return ch;
- break;
+ return ch;
case Ctrl('R'):
if (currutmp == NULL)
@@ -304,9 +329,7 @@ igetch()
continue;
}
}
- return ch;
- case '\n': /* Ptt把 \n拿掉 */
- continue;
+ return ch;
case Ctrl('T'):
if (WATERMODE(WATER_ORIG) || WATERMODE(WATER_NEW)) {
if (watermode > 0) {
@@ -318,7 +341,7 @@ igetch()
continue;
}
}
- return (ch);
+ return ch;
case Ctrl('F'):
if (WATERMODE(WATER_NEW)) {
@@ -337,7 +360,7 @@ igetch()
continue;
}
}
- return ch;
+ return ch;
case Ctrl('G'):
if (WATERMODE(WATER_NEW)) {
@@ -352,14 +375,10 @@ igetch()
continue;
}
}
- return ch;
- case IAC:
- // disallow user input telnet protocol leading char IAC chr(255)
- // TODO parse telnet protocol
- continue;
+ return ch;
default:
- return ch;
+ return ch;
}
}
return 0;
@@ -485,7 +504,7 @@ oldgetdata(int line, int col, char *prompt, char *buf, int len, int echo)
edit_outs(buf);
clen = currchar = strlen(buf);
- while (move(y, x + currchar), (ch = igetkey()) != '\r') {
+ while (move(y, x + currchar), (ch = igetch()) != '\r') {
switch (ch) {
case KEY_DOWN: case Ctrl('N'):
case KEY_UP: case Ctrl('P'):
@@ -604,43 +623,3 @@ getdata(int line, int col, char *prompt, char *buf, int len, int echo)
}
-int
-igetkey()
-{
- int mode;
- int ch, last;
-
- mode = last = 0;
- while (1) {
- if( !(ch = igetch()) )
- continue;
- if (mode == 0) {
- if (ch == KEY_ESC)
- mode = 1;
- else
- return ch; /* Normal Key */
- } else if (mode == 1) { /* Escape sequence */
- if (ch == '[' || ch == 'O')
- mode = 2;
- else if (ch == '1' || ch == '4')
- mode = 3;
- else {
- KEY_ESC_arg = ch;
- return KEY_ESC;
- }
- } else if (mode == 2) { /* Cursor key */
- if (ch >= 'A' && ch <= 'D')
- return KEY_UP + (ch - 'A');
- else if (ch >= '1' && ch <= '6')
- mode = 3;
- else
- return ch;
- } else if (mode == 3) { /* Ins Del Home End PgUp PgDn */
- if (ch == '~')
- return KEY_HOME + (last - '1');
- else
- return ch;
- }
- last = ch;
- }
-}
diff --git a/mbbsd/mbbsd.c b/mbbsd/mbbsd.c
index d881c2b2..41af43fb 100644
--- a/mbbsd/mbbsd.c
+++ b/mbbsd/mbbsd.c
@@ -424,7 +424,7 @@ write_request(int sig)
memmove(&currutmp->msgs[0],
&currutmp->msgs[1],
sizeof(msgque_t) * currutmp->msgcount);
- igetkey();
+ igetch();
}
}
diff --git a/mbbsd/othello.c b/mbbsd/othello.c
index 96fea2e2..eba90375 100644
--- a/mbbsd/othello.c
+++ b/mbbsd/othello.c
@@ -124,7 +124,7 @@ get_key(char nowx, char nowy)
int ch;
move(STARTX - 1 + nowx * 2, STARTY - 1 + nowy * 4);
- ch = igetkey();
+ ch = igetch();
move(STARTX - 1 + nowx * 2, STARTY - 2 + nowy * 4);
if (nowboard[(int)nowx][(int)nowy] != HINT || if_hint == 1)
outs(CHESS_TYPE[(int)nowboard[(int)nowx][(int)nowy]]);
@@ -274,7 +274,7 @@ end_of_game(int quit)
if (fp)
fclose(fp);
move(1, 1);
- igetkey();
+ igetch();
}
static void
diff --git a/mbbsd/stuff.c b/mbbsd/stuff.c
index ba29c84e..605e8cd3 100644
--- a/mbbsd/stuff.c
+++ b/mbbsd/stuff.c
@@ -415,15 +415,10 @@ vmsg_lines(const int lines, const char msg[])
outs("\033[46;1m \033[37m"
"\033[200m\033[1431m\033[506m□ 請按 \033[33m(Space/Return)\033[37m 繼續 □\033[201m (^T) 收到暫存檔 \033[m");
- do {
- ch = igetkey();
-
- if (ch == Ctrl('T')) {
+ ch = igetch();
+ if (ch == Ctrl('T')) {
capture_screen();
- break;
}
- } while ((ch != ' ') && (ch != KEY_LEFT) && (ch != '\r') && (ch != '\n'));
-
move(lines, 0);
clrtoeol();
@@ -449,7 +444,7 @@ vmsg(const char *fmt,...)
va_start(ap, fmt);
vsnprintf(msg+14, 55, fmt, ap);
va_end(ap);
- for(i=69; i>0 && *(msg+i); i--)
+ for(i=69; i>0 && *(msg+i+1); i--)
*(msg+i) = ' ';
strcat(msg+69,"\033[33;46m \033[200m\033[1431m\033[506m[請按任意鍵繼續]\033[201m \033[m");
return vmsg_lines(b_lines, msg);
diff --git a/mbbsd/talk.c b/mbbsd/talk.c
index 818591dc..92053e60 100644
--- a/mbbsd/talk.c
+++ b/mbbsd/talk.c
@@ -512,7 +512,7 @@ my_write2(void)
which = 0;
do {
- switch ((ch = igetkey())) {
+ switch ((ch = igetch())) {
case Ctrl('T'):
case KEY_UP:
if (water_usies != 1) {
@@ -1055,7 +1055,7 @@ do_talk(int fd)
add_io(fd, 0);
while (1) {
- ch = igetkey();
+ ch = igetch();
if (ch == I_OTHERDATA) {
datac = recv(fd, data, sizeof(data), 0);
if (datac <= 0)