Bug 847852

Summary: Backspace key sends ^H instead of erasechar()
Product: [Fedora] Fedora Reporter: John Haxby <jch>
Component: rogueAssignee: Petr Šabata <psabata>
Status: CLOSED ERRATA QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 17CC: john.haxby, psabata
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2012-08-22 21:13:10 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
Proposed patch
none
Proposed patch, corrected
none
Python test program none

Description John Haxby 2012-08-13 18:51:31 UTC
Created attachment 604070 [details]
Proposed patch

Description of problem:
   The backspace key, the one at the top right of the keyboard that curses
   maps to KEY_BACKSPACE, sends ctrl-H rather than erasechar() so it works
   as ctrl-H not as an erasechar 


Version-Release number of selected component (if applicable):
   rogue-5.4.5-7.fc15.x86_64

How reproducible:
   Always, easily

Steps to Reproduce:
1. I used a konsole, different terminal emulators produce different results
2. start rogue
3. "c", "b" to call armour something, type "xxx", hit backspace key to delete
  
Actual results:
  Nothing happens

Expected results:
  Characters erased

Additional info:
  The problem is that in mdport.c, KEY_BACKSPACE is mapped to CTRL('H') but
  it should be mapped to erasechar().   This works on terminal emulators
  that previously worked as well as terminal emulators (like konsole) that
  didn't.

Comment 1 John Haxby 2012-08-13 18:56:53 UTC
Created attachment 604071 [details]
Proposed patch, corrected

The patch the right way around this time.

Comment 2 Petr Šabata 2012-08-14 14:13:59 UTC
I can reproduce this with current xterm.
Thank you for the patch, John.  It works like a charm.

Comment 3 john.haxby@oracle.com 2012-08-14 14:27:17 UTC
Actually, it doesn't.

With a Mac's terminal emulator ^H behaves as erasechar() instead of go-left-until-you-reach something.   I need to re-think the patch a bit.

It's a pity that rogue maps the KEY_* symbols to ctrl-<something> as that causes trouble like this.   I think that the handling of the backspace key for deleting characters needs to treat ^H and erasechar() as both meaning delete-previous-characters.

Comment 4 Fedora Update System 2012-08-14 14:52:05 UTC
rogue-5.4.5-9.fc17 has been submitted as an update for Fedora 17.
https://admin.fedoraproject.org/updates/rogue-5.4.5-9.fc17

Comment 5 Petr Šabata 2012-08-14 14:59:28 UTC
(In reply to comment #3)
> Actually, it doesn't.
> 
> With a Mac's terminal emulator ^H behaves as erasechar() instead of
> go-left-until-you-reach something.   I need to re-think the patch a bit.

So Mac's terminal emulator sends backspace when ^H is pressed?

Comment 6 John Haxby 2012-08-14 20:24:36 UTC
Created attachment 604444 [details]
Python test program

This is a handy little python script to see what sends what.

The original fix is correct; the problem is actually to do with terminfo entries.

To demonstrate this run

    TERM=xterm ./test.py
    TERM=linux ./test.py
and
    TERM=xterm-color ./test.py


With the first two, the backspace key and ^H send KEY_BACKSPACE and '\x08' respectively as they should.   With the last, however, the backspace key sends '\x7f' and ^H sends KEY_BACKSPACE.    On the Mac, xterm and xterm-color behave the same, though TERM=linux is correct.

Perversely, the unpatched rogue works with xterm-color, but the patched version does not.   Given the behaviour of the test program I'm inclined to believe the patch is still correct, not least because the backspace key does send a '\x7f' outside of curses and not ctrl-h ('\x08').

Comment 7 Fedora Update System 2012-08-14 21:57:14 UTC
Package rogue-5.4.5-9.fc17:
* should fix your issue,
* was pushed to the Fedora 17 testing repository,
* should be available at your local mirror within two days.
Update it with:
# su -c 'yum update --enablerepo=updates-testing rogue-5.4.5-9.fc17'
as soon as you are able to.
Please go to the following url:
https://admin.fedoraproject.org/updates/FEDORA-2012-11868/rogue-5.4.5-9.fc17
then log in and leave karma (feedback).

Comment 8 Fedora Update System 2012-08-22 21:13:10 UTC
rogue-5.4.5-9.fc17 has been pushed to the Fedora 17 stable repository.  If problems still persist, please make note of it in this bug report.