-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from t33chong/t33chong
Add s/S/x/X actions, various synonyms, mode hooks, userspace docs; optionally differentiate w & e motions; fix process hooks & redo on Mac; automate updating firmware size table in readme
- Loading branch information
Showing
9 changed files
with
244 additions
and
49 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
FROM qmkfm/qmk_firmware:latest | ||
|
||
ENV MY_KEYMAP_PATH=/qmk_firmware/keyboards/uno/keymaps/qmk-vim-update-readme | ||
|
||
WORKDIR /qmk_firmware | ||
|
||
COPY keymap $MY_KEYMAP_PATH | ||
COPY run.py /qmk_firmware/qmk_vim_update_readme.py | ||
|
||
CMD python3 qmk_vim_update_readme.py |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#include QMK_KEYBOARD_H | ||
#include "qmk-vim/src/vim.h" | ||
|
||
enum keycodes { | ||
QMK_VIM = SAFE_RANGE | ||
}; | ||
|
||
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { | ||
[0] = LAYOUT(QMK_VIM) | ||
}; | ||
|
||
bool process_record_user(uint16_t keycode, keyrecord_t *record) { | ||
if (!process_vim_mode(keycode, record)) { | ||
return false; | ||
} | ||
if (keycode == QMK_VIM && record->event.pressed) { | ||
toggle_vim_mode(); | ||
return false; | ||
} | ||
return true; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
include keyboards/uno/keymaps/qmk-vim-update-readme/qmk-vim/rules.mk |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import os | ||
import re | ||
import subprocess | ||
|
||
# Path to QMK keymap used for firmware size calculations | ||
MY_KEYMAP_PATH = os.getenv('MY_KEYMAP_PATH') | ||
README_PATH = os.path.join(MY_KEYMAP_PATH, 'qmk-vim/README.org') | ||
|
||
# Split readme into sections: before feature macros table, table itself, and after table | ||
BEFORE, MACROS, AFTER = 0, 1, 2 | ||
lines = [[], [], []] | ||
position = BEFORE | ||
with open(README_PATH) as f: | ||
for line in f: | ||
if ((position == BEFORE and line.startswith('| =')) | ||
or (position == MACROS and not line.startswith('|'))): | ||
position += 1 | ||
lines[position].append(line) | ||
|
||
# Compile and parse output for firmware size | ||
def get_firmware_size(): | ||
process = subprocess.run( | ||
['qmk', 'compile', '-kb', 'uno', '-km', 'qmk-vim-update-readme'], capture_output=True) | ||
matches = re.search(r'The firmware size is fine - (\d+)', process.stdout.decode('utf-8')) | ||
return int(matches[1]) | ||
|
||
# Determine firmware size without any macros defined | ||
baseline = get_firmware_size() | ||
|
||
# Iterate over rows in table | ||
for i in range(len(lines[MACROS])): | ||
# Parse macro name | ||
line = lines[MACROS][i] | ||
cells = line.split('|') | ||
macro = cells[1].strip('= ') | ||
# Add macro to config | ||
with open(os.path.join(MY_KEYMAP_PATH, 'config.h'), 'w') as f: | ||
f.write(f'#define {macro}') | ||
# Determine firmware size difference | ||
size = get_firmware_size() | ||
size_diff = baseline - size | ||
if size_diff >= 0: | ||
new_val_str = f' +{size_diff} B' | ||
else: | ||
new_val_str = f' {size_diff} B' | ||
# Update table | ||
cells[3] = new_val_str.ljust(len(cells[3]), ' ') | ||
lines[MACROS][i] = '|'.join(cells) | ||
|
||
# Overwrite readme with new values | ||
with open(README_PATH, 'w') as f: | ||
f.write(''.join(line for section in lines for line in section)) |