tech-userlevel archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: junk characters from movement keys in vi in xterm via ssh
On Sun, 22 Feb 2009, Valeriy E. Ushakov wrote:
> > I have had this problem for years. Using different xterms, ssh, and NetBSD
> > versions.
> >
> > When I move in vi in an xterm over ssh connections over wireless or other
> > networks, I frequently get junk inserted into my document.
> >
> > I am not insert mode. For example, I may be holding my down arrow down
> > (which is ^[OB) and it will go into insert mode and enter a "B" into my
> > document on a new line -- like it lost the Escape, used "O" for adding a
> > new line above cursor and enter insert mode, and entered the "B".
> >
> > Or sometimes it will enter other characters. It is frustrating as it
> > frequently modifies a document and I may not notice until later.
>
> Nothing netbsd-specific here. If the delay between ESC and O exceeds
> certain threshold (see keypad(3), search for ESCDELAY) ESC gets
> interpreted as plain ESC (it's not "lost" as you hypothesize). That
> gets you into command mode, then O adds a new line and switches to
> insert mode and the next char is then inserted.
Thank you!
So ncurses supports this to be set as an environment variable. ncurses(3)
says "Portable applications should not rely upon the presence of ESCDELAY
in either form, ..."
Any problem with having NetBSD curses honor this as an environment
variable?
I am testing the following:
Index: setterm.c
===================================================================
RCS file: /cvsroot/src/lib/libcurses/setterm.c,v
retrieving revision 1.43
diff -u -r1.43 setterm.c
--- setterm.c 6 Oct 2007 20:14:41 -0000 1.43
+++ setterm.c 22 Feb 2009 02:13:41 -0000
@@ -164,6 +164,9 @@
if ((p = getenv("COLUMNS")) != NULL)
screen->COLS = (int) strtol(p, NULL, 10);
+ if ((p = getenv("ESCDELAY")) != NULL)
+ ESCDELAY = (int) strtol(p, NULL, 10);
+
/*
* Want cols > 4, otherwise things will fail.
*/
No error checking for valid values yet. I rebuilt and installed (as
libcurses.so.6.4).
(Not tested for wide curses.)
tx:libcurses$ ESCDELAY=1234 gdb vi
...
(gdb) run
Starting program: /usr/bin/vi
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
Program received signal SIGTSTP, Stopped (user).
0x00007f7ffd93267a in kill () from /usr/lib/libc.so.12
(gdb) print ESCDELAY
$1 = 1234
Note by default NetBSD curses has it set to 300 ms while ncurses defaults
to 1000 milliseconds. Maybe increasing the ESCDELAY default for NetBSD
curses would be acceptable?
For now (with my patched libcurses), I can export ESCDELAY=1000 and it
appears to help me with vi.
Any thoughts on this?
Jeremy C. Reed
p.s. I changed the list for this email to reach different audience.
Home |
Main Index |
Thread Index |
Old Index