summaryrefslogtreecommitdiff
path: root/security/putty/patches/patch-terminal.c
blob: 2b8c6a15cd014ada115f0c300c4feadbb3ff6c37 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
$NetBSD: patch-terminal.c,v 1.2 2012/11/01 19:32:44 joerg Exp $

Make the home/end keys work on BSD servers as well as Linux ones

--- terminal.c.orig	2011-07-16 11:27:05.000000000 +0000
+++ terminal.c
@@ -6202,13 +6202,6 @@ void term_key(Terminal *term, Key_Sym ke
 	    }
 	}
 
-	/* RXVT Home/End */
-	if (term->cfg.rxvt_homeend &&
-	    (keysym == PK_HOME || keysym == PK_END)) {
-	    p += sprintf((char *) p, keysym == PK_HOME ? "\x1B[H" : "\x1BOw");
-	    goto done;
-	}
-
 	if (term->vt52_mode) {
 	    int xkey;
 
@@ -6229,11 +6222,23 @@ void term_key(Terminal *term, Key_Sym ke
 	    goto done;
 	}
 
+	/* Home/End */
+	if (keysym == PK_HOME || keysym == PK_END) {
+	    /* Send the correct XTerm or rxvt codes for home/end
+	     * We used to send ^[1~ and [4~ for Xterm,
+	     * but those are Linux console */
+	    const char *he;
+	    if (term->cfg.rxvt_homeend)
+		he = keysym == PK_HOME ? "\x1B[7~" : "\x1B[8~";
+	    else
+		he = keysym == PK_HOME ? "\x1BOH" : "\x1BOF";
+	    p += sprintf((char *) p, "%s", he);
+	    goto done;
+	}
+
 	switch (keysym) {
-	  case PK_HOME:     code = 1; break;
 	  case PK_INSERT:   code = 2; break;
 	  case PK_DELETE:   code = 3; break;
-	  case PK_END:      code = 4; break;
 	  case PK_PAGEUP:   code = 5; break;
 	  case PK_PAGEDOWN: code = 6; break;
 	  default: code = 0; break; /* else gcc warns `enum value not used' */