如何检测来自QNX中ncurses的屏幕调整大小事件? [英] How to detect screen resize events coming from ncurses in QNX?

查看:172
本文介绍了如何检测来自QNX中ncurses的屏幕调整大小事件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法配置为使用ncurses QNX Momentics接收有关更改终端大小的事件. 我将Putyy用作终端,并且数据通过COM端口传输.

I can not configure to receive events about changing the size of the terminal using ncurses QNX Momentics. I am using Putyy as a terminal and data is transmitted through the COM port.

我的问题是在使用远程终端时如何实现屏幕切换事件的接收?

My question is how to realize the reception of screen change events when using a remote terminal?

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 的结果(有关窗口大小的协商-我不是 resize 程序可以,例如,

A plain serial-port connection like that won't send a SIGWINCH. In other configurations, e.g., telnet, that's done as a result of NAWS (negotiations about window size--I dont't see a duplicate). Your application could poll for this by doing what the resize program does, plus a little more, e.g.,

  • 保存光标位置
  • 将光标移动到非常遥远的右下角
  • 询问终端光标到底在哪里
  • 等待响应,以获取实际的屏幕尺寸
  • 使用系统调用设置终端的屏幕尺寸
  • 恢复光标位置
  • 向自己发送SIGWINCH
  • save the cursor-position
  • move the cursor to a very-far-off lower-right corner
  • ask the terminal where the cursor really is
  • wait for the response, to get the actual screensize
  • set the terminal's screensize using a system call
  • restore the cursor position
  • send a SIGWINCH to yourself

resize不同,这将在程序内部完成,因此必须保存/恢复光标位置(以避免混淆ncurses).请记住,ncurses已将终端设置为原始模式,因此不需要部分初始化.

Unlike resize, that would be done inside your program, so it would have to save/restore the cursor position (to avoid confusing ncurses). Keep in mind that ncurses has set the terminal to raw mode, so that part of the initialization would not be needed.

这篇关于如何检测来自QNX中ncurses的屏幕调整大小事件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆