From 7ebed894a8a99b340a3ffc9f6caffe1ac20d59ef Mon Sep 17 00:00:00 2001 From: Guido Bartolucci Date: Wed, 11 Jul 2018 11:41:15 -0400 Subject: Converted guidoism layout to new keyboard-agnostic form (#3367) * Initial commit of guidoism * created movement layer * movement layer works! * removed unnecessary layers * moved enter key up and recreated caps lock * cleaned up * num pad * checkpoint * checkpoint * checkpoint * Added num pad * changed max power draw so i can use this on ipad * move around quotes * added tri layer for a homed numpad * moved layout to new style * Update readme.md * Update readme.md * Update readme.md * Update readme.md * added keys to unicode conversion * removed adjust layer since its not used anymore --- .../community/ortho_4x12/guidoism/generate_c.py | 59 ++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 layouts/community/ortho_4x12/guidoism/generate_c.py (limited to 'layouts/community/ortho_4x12/guidoism/generate_c.py') diff --git a/layouts/community/ortho_4x12/guidoism/generate_c.py b/layouts/community/ortho_4x12/guidoism/generate_c.py new file mode 100644 index 000000000..7876bee68 --- /dev/null +++ b/layouts/community/ortho_4x12/guidoism/generate_c.py @@ -0,0 +1,59 @@ +import itertools +import json +from pprint import pprint as pp + +layers = dict(enumerate(['_QWERTY', '_LOWER', '_RAISE', '_MOVEMENT', '_NUMPAD'])) +key_names = {('MO(%d)' % i): layers.get(i).strip('_') for i in layers.keys()} + +unicodes = { + "": "next", + "": "vol-", + "": "vol+", + "": "play", +} + +d = json.load(open('layouts/community/ortho_4x12/guidoism/guidoism.json')) + +def grouper(iterable, n): + args = [iter(iterable)] * n + return itertools.zip_longest(*args, fillvalue='') + +def truthy(s): + return [a for a in s if a] + +def just(s, n): + return [a.center(n*2+1 if len(s) == 11 and i == 5 else n) for i, a in enumerate(s)] + +def replace(s): + return [key_names.get(a, a) for a in s] + +def layer(i, l): + n = max(len(s) for s in l) + rows = [', '.join(replace(truthy(row))) for row in grouper(l, 12)] + return '[%s] = %s(\n%s)' % (layers[i], d['layout'], ',\n'.join(rows)) + +print(',\n\n'.join(layer(i, l) for i, l in enumerate(d['layers']))) + +def surround(s, a, b, c): + return a + b.join(s) + c + +def pattern(cell, table): + return ['─'*cell for i in range(table)] + +keys = json.load(open('layouts/community/ortho_4x12/guidoism/keys.json')) + +def layer2(i, l): + def replace(s): + s = [keys.get(a, a) for a in s] + return [unicodes.get(a, a) for a in s] + n = max(len(s) for s in l) + return [surround(just(replace(truthy(row)), 5), '│', '│', '│') for row in grouper(l, 12)] + +for i, l in enumerate(d['layers']): + print(surround(pattern(5, 12), '┌', '┬', '┐')) + for n, row in enumerate(layer2(i, l)): + print(row) + if n < 3: + print(surround(pattern(5, 12), '├', '┼', '┤')) + else: + print(surround(pattern(5, 12), '└', '┴', '┘')) -- cgit v1.2.3