On Tue, Oct 26, 2004 at 02:30:16PM +0200, Michael Holzt wrote:
> Rob Weir wrote:
> > The home and end keys don't seem to work consistently: in vim they work
> > fine, but mutt and less don't recognise them as home and end (though
> > they do recognise that I pressed _something_).
> 
> I found a solution for this. First i set in xresources 'RXVTHomeEnd' to '1'
> and 'TerminalType' to 'rxvt'. Regarding to documentation setting RXVTHomeEnd
> to '1' should instruct pterm to emit rxvt-like home and end key sequences,
> and this should work when TerminalType is also set to rxvt. 
> 
> Documentation of pterm states: "'rxvt' sends 'ESC [H' for the Home key and 
> 'ESC [Ow' for the End key." But this is not correct. When trying out with
> rxvt, one finds out that rxvt (at least in the actual version as in debian 
> unstable) sends 'ESC [7~' for the Home Key and 'ESC [8~' for End key. 
> Therefore 
> the sources of pterm/putty needs to be modified in this.
> 
> I suggest adding the following patch at least to the debian version:
> --- putty-0.55/terminal.c       2004-07-29 19:56:50.000000000 +0200
> +++ putty-0.55-fixed/terminal.c 2004-10-26 14:23:37.000000000 +0200
> @@ -4586,7 +4586,7 @@
>         /* RXVT Home/End */
>         if (term->cfg.rxvt_homeend &&
>             (keysym == PK_HOME || keysym == PK_END)) {
> -           p += sprintf((char *) p, keysym == PK_HOME ? "\x1B[H" : "\x1BOw");
> +           p += sprintf((char *) p, keysym == PK_HOME ? "\x1B[7~" : 
> "\x1B[8~");
>             goto done;
>         }
> 
> diff -Naur putty-0.55/unix/pterm.c putty-0.55-fixed/unix/pterm.c
> --- putty-0.55/unix/pterm.c     2004-07-27 17:20:37.000000000 +0200
> +++ putty-0.55-fixed/unix/pterm.c       2004-10-26 14:23:27.000000000 +0200
> @@ -916,7 +916,7 @@
>                 goto done;
>             }
>             if (inst->cfg.rxvt_homeend && (code == 1 || code == 4)) {
> -               end = 1 + sprintf(output+1, code == 1 ? "\x1B[H" : "\x1BOw");
> +               end = 1 + sprintf(output+1, code == 1 ? "\x1B[7~" : 
> "\x1B[8~");
>                 use_ucsoutput = FALSE;
>                 goto done;
>             }
> diff -Naur putty-0.55/window.c putty-0.55-fixed/window.c
> --- putty-0.55/window.c 2004-07-29 19:56:50.000000000 +0200
> +++ putty-0.55-fixed/window.c   2004-10-26 14:23:11.000000000 +0200
> @@ -3793,7 +3793,7 @@
>             return p - output;
>         }
>         if (cfg.rxvt_homeend && (code == 1 || code == 4)) {
> -           p += sprintf((char *) p, code == 1 ? "\x1B[H" : "\x1BOw");
> +           p += sprintf((char *) p, code == 1 ? "\x1B[7~" : "\x1B[8~");
>             return p - output;
>         }
>         if (code) {
> 
> When applying this patch and adding the following Lines to ~/.Xresources
> everything works fine:
> 
> pterm.RXVTHomeEnd:      1
> pterm.TerminalType:     rxvt

This seems correct for rxvt mode, unless I'm missing something. In fact,
in current rxvt, <CSI O w> is numeric keypad Home, not End at all, so I
don't see how the current code can be correct? Anyway, belatedly
forwarding the patch.


Going back to xterm compatibility and surveying the available
LinuxFunctionKeys modes in pterm, "pterm.LinuxFunctionKeys: 5" (a.k.a.
FUNKY_SCO) appears to match xterm's current behaviour for Home/End, but
very little else; Insert/Delete/PageUp/PageDown match xterm in
LinuxFunctionKeys modes 0 (FUNKY_TILDE), 1 (FUNKY_LINUX), 2
(FUNKY_XTERM), and 4 (FUNKY_VT100P).

Here's a patch that makes pterm emit sequences that match current xterm
in FUNKY_XTERM mode. If you don't want to apply it without making it
configurable as well, would you mind if I applied this at least in
Debian, so that we're in sync with the way other Debian terminal
emulators behave?

Index: windows/window.c
===================================================================
--- windows/window.c    (revision 5386)
+++ windows/window.c    (working copy)
@@ -3981,6 +3981,10 @@
            p += sprintf((char *) p, code == 1 ? "\x1B[H" : "\x1BOw");
            return p - output;
        }
+       if (cfg.funky_type == FUNKY_XTERM && (code == 1 || code == 4)) {
+           p += sprintf((char *) p, code == 1 ? "\x1B[H" : "\x1B[F");
+           return p - output;
+       }
        if (code) {
            p += sprintf((char *) p, "\x1B[%d~", code);
            return p - output;
Index: terminal.c
===================================================================
--- terminal.c  (revision 5386)
+++ terminal.c  (working copy)
@@ -5984,6 +5984,13 @@
            goto done;
        }
 
+       /* Xterm Home/End */
+       if (term->cfg.funky_type == FUNKY_XTERM &&
+           (keysym == PK_HOME || keysym == PK_END)) {
+           p += sprintf((char *) p, keysym == PK_HOME ? "\x1B[H" : "\x1B[F");
+           goto done;
+       }
+
        if (term->vt52_mode) {
            int xkey;
 
Index: unix/gtkwin.c
===================================================================
--- unix/gtkwin.c       (revision 5386)
+++ unix/gtkwin.c       (working copy)
@@ -953,6 +953,11 @@
                use_ucsoutput = FALSE;
                goto done;
            }
+           if (inst->cfg.funky_type == FUNKY_XTERM && (code == 1 || code == 
4)) {
+               end = 1 + sprintf(output+1, code == 1 ? "\x1B[H" : "\x1B[F");
+               use_ucsoutput = FALSE;
+               goto done;
+           }
            if (code) {
                end = 1 + sprintf(output+1, "\x1B[%d~", code);
                use_ucsoutput = FALSE;

Thanks,

-- 
Colin Watson                                       [EMAIL PROTECTED]


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Reply via email to