2

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;
J. Konor
  • 33
  • 5

1 Answers1

0

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.

Thomas Dickey
  • 51,086
  • 7
  • 70
  • 105
  • The oddity is that the mouse clicks work for me. But to catch the resizing of the terminal does not work. Although both events occur when using the mouse. – J. Konor Feb 13 '19 at 09:46
  • resize-events aren't related to the mouse (nor are they handled the same way). ncurses asks PuTTY to send an escape sequence on mouse-events, but there's no protocol defined for sending escapes when the terminal is resized. – Thomas Dickey Feb 13 '19 at 09:58