|
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:Hi I'm building a simple application using ncurses in Mandriva 2008. I have a 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 is an ASCII character using isascii(). I'm also checking for special characters such as enter and backspace. I'm using KEY_BACKSPACE to detect for backspace. It's ASCII value seems to be 263, but when I test my app using Mandriva (Konsole), backspace seems to be ASCII value 127 instead, so the backspace is never detected. Why is there 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 theterminal 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 http://invisible-island.net ftp://invisible-island.net
[Prev in Thread] | Current Thread | [Next in Thread] |