I need to trap ^Y, ^Z, ^S, ^Q etc in my app. Have googled a lot but
unable to find anything.
Finally, I wrote a program and trapped all the signals.
1. Both C-z and C-y are trapped by SIGTSTP, but there is no key in
getch() that they seem to trigger. Regardless of whether I use "SIG_IGN"
or print, my curses program aborts.
2. I am still not getting C-s and C-q. They are not caught by any
signal.
I need to trap ^Y, ^Z, ^S, ^Q etc in my app. Have googled a lot but
unable to find anything.
I finally found a workaround.
On unix prompt did:
stty dsusp undef
stty susp undef
Now my program catches c-y and c-z. However, is there are pure ruby way
of doing this. googling reveals examples where "system stty ..." is
being used.
probbably best to set the terminal to raw mode if this is unix as I suspect. Ruby Quiz - Sokoban (#5)
shows an example of this. Search for the read_char method or just
for the string 'raw'.
Ron.
Nit Khair wrote:
···
I need to trap ^Y, ^Z, ^S, ^Q etc in my app. Have googled a lot but
unable to find anything.
Finally, I wrote a program and trapped all the signals.
1. Both C-z and C-y are trapped by SIGTSTP, but there is no key in
getch() that they seem to trigger. Regardless of whether I use "SIG_IGN"
or print, my curses program aborts.
2. I am still not getting C-s and C-q. They are not caught by any
signal.
I need to trap ^Y, ^Z, ^S, ^Q etc in my app. Have googled a lot but
unable to find anything.
I finally found a workaround.
On unix prompt did:
stty dsusp undef
stty susp undef
Now my program catches c-y and c-z. However, is there are pure ruby way of doing this. googling reveals examples where "system stty ..." is being used.
You can't catch SIGKILL or SIGSTOP ... has nothing to do with Ruby.
probbably best to set the terminal to raw mode if this is unix as I
suspect. Ruby Quiz - Sokoban (#5)
shows an example of this. Search for the read_char method or just
for the string 'raw'.
Ron.
Thanks to your tip, I just checked curses.raw(), and *there* it is !!!
Just what I needed.
···
------
curses.raw()
Enter raw mode. In raw mode, normal line buffering and processing of
interrupt, quit, suspend, and flow control keys are turned off;
characters are presented to curses input functions one by one.
------
--
Posted via http://www.ruby-forum.com/\.