Curses erase char question

draper at inmet.inmet.com draper at inmet.inmet.com
Sat Oct 27 03:53:00 AEST 1990


/* Written  7:37 pm  Oct 24, 1990 by ryan at sjuphil.uucp in inmet:comp.lang.c */
/* ---------- "Curses erase char question" ---------- */

Why does Curses sometimes print out the erase character instead of
erasing the previous character like it supposed to?  I checked it
out with the erasechar() function and it does, in fact, know what
the erase character is.   The backspace on my keyboard is set
to '^?' and it works just fine in the shell.  the application i'm
writing has a command line interface and will be tedious to use if
the user cannot use the backspace.

thanks,
pat

-- 
patrick m. ryan
ryan at sju.edu  / ryan%sjuphil.sju.edu at sh.cs.net
{bpa|burdvax|princeton|rutgers}!sjuphil!ryan
pmr at gemini.gsfc.nasa.gov
/* End of text from inmet:comp.lang.c */


The first and most important question I would ask is:

What version of curses are you using?

I have used BSD, SysV, Aspen, Ultix, VMS and HP-UX curses. Different
versions of curses treat erasechar and killchar differently.

For instance with Aspen curses on the PC both Backspace and Del are
mapped to be erasechar. On BSD curses they usually use whatever has
been defined in the .login or .profile as the erasechar unless you have
updated it by using the stty erase command. With HP-UX erasechar and
killchar are not really characters but functions that return the
erasechar and killchar the current shell had defined when you started
up the windows with initscr.

The following are a few examples of how we deal with erasechar
and killchar in our applications.

VMS - Aspen Curses VMS
----------------------
#define CONTROL(x) (x-'A'+1) /* macro to get ascii value of a control char */
#ifndef erasechar
#define erasechar() CONTROL('H')
#endif
#ifndef killchar
#define killchar() CONTROL('Z');
#endif


PC - Aspen Curses
-----------------

#define CONTROL(x) (x-'A'+1) /* macro to get ascii value of a control char */
#undef killchar
#define killchar() CONTROL('X')

Like I said above on the PC both Backspace and Del are mapped to erasechar.


Sun - BSD Curses
----------------

#define erasechar() (_tty.sg_erase)
#define killchar() (_tty.sg_kill)

The above will map erasechar and kill to what was currently defined 
for the shell when the program was executed.


Other problems may have to do with how youy are collecting your
input. I usually set the mode to be raw with no echo. 
By using noecho you can "look" at the characters that you have
read in and decide if you want them echoed to the screen or not.
For maximum control over input and input echoing I recommend that
you do all input on character by character basis without echo and
then make a desicion if you are going to display the char read in
or not.

I would experiment around defining erasechar and killchar and see what
I could get working. Also play with raw mode and no echo .If you still
have problems email a minimal test case along with information on whatever
you are running for curses and the host, host version of the OS and I
will see what I can do.

- Dave 


Internet: draper at inmet.inmet.com
UUNET: uunet!inmet!draper
-----
Intermetrics Microsystems Software, Incorporated
733 Concord Avenue	   Cambridge,  MA  02138
(617) 661-0072 x4573



More information about the Comp.lang.c mailing list