-
Notifications
You must be signed in to change notification settings - Fork 0
/
tabkey.h
277 lines (275 loc) · 18.3 KB
/
tabkey.h
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
fprintf(stdout, " var commandkey = false;\n");
fprintf(stdout, " var alertkey = false;\n");
fprintf(stdout, " window.onkeydown = function(event) {\n");
fprintf(stdout, " var esk = keysdown.shift = event.shiftKey;\n");
fprintf(stdout, " keysdown.reshift = false;\n");
fprintf(stdout, " var eck = keysdown.control = event.ctrlKey;\n");
fprintf(stdout, " var eak = keysdown.alt = event.altKey;\n");
fprintf(stdout, " var ekc = event.keyCode;\n");
fprintf(stdout, " var tln = lineid[inbosel];\n");
fprintf(stdout, " $$('optbox').innerHTML = '' + ekc;\n");
fprintf(stdout, " if (event.preventDefault === false)\n");
fprintf(stdout, " { commandkey = false; }\n");
fprintf(stdout, " var pastekey = false;\n");
fprintf(stdout, " if (commandkey == true && ekc == 86) {\n"); // CTRL-V
fprintf(stdout, " pastefocus();\n");
// fprintf(stdout, " commandkey = false;\n");
fprintf(stdout, " return true;\n");
fprintf(stdout, " } else if (commandkey == true && ekc == 67) {\n"); // CTRL-C
fprintf(stdout, " if (copying == false) {\n");
fprintf(stdout, " copyfocus();\n");
fprintf(stdout, " event.preventDefault();\n");
fprintf(stdout, " } else if (copying == true)\n");
fprintf(stdout, " { copying = 'up'; }\n");
fprintf(stdout, " return true;\n");
// fprintf(stdout, " } else if (pasting === undefined) {\n");
// fprintf(stdout, " pasting = undefined;\n");
// fprintf(stdout, " pastefocus();\n");
// fprintf(stdout, " return true;\n");
// fprintf(stdout, " } else if (commandkey == true && ekc == 67) {\n"); // CTRL-+
fprintf(stdout, " } else if (event.preventDefault == false) {\n");
fprintf(stdout, " pastekey = true;\n"); // called from function with struct
fprintf(stdout, " } else if (ekc == 224 || ekc == 17 || ekc == 91 || ekc == 93) {\n");
fprintf(stdout, " commandkey = true;\n"); // double .. a
/*
fprintf(stdout, " else if ((copying !== false || pasting !== false) && ekc == 27) {\n");
fprintf(stdout, " pasting = undefined;\n");
fprintf(stdout, " pastefocus();\n");
fprintf(stdout, " event.preventDefault();\n");
fprintf(stdout, " return false;\n");
fprintf(stdout, " } else if (loading !== false && commandkey == false) {\n");
// fprintf(stdout, " pasting = undefined;\n");
// fprintf(stdout, " loadfocus();\n");
fprintf(stdout, " if (ekc == 27)\n");
fprintf(stdout, " { bodyundrag(); }\n");
fprintf(stdout, " event.preventDefault();\n");
fprintf(stdout, " return false;\n");
*/
fprintf(stdout, " } else if (ekc == 76 && commandkey == true) {\n"); // CMD-L
fprintf(stdout, " commandkey = false; return true;\n");
fprintf(stdout, " } else if (ekc == 187 && commandkey == true) {\n"); // CMD-+
fprintf(stdout, " console.log('187!!!!'); return true;\n");
fprintf(stdout, " } else if (ekc == 189 && commandkey == true) {\n"); // CMD--
fprintf(stdout, " console.log('189!!!'); return true;\n");
fprintf(stdout, " } else if (pasting == true) {\n");
fprintf(stdout, " $$('pastext').value += '(' + ekc + ')';\n");
fprintf(stdout, " event.preventDefault();\n");
fprintf(stdout, " return false;\n");
fprintf(stdout, " } else { event.preventDefault(); }\n");
// fprintf(stdout, " if (commandkey == false) { event.preventDefault(); }\n");
fprintf(stdout, " if (ekc == 224 || ekc == 17 || ekc == 91 || ekc == 93)\n");
fprintf(stdout, " { commandkey = true; }\n"); // 17 == ctrl.. cross-platform[?]
fprintf(stdout, " else if (ekc == 82 && commandkey == true)\n"); // CMD-R
fprintf(stdout, " { location.reload(true); commandkey = false; }\n");
fprintf(stdout, " else if (ekc >= 65 && ekc <= 90)\n");
fprintf(stdout, " { wispkey(String.fromCharCode(esk ? ekc : ekc + 32)); }\n");
fprintf(stdout, " else if (ekc >= 97 && ekc <= 122)\n");
fprintf(stdout, " { wispkey(String.fromCharCode(esk ? ekc + 32 : ekc)); }\n");
fprintf(stdout, " else if (ekc >= 48 && ekc <= 57 && eck) {\n");
fprintf(stdout, " if (esk) { iosetinboxrangefrominbox(ekc - 48, inbosel); }\n");
fprintf(stdout, " iosetinbox(ekc - 48);\n");
// fprintf(stdout, " highlightnextline(0);\n");
fprintf(stdout, " wispswitch();\n");
fprintf(stdout, " } else if (ekc == 48) { wispkey(esk ? ')' : '0'); }\n");
fprintf(stdout, " else if (ekc == 41) { wispkey(')'); }\n");
fprintf(stdout, " else if (ekc == 49) { wispkey(esk ? '!' : '1'); }\n");
fprintf(stdout, " else if (ekc == 33) { wispkey('!'); }\n");
fprintf(stdout, " else if (ekc == 50) { wispkey(esk ? '@' : '2'); }\n");
fprintf(stdout, " else if (ekc == 64) { wispkey('@'); }\n");
fprintf(stdout, " else if (ekc == 51) { wispkey(esk ? '#' : '3'); }\n");
fprintf(stdout, " else if (ekc == 35) { wispkey('#'); }\n");
fprintf(stdout, " else if (ekc == 52) { wispkey(esk ? '$' : '4'); }\n");
fprintf(stdout, " else if (ekc == 36) { wispkey('$'); }\n");
fprintf(stdout, " else if (ekc == 53) { wispkey(esk ? '%' : '5'); }\n");
fprintf(stdout, " else if (ekc == 337) { wispkey('%'); }\n");
fprintf(stdout, " else if (ekc == 54) { wispkey(esk ? '^' : '6'); }\n");
fprintf(stdout, " else if (ekc == 94) { wispkey('^'); }\n");
fprintf(stdout, " else if (ekc == 55) { wispkey(esk ? '&' : '7'); }\n");
fprintf(stdout, " else if (ekc == 338) { wispkey('&'); }\n");
fprintf(stdout, " else if (ekc == 56) { wispkey(esk ? '*' : '8'); }\n");
fprintf(stdout, " else if (ekc == 42) { wispkey('*'); }\n");
fprintf(stdout, " else if (ekc == 57) { wispkey(esk ? '(' : '9'); }\n");
fprintf(stdout, " else if (ekc == 340) { wispkey('('); }\n");
// fprintf(stdout, " else if (ekc == 192) { wispkey(esk ? '~' : '`'); }\n");
fprintf(stdout, " else if (ekc == 192) { if (esk) { wispkey('~'); }\n");
fprintf(stdout, " else { wisptoggleesc(1); } }\n");
fprintf(stdout, " else if (ekc == 126) { wispkey('~'); }\n");
fprintf(stdout, " else if (ekc == 96) { wisptoggleesc(1); }\n"); //{ wispkey('`'); }\n");
fprintf(stdout, " else if (ekc == 188) { wispkey(esk ? '<' : ','); }\n");
fprintf(stdout, " else if (ekc == 44) { wispkey(','); }\n");
fprintf(stdout, " else if (ekc == 60) { wispkey('<'); }\n");
fprintf(stdout, " else if (ekc == 190) { wispkey(esk ? '>' : '.'); }\n");
fprintf(stdout, " else if (ekc == 46) { wispkey('.'); }\n");
fprintf(stdout, " else if (ekc == 62) { wispkey('>'); }\n");
fprintf(stdout, " else if (ekc == 191) { wispkey(esk ? '?' : '/'); }\n");
fprintf(stdout, " else if (ekc == 47) { wispkey('/'); }\n");
fprintf(stdout, " else if (ekc == 63) { wispkey('?'); }\n");
fprintf(stdout, " else if (ekc == 186) { wispkey(esk ? ':' : ';'); }\n");
fprintf(stdout, " else if (ekc == 58) { wispkey(':'); }\n");
fprintf(stdout, " else if (ekc == 59) { wispkey(';'); }\n");
fprintf(stdout, " else if (ekc == 222) { wispkey(esk ? '"' : '''); }\n");
fprintf(stdout, " else if (ekc == 34) { wispkey('"'); }\n");
fprintf(stdout, " else if (ekc == 339) { wispkey('''); }\n");
fprintf(stdout, " else if (ekc == 219) { wispkey(esk ? '{' : '['); }\n");
fprintf(stdout, " else if (ekc == 123) { wispkey('{'); }\n");
fprintf(stdout, " else if (ekc == 91) { wispkey('['); }\n");
fprintf(stdout, " else if (ekc == 391) { wispkey('['); }\n");
fprintf(stdout, " else if (ekc == 221) { wispkey(esk ? '}' : ']'); }\n");
fprintf(stdout, " else if (ekc == 125) { wispkey('}'); }\n");
fprintf(stdout, " else if (ekc == 93) { wispkey(']'); }\n");
fprintf(stdout, " else if (ekc == 393) { wispkey(']'); }\n");
fprintf(stdout, " else if (ekc == 220) { wispkey(esk ? '|' : '\'); }\n");
fprintf(stdout, " else if (ekc == 124) { wispkey('|'); }\n");
fprintf(stdout, " else if (ekc == 92) { wispkey('\'); }\n");
fprintf(stdout, " else if (ekc == 189) { wispkey(esk ? '_' : '-'); }\n");
fprintf(stdout, " else if (ekc == 95) { wispkey('_'); }\n");
fprintf(stdout, " else if (ekc == 45) { wispkey('-'); }\n");
fprintf(stdout, " else if (ekc == 187) { wispkey(esk ? '+' : '='); }\n");
fprintf(stdout, " else if (ekc == 43) { wispkey('+'); }\n");
fprintf(stdout, " else if (ekc == 61) { wispkey('='); }\n");
fprintf(stdout, " else if (ekc == 32) { wispkey(' '); }\n");
// fprintf(stdout, " else if (ekc == 27) { wispapplytriggers(); }\n");
fprintf(stdout, " else if (ekc == 27) {\n"); // ESCAPE
fprintf(stdout, " if (esk) { wisptoggletab(); }\n"); // enable/disable editing
fprintf(stdout, " else if (loading) { bodyundrag(); }\n"); // cancel upload
fprintf(stdout, " else if (copying || pasting)\n");
fprintf(stdout, " { pasting = undefined; pastefocus(); }\n"); // cancel copy/paste
fprintf(stdout, " else { wisptoggleesc(1); }\n"); // switch window
fprintf(stdout, " } else if (ekc == 9 && !pastekey) {\n"); // TAB
fprintf(stdout, " if (esk) { wisptoggleesc(0); }\n"); // line zero
fprintf(stdout, " else { wisptoggleesc(1); }\n"); // switch window.. maybe next tab later
fprintf(stdout, " } else if (ekc == 8 && !pastekey) {\n"); // BACKSPACE
fprintf(stdout, " if (eck && esk) { wispremoveline(eak ? 0 : -2); }\n"); // CHECK
fprintf(stdout, " else if (esk) { wisptogglestrike(); }\n");
fprintf(stdout, " else { wispbackspace(eck ? 5 : 1, esk); }\n");
fprintf(stdout, " } else if ((ekc == 10 || ekc == 13) && !pastekey) {\n"); // ENTER
fprintf(stdout, " if (wispinline()) {\n");
fprintf(stdout, " if (esk) { wispgoto('tsol'); }\n");
fprintf(stdout, " wispaddline('s');\n");
fprintf(stdout, " if (esk) { wispgoto('pl'); }\n");
fprintf(stdout, " } else {\n");
fprintf(stdout, " wispopen((eck) ? 'l' : 'h');\n");
fprintf(stdout, " if (esk) { wispgoto('nl'); }\n");
fprintf(stdout, " }\n");
fprintf(stdout, " } else if (ekc == 37 && !pastekey) {\n"); // LEFT ARROW
fprintf(stdout, " if (eak) {\n");
fprintf(stdout, " if (esk) { ionextinbox('l'); }\n");
fprintf(stdout, " else { iopageinbox('l'); }\n"); // ioprevoption
fprintf(stdout, " } else if (eck) {\n");
// fprintf(stdout, " if (esk) { iopageinbox('l'); }\n");
fprintf(stdout, " if (esk) { wispgoto('tsol'); }\n");
fprintf(stdout, " else { wispgoto('jl10'); }\n");
// fprintf(stdout, " else { wispopen('l'); }\n");
fprintf(stdout, " } else { wispleft(esk ? 5 : 1); }\n");
fprintf(stdout, " } else if (ekc == 39 && !pastekey) {\n"); // RIGHT ARROW
fprintf(stdout, " if (eak) {\n");
fprintf(stdout, " if (esk) { ionextinbox('r'); }\n");
fprintf(stdout, " else { iopageinbox('r'); }\n"); // ionextoption
fprintf(stdout, " } else if (eck) {\n");
// fprintf(stdout, " if (esk) { iopageinbox('r'); }\n");
fprintf(stdout, " if (esk) { wispgoto('teol'); }\n");
fprintf(stdout, " else { wispgoto('jr10'); }\n");
// fprintf(stdout, " else { wispopen('r'); }\n");
fprintf(stdout, " } else { wispright(esk ? 5 : 1); }\n");
// fprintf(stdout, " else if (ekc == 38) { clearhighlight(); prevlines(false); sethighlight(-5); }\n");
// fprintf(stdout, " else if (ekc == 40) { clearhighlight(); nextlines(false); sethighlight(5); }\n");
fprintf(stdout, " } else if (ekc == 38 && !pastekey) {\n"); // UP ARROW
fprintf(stdout, " if (eak) {\n");
fprintf(stdout, " if (esk) { ionextinbox('u'); }\n");
fprintf(stdout, " else { ioscrollinbox('u'); }\n");
// fprintf(stdout, " else { wispright(esk ? 5 : 1); }\n");
// fprintf(stdout, " if (eck) { if (wispen == 'n')\n");
// fprintf(stdout, " { rebuildinbox(-1, (esk ? -10 : -2)); }\n");
fprintf(stdout, " } else if (esk) {\n");
fprintf(stdout, " if (eck) { ioscrollinbox('u'); }\n");
fprintf(stdout, " else { highlightprevline(1); wispopen('h'); }\n");
// fprintf(stdout, " if (esk) { ioscrollinbox('u'); }\n");
// fprintf(stdout, " else { wispopen('u'); }\n");
fprintf(stdout, " } else {\n");
fprintf(stdout, " var wp = wisppos();\n");
fprintf(stdout, " if (wp < 0) {\n");
fprintf(stdout, " wispgoto('pl', true);\n");
fprintf(stdout, " if (esk) { wispopen('h'); }\n");
fprintf(stdout, " } else { wispgoto('psl', true); }\n");
// fprintf(stdout, " if (wp < 0) {\n");
// fprintf(stdout, " iohighlightnextline(eck ? -10 : -1);\n");
// fprintf(stdout, " if (!esk) { wisppos(wp); }\n");
// fprintf(stdout, " ioqueuemods();\n");
// fprintf(stdout, " wispswitch();\n");
// fprintf(stdout, " if (esk) { wispopen('h'); }\n");
// fprintf(stdout, " iohandlequeue();\n");
// fprintf(stdout, " } else { wispgoto('psl'); }\n");
fprintf(stdout, " }\n");
fprintf(stdout, " } else if (ekc == 40 && !pastekey) {\n"); // DOWN ARROW
fprintf(stdout, " if (eak) {\n");
fprintf(stdout, " if (esk) { ionextinbox('d'); }\n");
fprintf(stdout, " else { ioscrollinbox('d'); }\n");
// fprintf(stdout, " if (eck) { if (wispen == 'n')\n");
// fprintf(stdout, " { rebuildinbox(-1, (esk ? 10 : 2)); }\n");
fprintf(stdout, " } else if (esk) {\n");
fprintf(stdout, " if (eck) { ioscrollinbox('d'); }\n");
fprintf(stdout, " else { highlightnextline(1); wispopen('h'); }\n");
// fprintf(stdout, " if (esk) { ioscrollinbox('d'); }\n");
// fprintf(stdout, " else { wispopen('d'); }\n");
fprintf(stdout, " } else {\n");
fprintf(stdout, " var wp = wisppos();\n");
fprintf(stdout, " if (wp < 0) {\n");
fprintf(stdout, " wispgoto('nl', true);\n");
fprintf(stdout, " if (esk) { wispopen('h'); }\n");
fprintf(stdout, " } else { wispgoto('nsl', true); }\n");
// fprintf(stdout, " iohighlightnextline(eck ? 10 : 1);\n");
// fprintf(stdout, " if (!esk) { wisppos(wp); }\n");
// fprintf(stdout, " ioqueuemods();\n");
// fprintf(stdout, " wispswitch();\n");
// fprintf(stdout, " iohandlequeue();\n");
fprintf(stdout, " }\n");
fprintf(stdout, " } else if (ekc == 16) {\n");
fprintf(stdout, " if (esk && tln && tln.className == 'sel')\n");
fprintf(stdout, " { tln.className = 'set'; }\n");
fprintf(stdout, " } else if (ekc == 17) {\n");
fprintf(stdout, " } else if (ekc == 18) {\n");
fprintf(stdout, " }\n"); // else { alert(ekc); }\n");
fprintf(stdout, " if (alertkey == true) { alertkey = false; }\n");
fprintf(stdout, " else if (esk == true && eck == true && eak == true) { alertkey = true; }\n");
fprintf(stdout, " }\n");
fprintf(stdout, " window.onkeypress = function(event) {\n");
// fprintf(stdout, " if (event.keyCode == 38 || event.keyCode == 40)\n");
// fprintf(stdout, " if (commandkey == true && event.keyCode == 86)\n");
// fprintf(stdout, " { alert('paste!'); }\n");
// fprintf(stdout, " else if (event.keyCode == 86)\n");
// fprintf(stdout, " { alert('paste!'); }\n");
// fprintf(stdout, " else { event.preventDefault(); }\n");
fprintf(stdout, " var ekc = event.keyCode;\n");
fprintf(stdout, " if (copying == 'up') { return true; }\n");
fprintf(stdout, " else if ((ekc == 187 || ekc == 61) && commandkey == true) { return true; }\n");
fprintf(stdout, " else if ((ekc == 189 || ekc == 45) && commandkey == true) { return true; }\n");
fprintf(stdout, " else { event.preventDefault(); }\n");
fprintf(stdout, " }\n");
fprintf(stdout, " window.onkeyup = function(event) {\n");
fprintf(stdout, " var esk = keysdown.shift = event.shiftKey;\n");
fprintf(stdout, " var eck = keysdown.control = event.ctrlKey;\n");
fprintf(stdout, " var eak = keysdown.alt = event.altKey;\n");
fprintf(stdout, " var ekc = event.keyCode;\n"); // event.preventDefault();\n");
fprintf(stdout, " var tln = lineid[inbosel];\n");
// fprintf(stdout, " if (event.keyCode == 86)\n");
// fprintf(stdout, " { alert('paste!'); }\n");
// fprintf(stdout, " else { event.preventDefault(); }\n");
fprintf(stdout, " if (copying == 'up')\n");
fprintf(stdout, " { copying = true; copyfocus(); }\n");
fprintf(stdout, " else if (ekc == 187 && commandkey == true) { return true; }\n");
fprintf(stdout, " else if (ekc == 189 && commandkey == true) { return true; }\n");
fprintf(stdout, " else {\n");
fprintf(stdout, " event.preventDefault();\n");
// fprintf(stdout, " if (ekc == 38 || ekc == 40 || ekc == 13) { wispswitch(); }\n");
fprintf(stdout, " if (ekc == 224 || ekc == 17 || ekc == 91 || ekc == 93)\n");
fprintf(stdout, " { commandkey = false; }\n");
fprintf(stdout, " if (ekc == 16) {\n");
fprintf(stdout, " if (tln && tln.className == 'set')\n");
fprintf(stdout, " { tln.className = 'sel'; }\n");
fprintf(stdout, " } else if (ekc == 17) {\n");
fprintf(stdout, " } else if (ekc == 18) {\n");
fprintf(stdout, " }\n");
fprintf(stdout, " if (esk == false || eck == false || eak == false)\n");
fprintf(stdout, " { alertkey = false; }\n");
fprintf(stdout, " }\n");
fprintf(stdout, " }\n");