[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: libncurses and getch ()



In the spirit of my confusion, I shall reply to myself again.

--- James Morrison <rocketmail_com@rocketmail.com> wrote:
> 
> --- James Morrison <rocketmail_com@rocketmail.com> wrote:
> >  Hi,
> > 
> >  I've been trying to find out why pptop doesn't get characters with getch
> ()
> > from
> > libncurses.  I think I traced to problem code down to something that
> > resembles
> > the following program.
> > 

Now a working version.

#include <unistd.h>
#include <fcntl.h>
#include <stdio.h>
#include <termios.h> 
#include <ncurses.h>

int main (int argc, char *argv[]) 
{
         char q;
         struct termios info;
         int n, in = fileno (stdin);;
 
         fcntl (in, F_SETFL, fcntl (in, F_GETFL, 0) | O_NONBLOCK);
                                      
         tcgetattr (in, &info);
         info.c_lflag &= ~ICANON;
         info.c_iflag &= ~ICRNL;
         info.c_lflag |= ISIG;
         info.c_cc[VMIN] = 1;
         info.c_cc[VTIME] = 0;
 
         tcsetattr (in, TCSADRAIN, &info);
         initscr ();
         while (q != 'q')
         {
                 n = read (fileno (stdin), &q, 1);
                 printf ("%d\n", n);
                 sleep (1);
         }
         endwin ();
         return q;
}
 
> >   The problem is that this program works.  Anyone have any ideas?
> > 
> 
> 
>  Now, that works, but changing read () to q = getch (), and linking against
> ncurses causes this program to stop working.
> 
> 

 So what does this tell me.  Well very little, except that I need to compile
libncurses myself and find how what is going wrong.

=====
James Morrison
   University of Waterloo
   Computer Science - Digital Hardware
   2A co-op
http://hurd.dyndns.org

Anyone referring to this as 'Open Source' shall be eaten by a GNU

__________________________________________________
Do You Yahoo!?
LAUNCH - Your Yahoo! Music Experience
http://launch.yahoo.com


-- 
To UNSUBSCRIBE, email to debian-hurd-request@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org



Reply to: