如何检测来自 QNX 中 ncurses 的屏幕调整事件?
How to detect screen resize events coming from ncurses in QNX?
我无法配置为接收有关使用 ncurses QNX Momentics 更改终端大小的事件。
我使用的是Putyy作为终端,通过COM口传输数据。
我的问题是如何实现远程终端接收换屏事件?
FILE* fcons = fopen("/dev/ser1", "r+");
SCREEN* term = newterm("xterm-r5", fcons, fcons);
int y = 0, x = 0;
//if(y < 24 || x < 80)
// resizeterm(24, 80);
flushinp();
main_scr = newwin(24, 80, 0, 0);
head_scr = subwin(main_scr, 3, 80, 0, 0);
prompt_scr = subwin(main_scr, 1, 9, 3, 2);
cursor_scr = newwin(1, 60, 3, 6);
output_scr = subwin(main_scr, 18, 76, 5, 2);
keypad(cursor_scr, TRUE);
int f = mousemask(ALL_MOUSE_EVENTS, NULL);
chtype temp_ch = 0;
while(KEY_RESIZE == temp_ch)
temp_ch = wgetch(cursor_scr);
return 0;
像这样的普通串行端口连接不会发送 SIGWINCH
。在其他配置中,例如 telnet
,这是 NAWS 的结果(关于 window 大小的谈判——我不 see a duplicate). Your application could poll for this by doing what the resize
程序确实如此,再加上一点,例如
- 保存光标位置
- 将光标移动到很远的右下角
- 向终端询问光标的真实位置
- 等待响应,获取实际屏幕尺寸
- 使用系统调用设置终端的屏幕尺寸
- 恢复光标位置
- 发一个
SIGWINCH
给自己
与 resize
不同,这将在您的程序内部完成,因此它必须 save/restore 光标位置(以避免混淆 ncurses)。请记住,ncurses 已将终端设置为 原始模式,因此不需要部分初始化。
我无法配置为接收有关使用 ncurses QNX Momentics 更改终端大小的事件。 我使用的是Putyy作为终端,通过COM口传输数据。
我的问题是如何实现远程终端接收换屏事件?
FILE* fcons = fopen("/dev/ser1", "r+");
SCREEN* term = newterm("xterm-r5", fcons, fcons);
int y = 0, x = 0;
//if(y < 24 || x < 80)
// resizeterm(24, 80);
flushinp();
main_scr = newwin(24, 80, 0, 0);
head_scr = subwin(main_scr, 3, 80, 0, 0);
prompt_scr = subwin(main_scr, 1, 9, 3, 2);
cursor_scr = newwin(1, 60, 3, 6);
output_scr = subwin(main_scr, 18, 76, 5, 2);
keypad(cursor_scr, TRUE);
int f = mousemask(ALL_MOUSE_EVENTS, NULL);
chtype temp_ch = 0;
while(KEY_RESIZE == temp_ch)
temp_ch = wgetch(cursor_scr);
return 0;
像这样的普通串行端口连接不会发送 SIGWINCH
。在其他配置中,例如 telnet
,这是 NAWS 的结果(关于 window 大小的谈判——我不 see a duplicate). Your application could poll for this by doing what the resize
程序确实如此,再加上一点,例如
- 保存光标位置
- 将光标移动到很远的右下角
- 向终端询问光标的真实位置
- 等待响应,获取实际屏幕尺寸
- 使用系统调用设置终端的屏幕尺寸
- 恢复光标位置
- 发一个
SIGWINCH
给自己
与 resize
不同,这将在您的程序内部完成,因此它必须 save/restore 光标位置(以避免混淆 ncurses)。请记住,ncurses 已将终端设置为 原始模式,因此不需要部分初始化。