diff options
Diffstat (limited to 'users/rupa/rupa.c')
| -rwxr-xr-x | users/rupa/rupa.c | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/users/rupa/rupa.c b/users/rupa/rupa.c new file mode 100755 index 000000000..60fec3caf --- /dev/null +++ b/users/rupa/rupa.c | |||
| @@ -0,0 +1,49 @@ | |||
| 1 | /* | ||
| 2 | Copyright 2020 rupa <rupa@lrrr.us> @rupa | ||
| 3 | |||
| 4 | This program is free software: you can redistribute it and/or modify | ||
| 5 | it under the terms of the GNU General Public License as published by | ||
| 6 | the Free Software Foundation, either version 2 of the License, or | ||
| 7 | (at your option) any later version. | ||
| 8 | |||
| 9 | This program is distributed in the hope that it will be useful, | ||
| 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 12 | GNU General Public License for more details. | ||
| 13 | |||
| 14 | You should have received a copy of the GNU General Public License | ||
| 15 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 16 | */ | ||
| 17 | |||
| 18 | #include <print.h> | ||
| 19 | #include "rupa.h" | ||
| 20 | |||
| 21 | // https://en.wikipedia.org/wiki/Mathematical_Alphanumeric_Symbols | ||
| 22 | font_t script_bold = {0x1D4D0, 0x1D4EA, 0x1D7CE}; // with bold numbers | ||
| 23 | font_t fraktu_bold = {0x1D56C, 0x1D586, 0x1D7D8}; // with doublestruck numbers | ||
| 24 | font_t monosp_bold = {0x1D670, 0x1D68A, 0x1D7F6}; | ||
| 25 | |||
| 26 | // Maps A-Z, a-z, and 0-9 to other unicode ranges. We also map space to EN | ||
| 27 | // SPACE for some reason :) | ||
| 28 | uint32_t map_alnum(font_t *f, bool is_shifted, uint32_t keycode) { | ||
| 29 | switch (keycode) { | ||
| 30 | case KC_SPACE: | ||
| 31 | return (is_shifted ? 0 : 0x2002); // EN SPACE | ||
| 32 | case KC_0: | ||
| 33 | return (is_shifted ? 0 : f->zero_glyph); | ||
| 34 | case KC_A ... KC_Z: | ||
| 35 | return (is_shifted ? f->upper_alpha : f->lower_alpha) + keycode - KC_A; | ||
| 36 | case KC_1 ... KC_9: | ||
| 37 | return (is_shifted ? 0 : f->zero_glyph + keycode - KC_1 + 1); | ||
| 38 | default: | ||
| 39 | return 0; | ||
| 40 | } | ||
| 41 | } | ||
| 42 | |||
| 43 | bool script_mode_translate(font_t *translator, bool is_shifted, uint32_t keycode) { | ||
| 44 | uint32_t translated = map_alnum(translator, is_shifted, keycode); | ||
| 45 | if (translated == 0) return true; | ||
| 46 | dprintf("script_mode_translate: %u => %d\n", keycode, translated); | ||
| 47 | register_unicode(translated); | ||
| 48 | return false; | ||
| 49 | } | ||
