diff options
Diffstat (limited to 'keyboards/handwired/MS-sculpt-mobile/babblePaste.h')
-rw-r--r-- | keyboards/handwired/MS-sculpt-mobile/babblePaste.h | 238 |
1 files changed, 238 insertions, 0 deletions
diff --git a/keyboards/handwired/MS-sculpt-mobile/babblePaste.h b/keyboards/handwired/MS-sculpt-mobile/babblePaste.h new file mode 100644 index 000000000..3067c854d --- /dev/null +++ b/keyboards/handwired/MS-sculpt-mobile/babblePaste.h | |||
@@ -0,0 +1,238 @@ | |||
1 | /* A library to output the right key shortcut in any common app. | ||
2 | Given a global variable babble_mode to show the environment and a | ||
3 | key that calls the paste macro, do the right type of paste. | ||
4 | |||
5 | Setting the bable_mode is done by another macro, or TBD interaction with the host. | ||
6 | |||
7 | Huge thanks to https://en.wikipedia.org/wiki/Table_of_keyboard_shortcuts | ||
8 | and jeebak & algernon's keymap | ||
9 | */ | ||
10 | #ifndef _babblePaste_h_included__ | ||
11 | #define _babblePaste_h_included__ | ||
12 | #include "action_layer.h" | ||
13 | #include "quantum_keycodes.h" | ||
14 | #include "config.h" | ||
15 | |||
16 | #ifdef USE_BABLPASTE | ||
17 | |||
18 | /* *************************** | ||
19 | |||
20 | // Uncomment any modes you want. Whatever mode = 0 will be the default on boot | ||
21 | // Expect to get errors if you comment a feature out and leave it in your keymap. | ||
22 | |||
23 | #define USE_BABLPASTE | ||
24 | |||
25 | //#define MS_MODE 0 // Windows. | ||
26 | //#define MAC_MODE 1 | ||
27 | //#define LINUX_MODE 2 //aka gnome+KDE | ||
28 | //#define EMACS_MODE 3 | ||
29 | //#define VI_MODE 4 | ||
30 | //#define WORDSTAR_MODE 5 | ||
31 | //#define READMUX 6 // Readline and tmux | ||
32 | |||
33 | // This removes everything but cursor movement | ||
34 | //#define BABL_MOVEMENTONLY | ||
35 | // and this just removes browser shortcuts | ||
36 | //#define BABL_NOBROWSER | ||
37 | ****************************/ | ||
38 | |||
39 | |||
40 | // Uncomment if you need more free flash space | ||
41 | // It removes everything but cursor movement | ||
42 | //#define BABL_MOVEMENTONLY | ||
43 | |||
44 | |||
45 | // Define starting number for BABL macros in the macro range. | ||
46 | // Probably can start the default even lower | ||
47 | #define BABL_START_NUM 50 | ||
48 | |||
49 | /* Macros handled by babblepaste. Most should be available for all platforms. | ||
50 | Whatever isn't defined will NOP */ | ||
51 | enum { | ||
52 | // Movement macros | ||
53 | // left & right | ||
54 | BABL_GO_LEFT_1C= BABL_START_NUM, | ||
55 | BABL_GO_RIGHT_1C, | ||
56 | BABL_GO_LEFT_WORD, | ||
57 | BABL_GO_RIGHT_WORD, | ||
58 | BABL_GO_START_LINE, | ||
59 | BABL_GO_END_LINE, | ||
60 | // now up & down | ||
61 | BABL_GO_START_DOC, | ||
62 | BABL_GO_END_DOC, | ||
63 | BABL_GO_NEXT_LINE, | ||
64 | BABL_GO_PREV_LINE, | ||
65 | BABL_PGDN, | ||
66 | BABL_PGUP, | ||
67 | // And the delete options | ||
68 | //BABL_DEL_LEFT_1C == backspace, so why bother. | ||
69 | BABL_DEL_RIGHT_1C, // usually = Del | ||
70 | BABL_DEL_LEFT_WORD, | ||
71 | BABL_DEL_RIGHT_WORD, | ||
72 | BABL_DEL_TO_LINE_END, // delete from cursor to end of line | ||
73 | BABL_DEL_TO_LINE_START, // delete from cursor to begining line | ||
74 | #ifndef BABL_MOVEMENTONLY | ||
75 | // Cut & Paste | ||
76 | BABL_UNDO, | ||
77 | BABL_REDO, | ||
78 | BABL_CUT, | ||
79 | BABL_COPY, | ||
80 | BABL_PASTE, | ||
81 | BABL_SELECT_ALL, | ||
82 | /* not yet implemented | ||
83 | BABL_SWAP_LAST2C // swap last characters before the cursor | ||
84 | BABL_SWAP_LAST2W // Swap the last two words before the cursor | ||
85 | */ | ||
86 | // find & replace | ||
87 | BABL_FIND, | ||
88 | BABL_FIND_NEXT, | ||
89 | BABL_FIND_REPLACE, | ||
90 | // GUI or app | ||
91 | BABL_RUNAPP, | ||
92 | BABL_SWITCH_APP_NEXT, | ||
93 | BABL_SWITCH_APP_LAST, // previous | ||
94 | BABL_CLOSE_APP, | ||
95 | BABL_HELP, | ||
96 | |||
97 | #ifndef BABL_NOBROWSER | ||
98 | BABL_BROWSER_NEW_TAB, | ||
99 | BABL_BROWSER_CLOSE_TAB, | ||
100 | BABL_BROWSER_REOPEN_LAST_TAB, | ||
101 | BABL_BROWSER_NEXT_TAB, | ||
102 | BABL_BROWSER_PREV_TAB, | ||
103 | BABL_BROWSER_URL_BAR, | ||
104 | BABL_BROWSER_FORWARD, | ||
105 | BABL_BROWSER_BACK, | ||
106 | BABL_BROWSER_FIND, | ||
107 | BABL_BROWSER_BOOKMARK, | ||
108 | BABL_BROWSER_DEV_TOOLS, // hard one to remember | ||
109 | BABL_BROWSER_RELOAD, | ||
110 | BABL_BROWSER_FULLSCREEN, | ||
111 | BABL_BROWSER_ZOOM_IN, | ||
112 | BABL_BROWSER_ZOOM_OUT, | ||
113 | |||
114 | #endif | ||
115 | |||
116 | #endif | ||
117 | // Macros for mode switching | ||
118 | #ifdef MS_MODE | ||
119 | BABL_WINDOWS, | ||
120 | #endif | ||
121 | #ifdef MAC_MODE | ||
122 | BABL_MAC, | ||
123 | #endif | ||
124 | #ifdef LINUX_MODE | ||
125 | BABL_LINUX, | ||
126 | #endif | ||
127 | #ifdef EMACS_MODE | ||
128 | BABL_EMACS, | ||
129 | #endif | ||
130 | #ifdef VI_MODE | ||
131 | BABL_VI, | ||
132 | #endif | ||
133 | #ifdef READMUX_MODE | ||
134 | BABL_READLINE, | ||
135 | #endif | ||
136 | |||
137 | |||
138 | }; | ||
139 | |||
140 | // BUG, used to jump to babble functiion. Surely there is a way to calculate size of enum? | ||
141 | #define BABL_NUM_MACROS 48+4 // 48 + # of defined modes. | ||
142 | |||
143 | /* And all the shorthand keymap ready versions */ | ||
144 | // First the mode switching macros | ||
145 | #ifdef MS_MODE | ||
146 | #define B_WIN M(BABL_WINDOWS) | ||
147 | #endif | ||
148 | #ifdef MAC_MODE | ||
149 | #define B_MAC M(BABL_MAC) | ||
150 | #endif | ||
151 | #ifdef LINUX_MODE | ||
152 | #define B_LNX M(BABL_LINUX) | ||
153 | #endif | ||
154 | #ifdef EMACS_MODE | ||
155 | #define B_EMAX M(BABL_EMACS) | ||
156 | #endif | ||
157 | #ifdef VI_MODE | ||
158 | #define B_VI M(BABL_VI) | ||
159 | #endif | ||
160 | #ifdef READMUX_MODE | ||
161 | #define B_READ M(BABL_READLINE) | ||
162 | #endif | ||
163 | |||
164 | // and all the movement & action. | ||
165 | |||
166 | #define B_L1C M(BABL_GO_LEFT_1C) | ||
167 | #define B_R1C M(BABL_GO_RIGHT_1C) | ||
168 | #define B_L1W M(BABL_GO_LEFT_WORD) | ||
169 | #define B_R1W M(BABL_GO_RIGHT_WORD) | ||
170 | #define B_GSOL M(BABL_GO_START_LINE) | ||
171 | #define B_GEOL M(BABL_GO_END_LINE) | ||
172 | #define B_GTOP M(BABL_GO_START_DOC) | ||
173 | #define B_GEND M(BABL_GO_END_DOC) | ||
174 | #define B_DOWN M(BABL_GO_NEXT_LINE) | ||
175 | #define B_UP M(BABL_GO_PREV_LINE) | ||
176 | #define B_PGDN M(BABL_PGDN) | ||
177 | #define B_PGUP M(BABL_PGUP) | ||
178 | //#define B_BKSP M(BABL_DEL_LEFT_1C) == backspace so why bother. | ||
179 | #define B_DEL M(BABL_DEL_RIGHT_1C) // usually = Del | ||
180 | #define B_DLW M(BABL_DEL_LEFT_WORD) | ||
181 | #define B_DRW M(BABL_DEL_RIGHT_WORD) | ||
182 | #define B_DEOL M(BABL_DEL_TO_LINE_END) // delete from cursor to end of line | ||
183 | #define B_DSOL M(BABL_DEL_TO_LINE_START) // delete from cursor to begining line | ||
184 | #define B_UNDO M(BABL_UNDO) | ||
185 | #define B_REDO M(BABL_REDO) | ||
186 | #define B_CUT M(BABL_CUT) | ||
187 | #define B_COPY M(BABL_COPY) | ||
188 | #define B_PAST M(BABL_PASTE) | ||
189 | #define B_SELA M(BABL_SELECT_ALL) | ||
190 | #define B_FIND M(BABL_FIND) | ||
191 | #define B_FINDN M(BABL_FIND_NEXT) | ||
192 | #define B_FINDR M(BABL_FIND_REPLACE) | ||
193 | #define B_RAPP M(BABL_RUNAPP) | ||
194 | #define B_NAPP M(BABL_SWITCH_APP_NEXT) | ||
195 | #define B_PAPP M(BABL_SWITCH_APP_LAST) // previous | ||
196 | #define B_CAPP M(BABL_CLOSE_APP) | ||
197 | #define B_HELP M(BABL_HELP) | ||
198 | #define B_NTAB M(BABL_BROWSER_NEW_TAB) | ||
199 | #define B_CTAB M(BABL_BROWSER_CLOSE_TAB) | ||
200 | #define B_ROTB M(BABL_BROWSER_REOPEN_LAST_TAB) | ||
201 | #define B_NXTB M(BABL_BROWSER_NEXT_TAB) | ||
202 | #define B_PTAB M(BABL_BROWSER_PREV_TAB) | ||
203 | #define B_NURL M(BABL_BROWSER_URL_BAR) | ||
204 | #define B_BFWD M(BABL_BROWSER_FORWARD) | ||
205 | #define B_BBAK M(BABL_BROWSER_BACK) | ||
206 | #define B_BFND M(BABL_BROWSER_FIND) | ||
207 | #define B_BOOK M(BABL_BROWSER_BOOKMARK) | ||
208 | #define B_BDEV M(BABL_BROWSER_DEV_TOOLS) // hard one to remember | ||
209 | #define B_BRLD M(BABL_BROWSER_RELOAD) | ||
210 | #define B_BFUlL M(BABL_BROWSER_FULLSCREEN) | ||
211 | #define B_ZMIN M(BABL_BROWSER_ZOOM_IN) | ||
212 | #define B_ZMOT M(BABL_BROWSER_ZOOM_OUT) | ||
213 | |||
214 | |||
215 | |||
216 | |||
217 | |||
218 | |||
219 | |||
220 | /* from action_macro.h | ||
221 | typedef uint8_t macro_t; | ||
222 | |||
223 | #define MACRO_NONE (macro_t*)0 | ||
224 | #define MACRO(...) ({ static const macro_t __m[] PROGMEM = { __VA_ARGS__ }; &__m[0]; }) | ||
225 | #define MACRO_GET(p) pgm_read_byte(p) | ||
226 | |||
227 | #define BABL_MSTART (entry, os, macro...) ( const macro_t bablDict[entry][os] PROGMEM = { macro... }; ) | ||
228 | |||
229 | */ | ||
230 | |||
231 | const macro_t *babblePaste(keyrecord_t *record, uint8_t shortcut); | ||
232 | |||
233 | macro_t* switch_babble_mode( uint8_t id); | ||
234 | |||
235 | |||
236 | #endif | ||
237 | #endif | ||
238 | |||