看板Maple
标 题Re: 有没有人试过让maple支持非标准行列数?
发信站清华生命科学 BBS (Fri May 16 12:30:43 2003)
转信站Ptt!news.cs.nthu!nthuls
下面的程式在使用 kkman 时会有问题。pcman,multiterm 都确认过可以用。
putty 也没问题。
在 bbsd.c 里面加入一个 term_init()
void
term_init()
{
#ifdef BIGTERM
/* ask client to report it's term size */
static char svr[] = {
IAC, DO, TELOPT_NAWS
};
static char rvr[] = {
IAC, WILL, TELOPT_NAWS,
IAC, SB, TELOPT_NAWS,
IAC, WONT, TELOPT_NAWS
};
int len;
char *cmd, *res;
int rset;
struct timeval to;
char buf[64];
cmd = svr;
len = 3;
/* 问对方 (telnet client) 有没有支援不同的萤幕宽高 */
send(0, cmd, len, 0);
rset = 1;
if (select(1, (fd_set *) & rset, NULL, NULL, &to) > 0)
recv(0, buf, sizeof(buf), 0);
/* try to read rows and columns of the client terminal */
cmd = rvr;
res = buf;
if (!memcmp(res, cmd, 3)) {
/* got IAC WILL NAWS : 对方说有 */
res += 3;
if (!memcmp(res, cmd+3, 3)) {
/* got IAC SB NAWS :接着回传资料 */
res += 3;
t_width = res[0]*256+res[1];
t_height = res[2]*256+res[3];
}
} else if (!memcmp(res, cmd+3, 3)) {
/* got IAC SB NAWS */
res += 3;
t_width = res[0]*256+res[1];
t_height = res[2]*256+res[3];
} else if (!memcmp(res, cmd+6, 3)) {
/* got IAC WONT NAWS; default to 80x24 :对方说没有 */
t_width = 80;
t_height = 24;
} else {
/* what ever else; default to 80x24 :没有回覆 */
t_width = 80;
t_height = 24;
}
#else
t_width = 80;
t_height = 24;
#endif /* BIGTERM */
}
在 bbsd.c 里的 main() 最後
telnet_init();
term_init(); <--- 加入这一行
visio_init();
xover_init();
另外,在 visio.c 里面
/* 把这些
#define t_columns 80
#define t_lines 24
#define p_lines 18
换成下面那些
*/
/* for term-size awareness */
extern int t_width;
extern int t_height;
#define t_columns t_width
#define t_lines t_height
#define p_lines t_lines - 6
int b_lines;
※ 引述《[email protected] (保险丝)》之铭言:
> ※ 引述《[email protected]》之铭言:
> > 可以到 news.tfcis.org 的 TFCIS.personal.itoc 找找
> > 有支援超过 24 行长萤幕的程式 (抓 telnet 的 signal)
> 多谢您的回应
> 找到了
> 这里有一段话看不懂,不知哪位大大可以解释一下:
> ----
> 发信人: [email protected] (:MM:), 信区: maplePlanITOC
> 标 题: Re: [□□]_や穿□□_24_□□□□
> 发信站: XEON (Fri Apr 11 14:29:42 2003)
> 转信站: Feeling!news.tfcis.org!PROCESSOR
> 出 处: svrequ.tnfsh.tn.edu.tw
> 还没上站就必须把视窗大小设好
> 视窗的大小是以刚上站时的大小为准
> 后来再改也没用了 (因为我抓不到 SIGWINCH)
> -----
> 我理解中.........在telnet刚建立时,会作协商:
> server问:你会改变行列数么?(TN_NAWS)
> client答:Yes, I do. (TNCH_DO)
> 那么在连线时,
> 当TERM变化行列数时就会发出:
> TNCH_IAC + TNCH_SB + TN_NAWS + 行数列数 + TNCH_IAC + TNCH_SE;
> 那么也就是在连线阶段会发现这个串,解析就是了。
> 那itoc大大说的SIGWINCH又是什么意思呢?
--
※ Origin: 生命科学 BBS <bbs.life.nthu.edu.tw>
◆ From: feminism.life.nthu.edu.tw