aboutsummaryrefslogtreecommitdiff
path: root/users/miles2go/babblePaste.h
diff options
context:
space:
mode:
Diffstat (limited to 'users/miles2go/babblePaste.h')
-rw-r--r--users/miles2go/babblePaste.h349
1 files changed, 349 insertions, 0 deletions
diff --git a/users/miles2go/babblePaste.h b/users/miles2go/babblePaste.h
new file mode 100644
index 000000000..606640227
--- /dev/null
+++ b/users/miles2go/babblePaste.h
@@ -0,0 +1,349 @@
1/* A library to output the right key shortcut in any common app.
2Given a global variable babble_mode to show the environment and a
3key that calls the paste macro, do the right type of paste.
4
5Setting the bable_mode is done by another macro, or TBD interaction with the host.
6
7Huge thanks to https://en.wikipedia.org/wiki/Table_of_keyboard_shortcuts
8and jeebak & algernon's keymap
9*/
10
11#pragma once
12#include "quantum.h"
13
14#ifdef USE_BABBLEPASTE
15
16void set_babble_mode(uint8_t id);
17void babble_mode_increment(void);
18void babble_mode_decrement(void);
19void babble_led_user(void);
20
21// manually re-order these if you want to set the order or default.
22enum babble_modes {
23# ifdef BABL_MAC
24 BABL_MAC_MODE,
25# endif
26# ifdef BABL_READMUX
27 BABL_READMUX_MODE,
28# endif
29# ifdef BABL_WINDOWS
30 BABL_WINDOWS_MODE,
31# endif
32# ifdef BABL_VI
33 BABL_VI_MODE,
34# endif
35# ifdef BABL_LINUX
36 BABL_LINUX_MODE,
37# endif
38# ifdef BABL_EMACS
39 BABL_EMACS_MODE,
40# endif
41# ifdef BABL_CHROMEOS
42 BABL_CHROMEOS_MODE,
43# endif
44 BABL_MODEMAX
45};
46
47// void babble_led_user( uint8_t id)
48
49/// Hacks to make it easier to create sendstring macros
50
51//"outer" versions wrap text
52# define OMCTL(arg) SS_DOWN(X_LCTRL) arg SS_UP(X_LCTRL)
53# define OMGUI(arg) SS_DOWN(X_LGUI) arg SS_UP(X_LGUI)
54# define OMALT(arg) SS_DOWN(X_LALT) arg SS_UP(X_LALT)
55# define OMSFT(...) SS_DOWN(X_LSHIFT) __VA_ARGS__ SS_UP(X_LSHIFT)
56//"inner" versions wrap a key tap
57# define IMCTL(arg) SS_DOWN(X_LCTRL) SS_TAP(arg) SS_UP(X_LCTRL)
58# define IMGUI(arg) SS_DOWN(X_LGUI) SS_TAP(arg) SS_UP(X_LGUI)
59# define IMALT(arg) SS_DOWN(X_LALT) SS_TAP(arg) SS_UP(X_LALT)
60# define IMSFT(arg) SS_DOWN(X_LSHIFT) SS_TAP(arg) SS_UP(X_LSHIFT)
61
62# define BABLM(ent, ...) \
63 if (ent == keycode) { \
64 SEND_STRING(__VA_ARGS__); \
65 return true; \
66 }
67
68// BabblePaste should be loaded first (header in userspace .h file, before all else)
69// if not,we'll do our best.
70# if defined(NEW_SAFE_RANGE)
71# define BABBLE_START NEW_SAFE_RANGE
72# else
73# if defined(KEYMAP_SAFE_RANGE)
74# define BABBLE_START KEYMAP_SAFE_RANGE
75# else
76# define BABBLE_START SAFE_RANGE
77# endif
78# endif
79
80enum babble_keycodes {
81 FIRST = BABBLE_START,
82# ifdef BABL_MOVE
83 // Movement macros
84 // left & right
85 BABL_GO_LEFT_1C,
86 BABL_GO_RIGHT_1C,
87 BABL_GO_LEFT_WORD,
88 BABL_GO_RIGHT_WORD,
89 BABL_GO_START_LINE,
90 BABL_GO_END_LINE,
91 // now up & down
92 BABL_GO_START_DOC,
93 BABL_GO_END_DOC,
94 BABL_GO_NEXT_LINE,
95 BABL_GO_PREV_LINE,
96 BABL_GO_PARA_START,
97 BABL_GO_PARA_END,
98 BABL_PGDN,
99 BABL_PGUP,
100 // And the delete options
101 BABL_DEL_LEFT_1C, // == backspace, so why bother?
102 BABL_DEL_RIGHT_1C, // usually = Del
103 BABL_DEL_LEFT_WORD,
104 BABL_DEL_RIGHT_WORD,
105 BABL_DEL_TO_LINE_END, // delete from cursor to end of line
106 BABL_DEL_TO_LINE_START, // delete from cursor to begining line
107 BABL_MODE, // print out string saying what mode we're in.
108# endif
109# ifdef BABL_OSKEYS
110 BABL_UNDO,
111 BABL_REDO,
112 BABL_CUT,
113 BABL_COPY,
114 BABL_PASTE,
115 BABL_SELECT_ALL,
116 /* not yet implemented
117 BABL_SWAP_LAST2C, // swap last characters before the cursor
118 BABL_SWAP_LAST2W, // Swap the last two words before the cursor
119 */
120 // find & replace
121 BABL_FIND,
122 BABL_FIND_NEXT,
123 BABL_FIND_PREV,
124 BABL_FIND_REPLACE,
125 // GUI or app
126 BABL_RUNAPP,
127 BABL_SWITCH_APP_NEXT,
128 BABL_SWITCH_APP_LAST, // previous
129 BABL_WINDOW_NEXT,
130 BABL_WINDOW_PREV,
131 BABL_WINDOW_NEW,
132 BABL_CLOSE_APP,
133 BABL_HELP,
134 BABL_LOCK,
135 BABL_SCREENCAPTURE,
136 BABL_SWITCH_KEYBOARD_LAYOUT,
137# endif
138# ifdef BABL_BROWSER
139 BABL_BROWSER_NEW_TAB,
140 BABL_BROWSER_CLOSE_TAB,
141 BABL_BROWSER_REOPEN_LAST_TAB,
142 BABL_BROWSER_NEXT_TAB,
143 BABL_BROWSER_PREV_TAB,
144 BABL_BROWSER_URL_BAR,
145 BABL_BROWSER_FORWARD,
146 BABL_BROWSER_BACK,
147 BABL_BROWSER_FIND,
148 BABL_BROWSER_BOOKMARK,
149 BABL_BROWSER_DEV_TOOLS, // hard one to remember
150 BABL_BROWSER_RELOAD,
151 BABL_BROWSER_FULLSCREEN,
152 BABL_BROWSER_ZOOM_IN,
153 BABL_BROWSER_ZOOM_OUT,
154 BABL_BROWSER_VIEWSRC,
155# endif
156# ifdef BABL_APP
157 BABL_APP_SAVE, // save file blurs app & os. Move?
158 BABL_APP_PASTE_VALUES, // paste only values, or with some special formatting. ctrl shift v chrome, // Ctrl+Alt+V, excel
159 // App hotkeys will be flawed, since you may use different spreadsheets across OSes.
160# ifdef BABL_APP_CELLS // spreadsheets and tables
161 BABL_APP_CENTER_ALIGN, // Center align contents of a cell in table or spreadsheet.
162 BABL_APP_CLEAR_FORMATTING, //
163 BABL_APP_SCROLL_ACTIVE_CELL, // scroll to active cell.
164 BABL_NEWLINE_IN_CELL, // newline inside cell of table,
165 BABL_INSERT_COMMENT, // insert comment
166 BABL_INSERT_COL_LEFT, // insert columns to the left
167 BABL_INSERT_ROW, // insert row
168 BABL_DELETE_ROW, // delete row // excel ctrl minus // chrome ctrl alt minus
169 BABL_SELECT_COL, // select column - ctrl space //same in both
170 BABL_SELECT_ROW, // select row shift spaced // same in both.
171# endif // BABL_APP_CELLS
172# ifdef BABL_APP_EDITOR
173 BABL_APP_MULTI_SELECT, /* www.sublimetext.com/docs/2/multiple_selection_with_the_keyboard.html */
174# endif // BABL_APP_EDITOR
175# ifdef BABL_APP_WINDOWSPLITTING
176 // These aren't useful on most oses.
177 BABL_SPLIT_FRAME_VERT,
178 BABL_UNSPLIT_FRAME_VERT,
179 BABL_SPLIT_FRAME_HORIZONTAL,
180 BABL_UNSPLIT_FRAME_HORIZONTAL,
181 BABL_NEXT_FRAME,
182 BABL_PREV_FRAME,
183# endif
184
185# endif
186
187// Macros for mode switching
188# ifdef BABL_WINDOWS
189 BABL_DO_WINDOWS,
190# endif
191# ifdef BABL_MAC
192 BABL_DO_MAC,
193# endif
194# ifdef BABL_LINUX
195 BABL_DO_LINUX,
196# endif
197# ifdef BABL_EMACS
198 BABL_DO_EMACS,
199# endif
200# ifdef BABL_VI
201 BABL_DO_VI,
202# endif
203# ifdef BABL_READMUX
204 BABL_DO_READMUX,
205# endif
206# ifdef BABL_CHROMEOS
207 BABL_DO_CHROMEOS,
208# endif
209 BABBLE_END_RANGE
210};
211
212// primary function.
213bool babblePaste(uint16_t keycode);
214
215/****************************************************/
216/* All per-os includes and short mode switch macros*/
217# ifdef BABL_WINDOWS
218# define B_WIN BABL_DO_WINDOWS
219bool babblePaste_win(uint16_t keycode);
220# endif
221# ifdef BABL_MAC
222# define B_MAC BABL_DO_MAC
223bool babblePaste_mac(uint16_t keycode);
224# endif
225# ifdef BABL_LINUX
226# define B_LINUX BABL_DO_LINUX
227bool babblePaste_linux(uint16_t keycode);
228# endif
229# ifdef BABL_EMACS
230# define B_EMACS BABL_DO_EMACS
231bool babblePaste_emacs(uint16_t keycode);
232# endif
233# ifdef BABL_VI
234# define B_VI BABL_DO_VI
235bool babblePaste_vi(uint16_t keycode);
236# endif
237# ifdef BABL_READMUX
238# define B_READ BABL_DO_READMUX
239bool babblePaste_readmux(uint16_t keycode);
240# endif
241# ifdef BABL_CHROMEOS
242# define B_CROM BABL_DO_CHROMEOS
243bool babblePaste_chromeos(uint16_t keycode);
244# endif
245
246# define BABL_INC babble_mode_increment();
247# define BABL_DEC babble_mode_decrement();
248
249/****************************************************
250** All keyboard macros for Babble Actions
251*****************************************************/
252
253# ifdef BABL_MOVE
254# define B_L1C BABL_GO_LEFT_1C
255# define B_R1C BABL_GO_RIGHT_1C
256# define B_L1W BABL_GO_LEFT_WORD
257# define B_R1W BABL_GO_RIGHT_WORD
258# define B_GSOL BABL_GO_START_LINE
259# define B_GEOL BABL_GO_END_LINE
260# define B_GTOP BABL_GO_START_DOC
261# define B_GEND BABL_GO_END_DOC
262# define B_DOWN BABL_GO_NEXT_LINE
263# define B_UP BABL_GO_PREV_LINE
264# define B_PTOP BABL_GO_PARA_START
265# define B_PEND BABL_GO_PARA_END
266# define B_PGDN BABL_PGDN
267# define B_PGUP BABL_PGUP
268//#define B_BKSP BABL_DEL_LEFT_1C == backspace so why bother.
269# define B_DEL BABL_DEL_RIGHT_1C // usually = Del
270# define B_DLW BABL_DEL_LEFT_WORD
271# define B_DRW BABL_DEL_RIGHT_WORD
272# define B_DEOL BABL_DEL_TO_LINE_END // delete from cursor to end of line
273# define B_DSOL BABL_DEL_TO_LINE_START // delete from cursor to begining line
274# define B_MODE BABL_MODE // type out name of current mode.
275# endif
276
277# ifdef BABL_OSKEYS
278# define B_UNDO BABL_UNDO
279# define B_REDO BABL_REDO
280# define B_CUT BABL_CUT
281# define B_COPY BABL_COPY
282# define B_PASTE BABL_PASTE
283# define B_SELALL BABL_SELECT_ALL
284# define B_SELA BABL_SELECT_ALL
285# define B_FIND BABL_FIND
286# define B_FINDN BABL_FIND_NEXT
287# define B_FINDP BABL_FIND_PREV
288# define B_RPLACE BABL_FIND_REPLACE
289# define B_RUNAPP BABL_RUNAPP
290# define B_NAPP BABL_SWITCH_APP_NEXT
291# define B_PAPP BABL_SWITCH_APP_LAST // previous
292# define B_NWIN BABL_WINDOW_NEXT
293# define B_PWIN BABL_WINDOW_PREV
294# define B_WINN BABL_WINDOW_NEW
295# define B_CAPP BABL_CLOSE_APP
296# define B_HELP BABL_HELP
297# define B_LOCK BABL_LOCK
298# define B_SCAP BABL_SCREENCAPTURE
299# define B_KEYB BABL_SWITCH_KEYBOARD_LAYOUT
300# endif
301
302# ifdef BABL_BROWSER
303# define B_NTAB BABL_BROWSER_NEW_TAB
304# define B_CTAB BABL_BROWSER_CLOSE_TAB
305# define B_ROTB BABL_BROWSER_REOPEN_LAST_TAB
306# define B_NXTB BABL_BROWSER_NEXT_TAB
307# define B_PTAB BABL_BROWSER_PREV_TAB
308# define B_NURL BABL_BROWSER_URL_BAR
309# define B_BFWD BABL_BROWSER_FORWARD
310# define B_BBAK BABL_BROWSER_BACK
311# define B_BFND BABL_BROWSER_FIND
312# define B_BOOK BABL_BROWSER_BOOKMARK
313# define B_BDEV BABL_BROWSER_DEV_TOOLS // hard one to remember
314# define B_BRLD BABL_BROWSER_RELOAD
315# define B_BFULL BABL_BROWSER_FULLSCREEN
316# define B_ZIN BABL_BROWSER_ZOOM_IN
317# define B_ZOUT BABL_BROWSER_ZOOM_OUT
318# endif
319
320# ifdef BABL_APP
321# define B_SAVE BABL_APP_SAVE
322# ifdef BABL_APP_CELLS // spreadsheets and tables
323# define B_PASTV BABL_APP_PASTE_VALUES
324# define B_CALN BABL_APP_CENTER_ALIGN
325# define B_CFMT BABL_APP_CLEAR_FORMATTING
326# define B_SCLA BABL_APP_SCROLL_ACTIVE_CELL
327# define B_NCEL BABL_NEWLINE_IN_CELL
328# define B_IPRW BABL_INSERT_ROW_ABOVE
329# define B_ICOL BABL_INSERT_COL_LEFT
330# define B_IROW BABL_INSERT_ROW
331# define B_DROW BABL_DELETE_ROW
332# define B_SELC BABL_SELECT_COL
333# define B_SELR BABL_SELECT_ROW
334# endif // BABL_APP_CELLS
335# ifdef BABL_APP_EDITOR
336# define B_MSEL BABL_APP_MULTI_SELECT
337/* www.sublimetext.com/docs/2/multiple_selection_with_the_keyboard.html */
338# endif // BABL_APP_EDITOR
339# ifdef BABL_APP_WINDOWSPLITTING
340# define B_VSPLIT BABL_SPLIT_FRAME_VERT
341# define B_VUNSPT BABL_UNSPLIT_FRAME_VERT
342# define B_HSPLIT BABL_SPLIT_FRAME_HORIZONTAL
343# define B_HUNSPT BABL_UNSPLIT_FRAME_HORIZONTAL
344# define B_NXTFM BABL_NEXT_FRAME
345# define B_PRVFM BABL_PREV_FRAME
346# endif // BABL_APP_WINDOWSPLITTING
347# endif // BABL_APP
348
349#endif