How to detect screen resize events coming from ncurses in QNX?

安稳与你 提交于 2019-12-24 03:25:37

问题


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;

回答1:


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.,

  • 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

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.



来源:https://stackoverflow.com/questions/54665257/how-to-detect-screen-resize-events-coming-from-ncurses-in-qnx

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!