LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 05-02-2008, 04:59 AM   #1
galapogos
Member
 
Registered: May 2008
Posts: 227

Rep: Reputation: 30
Problem with ncurses and character sets/keys


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 backspace. Its 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?

Also, I've tested the app on another self compiled Linux kernel(2.6.22.19) with busybox. In this environment, backspace is ASCII value 263, so KEY_BACKSPACE works. However, the "Break" key, as well as Alt-Break, Shift-Break, Ctrl-Break, seems to convert to 2 ASCII characters - "[P". This doesn't happen in Mandriva. What's wrong here? Why is break an ASCII character when it's clearly not? Has this something to do with the character set and/or termcap/terminfo or something?

Thanks.
 
Old 05-04-2008, 04:49 AM   #2
eggixyz
Member
 
Registered: Apr 2008
Posts: 310

Rep: Reputation: 30
Yes, it's most permanently set in /etc/termcap or terminfo, but you can edit those if you want

vt100|vt100-am|dec vt100 (w/advanced video):\
:am:bs:ms:xn:xo:\
:co#80:it#8:li#24:vt#3:\
:@8=\EOMO=\E[%dB:K1=\EOq:K2=\EOr:K3=\EOs:K4=\EOp:K5=\EOn:\

This system assume bs=^? for the vt100 terminal setting -- so

... etc

You change it at the command line with

stty erase ctl-v [backspace] (define it to be what you want no matter what)

or

tput kbs (make sure it's set correctly for the terminal type

Hope that helps

, Mike
 
Old 05-05-2008, 11:19 PM   #3
galapogos
Member
 
Registered: May 2008
Posts: 227

Original Poster
Rep: Reputation: 30
Hi,

Thanks, but that didn't work. I changed the erase using "stty erase ^h" and now in the console whenever I press backspace the characters "^?" show up instead. The setting also had no effect in the ncurses application. Backspace is still being translated into ASCII value 127.
 
Old 05-07-2008, 02:00 AM   #4
eggixyz
Member
 
Registered: Apr 2008
Posts: 310

Rep: Reputation: 30
Hey There,

Try doing [ctl]-v and then pressing the backspace key and you should get

stty erase ^?

You have to do ctl-v first and then hit the actual button for this to work. It's just one character, not really "caret" followed by "h"

Hope that helps

, Mike
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
ncurses wide character/extended ASCII problem Hosiah Programming 3 03-03-2009 12:55 PM
Webmail and other character sets nextekcarl Linux - General 0 04-28-2007 11:58 AM
Samba character sets 1337_penguin Linux - Networking 0 03-22-2007 05:25 PM
changing character sets on my console?(SuSe 7.3) Fin7PL SUSE / openSUSE 1 02-27-2006 08:36 AM
International Character sets in Pine / Konsole LauraK6 Linux - Software 0 10-28-2004 10:56 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 06:35 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration