diff --git a/etc/generate-keylist/extract-keys.sh b/etc/generate-keylist/extract-keys.sh new file mode 100644 index 0000000000..23e9d2a53e --- /dev/null +++ b/etc/generate-keylist/extract-keys.sh @@ -0,0 +1,6 @@ +# Find potential argument-taking macros +ggrep --no-filename -oP '^#define \K\w+\s*\([^)]*\)' src/kaleidoscope/key_defs/*.h > /tmp/arg_macros.txt + +# Find non-argument-taking macros +ggrep --no-filename -oP '^#define \K\w+' src/kaleidoscope/key_defs/*.h | ggrep -vFf /tmp/arg_macros.txt > /tmp/non_arg_macros.txt + diff --git a/etc/generate-keylist/generate-macro-printer.sh b/etc/generate-keylist/generate-macro-printer.sh new file mode 100644 index 0000000000..76ecd4165f --- /dev/null +++ b/etc/generate-keylist/generate-macro-printer.sh @@ -0,0 +1,27 @@ +PROGRAM=/tmp/list-macros.cpp +echo '#include ' > ${PROGRAM} +echo '#include "kaleidoscope/key_defs.h"' >> ${PROGRAM} +echo '#include "kaleidoscope/HIDTables.h"' >> ${PROGRAM} +echo 'int main() {' >> ${PROGRAM} +echo 'printf("{\\n");' >> ${PROGRAM} + +# Handle non-argument-taking macros +while IFS= read -r macro; do + echo "printf(\"'$macro': %d,\", $macro.getRaw());" >> ${PROGRAM} + echo "printf(\"\\\n\");" >> ${PROGRAM} +done < /tmp/non_arg_macros.txt + +# Handle argument-taking macros, generating 32 versions for each +while IFS= read -r macro; do + # Strip off parentheses for the argument-taking macro names + macro=$(echo $macro | sed 's/(.*)//') + for i in {0..31}; do + echo "printf(\"'$macro$i': %d,\", $macro($i).getRaw());" >> ${PROGRAM} + echo "printf(\"\\\n\");" >> ${PROGRAM} + done +done < /tmp/arg_macros.txt + +echo 'printf("};\\n");' >> ${PROGRAM} +echo 'return 0;' >> ${PROGRAM} +echo '}' >> ${PROGRAM} +