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
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
|
/* A library to output the right key shortcut in any common app.
Given a global variable babble_mode to show the environment and a
key that calls the paste macro, do the right type of paste.
Setting the context is done by another macro, or TBD interaction with the host.
Huge thanks to https://en.wikipedia.org/wiki/Table_of_keyboard_shortcuts
and https://github.com/qmk/qmk_firmware/blob/master/keyboards/planck/keymaps/jeebak/keymap.c
*/
#include "eeconfig.h"
// Comment out anything you will never use.
// Windows.
#define MS_MODE 0
#define MAC_MODE 1
//aka gnome+KDE
#define LINUX_MODE 2
#define EMACS_MODE 3
#define VI_MODE 4
//#define WORDSTAR_MODE 5
// Readline and tmux
#define READMUX 6
// GLOBAL variable. Sets startup default if no eeppom
char babble_mode = MAC_MODE ;
/* minimum set required for babble:
// Cut & Paste
BABL_UNDO
BABL_REDO
BABL_CUT
BABL_COPY
BABL_PASTE
BABL_SELECT_ALL
// Movement
BABL_DEL_RIGHT_1C
BABL_DEL_RIGHT_1C
BABL_DEL_LEFT_WORD
BABL_DEL_RIGHT_WORD
BABL_GO_LEFT_1C
BABL_GO_LEFT_WORD
BABL_GO_RIGHT_WORD
BABL_GOTO_START_LINE
BABL_GOTO_START_DOC
BABL_GOTO_END_LINE
BABL_GOTO_END_DOC
BABL_GOTO_NEXT_LINE // down arrow will do.
BABL_GOTO_PREV_LINE // up arrow will do.
BABL_PGDN
BABL_PGUP
// GUI
BABL_FIND
BABL_FIND_NEXT
BABL_FIND_REPLACE
BABL_RUNAPP
BABL_SWITCH_NEXT
BABL_SWITCH_LAST // previous
BABL_CLOSE_APP
BABL_HELP
*/
static macro_t *babblePaste (keyrecord_t *record, uint16_t shortcut) {
switch(babble_mode) {
#ifdef MS_MODE
case MS_MODE:
switch(shortcut) {
case BABL_UNDO:
return MACRO( D(LCTRL), T(Z), U(LCTRL), END );
case BABL_REDO:
return MACRO( D(LCTRL), T(Y), U(LCTRL), END );
case BABL_CUT:
return MACRO( D(LCTRL), T(X), U(LCTRL), END );
case BABL_COPY:
return MACRO( D(LCTRL), T(C), U(LCTRL), END );
case BABL_PASTE:
return MACRO( D(LCTRL), T(V), U(LCTRL), END );
case BABL_SELECT_ALL:
return MACRO( D(LCTRL), T(A), U(LCTRL), END );
case BABL_DEL_RIGHT_1C:
return MACRO( D(DEL), END );
case BABL_DEL_LEFT_WORD:
return MACRO( D(LCTRL), T(BSPACE), U(LCTRL), END );
case BABL_DEL_RIGHT_WORD:
return MACRO( D(LCTRL), T(DEL), U(LCTRL), END );
case BABL_GO_LEFT_1C:
return MACRO( T(LEFT), END );
case BABL_GO_RIGHT_1C:
return MACRO( T(RIGHT), END );
case BABL_GO_LEFT_WORD:
return MACRO( D(LCTRL), T(LEFT), U(LCTRL), END );
case BABL_GO_RIGHT_WORD:
return MACRO( D(LCTRL), T(RIGHT), U(LCTRL), END );
case BABL_GOTO_START_LINE:
return MACRO( T(HOME), END );
case BABL_GOTO_START_DOC:
return MACRO( D(LCTRL),T(HOME), U(LCTRL),END );
case BABL_GOTO_END_LINE:
return MACRO( T(END), END );
case BABL_GOTO_END_DOC:
return MACRO( D(LCTRL),T(END), U(LCTRL),END );
case BABL_GOTO_NEXT_LINE:
return MACRO( T(DOWN), END );
case BABL_GOTO_PREV_LINE:
return MACRO( T(UP), END );
case BABL_PGDN:
return MACRO( T(PGDN), END );
case BABL_PGUP:
return MACRO( T(PGUP), END );
case BABL_FIND:
return MACRO( D(LCTRL),T(F), U(LCTRL),END );
case BABL_FIND_NEXT:
return MACRO( T(F3),END );
case BABL_FIND_REPLACE:
return MACRO( D(LCTRL),T(H), U(LCTRL),END );
case BABL_RUNAPP:
return MACRO( D(LGUI),T(R), U(LGUI),END );
case BABL_SWITCH_APP_NEXT:
return MACRO( D(LALT),T(TAB), U(LALT),END );
case BABL_SWITCH_APP_LAST:
return MACRO( D(LSFT),D(LALT),T(TAB), U(LALT), U(LSFT),END );
case BABL_CLOSE_APP:
return MACRO( D(LALT),T(F4), U(LALT),END );
case BABL_HELP:
return MACRO( T(F1),END );
break;
return MACRO_NONE;
}
#endif
#ifdef LINUX_MODE
case LINUX_MODE:
switch(shortcut) {
case BABL_UNDO:
return MACRO( D(LCTRL), T(Z), U(LCTRL), END );
case BABL_REDO:
return MACRO( D(LCTRL), T(Y), U(LCTRL), END );
case BABL_CUT:
return MACRO( D(LCTRL), T(X), U(LCTRL), END );
case BABL_COPY:
return MACRO( D(LCTRL), T(C), U(LCTRL), END );
case BABL_PASTE:
return MACRO( D(LCTRL), T(V), U(LCTRL), END );
case BABL_SELECT_ALL:
return MACRO( D(LCTRL), T(A), U(LCTRL), END );
case BABL_DEL_RIGHT_1C:
return MACRO( D(DEL), END );
case BABL_DEL_LEFT_WORD:
return MACRO( D(LCTRL), T(BSPACE), U(LCTRL), END );
case BABL_DEL_RIGHT_WORD:
return MACRO( D(LCTRL), T(DEL), U(LCTRL), END );
case BABL_GO_LEFT_1C:
return MACRO( T(LEFT), END );
case BABL_GO_RIGHT_1C:
return MACRO( T(RIGHT), END );
case BABL_GO_LEFT_WORD:
return MACRO( D(LCTRL), T(LEFT), U(LCTRL), END );
case BABL_GO_RIGHT_WORD:
return MACRO( D(LCTRL), T(RIGHT), U(LCTRL), END );
case BABL_GOTO_START_LINE:
return MACRO( T(HOME), END );
case BABL_GOTO_START_DOC:
return MACRO( D(LCTRL),T(HOME), U(LCTRL),END );
case BABL_GOTO_END_LINE:
return MACRO( T(END), END );
case BABL_GOTO_END_DOC:
return MACRO( D(LCTRL),T(END), U(LCTRL),END );
case BABL_GOTO_NEXT_LINE:
return MACRO( T(DOWN), END );
case BABL_GOTO_PREV_LINE:
return MACRO( T(UP), END );
case BABL_PGDN:
return MACRO( T(PGDN), END );
case BABL_PGUP:
return MACRO( T(PGUP), END );
case BABL_FIND:
return MACRO( D(LCTRL),T(F), U(LCTRL),END );
case BABL_FIND_NEXT:
/* return MACRO( T(F3),END ); KDE */
return MACRO( D(LCTRL),T(G), U(LCTRL),END ); // Gnome*/
case BABL_FIND_REPLACE:
/* return MACRO( D(LCTRL),T(R), U(LCTRL),END ); KDE */
return MACRO( D(LCTRL),T(H), U(LCTRL),END ); // Gnome*/
case BABL_RUNAPP:
return MACRO( D(LALT),T(F2), U(LALT),END );
case BABL_SWITCH_APP_NEXT:
return MACRO( D(LCTL),T(TAB), U(LCTL),END );
case BABL_SWITCH_APP_LAST:
return MACRO( D(LSFT),D(LCTL),T(TAB), U(LCTL), U(LSFT),END );
case BABL_CLOSE_APP:
return MACRO( D(LALT),T(F4), U(LALT),END );
case BABL_HELP:
return MACRO_NONE;
break;
return MACRO_NONE;
}
#endif
#ifdef MAC_MODE
case MAC_MODE:
switch(shortcut) {
case BABL_UNDO:
return MACRO( D(LGUI), T(Z), U(LGUI), END );
case BABL_REDO:
return MACRO( D(LSFT),D(LGUI), T(Z), U(LSFT),U(LGUI), END );
case BABL_CUT:
return MACRO( D(LGUI), T(X), U(LGUI), END );
case BABL_COPY:
return MACRO( D(LGUI), T(C), U(LGUI), END );
case BABL_PASTE:
return MACRO( D(LGUI), T(V), U(LGUI), END );
case BABL_SELECT_ALL:
return MACRO( D(LGUI), T(A), U(LGUI), END );
case BABL_DEL_RIGHT_1C:
return MACRO( D(DEL), END );
case BABL_DEL_LEFT_WORD:
return MACRO( D(LALT), T(BSPACE), U(LALT), END );
case BABL_DEL_RIGHT_WORD:
return MACRO( D(LALT), T(DEL), U(LALT), END );
case BABL_GO_LEFT_1C:
return MACRO( T(LEFT), END );
case BABL_GO_RIGHT_1C:
return MACRO( T(RIGHT), END );
case BABL_GO_LEFT_WORD:
return MACRO( D(LALT), T(LEFT), U(LALT), END );
case BABL_GO_RIGHT_WORD:
return MACRO( D(LALT), T(RIGHT), U(LALT), END );
case BABL_GOTO_START_LINE:
return MACRO( D(LGUI), T(LEFT), U(LGUI), END );
case BABL_GOTO_START_DOC:
return MACRO( D(LGUI),T(UP), U(LGUI),END );
case BABL_GOTO_END_LINE:
return MACRO( D(LGUI), T(RIGHT), U(LGUI), END );
case BABL_GOTO_END_DOC:
return MACRO( D(LGUI),T(DOWN), U(LGUI),END );
case BABL_GOTO_NEXT_LINE:
return MACRO( T(DOWN), END );
case BABL_GOTO_PREV_LINE:
return MACRO( T(UP), END );
case BABL_PGDN:
return MACRO( D(LALT), T(DOWN), U(LALT), END );
case BABL_PGUP:
return MACRO( D(LALT), T(UP), U(LALT), END );
case BABL_FIND:
return MACRO( D(LGUI),T(F), U(LGUI),END );
case BABL_FIND_NEXT:
return MACRO( D(LGUI),T(G), U(LGUI),END );
case BABL_FIND_REPLACE:
return MACRO( D(LGUI),T(F), U(LGUI),END );
case BABL_RUNAPP:
return MACRO( D(LGUI),T(R), U(LGUI),END );
case BABL_SWITCH_APP_NEXT:
return MACRO( D(LGUI),T(TAB), U(LGUI),END );
case BABL_SWITCH_APP_LAST:
return MACRO( D(LSFT),D(LGUI),T(TAB), U(LGUI), U(LSFT),END );
case BABL_CLOSE_APP:
return MACRO( D(LGUI),T(Q), U(LGUI),END );
case BABL_HELP:
return MACRO( D(LSFT),D(LGUI),T(SLASH), U(LGUI), U(LSFT),END );
break;
return MACRO_NONE;
}
#endif
#ifdef EMACS_MODE
case EMACS_MODE:
switch(shortcut) {
//probably should allow meta to not be ALT
case BABL_UNDO:
return MACRO( D(LCTL), T(X), U(LCTL),T(C), END );
case BABL_REDO:
return MACRO( D(LCTL), T(X), U(LCTL),T(C), END ); // arguably
case BABL_CUT:
return MACRO( D(LCTL), T(W), U(LCTL), END );
case BABL_COPY:
return MACRO( D(LALT), T(W), U(LALT), END );
case BABL_PASTE:
return MACRO( D(LCTL), T(Y), U(LCTL), END );
case BABL_SELECT_ALL:
return MACRO(D(LCTL), T(X), U(LCTL),T(H), END );
case BABL_DEL_RIGHT_1C:
return MACRO( D(LCTL), T(D), U(LCTL),END );
case BABL_DEL_LEFT_WORD:
return MACRO( D(LCTL), T(BSPACE), U(LCTL), END );
case BABL_DEL_RIGHT_WORD:
return MACRO( D(LALT), T(D), U(LALT), END );
case BABL_GO_LEFT_1C:
return MACRO( T(LEFT), END );
case BABL_GO_RIGHT_1C:
return MACRO( T(RIGHT), END );
case BABL_GO_LEFT_WORD:
return MACRO( D(LALT), T(B), U(LALT), END );
case BABL_GO_RIGHT_WORD:
return MACRO( D(LALT), T(F), U(LALT), END );
case BABL_GOTO_START_LINE:
return MACRO( D(LCTRL), T(A), U(LCTRL), END );
case BABL_GOTO_START_DOC:
return MACRO( D(LALT), D(LSFT), T(COMM),U(LSFT), U(LALT) ,END );
case BABL_GOTO_END_LINE:
return MACRO( D(LCTRL), T(E), U(LCTRL), END );
case BABL_GOTO_END_DOC:
return MACRO( D(LALT), D(LSFT), T(DOT),U(LSFT), U(LALT) ,END );
case BABL_GOTO_NEXT_LINE:
return MACRO( D(LCTRL), T(N), U(LCTRL), END );
case BABL_GOTO_PREV_LINE:
rreturn MACRO( D(LCTRL), T(P), U(LCTRL), END );
case BABL_PGDN:
return MACRO(D(LCTRL), T(V), U(LCTRL), END );
case BABL_PGUP:
return MACRO( D(LALT), T(V), U(LALT), END );
case BABL_FIND:
return MACRO( D(LCTRL), T(S), U(LCTRL),END );
case BABL_FIND_NEXT:
return MACRO( D(LCTRL), T(S), U(LCTRL),END );
case BABL_FIND_REPLACE:
return MACRO( D(LALT),D(LSFT), T(5),U(LSFT), U(LALT), END );
case BABL_RUNAPP:
return MACRO( D(LALT), T(X), U(LALT),T(S),T(H),T(E),T(L),T(L),END );// arguably
case BABL_SWITCH_APP_NEXT:
return MACRO( D(LCTL), T(X), U(LCTL),T(RIGHT), END ); // arguably
case BABL_SWITCH_APP_LAST:
return MACRO( D(LCTL), T(X), U(LCTL),T(LEFT), END ); // arguably
case BABL_CLOSE_APP:
return MACRO(D(LCTL), T(X), U(LCTL),T(C),END );
case BABL_HELP:
return MACRO( D(LCTL),T(H), U(LCTL),T(A),END); // start search in help
break;
return MACRO_NONE;
}
#endif
#ifdef VI_MODE
case VI_MODE:
switch(shortcut) {
//assume esc is already called
case BABL_UNDO:
return MACRO( T(U), END );
case BABL_REDO:
return MACRO( D(LCTL), T(R), U(LCTL), END );
case BABL_CUT:
return MACRO( T(X), END );
case BABL_COPY:
return MACRO( T(Y),END );
case BABL_PASTE:
return MACRO( T(P), END );
case BABL_SELECT_ALL:
return MACRO( T(COLN),T(PERC),T(Y), END ); // wrong but helpful?
case BABL_DEL_RIGHT_1C:
return MACRO( T(X),END );
case BABL_DEL_LEFT_WORD:
return MACRO( T(D),T(G),T(E),END );
case BABL_DEL_RIGHT_WORD:
return MACRO( T(D),T(W),END );
case BABL_GO_LEFT_1C:
return MACRO( T(H), END );
case BABL_GO_RIGHT_1C:
return MACRO( T(L), END );
case BABL_GO_LEFT_WORD:
return MACRO( T(B),END );
case BABL_GO_RIGHT_WORD:
return MACRO( T(W), END );
case BABL_GOTO_START_LINE:
return MACRO( T(CIRC), END );
case BABL_GOTO_START_DOC:
return MACRO( T(G),T(G) ,END );
case BABL_GOTO_END_LINE:
return MACRO( T(DLR), END );
case BABL_GOTO_END_DOC:
return MACRO( D(LSFT), T(G),U(LSFT), ,END );
case BABL_GOTO_NEXT_LINE:
return MACRO( T(J), END );
case BABL_GOTO_PREV_LINE:
rreturn MACRO( T(K), END );
case BABL_PGDN:
return MACRO(D(LCTRL), T(F), U(LCTRL), END );
case BABL_PGUP:
return MACRO( D(LCTRL), T(B), U(LCTRL), END );
case BABL_FIND:
return MACRO( T(SLASH),END );
case BABL_FIND_NEXT:
return MACRO( T(N),END );
case BABL_FIND_REPLACE:
return MACRO( D(LALT),D(LSFT), T(5),U(LSFT), U(LALT), END );
case BABL_RUNAPP:
return MACRO_NONE;
case BABL_SWITCH_APP_NEXT:
return MACRO_NONE;
case BABL_SWITCH_APP_LAST:
return MACRO_NONE;
case BABL_CLOSE_APP:
return MACRO(T(COLN), T(Q), T(EXLM),END );
case BABL_HELP:
return MACRO(T(COLN),T(H),END); // start search in help
break;
return MACRO_NONE;
}
#endif
#ifdef READMUX_MODE
// I havent decided how much to do bash and how much tmux
case READMUX_MODE:
switch(shortcut) {
case BABL_UNDO:
return MACRO( D(LALT), T(R), U(LALT) , END );
case BABL_REDO:
return MACRO( D(LCTL), T(X), U(LCTL),T(C), END ); // arguably
case BABL_CUT:
return MACRO( D(LCTL), T(K), U(LCTL), END ); // wrong half the time
case BABL_COPY:
return MACRO_NONE;
case BABL_PASTE:
return MACRO( D(LCTL), T(Y), U(LCTL), END );
case BABL_SELECT_ALL:
return MACRO(D(LCTL), T(A), T(K), T(Y), U(LCTL) , END ); // should this be tmux all?
case BABL_DEL_RIGHT_1C:
return MACRO( D(LCTL), T(D), U(LCTL),END );
case BABL_DEL_LEFT_WORD:
return MACRO( D(LCTL), T(W), U(LCTL), END );
case BABL_DEL_RIGHT_WORD:
return MACRO( D(LALT), T(D), U(LALT), END );
case BABL_GO_LEFT_1C:
return MACRO( T(LEFT), END );
case BABL_GO_RIGHT_1C:
return MACRO( T(RIGHT), END );
case BABL_GO_LEFT_WORD:
return MACRO( D(LALT), T(B), U(LALT), END );
case BABL_GO_RIGHT_WORD:
return MACRO( D(LALT), T(F), U(LALT), END );
case BABL_GOTO_START_LINE:
return MACRO( D(LCTRL), T(A), U(LCTRL), END );
case BABL_GOTO_START_DOC:
return MACRO_NONE; // tmux?
case BABL_GOTO_END_LINE:
return MACRO( D(LCTRL), T(E), U(LCTRL), END );
case BABL_GOTO_END_DOC:
return MACRO_NONE; // tmux?
case BABL_GOTO_NEXT_LINE:
return MACRO( D(LCTRL), T(N), U(LCTRL), END );
case BABL_GOTO_PREV_LINE:
return MACRO( D(LCTRL), T(P), U(LCTRL), END );
case BABL_PGDN:
return MACRO( T(PGDN), END );
case BABL_PGUP:
return MACRO( T(PGUP), END );
case BABL_FIND:
return MACRO( D(LCTRL), T(R), U(LCTRL), END ); // search history
case BABL_FIND_NEXT:
eturn MACRO( D(LCTRL), T(S), U(LCTRL), END );
case BABL_FIND_REPLACE:
return MACRO_NONE; // tmux?
case BABL_RUNAPP:
return MACRO( D(LCTRL), T(B), U(LCTRL), T(C),END ); //tmux
case BABL_SWITCH_APP_NEXT:
return MACRO( D(LCTRL), T(B), U(LCTRL), T(N),END ); //tmux
case BABL_SWITCH_APP_LAST:
return MACRO( D(LCTRL), T(B), U(LCTRL), T(P),END ); //tmux
case BABL_CLOSE_APP:
return MACRO( D(LCTRL), T(B), U(LCTRL), T(D),END); // usually what I want
break;
case BABL_HELP:
return MACRO_NONE;
break;
return MACRO_NONE;
}
#endif
return MACRO_NONE;
}
|