[links-list] eterm keycodes & mc clipboard

Jan Bobrowski jb at wizard.ae.krakow.pl
Mon Jan 15 09:02:45 PST 2001


Hi

Here are two patches you.

First adds support for Eterm keycodes and scrolling window with Ctrl-Arrow
or Shift-Arrow. There's also Linux console keymap file with (some) of
Eterm keycodes. (In standard vt100 there's no difference when you press
function key with or without control or shift)

For example ESC [ A is code for up arrow while ESC [ a is shifted version
and Ctrl-Up gives ESC O a.

Second patch provides support for Midnight Commander clipboard file
~/.cedit/cooledit.clip (if present). With previous patch you may copy
link using Ctrl-Ins and then paste it with Shift-Ins.

Jan Bobrowski
-------------- next part --------------
diff -u links-0.95/kbd.c links/kbd.c
--- links-0.95/kbd.c	Sun Dec 31 23:26:52 2000
+++ links/kbd.c	Wed Jan 10 04:34:24 2001
@@ -455,6 +455,12 @@
 /* 256 */
 };
 
+static long funkey[25] = {
+	-1, KBD_HOME, KBD_INS, KBD_DEL, KBD_END, KBD_PAGE_UP, KBD_PAGE_DOWN,
+	KBD_END, KBD_HOME, -1,-1,-1,-1,-1,-1,-1,-1, KBD_F6, KBD_F7, KBD_F8,
+	KBD_F9,	KBD_F10, -1, KBD_F11, KBD_F12
+};
+
 int xterm_button = -1;
 
 int process_queue(struct itrm *itrm)
@@ -494,25 +500,28 @@
 					case 222: ev.x = KBD_PAGE_DOWN; break;
 					case 249: ev.x = KBD_DEL; break;
 					} break;
-				case '~': switch (v) {
-					case 1: ev.x = KBD_HOME; break;
-					case 2: ev.x = KBD_INS; break;
-					case 3: ev.x = KBD_DEL; break;
-					case 4: ev.x = KBD_END; break;
-					case 5: ev.x = KBD_PAGE_UP; break;
-					case 6: ev.x = KBD_PAGE_DOWN; break;
-					case 7: ev.x = KBD_END; break;
-					case 8: ev.x = KBD_HOME; break;
-					case 17: ev.x = KBD_F6; break;
-					case 18: ev.x = KBD_F7; break;
-					case 19: ev.x = KBD_F8; break;
-					case 20: ev.x = KBD_F9; break;
-					case 21: ev.x = KBD_F10; break;
-					case 23: ev.x = KBD_F11; break;
-					case 24: ev.x = KBD_F12; break;
-					} break;
+
+				case '@': ev.y = KBD_CTRL;
+				case '$': ev.y |= KBD_SHIFT;
+					if(0) {;
+				case '^': ev.y = KBD_CTRL;
+					}
+				case '~':
+					if(v < sizeof funkey/sizeof *funkey)
+						ev.x = funkey[v];
+					break;
+/*				case 'Z': ev.x = KBD_TAB; ev.y = KBD_SHIFT; break; */
+
+				case 'a': ev.x = KBD_UP; goto shift;
+				case 'b': ev.x = KBD_DOWN; goto shift;
+				case 'c': ev.x = KBD_RIGHT; goto shift;
+				case 'd': ev.x = KBD_LEFT;
+shift:					ev.y = KBD_SHIFT;
+					if(itrm->kqueue[1] == 'O') ev.y = KBD_CTRL;
+					break;
+
 				case 'R':
-						  resize_terminal (); break ;
+					resize_terminal(); break;
 				case 'M': if (itrm->qlen - el < 3) goto ret;
 					ev.ev = EV_MOUSE;
 					ev.x = itrm->kqueue[el+1] - ' ' - 1;
diff -u links-0.95/kbdbind.c links/kbdbind.c
--- links-0.95/kbdbind.c	Sun Dec 31 23:26:52 2000
+++ links/kbdbind.c	Wed Jan 10 04:25:43 2001
@@ -60,8 +60,12 @@
 {
 	struct keybinding *kb;
 	if (ev->ev == EV_KBD)
-		foreach(kb, keymaps[kmap]) 
-			if (ev->x == kb->x && ev->y == kb->y) return kb->act;
+		foreach(kb, keymaps[kmap]) {
+			if (ev->x != kb->x) continue;
+			if (ev->y == kb->y || ev->y && kb->y == KBD_ANYMOD)
+				return kb->act;
+		}
+			
 	return -1;
 }
 
@@ -270,11 +274,15 @@
 	{ ACT_UP, KBD_UP, 0 },
 	{ ACT_COPY_CLIPBOARD, KBD_INS, KBD_CTRL },
 	{ ACT_COPY_CLIPBOARD, 'C', KBD_CTRL },
+	{ ACT_SCROLL_UP, KBD_UP, KBD_ANYMOD },
 	{ ACT_SCROLL_UP, KBD_INS, 0 },
 	{ ACT_SCROLL_UP, 'P', KBD_CTRL },
+	{ ACT_SCROLL_DOWN, KBD_DOWN, KBD_ANYMOD },
 	{ ACT_SCROLL_DOWN, KBD_DEL, 0 },
 	{ ACT_SCROLL_DOWN, 'N', KBD_CTRL },
+	{ ACT_SCROLL_LEFT, KBD_LEFT, KBD_ANYMOD },
 	{ ACT_SCROLL_LEFT, '[', 0 },
+	{ ACT_SCROLL_RIGHT, KBD_RIGHT, KBD_ANYMOD },
 	{ ACT_SCROLL_RIGHT, ']', 0 },
 	{ ACT_HOME, KBD_HOME, 0 },
 	{ ACT_END, KBD_END, 0 },
@@ -320,7 +328,9 @@
 	{ ACT_END, 'E', KBD_CTRL },
 	{ ACT_COPY_CLIPBOARD, KBD_INS, KBD_CTRL },
 	{ ACT_COPY_CLIPBOARD, 'B', KBD_CTRL },
+	{ ACT_CUT_CLIPBOARD, KBD_DEL, KBD_SHIFT },
 	{ ACT_CUT_CLIPBOARD, 'X', KBD_CTRL },
+	{ ACT_PASTE_CLIPBOARD, KBD_INS, KBD_SHIFT },
 	{ ACT_PASTE_CLIPBOARD, 'V', KBD_CTRL },
 	{ ACT_ENTER, KBD_ENTER, 0 },
 	{ ACT_BACKSPACE, KBD_BS, 0 },
diff -u links-0.95/links.h links/links.h
--- links-0.95/links.h	Sun Dec 31 23:26:52 2000
+++ links/links.h	Wed Jan 10 03:04:41 2001
@@ -904,6 +904,7 @@
 #define KBD_SHIFT	1
 #define KBD_CTRL	2
 #define KBD_ALT		4
+#define KBD_ANYMOD	255
 
 void handle_trm(int, int, int, int, int, void *, int);
 void free_all_itrms();
-------------- next part --------------
diff -u links-0.95/os_dep.c links/os_dep.c
--- links-0.95/os_dep.c	Sun Dec 31 23:26:52 2000
+++ links/os_dep.c	Wed Jan 10 04:16:06 2001
@@ -284,6 +284,8 @@
 
 #endif
 
+#ifndef UNIX
+
 char *get_clipboard_text()	/* !!! FIXME */
 {
 	char *ret = 0;
@@ -295,6 +297,39 @@
 {
 	/* !!! FIXME */
 }
+
+#else
+
+/* Midnight Commander clipboard support */
+
+static unsigned char *get_clip_path()
+{
+	unsigned char *p = init_str();
+	unsigned char *h = getenv("HOME");
+	int l = 0;
+	if(h) add_to_str(&p, &l, h);
+	add_to_str(&p, &l, "/.cedit/cooledit.clip");
+	return p;
+}
+
+char *get_clipboard_text()
+{
+	unsigned char *read_config_file(unsigned char *name);
+	unsigned char *p = get_clip_path();
+	unsigned char *f = read_config_file(p);
+	mem_free(p);
+	for(p=f; *p; p++) if(*p == '\n') *p = ' ';
+	return f ? f : init_str();
+}
+
+void set_clipboard_text(char *data)
+{
+	unsigned char *p = get_clip_path();
+	write_to_config_file(p, data);
+	mem_free(p);
+}
+
+#endif
 
 void set_window_title(unsigned char *url)
 {
-------------- next part --------------
#
# by Jan Bobrowski <jb at mohan.krakow.pl>
#
#              Plain  +Shift  +AltGr  +Shift+AltGr
# Plain          0       1       2       3
# +Control       4       5       6       7
# +Alt           8       9      10      11
# +Control+Alt  12      13      14      15

keymaps 0-4,8,9,12

		keycode 1 = Escape Escape
alt		keycode 1 = Meta_Escape
		keycode 2 = one exclam
alt		keycode 2 = Meta_one
shift alt	keycode 2 = Meta_exclam
		keycode 3 = two at at
alt		keycode 3 = Meta_two
shift alt	keycode 3 = Meta_at
control		keycode 3 = nul
		keycode 4 = three numbersign
alt		keycode 4 = Meta_three
shift alt	keycode 4 = Meta_numbersign
control		keycode 4 = Escape
		keycode 5 = four dollar section
alt		keycode 5 = Meta_four
shift alt	keycode 5 = Meta_dollar
control		keycode 5 = Control_backslash
		keycode 6 = five percent
alt		keycode 6 = Meta_five
shift alt	keycode 6 = Meta_percent
control		keycode 6 = Control_bracketright
		keycode 7 = six asciicircum
alt		keycode 7 = Meta_six
shift alt	keycode 7 = Meta_asciicircum
control		keycode 7 = Control_asciicircum
		keycode 8 = seven ampersand braceleft
alt		keycode 8 = Meta_seven
shift alt	keycode 8 = Meta_ampersand
control		keycode 8 = Control_underscore
		keycode 9 = eight asterisk bracketleft
alt		keycode 9 = Meta_eight
shift alt	keycode 9 = Meta_asterisk
control		keycode 9 = Delete
		keycode 10 = nine parenleft bracketright
alt		keycode 10 = Meta_nine
shift alt	keycode 10 = Meta_parenleft
		keycode 11 = zero parenright braceright
alt		keycode 11 = Meta_zero
shift alt	keycode 11 = Meta_parenright
		keycode 12 = minus underscore backslash
alt		keycode 12 = Meta_minus
shift alt	keycode 12 = Meta_underscore
altgr		keycode 12 = hyphen
control		keycode 12 = Control_underscore
#shift control	keycode 12 = Control_underscore
		keycode 13 = equal plus
alt		keycode 13 = Meta_equal
shift alt	keycode 13 = Meta_plus
altgr		keycode 13 = degree
		keycode 14 = Delete Delete
alt		keycode 14 = Meta_Delete
control		keycode 14 = Meta_Delete
alt control	keycode 14 = Meta_Delete
altgr		keycode 14 = BackSpace
shift altgr	keycode 14 = Meta_BackSpace
		keycode 15 = Tab F100
alt		keycode 15 = Meta_Tab
		keycode 16 = q
		keycode 17 = w
		keycode 18 = e
		keycode 19 = r
		keycode 20 = t
		keycode 21 = y
		keycode 22 = u
		keycode 23 = i
		keycode 24 = o
		keycode 25 = p
		keycode 26 = bracketleft braceleft
alt		keycode 26 = Meta_bracketleft
shift alt	keycode 26 = Meta_braceleft
control		keycode 26 = Escape
		keycode 27 = bracketright braceright asciitilde
alt		keycode 27 = Meta_bracketright
shift alt	keycode 27 = Meta_braceright
control		keycode 27 = Control_bracketright
		keycode 28 = Return
alt		keycode 28 = Meta_Control_m
altgr		keycode 28 = Linefeed
		keycode 29 = Control
		keycode 30 = a
		keycode 31 = s
		keycode 32 = d
		keycode 33 = f
		keycode 34 = g
		keycode 35 = h
		keycode 36 = j
		keycode 37 = k
		keycode 38 = l
		keycode 39 = semicolon colon
alt		keycode 39 = Meta_semicolon
shift alt	keycode 39 = Meta_colon
		keycode 40 = apostrophe quotedbl
alt		keycode 40 = Meta_apostrophe
shift alt	keycode 40 = Meta_quotedbl
control		keycode 40 = Control_g
		keycode 41 = grave asciitilde
alt		keycode 41 = Meta_grave
shift alt	keycode 41 = Meta_asciitilde
control		keycode 41 = nul
		keycode 42 = Shift
		keycode 43 = backslash bar
alt		keycode 43 = Meta_backslash
shift alt	keycode 43 = Meta_bar
control		keycode 43 = Control_backslash
		keycode 44 = z
		keycode 45 = x
		keycode 46 = c
		keycode 47 = v
		keycode 48 = b
		keycode 49 = n
		keycode 50 = m
		keycode 51 = comma less
alt		keycode 51 = Meta_comma
shift alt	keycode 51 = Meta_less
		keycode 52 = period greater
alt		keycode 52 = Meta_period
shift alt	keycode 52 = Meta_greater
control		keycode 52 = Compose
altgr		keycode 52 = Compose
		keycode 53 = slash question
alt		keycode 53 = Meta_slash
shift alt	keycode 53 = Meta_question
control		keycode 53 = Delete
		keycode 54 = Shift
		keycode 55 = KP_Multiply
altgr		keycode 55 = Hex_C
alt		keycode 55 = multiply
		keycode 56 = Alt
		keycode 57 = space space
control		keycode 57 = nul
alt		keycode 57 = Meta_space
altgr		keycode 57 = nobreakspace
		keycode 58 = Caps_Lock
		keycode 59 = F1 F11 Console_13
control		keycode 59 = F1
alt		keycode 59 = Console_1
control alt	keycode 59 = Console_1
		keycode 60 = F2 F12 Console_14
control		keycode 60 = F2
alt		keycode 60 = Console_2
control alt	keycode 60 = Console_2
		keycode 61 = F3 F13 Console_15
control		keycode 61 = F3
alt		keycode 61 = Console_3
control alt	keycode 61 = Console_3
		keycode 62 = F4 F14 Console_16
control		keycode 62 = F4
alt		keycode 62 = Console_4
control alt	keycode 62 = Console_4
		keycode 63 = F5 F15 Console_17
control		keycode 63 = F5
alt		keycode 63 = Console_5
control alt	keycode 63 = Console_5
		keycode 64 = F6 F16 Console_18
control		keycode 64 = F6
alt		keycode 64 = Console_6
control alt	keycode 64 = Console_6
		keycode 65 = F7 F17 Console_19
control		keycode 65 = F7
alt		keycode 65 = Console_7
control alt	keycode 65 = Console_7
		keycode 66 = F8 F18 Console_20
control		keycode 66 = F8
alt		keycode 66 = Console_8
control alt	keycode 66 = Console_8
		keycode 67 = F9 F19 Console_21
control		keycode 67 = F9
alt		keycode 67 = Console_9
control alt	keycode 67 = Console_9
		keycode 68 = F10 F20 Console_22
control		keycode 68 = F10
alt		keycode 68 = Console_10
control alt	keycode 68 = Console_10
		keycode 69 = Num_Lock
shift		keycode 69 = Bare_Num_Lock
altgr		keycode 69 = Hex_A
		keycode 70 = Scroll_Lock Show_Memory Show_Registers
control		keycode 70 = Show_State
alt		keycode 70 = Scroll_Lock
		keycode 71 = KP_7 F211
control		keycode 71 = F221
alt		keycode 71 = Ascii_7
altgr		keycode 71 = Hex_7
		keycode 72 = KP_8 F101
alt		keycode 72 = Ascii_8
altgr		keycode 72 = Hex_8
control		keycode 72 = F121	# Ctrl-Up
		keycode 73 = KP_9 F215
alt		keycode 73 = Ascii_9
altgr		keycode 73 = Hex_9
control		keycode 73 = F225
		keycode 74 = KP_Subtract
altgr		keycode 74 = Hex_D
		keycode 75 = KP_4 F104
alt		keycode 75 = Ascii_4
altgr		keycode 75 = Hex_4
control		keycode 75 = F124	# Ctrl-Left
		keycode 76 = KP_5
alt		keycode 76 = Ascii_5
altgr		keycode 76 = Hex_5
		keycode 77 = KP_6 F103
alt		keycode 77 = Ascii_6
altgr		keycode 77 = Hex_6
control		keycode 77 = F123	# Ctrl-Right
		keycode 78 = KP_Add
altgr		keycode 78 = Hex_E
		keycode 79 = KP_1 F214
alt		keycode 79 = Ascii_1
altgr		keycode 79 = Hex_1
control		keycode 79 = F224
		keycode 80 = KP_2 F102
alt		keycode 80 = Ascii_2
altgr		keycode 80 = Hex_2
control		keycode 80 = F122	# Ctrl-Down
		keycode 81 = KP_3 F216
alt		keycode 81 = Ascii_3
altgr		keycode 81 = Hex_3
control		keycode 81 = F226
		keycode 82 = KP_0 F212
alt		keycode 82 = Ascii_0
altgr		keycode 82 = Hex_0
control		keycode 82 = F222
		keycode 83 = KP_Period F213
control		keycode 83 = F223
#altgr control	keycode 83 = Boot
control alt	keycode 83 = Boot
		keycode 84 = Last_Console
		keycode 85 =
		keycode 86 = less greater bar
alt		keycode 86 = Meta_less
		keycode 87 = F11 F21 Console_23
control		keycode 87 = F11
alt		keycode 87 = Console_11
control alt	keycode 87 = Console_11
		keycode 88 = F12 F22 Console_24
control		keycode 88 = F12
alt		keycode 88 = Console_12
control alt	keycode 88 = Console_12
		keycode 89 =
		keycode 90 =
		keycode 91 =
		keycode 92 =
		keycode 93 =
		keycode 94 =
		keycode 95 =
		keycode 96 = KP_Enter
altgr		keycode 96 = Hex_F
		keycode 97 = Control
		keycode 98 = KP_Divide
altgr		keycode 98 = Hex_B
alt		keycode 98 = division
		keycode 99 = Control_backslash
control		keycode 99 = Control_backslash
alt		keycode 99 = Control_backslash
		keycode 100 = AltGr
		keycode 101 = Break
		keycode 102 = Find F211
control		keycode 102 = F221
		keycode 103 = Up F101
control		keycode 103 = F121	# Ctrl-Up
		keycode 104 = Prior F215
shift		keycode 104 = Scroll_Backward
control		keycode 104 = F225
		keycode 105 = Left F104
alt		keycode 105 = Decr_Console
control		keycode 105 = F124	# Ctrl-Left
		keycode 106 = Right F103
alt		keycode 106 = Incr_Console
control		keycode 106 = F123	# Ctrl-Right
		keycode 107 = Select F214
control		keycode 107 = F224
		keycode 108 = Down F102
control		keycode 108 = F122	# Ctrl-Down
		keycode 109 = Next F216
shift		keycode 109 = Scroll_Forward
control		keycode 109 = F226
		keycode 110 = Insert F212
control		keycode 110 = F222
		keycode 111 = Remove F213
control		keycode 111 = F223
#altgr control	keycode 111 = Boot
control alt	keycode 111 = Boot
		keycode 112 = Macro
		keycode 113 = F13
		keycode 114 = F14
		keycode 115 = Help
		keycode 116 = Do
		keycode 117 = F17
		keycode 118 = KP_MinPlus
		keycode 119 = Pause
		keycode 120 =
		keycode 121 =
		keycode 122 =
		keycode 123 =
		keycode 124 =
		keycode 125 = AltGr
		keycode 126 = AltGr
		keycode 127 = F16

string F1 = "\33[[A"
string F2 = "\33[[B"
string F3 = "\33[[C"
string F4 = "\33[[D"
string F5 = "\33[[E"
string F6 = "\33[17~"
string F7 = "\33[18~"
string F8 = "\33[19~"
string F9 = "\33[20~"
string F10 = "\33[21~"
string F11 = "\33[23~"
string F12 = "\33[24~"
string F13 = "\33[25~"
string F14 = "\33[26~"
string F15 = "\33[28~"
string F16 = "\33[29~"
string F17 = "\33[31~"
string F18 = "\33[32~"
string F19 = "\33[33~"
string F20 = "\33[34~"
string F21 = "\33[23$"
string F22 = "\33[24$"
string F23 = "\33[25$"
string F24 = "\33[26$"
string F25 = "\33[28$"
string F26 = "\33[29$"
string F27 = "\33[31$"
string F28 = "\33[32$"
string F29 = "\33[33$"
string F30 = "\33[34$"

string Find = "\33[1~"		# Home
string F211 = "\33[1$"
string F221 = "\33[1^"
string Select = "\33[4~"	# End
string F214 = "\33[4$"
string F224 = "\33[4^"
string Prior = "\33[5~"		# PgUp
string F215 = "\33[5$"
string F225 = "\33[5^"
string Next = "\33[6~"		# PgDn
string F216 = "\33[6$"
string F226 = "\33[6^"
string Insert = "\33[2~"	# Ins
string F212 = "\33[2$"
string F222 = "\33[2^"
string Remove = "\33[3~"	# Del
string F213 = "\33[3$"
string F223 = "\33[3^"
string Macro = "\33[M"
string Pause = "\33[P"
string Help = "\33[28~"

string F100 = "\33[Z"	# Shift-Tab

string F101 = "\33[a"	# Shift-Up
string F102 = "\33[b"	# Shift-Down
string F103 = "\33[c"	# Shift-Right
string F104 = "\33[d"	# Shift-Left
string F121 = "\33Oa"	# Ctrl-Up
string F122 = "\33Ob"	# Ctrl-Down
string F123 = "\33Oc"	# Ctrl-Right
string F124 = "\33Od"	# Ctrl-Left


More information about the links-list mailing list