Curses sorely lacking an event loop?

J

James Stroud

Hello,

Is curses really lacking an event loop? Do I have to write my own? I
infer from the docs that this is the case. For example, I want the
screen to be updated with resize but I find myself waiting for getch()
if I want user input, and so the screen must remain ugly until the user
presses a key. What am I missing?

Also, does anyone have boilerplate for handling mouse events? getmouse()
returns an "ERR" of no particular description and also appears to
require a preceding getch() and hence does not seem to be wired at all
for clicks, although allusion to clicks is found in the descriptions for
mouseinterval() and mousemask().

Here is the error message for getmouse() in case anyone wants details:
"_curses.error: getmouse() returned ERR". This is much less informative
than one might hope.

Thanks in advance for any help.

James
 
M

Michael Zawrotny

Is curses really lacking an event loop? Do I have to write my own? I
infer from the docs that this is the case. For example, I want the
screen to be updated with resize but I find myself waiting for getch()
if I want user input, and so the screen must remain ugly until the user
presses a key. What am I missing?

I'm not a curses expert, but I can answer this part. When the screen
is resized, SIGWINCH is sent to the process. You can use the normal
signal handling apparatus to install a handler that updates the screen
when that signal arrives.


Mike
 
M

Michele Simionato

Hello,

Is curses really lacking an event loop? Do I have to write my own? I
infer from the docs that this is the case. For example, I want the
screen to be updated with resize but I find myself waiting for getch()
if I want user input, and so the screen must remain ugly until the user
presses a key. What am I missing?

Also, does anyone have boilerplate for handling mouse events? getmouse()
returns an "ERR" of no particular description and also appears to
require a preceding getch() and hence does not seem to be wired at all
for clicks, although allusion to clicks is found in the descriptions for
mouseinterval() and mousemask().

Here is the error message for getmouse() in case anyone wants details:
"_curses.error: getmouse() returned ERR". This is much less informative
than one might hope.

Thanks in advance for any help.

James

Did you check Urwid? http://excess.org/urwid

Michele Simionato
 
J

James Stroud

Michael said:
I'm not a curses expert, but I can answer this part. When the screen
is resized, SIGWINCH is sent to the process. You can use the normal
signal handling apparatus to install a handler that updates the screen
when that signal arrives.


Mike

Thank you. This is good to know.

James
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,763
Messages
2,569,563
Members
45,039
Latest member
CasimiraVa

Latest Threads

Top