bug-ncurses
[Top][All Lists]
Advanced

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

Re: alt key


From: Bob Rossi
Subject: Re: alt key
Date: Thu, 7 Dec 2006 11:54:12 -0500
User-agent: Mutt/1.5.12-2006-07-14

On Thu, Dec 07, 2006 at 10:21:23AM -0600, Christ, Bryan wrote:
> As long as your not dealing with wide/mb characters, here's how I handle
> it.
> 
> gint32 get_keystroke(void)
> {
>       gint32  keystroke=0;
>       gint    key_code=0;
> 
>       key_code=getch();
>       if(key_code==-1) return -1;
I understand this.
>       if(key_code!=27) /* esc sequence */
>       {
> #ifdef _DEBUG_VERSION
>               printw(" %d ",key_code);
> #endif
>               return (gint32)key_code;
>       }               
I also understand the above if. Now below is where it get's interesting.
You read another key into the key_code, and assign keystroke the same
value. Then you get another key, why? What do teh special 8 and 16
numbers represent? I'm surprised to see 4 keys being read here. I hope
you can shed some light on this.

Thanks,
Bob Rossi
>       key_code=getch();
>       keystroke=key_code;
>       key_code=getch();
>       keystroke=keystroke | (key_code<<8);
>       key_code=getch();
>       keystroke=keystroke | (key_code<<16);
> 
> #ifdef _DEBUG_VERSION 
>       printw(" %d %d %d ",(keystroke & 0xff),
>               ((keystroke>>8) & 0xff),((keystroke>>16) & 0xff));
> #endif        
>       return keystroke;
> }





reply via email to

[Prev in Thread] Current Thread [Next in Thread]