[comp.unix.aix] More Problems with Curses

mroz@eplrx7.uucp (Peter Mroz) (08/25/90)

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@uunet.uu.net      |    Consultant, Scicon
    mrozpa%wmvx@dupont.com        |    DuPont Building, D4078
                                  |    Wilmington, DE 19898
--
The UUCP Mailer

jeffe@sandino.austin.ibm.com (Peter Jeffe 512.823.4091) (08/29/90)

In article <1990Aug24.175432.26025@eplrx7.uucp> mroz@eplrx7.uucp (Peter Mroz) writes:
>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?

The curses library has dealt with this issue by allowing you to redefine the
maximum delay between the escape character and succeeding ones in an escape
sequence.  You can do this with the ESCDELAY environment variable, which
specifies the number of 200 microsecond intervals to wait after an escape
character is seen.  The default value is 100000 usecs, or an ESCDELAY value
of 500.  I've found that a value of 1000 does the trick with an rlogin over
one gateway.

This feature is avaliable in the July update.
-------------------------------------------------------------------------------
Peter Jeffe   ...uunet!cs.utexas.edu!ibmaus!auschs!sandino.austin.ibm.com!jeffe
        first they want a disclaimer, then they make you pee in a jar,
                   then they come for you in the night