Unix Programming - ncurses chtype and ordinary char?

This is Interesting: Free IT Magazines  
Home > Archive > Unix Programming > November 2004 > ncurses chtype and ordinary char?





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author ncurses chtype and ordinary char?
alex k

2004-11-16, 8:48 pm

hi!

i am writing a program that uses ncurses.
i want non-blocking input, so i guess i should
use wgetch() and not wgetstr().
but wgetch() returns a special kind of ncurses
character, an int big i think. how do i get an
ordinary C char from that?

i have googled, read manpages and source, but
failed to get a clue. perhaps i shouldnt use wgetch()
at all?

tia / alex
Johan

2004-11-17, 5:51 pm

Hi,

getch() returns a chtype ( = unsigned long ).

here is an example.

chtype waitkey()
{
chtype ch;

ch = getch(); // getch return -1 when non blocking !!!
switch(ch)
{
case KEY_F(1) : cout << "F1 pressed" << endl;
break;
case 0x1b : cout << "Escape key pressed" << endl;
break
case 'A' : cout << "Capital A pressed" << endl;
break;
etc, etc, etc
}

return ch;
}


"alex k" <pirx@df.lth.se> schreef in bericht
news:7e21850b.0411161813.341eec2d@posting.google.com...
> hi!
>
> i am writing a program that uses ncurses.
> i want non-blocking input, so i guess i should
> use wgetch() and not wgetstr().
> but wgetch() returns a special kind of ncurses
> character, an int big i think. how do i get an
> ordinary C char from that?
>
> i have googled, read manpages and source, but
> failed to get a clue. perhaps i shouldnt use wgetch()
> at all?
>
> tia / alex



Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com