lang.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. #pragma once
  2. /*
  3. Copyright 2018-2022 Eric Gebhart <e.a.gebhart@gmail.com>
  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. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with this program. If not, see <http://www.gnu.org/licenses/>.
  14. */
  15. // Language macros to change the names of things to
  16. // match the value of LANG_IS, and EDGE_COLS.
  17. // it would be nice to have consistency, but there isn't.
  18. // Keys need a prefix, layer chunks need a different suffix,
  19. // defines that are are opposite, of keys.
  20. //
  21. // In order to change layer and other names to match lang.
  22. // foo --> foo_bp or foo.
  23. // A new language just needs entries to match so
  24. // that it will create the proper names when LANG_IS
  25. // set to the appropriate values.
  26. // sonly the pfx and sfx functions need additions for
  27. // another language.
  28. // The rest is making sure there are keymap chunks
  29. // defined as needed.
  30. #define COMMA ,
  31. #define CONCATENATE(a, ...) a ## __VA_ARGS__
  32. #define CAT(a, ...) CONCATENATE(a, __VA_ARGS__)
  33. // We need another one with a different name.
  34. // The macros are painted blue otherwise.
  35. // Cat gets used at a low level, around keys, or layers basically.
  36. // Cat 2 is used for thumb cluster choices, any of which can contain
  37. // a number of CATS down at the bottom. -- nested macros of the same
  38. // name get painted blue. So here we are. :-). look in edge_keys.h
  39. // for THUMBS
  40. #define CONCATENATE2(a, ...) a ## __VA_ARGS__
  41. #define CAT2(a, ...) CONCATENATE2(a, __VA_ARGS__)
  42. #define CONCATENATE3(a, ...) a ## __VA_ARGS__
  43. #define CAT3(a, ...) CONCATENATE3(a, __VA_ARGS__)
  44. #define EMPTY()
  45. #define DEFER(id) id EMPTY()
  46. #define OBSTRUCT(...) __VA_ARGS__ DEFER(EMPTY)()
  47. #define EXPAND(...) __VA_ARGS__
  48. // Give the right keycode prefix by LANG_IS
  49. #define LANG_PFX CAT(LANG_IS, KC)
  50. #define COMBOKC CB
  51. #define COMBO2KC CB2
  52. #define BEPOKC BP
  53. #define ENKC KC
  54. #define US_INTKC US
  55. // Give the right symbol suffix by LANG_IS
  56. #define LANG_SFX CAT(CAT(LANG_IS, _), SFX)
  57. #define LOCALE_LAYERS_SFX _LL // for counting the base layers.
  58. #define COMBO_SFX _CB
  59. #define COMBO2_SFX _CB2
  60. #define BEPO_SFX _BP
  61. #define EN_SFX _EN
  62. #define US_INT_SFX _EN
  63. // Give the right map chunk suffix by LANG_IS
  64. #define LANG_MAPSFX CAT(CAT(LANG_IS, _), MAPSFX)
  65. #define COMBO_MAPSFX _CB___
  66. #define COMBO2_MAPSFX _CB2___
  67. #define BEPO_MAPSFX _BP___
  68. #define EN_MAPSFX _EN___
  69. #define US_INT_MAPSFX _EN___
  70. // These use the mapping above to get their job done.
  71. // In order to create keycode names to match lang.
  72. // A --> BP_A or KC_A,US_A
  73. #define LANG_KC(NAME) CAT(LANG_PFX, NAME)
  74. // _SYMB -> _SYMB_EN
  75. // _SYMB -> _SYMB_BP
  76. #define LANG_N(NAME) CAT(NAME, LANG_SFX)
  77. // In order to map chunk names to match lang.
  78. // MAP_CHUNK(___15_BOTTOM) --> ___15_BOTTOM_EN___ or ___15_BOTTOM_BP___
  79. #define MAP_CHUNK(NAME) CAT3(NAME, LANG_MAPSFX)
  80. // for the oled layer map switch
  81. #ifdef SECOND_LOCALE
  82. #define LCASE(NAME) \
  83. case CAT2(NAME, _EN): \
  84. case CAT2(NAME, _BP):
  85. #else
  86. #define LCASE(NAME) \
  87. case CAT2(NAME, _EN):
  88. #endif