[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Problem with keys

From: Thomas Dickey
Subject: Re: Problem with keys
Date: Tue, 6 May 2008 09:09:18 -0400 (EDT)

On Mon, 5 May 2008, galapogos wrote:

Thomas Dickey-2 wrote:

On Fri, May 02, 2008 at 01:42:01AM -0700, galapogos wrote:

I'm building a simple application using ncurses in Mandriva 2008. I have
simple text user interface asking the user to enter an ASCII string, and
then I'm using wgetch() to parse the string, checking if each character
an ASCII character using isascii(). I'm also checking for special
such as enter and backspace.

I'm using KEY_BACKSPACE to detect for backspace. It's ASCII value seems
be 263, but when I test my app using Mandriva (Konsole), backspace seems
be ASCII value 127 instead, so the backspace is never detected. Why is
a discrepancy between the 2?

ncurses will only return KEY_BACKSPACE if the character(s) happen to
match the string kbs in your terminal's description.  It's likely
that is ^H (8) instead.  For some platforms, kbs is normally ^H,
and for others it is normally ^? (127).

I've used infocmp to check. kbs is mapped to ^H, but somehow it's still
being translated to ^? or ASCII 127. When I use stty to  change it to ^H
with the command "stty erase ^H", in the Linux console a "^?" shows up
whenever I press the backspace key, and the ncurses application still shows
backspace as ASCII 127.

If kbs is ^H, then ncurses looks for control/H.
But if your terminal sends ^?, then ncurses will not know it is backspace.

Most of the Linux distributions make changes as needed to make the
terminal emulators send ^? for "backspace", while almost everyone else uses ^H. They should also modify the terminfo entries in ncurses, but
not all of the Linux distributions do _that_.

Thomas E. Dickey

reply via email to

[Prev in Thread] Current Thread [Next in Thread]