summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorQMK Bot <hello@qmk.fm>2022-03-05 22:55:11 +0000
committerQMK Bot <hello@qmk.fm>2022-03-05 22:55:11 +0000
commitf7512d61bd1c817f01011091c0eff3df9cf8c1b9 (patch)
tree95d067806352cc26c489f1255749ab15d253a6ba /lib
parente2ab5056f1a799d583ebdb3cc949af503ddcd873 (diff)
parent8e9d45d2708d71cf89bed704e8e0e1bf5671804f (diff)
downloadqmk_firmware-f7512d61bd1c817f01011091c0eff3df9cf8c1b9.tar.gz
qmk_firmware-f7512d61bd1c817f01011091c0eff3df9cf8c1b9.zip
Merge remote-tracking branch 'origin/master' into develop
Diffstat (limited to 'lib')
-rw-r--r--lib/python/qmk/keyboard.py94
1 files changed, 69 insertions, 25 deletions
diff --git a/lib/python/qmk/keyboard.py b/lib/python/qmk/keyboard.py
index c87ea9050b..0530c4acc5 100644
--- a/lib/python/qmk/keyboard.py
+++ b/lib/python/qmk/keyboard.py
@@ -162,13 +162,12 @@ def render_layout(layout_data, render_ascii, key_labels=None):
"""
textpad = [array('u', ' ' * 200) for x in range(100)]
style = 'ascii' if render_ascii else 'unicode'
- box_chars = BOX_DRAWING_CHARACTERS[style]
for key in layout_data:
- x = ceil(key.get('x', 0) * 4)
- y = ceil(key.get('y', 0) * 3)
- w = ceil(key.get('w', 1) * 4)
- h = ceil(key.get('h', 1) * 3)
+ x = key.get('x', 0)
+ y = key.get('y', 0)
+ w = key.get('w', 1)
+ h = key.get('h', 1)
if key_labels:
label = key_labels.pop(0)
@@ -177,26 +176,10 @@ def render_layout(layout_data, render_ascii, key_labels=None):
else:
label = key.get('label', '')
- label_len = w - 2
- label_leftover = label_len - len(label)
-
- if len(label) > label_len:
- label = label[:label_len]
-
- label_blank = ' ' * label_len
- label_border = box_chars['h'] * label_len
- label_middle = label + ' '*label_leftover # noqa: yapf insists there be no whitespace around *
-
- top_line = array('u', box_chars['tl'] + label_border + box_chars['tr'])
- lab_line = array('u', box_chars['v'] + label_middle + box_chars['v'])
- mid_line = array('u', box_chars['v'] + label_blank + box_chars['v'])
- bot_line = array('u', box_chars['bl'] + label_border + box_chars['br'])
-
- textpad[y][x:x + w] = top_line
- textpad[y + 1][x:x + w] = lab_line
- for i in range(h - 3):
- textpad[y + i + 2][x:x + w] = mid_line
- textpad[y + h - 1][x:x + w] = bot_line
+ if x >= 0.25 and w == 1.25 and h == 2:
+ render_key_isoenter(textpad, x, y, w, h, label, style)
+ else:
+ render_key_rect(textpad, x, y, w, h, label, style)
lines = []
for line in textpad:
@@ -216,3 +199,64 @@ def render_layouts(info_json, render_ascii):
layouts[layout] = render_layout(layout_data, render_ascii)
return layouts
+
+
+def render_key_rect(textpad, x, y, w, h, label, style):
+ box_chars = BOX_DRAWING_CHARACTERS[style]
+ x = ceil(x * 4)
+ y = ceil(y * 3)
+ w = ceil(w * 4)
+ h = ceil(h * 3)
+
+ label_len = w - 2
+ label_leftover = label_len - len(label)
+
+ if len(label) > label_len:
+ label = label[:label_len]
+
+ label_blank = ' ' * label_len
+ label_border = box_chars['h'] * label_len
+ label_middle = label + ' '*label_leftover # noqa: yapf insists there be no whitespace around *
+
+ top_line = array('u', box_chars['tl'] + label_border + box_chars['tr'])
+ lab_line = array('u', box_chars['v'] + label_middle + box_chars['v'])
+ mid_line = array('u', box_chars['v'] + label_blank + box_chars['v'])
+ bot_line = array('u', box_chars['bl'] + label_border + box_chars['br'])
+
+ textpad[y][x:x + w] = top_line
+ textpad[y + 1][x:x + w] = lab_line
+ for i in range(h - 3):
+ textpad[y + i + 2][x:x + w] = mid_line
+ textpad[y + h - 1][x:x + w] = bot_line
+
+
+def render_key_isoenter(textpad, x, y, w, h, label, style):
+ box_chars = BOX_DRAWING_CHARACTERS[style]
+ x = ceil(x * 4)
+ y = ceil(y * 3)
+ w = ceil(w * 4)
+ h = ceil(h * 3)
+
+ label_len = w - 1
+ label_leftover = label_len - len(label)
+
+ if len(label) > label_len:
+ label = label[:label_len]
+
+ label_blank = ' ' * (label_len-1) # noqa: yapf insists there be no whitespace around - and *
+ label_border_top = box_chars['h'] * label_len
+ label_border_bottom = box_chars['h'] * (label_len-1) # noqa
+ label_middle = label + ' '*label_leftover # noqa
+
+ top_line = array('u', box_chars['tl'] + label_border_top + box_chars['tr'])
+ lab_line = array('u', box_chars['v'] + label_middle + box_chars['v'])
+ crn_line = array('u', box_chars['bl'] + box_chars['tr'] + label_blank + box_chars['v'])
+ mid_line = array('u', box_chars['v'] + label_blank + box_chars['v'])
+ bot_line = array('u', box_chars['bl'] + label_border_bottom + box_chars['br'])
+
+ textpad[y][x - 1:x + w] = top_line
+ textpad[y + 1][x - 1:x + w] = lab_line
+ textpad[y + 2][x - 1:x + w] = crn_line
+ textpad[y + 3][x:x + w] = mid_line
+ textpad[y + 4][x:x + w] = mid_line
+ textpad[y + h - 1][x:x + w] = bot_line