Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 21356 - xterm and nano don't mix
Summary: xterm and nano don't mix
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: High normal (vote)
Assignee: Seemant Kulleen (RETIRED)
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-05-20 15:26 UTC by Peter Ruskin
Modified: 2003-11-01 22:24 UTC (History)
3 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
ncurses-5.3-xterm.patch (ncurses-5.3-xterm.patch,1002 bytes, patch)
2003-06-06 05:47 UTC, bartron
Details | Diff
ncurses-5.3-r1.ebuild.diff (ncurses-5.3-r1.ebuild.diff,768 bytes, patch)
2003-06-06 05:49 UTC, bartron
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Peter Ruskin 2003-05-20 15:26:53 UTC
If I'm editing a file that has long lines, using `nano -w`, the Home and 
End keys don't work as expected.

^a and ^e work OK as  Home and End respectively, but:
End inserts "F" at the line start and Home inserts "H" at the line 
start.

I've remerged nano and baselayout (for /etc/initrc) to no avail.
vim works perfectly.

This only happens from KDE's konsole or from xterm. aterm is OK as 
is a non-gui console.

In KDE my workaround is to edit ~/.kde3.1/share/apps/konsole/shell.desktop,
changing 'Exec=' to 'Exec=bash' and 'Term=xterm' to 'Term=linux'.

I posted this on gentoo-dev and got my knuckles rapped by foser for posting
there; he said it is being worked on but I couldn't find it in bugzilla
Comment 1 bartron 2003-06-06 05:44:04 UTC
Problem is xterm's terminfo entry is lacking khome/kend definitions.

  Technically, whenever ncurses sees an escape character 
followed by another character sequence, it checks what TERM 
is set to and consults the corresponding terminfo entry 
for key definitions.  If there's a match, ncurses translates 
this sequence to a single value, if not, the sequence is 
seen by applications as individual keystrokes.  You can check 
this with the `tack' command, or use the test program below.

  For example, home and end in xterm send "\e[H" and "\e[F", 
respectively.  

  Nano tries to interpret some of those sequences itself -- it 
seems to recognize "\e[", but gives up if they're followed by 
H or F, so it eats "\e[" and prints H or F.

  As a quick fix, go to `/usr/share/terminfo/x', there's a
`xterm' symlink that points to `xterm-color'.  Change that 
so it points to `xterm-xfree86', and with the xfree-4.2 xterm 
all keys should be working now (in xfree-4.3, some shifted 
keys have changed, but normal home/end are not affected).

Here's my test program, compile with 
       `gcc -lncurses ti_test.c -o ti_test'

---

#include <curses.h>

int main() {
    int ch; char *key;
    initscr(); cbreak(); noecho();
    keypad(stdscr, TRUE); scrollok(stdscr, TRUE);
    printw("press any key to see its keycode, 'q' quits\n");
    for(;;) {
        if((ch = getch()) == 'q') break;
        key = ch == 0x1B ? "<ESC>" : keyname(ch);
        printw("0x%04X: %s\n", ch, key);
    }
    endwin();
    return 0;
}

---

If terminfo is set up correctly, it will print `KEY_HOME' and 
`KEY_END' when home and end are pressed.
Comment 2 bartron 2003-06-06 05:47:29 UTC
Created attachment 12875 [details, diff]
ncurses-5.3-xterm.patch

patch for ncurses-5.3 to make the `xterm' terminfo 
entry an alias for `xterm-xfree86' and update
`xterm-xfree86' keydefs that have changed in xfree-4.3.
Comment 3 bartron 2003-06-06 05:49:12 UTC
Created attachment 12876 [details, diff]
ncurses-5.3-r1.ebuild.diff

modified ebuild that makes use of the above patch 
and doesn't create the terminfo/x/xterm symlink.
Comment 4 Seemant Kulleen (RETIRED) gentoo-dev 2003-06-10 06:35:32 UTC
bartron, can you do me favour and open a bug in Gentoo New Developer section, please?
Comment 5 Seemant Kulleen (RETIRED) gentoo-dev 2003-06-11 16:02:39 UTC
bartron, 

2 things: 1.  Thanks a bunch for this and the openmotif stuff (openmotif is being checked in in a few minutes, with your fixes).

2.  Please see comment #4 above
Comment 6 Rainer Größlinger (RETIRED) gentoo-dev 2003-10-16 12:56:39 UTC
uh, I know this bug has been closed long ago, but indirectly there is still
an issue with it:
Currently ncurses-5.3-r2, -r3 and -r4 have the patch, but the latest stable
version for all archs (besides alpha) is -r1
Comment 7 bartron 2003-10-16 18:17:53 UTC
  I think there is still an open issue with PuTTY that hasn't 
been confirmed yet (bug #26076).  By default, PuTTY assumes xterms
can't do `background-color-erase' (which in fact they do, even 
in really ancient versions as shipped with some commercial OSs).

  But since >=-r2 still masked... there's another issue -r0..-r4 
don't address yet... `kbs'.  Traditionally, backspace would send
^H, but since emacs has adopted ^H to mean `help' a long time ago, 
the linux console as well as some xterms around have redefined 
backspace to send ^? instead.  Looking through the tree, the only 
other term that should set `TERM=xterm' is konsole (easily fixed 
to send ^? as well).
Question is, is there some way to force-update xfree(xterm), 
kde(konsole), and ncurses all at the same time to break as few 
systems as possible with this change.
Comment 8 Reporter 2003-11-01 22:24:57 UTC
Wasn't -r2 in x86 a long time ago? I sure never used ~x86; but I still have
-r2 on my box since early july. Whats the point haveing a broken setup just
to support putty, a windoze program?

Just out of curiosity, is this kbs thingy the reason, why C-H in emacs in
xterms acts like backspace? If so, it would be nice to see this fixed in
-r5; would make Gentoo the only linux in existence, where every key in xterm
does exactly what it should.