Subject: curses problem
To: None <netbsd-users@netbsd.org>
From: Christian Groessler <cpg@aladdin.de>
List: netbsd-users
Date: 03/31/2001 22:58:57
Hi,

I tried to write my first program which uses the curses library. I
found a problem (which surely comes from my cluelessness of curses) so
I'm asking for help.

I'm using scanw() for get some input data from the user.

This works fine on all terminals I've tried, but when running in a
telnet session the enter key to finish the input isn't handled
correctly.
It doesn't end the input, it does a CR and the next key pressed
appears at the beginning of the line. (Ctrl-J works for ending the
input.)

I've played with stty settings to no avail, icrnl is set.

I also tried on Solaris and Linux (which uses ncurses) and there the
problem isn't present. Also if I use ncurses from /usr/pkg it works.

Is this a bug in the NetBSD curses lib? I assume no, but then what am
I doing wrong?

I've attached a simple test program.

regards,
chris


------------------------ [cut here]
#include <stdio.h>

#ifdef USE_NCURSES
#  include <ncurses.h>
#else
#  include <curses.h>
#endif

void putsat( int x, int y, char *s )
/* Show a string at x,y, also erasing to end of line */
{
    move( y, x );
    clrtoeol();
    addstr( s );
}

int main( int argc, char **argv )
{
  int val1, val2;

  initscr();

  putsat(10,2, "Test Program");
  putsat(9,3, "--------------");

  putsat( 1, 5, "Value 1: " );
  refresh();

  scanw( "%d", &val1 );
  if( !val1 )              /* enter 0 to exit... */
    goto raus;

  putsat( 1, 6, "Value 2: " );
  refresh();

  scanw( "%d", &val2 );
  if( !val2 )              /* enter 0 to exit... */
    goto raus;

  endwin();
  printf("\n\n\tVal1: %d, Val2: %d\n",val1, val2);
  return(0);

 raus:
  endwin();
  return(0);
}
------------------------ [cut here end]