summaryrefslogtreecommitdiffstats
path: root/mbbsd/term.c
diff options
context:
space:
mode:
authorin2 <in2@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2005-04-08 10:27:19 +0800
committerin2 <in2@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2005-04-08 10:27:19 +0800
commit0666dd02983c5a7ad580a29d7d6deec1cbcd80b5 (patch)
tree4ad1a26d8b3bbad4afc2a8396cbd7b8651a40b73 /mbbsd/term.c
parenta0296382b6836538ae15de74b4adf96b54e8d9ad (diff)
downloadpttbbs-0666dd02983c5a7ad580a29d7d6deec1cbcd80b5.tar
pttbbs-0666dd02983c5a7ad580a29d7d6deec1cbcd80b5.tar.gz
pttbbs-0666dd02983c5a7ad580a29d7d6deec1cbcd80b5.tar.bz2
pttbbs-0666dd02983c5a7ad580a29d7d6deec1cbcd80b5.tar.lz
pttbbs-0666dd02983c5a7ad580a29d7d6deec1cbcd80b5.tar.xz
pttbbs-0666dd02983c5a7ad580a29d7d6deec1cbcd80b5.tar.zst
pttbbs-0666dd02983c5a7ad580a29d7d6deec1cbcd80b5.zip
handle telnet protocol and enable NAWS (resize terminal) capability.
SKIP_TELNET_CONTROL_SIGNAL can be disabled now. by piaip git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@2690 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
Diffstat (limited to 'mbbsd/term.c')
-rw-r--r--mbbsd/term.c28
1 files changed, 17 insertions, 11 deletions
diff --git a/mbbsd/term.c b/mbbsd/term.c
index 94067e99..782d07b8 100644
--- a/mbbsd/term.c
+++ b/mbbsd/term.c
@@ -30,21 +30,27 @@ init_tty(void)
#define TERMCOMSIZE (40)
static void
-term_resize(int sig)
+sig_term_resize(int sig)
{
struct winsize newsize;
+ Signal(SIGWINCH, SIG_IGN); /* Don't bother me! */
+ ioctl(0, TIOCGWINSZ, &newsize);
+ term_resize(newsize.ws_col, newsize.ws_row);
+}
+
+void term_resize(int w, int h)
+{
screenline_t *new_picture;
Signal(SIGWINCH, SIG_IGN); /* Don't bother me! */
- ioctl(0, TIOCGWINSZ, &newsize);
/* make sure reasonable size */
- newsize.ws_row = MAX(24, MIN(100, newsize.ws_row));
- newsize.ws_col = MAX(80, MIN(200, newsize.ws_col));
+ h = MAX(24, MIN(100, h));
+ w = MAX(80, MIN(200, w));
- if (newsize.ws_row > t_lines) {
- new_picture = (screenline_t *) calloc(newsize.ws_row,
- sizeof(screenline_t));
+ if (h > t_lines && big_picture) {
+ new_picture = (screenline_t *)
+ calloc(h, sizeof(screenline_t));
if (new_picture == NULL) {
syslog(LOG_ERR, "calloc(): %m");
return;
@@ -53,19 +59,19 @@ term_resize(int sig)
free(big_picture);
big_picture = new_picture;
}
- t_lines = newsize.ws_row;
- t_columns = newsize.ws_col;
+ t_lines = h;
+ t_columns = w;
scr_lns = t_lines; /* XXX: scr_lns 跟 t_lines 有什麼不同, 為何分成兩個 */
b_lines = t_lines - 1;
p_lines = t_lines - 4;
- Signal(SIGWINCH, term_resize);
+ Signal(SIGWINCH, sig_term_resize);
}
int
term_init(void)
{
- Signal(SIGWINCH, term_resize);
+ Signal(SIGWINCH, sig_term_resize);
return YEA;
}