More Problems with Curses

Peter Mroz mroz at eplrx7.uucp
Sat Aug 25 03:54:32 AEST 1990


Hello once again netlanders.  I've got another curses question which
I don't know how to solve.  Hardware: RS/6000 530, software: AIX 9021.
Terminal: vt100 emulation (Versaterm Pro on a MAC, or Relay Gold on a PC).

In curses it is possible to obtain arrow keys with the getch() function.
Depending on what you hit, you get back the predefined values KEY_DOWN,
KEY_UP, KEY_LEFT, or KEY_RIGHT.  The problem is that because of the way I'm
connected in to the RS/6000, sometimes there is a delay in sending the three
bytes for a cursor strike (ESC [ A, ESC [ B, etc.), so that I get back
three characters instead of "one" (KEY_xxxx).  

Called IBM Software Support and was told that this was not a defect; we would
have to get curses to understand the delay.

Is there some stty setting or curses call that will alleviate this problem?

I could parse ESC [ ( A | B | C | D ) but this is vendor code that we are 
using, and it would be easier if there was some setting we could change.

By the way, the way I'm coming in to the RS/6000 is via LAT and a DECserver.


Attached is a little program that illustrates the problem.  Thanks if you
can help.

-------------------------------------------------------------------------------
main()
{
#include "ctype.h"
#include "stdio.h"
#include "time.h"
 
#include "cur00.h"
#include "cur02.h"
extern char ttytype[];
 
    int c;
    char text[80];
    int sd = 0;
 
/** INITIALIZE                                                       **/
    initscr();
    crmode();
    noecho();
    nonl();
    raw();
    keypad(stdscr,TRUE);
/** CLEAR SCREEN                                                     **/
    clear();
/** SAY HELLO                                                        **/
    move(1,1);
    addstr("PLEASE TYPE A KEY");
    refresh();
/** READ KEY                                                         **/
 while ((c = getch()) != 13 && c != 303) {
    sprintf(text,"keychar='%c'  keycode=%d",c,c);
    if (c == KEY_DOWN)       strcpy(text,"DOWN ARROW KEY");
    if (c == KEY_UP)         strcpy(text,"UP ARROW KEY");
    if (c == KEY_LEFT)       strcpy(text,"LEFT ARROW KEY");
    if (c == KEY_RIGHT)      strcpy(text,"RIGHT ARROW KEY");
    if (c == 27)             {
               strcpy(text,"ESC");
               move(15,1);
               addstr(text);
               refresh();
               c = getch();
               sprintf(text,"keychar='%c'  keycode=%d",c,c);
               move(16,1);
               addstr(text);
               refresh();
               c = getch();
               sprintf(text,"keychar='%c'  keycode=%d",c,c);
               move(17,1);
               addstr(text);
               refresh();
               c = getch();
               sprintf(text,"keychar='%c'  keycode=%d",c,c);
               move(18,1);
               addstr(text);
               refresh();
               break;
               }
    if (c == '+') sd = 1;
    if (c == '-') sd = 0;
    move(20,1);
    addstr(text);
    refresh();
    sleep(sd);
    clear();
/** SAY HELLO                                                        **/
    move(1,1);
    addstr("PLEASE TYPE A KEY");
    refresh();
  }
  endwin();
  printf("\r\n");
  exit();
}
-- 
    Peter Mroz                    |    E.I. Du Pont de Nemours & Co.
    eplrx7!mroz at uunet.uu.net      |    Consultant, Scicon
    mrozpa%wmvx at dupont.com        |    DuPont Building, D4078
                                  |    Wilmington, DE 19898
--
The UUCP Mailer



More information about the Comp.unix.aix mailing list