forked from forks/qmk_firmware
Merge pull request #235 from mbarkhau/master
add indent to generated keymap
This commit is contained in:
commit
0cdf5d292c
|
@ -43,6 +43,9 @@ KEYBOARD_LAYOUTS = {
|
|||
]
|
||||
}
|
||||
|
||||
ROW_INDENTS = {
|
||||
'ergodox_ez': [0, 0, 0, 0, 0, 1, 0, 0, 0, 2, 5, 0, 6, 0, 4, 0]
|
||||
}
|
||||
|
||||
BLANK_LAYOUTS = [
|
||||
# Compact Layout
|
||||
|
@ -591,16 +594,43 @@ def unicode_macro_cases(config):
|
|||
)
|
||||
|
||||
|
||||
def iter_keymap_lines(keymap):
|
||||
def iter_keymap_lines(keymap, row_indents=None):
|
||||
col_widths = {}
|
||||
col = 0
|
||||
# first pass, figure out the column widths
|
||||
prev_row_index = None
|
||||
for code, row_index in keymap.values():
|
||||
if row_index != prev_row_index:
|
||||
col = 0
|
||||
if row_indents:
|
||||
col = row_indents[row_index]
|
||||
col_widths[col] = max(len(code), col_widths.get(col, 0))
|
||||
prev_row_index = row_index
|
||||
col += 1
|
||||
|
||||
# second pass, yield the cell values
|
||||
col = 0
|
||||
prev_row_index = None
|
||||
for key_index in sorted(keymap):
|
||||
code, row_index = keymap[key_index]
|
||||
if row_index != prev_row_index:
|
||||
col = 0
|
||||
yield "\n"
|
||||
if row_indents:
|
||||
for indent_col in range(row_indents[row_index]):
|
||||
pad = " " * (col_widths[indent_col] - 4)
|
||||
yield (" /*-*/" + pad)
|
||||
col = row_indents[row_index]
|
||||
else:
|
||||
yield pad
|
||||
yield " {}".format(code)
|
||||
if key_index < len(keymap) - 1:
|
||||
yield ","
|
||||
# This will be yielded on the next iteration when
|
||||
# we know that we're not at the end of a line.
|
||||
pad = " " * (col_widths[col] - len(code))
|
||||
prev_row_index = row_index
|
||||
col += 1
|
||||
|
||||
|
||||
def iter_keymap_parts(config, keymaps):
|
||||
|
@ -632,7 +662,8 @@ def iter_keymap_parts(config, keymaps):
|
|||
|
||||
# keymap codes
|
||||
keymap = keymaps[layer_name]
|
||||
keymap_lines = "".join(iter_keymap_lines(keymap))
|
||||
row_indents = ROW_INDENTS.get(config['layout'])
|
||||
keymap_lines = "".join(iter_keymap_lines(keymap, row_indents))
|
||||
yield "[L{0}] = KEYMAP({1}\n),\n".format(i, keymap_lines)
|
||||
|
||||
yield "};\n\n"
|
||||
|
|
|
@ -134,14 +134,14 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
|||
MO(1), DE_U, DE_I, DE_A, DE_E, DE_O,
|
||||
MO(3), DE_UE, DE_OE, DE_AE, DE_C, DE_V, KC_END,
|
||||
KC_TRNS, KC_TRNS, KC_LGUI, KC_LALT, KC_LCTL,
|
||||
KC_INS, TG(2),
|
||||
KC_APP,
|
||||
KC_BSPC, KC_LSFT, KC_ESC,
|
||||
/*-*/ /*-*/ /*-*/ /*-*/ /*-*/ KC_INS, TG(2),
|
||||
/*-*/ /*-*/ /*-*/ /*-*/ /*-*/ /*-*/ KC_APP,
|
||||
/*-*/ /*-*/ /*-*/ /*-*/ KC_BSPC, KC_LSFT, KC_ESC,
|
||||
DE_GRV, DE_6, DE_7, DE_8, DE_9, DE_0, DE_CIRC,
|
||||
TG(2), DE_H, DE_J, DE_K, DE_L, DE_Q, DE_Z,
|
||||
DE_S, DE_N, DE_R, DE_T, DE_D, DE_SS,
|
||||
/*-*/ DE_S, DE_N, DE_R, DE_T, DE_D, DE_SS,
|
||||
KC_TAB, DE_B, DE_M, DE_COMM, DE_DOT, KC_UP, DE_Y,
|
||||
KC_RCTL, KC_RALT, KC_LEFT, KC_DOWN, KC_RGHT,
|
||||
/*-*/ /*-*/ KC_RCTL, KC_RALT, KC_LEFT, KC_DOWN, KC_RGHT,
|
||||
M(UM), KC_DELT,
|
||||
KC_PGUP,
|
||||
KC_PGDN, KC_ENTER, KC_SPACE
|
||||
|
@ -172,14 +172,14 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
|||
KC_TRNS, DE_UNDS, DE_MINS, DE_AMPR, DE_LBRC, DE_RBRC,
|
||||
KC_TRNS, KC_TRNS, DE_PLUS, DE_EQL, KC_TRNS, KC_TRNS, KC_TRNS,
|
||||
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
|
||||
KC_TRNS, KC_TRNS,
|
||||
KC_TRNS,
|
||||
KC_TRNS, KC_TRNS, KC_TRNS,
|
||||
/*-*/ /*-*/ /*-*/ /*-*/ /*-*/ KC_TRNS, KC_TRNS,
|
||||
/*-*/ /*-*/ /*-*/ /*-*/ /*-*/ /*-*/ KC_TRNS,
|
||||
/*-*/ /*-*/ /*-*/ /*-*/ KC_TRNS, KC_TRNS, KC_TRNS,
|
||||
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, DE_RING, KC_TRNS,
|
||||
KC_TRNS, DE_HASH, DE_LESS, DE_MORE, KC_TRNS, DE_DQOT, KC_TRNS,
|
||||
DE_DLR, DE_LPRN, DE_RPRN, DE_TILD, DE_QUOT, DE_QST,
|
||||
/*-*/ DE_DLR, DE_LPRN, DE_RPRN, DE_TILD, DE_QUOT, DE_QST,
|
||||
KC_TRNS, DE_BSLS, DE_PERC, DE_SCLN, DE_COLN, M(UC_UPWARDS_ARROW), KC_TRNS,
|
||||
KC_TRNS, KC_TRNS, M(UC_LEFTWARDS_ARROW), M(UC_DOWNWARDS_ARROW), M(UC_RIGHTWARDS_ARROW),
|
||||
/*-*/ /*-*/ KC_TRNS, KC_TRNS, M(UC_LEFTWARDS_ARROW), M(UC_DOWNWARDS_ARROW), M(UC_RIGHTWARDS_ARROW),
|
||||
KC_TRNS, KC_TRNS,
|
||||
KC_TRNS,
|
||||
KC_TRNS, KC_TRNS, KC_TRNS
|
||||
|
@ -210,14 +210,14 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
|||
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
|
||||
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
|
||||
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
|
||||
KC_TRNS, KC_TRNS,
|
||||
KC_TRNS,
|
||||
KC_TRNS, KC_TRNS, KC_TRNS,
|
||||
/*-*/ /*-*/ /*-*/ /*-*/ /*-*/ KC_TRNS, KC_TRNS,
|
||||
/*-*/ /*-*/ /*-*/ /*-*/ /*-*/ /*-*/ KC_TRNS,
|
||||
/*-*/ /*-*/ /*-*/ /*-*/ KC_TRNS, KC_TRNS, KC_TRNS,
|
||||
KC_F12, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_PEQL,
|
||||
KC_TRNS, KC_TRNS, KC_P7, KC_P8, KC_P9, KC_PAST, KC_PSLS,
|
||||
KC_TRNS, KC_P4, KC_P5, KC_P6, KC_PMNS, KC_PMNS,
|
||||
/*-*/ KC_TRNS, KC_P4, KC_P5, KC_P6, KC_PMNS, KC_PMNS,
|
||||
KC_NLCK, KC_TRNS, KC_P1, KC_P2, KC_P3, KC_PPLS, KC_PPLS,
|
||||
KC_P0, KC_PCMM, KC_PDOT, KC_PENT, KC_PENT,
|
||||
/*-*/ /*-*/ KC_P0, KC_PCMM, KC_PDOT, KC_PENT, KC_PENT,
|
||||
KC_TRNS, KC_TRNS,
|
||||
KC_TRNS,
|
||||
KC_TRNS, KC_TRNS, KC_TRNS
|
||||
|
@ -248,14 +248,14 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
|||
KC_TRNS, KC_TRNS, M(UC_PLUS_MINUS_SIGN), DE_AT, DE_EURO, M(UC_EMPTY_SET),
|
||||
KC_TRNS, M(UC_VULGAR_FRACTION_ONE_THIRD), M(UC_NOT_EQUAL_TO), M(UC_VULGAR_FRACTION_TWO_THIRDS), M(UC_VULGAR_FRACTION_THREE_QUARTERS), M(UC_ASYMPTOTICALLY_EQUAL_TO), KC_TRNS,
|
||||
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
|
||||
KC_TRNS, KC_TRNS,
|
||||
KC_TRNS,
|
||||
KC_TRNS, KC_TRNS, KC_TRNS,
|
||||
/*-*/ /*-*/ /*-*/ /*-*/ /*-*/ KC_TRNS, KC_TRNS,
|
||||
/*-*/ /*-*/ /*-*/ /*-*/ /*-*/ /*-*/ KC_TRNS,
|
||||
/*-*/ /*-*/ /*-*/ /*-*/ KC_TRNS, KC_TRNS, KC_TRNS,
|
||||
KC_TRNS, M(UC_SUPERSCRIPT_SIX), M(UC_SUPERSCRIPT_SEVEN), M(UC_SUPERSCRIPT_EIGHT), M(UC_SUPERSCRIPT_NINE), M(UC_SUPERSCRIPT_ZERO), KC_TRNS,
|
||||
KC_TRNS, M(UC_VULGAR_FRACTION_ONE_SIXTH), KC_TRNS, M(UC_VULGAR_FRACTION_ONE_EIGHTH), KC_TRNS, KC_TRNS, KC_TRNS,
|
||||
M(UC_INFINITY), M(UC_SUPERSCRIPT_LATIN_SMALL_LETTER_N), M(UC_THERE_EXISTS), M(UC_ELEMENT_OF), KC_TRNS, KC_TRNS,
|
||||
/*-*/ M(UC_INFINITY), M(UC_SUPERSCRIPT_LATIN_SMALL_LETTER_N), M(UC_THERE_EXISTS), M(UC_ELEMENT_OF), KC_TRNS, KC_TRNS,
|
||||
KC_TRNS, DE_EXLM, KC_TRNS, M(UC_THERE_DOES_NOT_EXIST), M(UC_NOT_AN_ELEMENT_OF), KC_TRNS, KC_TRNS,
|
||||
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
|
||||
/*-*/ /*-*/ KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
|
||||
KC_TRNS, KC_TRNS,
|
||||
KC_TRNS,
|
||||
KC_TRNS, KC_TRNS, KC_TRNS
|
||||
|
@ -286,14 +286,14 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
|||
KC_TRNS, M(UC_GREEK_SMALL_LETTER_UPSILON), M(UC_GREEK_SMALL_LETTER_IOTA), M(UC_GREEK_SMALL_LETTER_ALPHA), M(UC_GREEK_SMALL_LETTER_EPSILON), M(UC_GREEK_SMALL_LETTER_OMICRON),
|
||||
KC_TRNS, KC_TRNS, M(UC_GREEK_SMALL_LETTER_THETA), KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
|
||||
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
|
||||
KC_TRNS, KC_TRNS,
|
||||
KC_TRNS,
|
||||
KC_TRNS, KC_TRNS, KC_TRNS,
|
||||
/*-*/ /*-*/ /*-*/ /*-*/ /*-*/ KC_TRNS, KC_TRNS,
|
||||
/*-*/ /*-*/ /*-*/ /*-*/ /*-*/ /*-*/ KC_TRNS,
|
||||
/*-*/ /*-*/ /*-*/ /*-*/ KC_TRNS, KC_TRNS, KC_TRNS,
|
||||
KC_TRNS, M(UC_SUBSCRIPT_SIX), M(UC_SUBSCRIPT_SEVEN), M(UC_SUBSCRIPT_EIGHT), M(UC_SUBSCRIPT_NINE), M(UC_SUBSCRIPT_ZERO), KC_TRNS,
|
||||
KC_TRNS, M(UC_GREEK_SMALL_LETTER_ETA), M(UC_GREEK_SMALL_LETTER_XI), M(UC_GREEK_SMALL_LETTER_KAPPA), M(UC_GREEK_SMALL_LETTER_LAMDA), KC_TRNS, M(UC_GREEK_SMALL_LETTER_ZETA),
|
||||
M(UC_GREEK_SMALL_LETTER_SIGMA), M(UC_GREEK_SMALL_LETTER_NU), M(UC_GREEK_SMALL_LETTER_RHO), M(UC_GREEK_SMALL_LETTER_TAU), M(UC_GREEK_SMALL_LETTER_DELTA), M(UC_GREEK_SMALL_LETTER_FINAL_SIGMA),
|
||||
/*-*/ M(UC_GREEK_SMALL_LETTER_SIGMA), M(UC_GREEK_SMALL_LETTER_NU), M(UC_GREEK_SMALL_LETTER_RHO), M(UC_GREEK_SMALL_LETTER_TAU), M(UC_GREEK_SMALL_LETTER_DELTA), M(UC_GREEK_SMALL_LETTER_FINAL_SIGMA),
|
||||
KC_TRNS, M(UC_GREEK_SMALL_LETTER_BETA), M(UC_GREEK_SMALL_LETTER_MU), KC_TRNS, KC_TRNS, KC_TRNS, M(UC_GREEK_SMALL_LETTER_PSI),
|
||||
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
|
||||
/*-*/ /*-*/ KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
|
||||
KC_TRNS, KC_TRNS,
|
||||
KC_TRNS,
|
||||
KC_TRNS, KC_TRNS, KC_TRNS
|
||||
|
@ -324,14 +324,14 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
|||
KC_TRNS, M(UC_GREEK_CAPITAL_LETTER_UPSILON), M(UC_GREEK_CAPITAL_LETTER_IOTA), M(UC_GREEK_CAPITAL_LETTER_ALPHA), M(UC_GREEK_CAPITAL_LETTER_EPSILON), M(UC_GREEK_CAPITAL_LETTER_OMICRON),
|
||||
KC_TRNS, KC_TRNS, M(UC_GREEK_CAPITAL_LETTER_THETA), KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
|
||||
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
|
||||
KC_TRNS, KC_TRNS,
|
||||
KC_TRNS,
|
||||
KC_TRNS, KC_TRNS, KC_TRNS,
|
||||
/*-*/ /*-*/ /*-*/ /*-*/ /*-*/ KC_TRNS, KC_TRNS,
|
||||
/*-*/ /*-*/ /*-*/ /*-*/ /*-*/ /*-*/ KC_TRNS,
|
||||
/*-*/ /*-*/ /*-*/ /*-*/ KC_TRNS, KC_TRNS, KC_TRNS,
|
||||
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
|
||||
KC_TRNS, M(UC_GREEK_CAPITAL_LETTER_ETA), M(UC_GREEK_CAPITAL_LETTER_XI), M(UC_GREEK_CAPITAL_LETTER_KAPPA), M(UC_GREEK_CAPITAL_LETTER_LAMDA), KC_TRNS, M(UC_GREEK_CAPITAL_LETTER_ZETA),
|
||||
M(UC_GREEK_CAPITAL_LETTER_SIGMA), M(UC_GREEK_CAPITAL_LETTER_NU), M(UC_GREEK_CAPITAL_LETTER_RHO), M(UC_GREEK_CAPITAL_LETTER_TAU), M(UC_GREEK_CAPITAL_LETTER_DELTA), KC_TRNS,
|
||||
/*-*/ M(UC_GREEK_CAPITAL_LETTER_SIGMA), M(UC_GREEK_CAPITAL_LETTER_NU), M(UC_GREEK_CAPITAL_LETTER_RHO), M(UC_GREEK_CAPITAL_LETTER_TAU), M(UC_GREEK_CAPITAL_LETTER_DELTA), KC_TRNS,
|
||||
KC_TRNS, M(UC_GREEK_CAPITAL_LETTER_BETA), M(UC_GREEK_CAPITAL_LETTER_MU), KC_TRNS, KC_TRNS, KC_TRNS, M(UC_GREEK_CAPITAL_LETTER_PSI),
|
||||
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
|
||||
/*-*/ /*-*/ KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
|
||||
KC_TRNS, KC_TRNS,
|
||||
KC_TRNS,
|
||||
KC_TRNS, KC_TRNS, KC_TRNS
|
||||
|
@ -362,14 +362,14 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
|||
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
|
||||
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
|
||||
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
|
||||
KC_TRNS, KC_TRNS,
|
||||
KC_TRNS,
|
||||
KC_TRNS, KC_TRNS, KC_TRNS,
|
||||
/*-*/ /*-*/ /*-*/ /*-*/ /*-*/ KC_TRNS, KC_TRNS,
|
||||
/*-*/ /*-*/ /*-*/ /*-*/ /*-*/ /*-*/ KC_TRNS,
|
||||
/*-*/ /*-*/ /*-*/ /*-*/ KC_TRNS, KC_TRNS, KC_TRNS,
|
||||
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
|
||||
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
|
||||
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
|
||||
/*-*/ KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
|
||||
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
|
||||
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
|
||||
/*-*/ /*-*/ KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
|
||||
KC_TRNS, KC_TRNS,
|
||||
KC_TRNS,
|
||||
KC_TRNS, KC_TRNS, KC_TRNS
|
||||
|
|
Loading…
Reference in a new issue