ncurses: F1-F8 keys
Web Server forum
Back To The Forum Home!Search!Private Messaging System

Web Server Talk Web Server Talk > Unix and Linux reviews > Free Unix support > Unix Programming > ncurses: F1-F8 keys




  Last Thread   Next Thread Next
  Show Printable Version Email this Page Subscribe to this Thread      Post New Thread    Post A Reply      

    ncurses: F1-F8 keys  
vertigo


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
08-23-04 01:01 PM

Hello
I found that KEY_F(int n) returns me codes for keys F1-F8, but
the problem is that when i read getchar() i receive codes:
F1 126
F2 126
F3 126
F4 126
F5 269
F6 270
F7 271
F8 272

Why for F1-F4 keys i always receive the same code ?
I use 5.1-RELEASE-p16, default installation.

Thanx
Michal






[ Post a follow-up to this message ]



    Re: ncurses: F1-F8 keys  
vertigo


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
08-23-04 01:01 PM


Maybe i show the code which i used to test that values:

int main(void){
int key;
initscr();
crmode();
keypad(stdscr,TRUE);
noecho();
clear();

mvprintw(5,5,"Demo, type q to quit");
move(7,5);
refresh();

key=getch();
while(key!=ERR && key!='q'){
move(7,5);
clrtoeol();
printw("Key code: %d",key);
refresh();
key=getch();
}
endwin();
exit(0);
}

Why do i have strange values for F1-F4 = 126 ??








[ Post a follow-up to this message ]



    Re: ncurses: F1-F8 keys  
Floyd L. Davidson


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
08-23-04 01:01 PM

vertigo <none@microsoft.com> wrote:
>int main(void){
>     int key;
>     initscr();
>     crmode();
>     keypad(stdscr,TRUE);
>     noecho();
>     clear();
>
>     mvprintw(5,5,"Demo, type q to quit");
>     move(7,5);
>     refresh();
>
>     key=getch();
>     while(key!=ERR && key!='q'){
>         move(7,5);
>         clrtoeol();
>         printw("Key code: %d",key);
>         refresh();
>         key=getch();
>     }
>     endwin();
>     exit(0);
>}

I tested your code (after reformatting to make it readable, and
adding includes for the appropriate header files) on a Linux box.

I could get the same effect you describe by running it in an
xterm and using either TERM=linux or TERM=xterm.

If it is run on a virtual console, with TERM=linux, it provides
unique codes for each function key.  Likewise if run from xterm
with TERM=xterm-color it also provides unique (though very
different) codes for the function keys.

I didn't check to see what version of ncurses I have, and I
don't know exactly how old my terminfo database definitions for
those specific terminals are, or if they have been locally
modified or not.

None of that probably makes any difference though, as it appears
the point is that matching the TERM definition to the actual
terminal in use is essential!

--
FloydL. Davidson           <http://web.newsguy.com/floyd_davidson>
Ukpeagvik (Barrow, Alaska)                         floyd@barrow.com





[ Post a follow-up to this message ]



    Sponsored Links  




 





   All times are GMT. The time now is 09:30 AM.      Post New Thread    Post A Reply      
  Last Thread   Next Thread Next


Most Popular forums 

Forum Jump:
Rate This Thread:

Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is OFF
vB code is ON
Smilies are ON
[IMG] code is OFF
 
Medical and Health forum | Computer Games Reviews | Graphics design forum

Back To The Top
Home | Usercp | Faq | Register