home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #18 / NN_1992_18.iso / spool / comp / unix / misc / 3327 < prev    next >
Encoding:
Text File  |  1992-08-21  |  2.3 KB  |  77 lines

  1. Xref: sparky comp.unix.misc:3327 comp.sys.sun.misc:3823 comp.unix.programmer:4393
  2. Newsgroups: comp.unix.misc,comp.sys.sun.misc,comp.unix.programmer
  3. Path: sparky!uunet!haven.umd.edu!darwin.sura.net!news.duc.auburn.edu!ducvax.auburn.edu!swanger
  4. From: swanger@ducvax.auburn.edu
  5. Subject: Curses/Sun problem
  6. Message-ID: <1992Aug21.093130.1@ducvax.auburn.edu>
  7. Lines: 63
  8. Sender: usenet@news.duc.auburn.edu (News Account)
  9. Nntp-Posting-Host: ducvax
  10. Organization: Auburn University, AL
  11. Date: Fri, 21 Aug 1992 14:31:30 GMT
  12. Lines: 63
  13.  
  14. I am writing a program that uses curses (Sys V) to capture information from
  15. the keyboard.  I am using a SUN Sparcstation IPC, with SUNOS 4.1.2.  I can't
  16. seem to get unique values for some of the keypad keys.  If I press any of
  17. the cursor (arrow) keys, I get a value that is consistent with the values
  18. listed in the curses(v) man pages under SYSTEM V FUNCTION KEYS.  However, if
  19. I press any other key on the keypad, a unique value is not returned.  All I
  20. seem to get for any of these keys is a lowercase 'z'.  Actually, I suspect
  21. some sort of escape sequence that ends (or begins) with 'z' is being
  22. returned.  Still, I am using the curses keypad() function that I thought
  23. would cause these keys to return a unique value, not a sequence.
  24.  
  25. I have included the program below.  I compile and link the program with the
  26. following command:
  27.  
  28. /usr/5bin/cc -I/usr/5include -L/usr/5lib -o ctest ctest.c -lcurses -ltermcap
  29.  
  30. -----------------------------cut here-------------------------------------
  31. #include "curses.h"
  32.  
  33. main()
  34. {
  35.    int key, finished;
  36.    WINDOW *input;
  37.  
  38.    finished = FALSE;
  39.  
  40.    if ((int)initscr() == ERR)
  41.    {
  42.       exit(0);
  43.    }
  44.  
  45.    refresh();
  46.  
  47.    input     = newwin(LINES,COLS,0,0);
  48.    wrefresh(input);
  49.  
  50.    cbreak();
  51.    noecho();
  52.    nonl();
  53.    intrflush(input, FALSE);
  54.    keypad(input, TRUE);
  55.  
  56.    while(finished == FALSE)
  57.    {
  58.       wmove(input,0,0);
  59.       wrefresh(input);
  60.       key = wgetch(input);
  61.       wmove(input, 1, 0);
  62.       wprintw(input, "%c     ", key);
  63.       wmove(input, 2, 0);
  64.       wprintw(input," %o  %d    ", key, key);
  65.       wrefresh(input);
  66.       if (key == 'x') finished = TRUE;
  67.    }
  68.  
  69.    delwin(input);
  70.    endwin();
  71. }
  72. -----------------------------cut here-------------------------------------
  73.  
  74. Thanks in advance for any help you can send!
  75. -- 
  76. David Swanger,   Auburn University, Alabama,   swanger@ducvax.auburn.edu 
  77.