summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars-Dominik Braun <lars@6xq.net>2020-11-14 15:37:02 +0100
committerLars-Dominik Braun <lars@6xq.net>2020-11-14 15:37:02 +0100
commit286bd8b6f17beb77829c7fabcb8e7b1c48b734e3 (patch)
treed6b44f6c07e12925d38443116f43df33f700cb91
parentde1e1d09f5ab46f0b07f55b2bc5d9722a156bb2c (diff)
downloadlulua-286bd8b6f17beb77829c7fabcb8e7b1c48b734e3.tar.gz
lulua-286bd8b6f17beb77829c7fabcb8e7b1c48b734e3.tar.bz2
lulua-286bd8b6f17beb77829c7fabcb8e7b1c48b734e3.zip
render: Add Klavaro keyboard file
Fixes #8, although Klavaro’s support for diacritics seems to be lacking right now.
-rwxr-xr-xgen.sh7
-rw-r--r--lulua/data/report/index.html4
-rw-r--r--lulua/render.py31
3 files changed, 42 insertions, 0 deletions
diff --git a/gen.sh b/gen.sh
index f02a89c..47d01ea 100755
--- a/gen.sh
+++ b/gen.sh
@@ -120,6 +120,9 @@ rule zipR
rule render-winkbd
command = lulua-render -l ar-lulua winkbd \$out
+rule render-klavaro
+ command = lulua-render -l ar-lulua klavaro \$out
+
rule ninjaC
command = ninja -C \$dir
@@ -141,6 +144,10 @@ build \$reportdir/fonts/IBMPlexSansArabic-Thin.woff2: cp \$fontdir/IBMPlexSansAr
# build osmconvert
build \$osmconvert: configure-make 3rdparty/osmctools
+# Klavaro keyboard
+build \$reportdir/lulua_ar.kbd: render-klavaro || \$reportdir
+ layout = ${l}
+
# windows drivers
build \$tempdir/winkbd: mkdir lulua/data/winkbd
EOF
diff --git a/lulua/data/report/index.html b/lulua/data/report/index.html
index cae6024..9aa06fd 100644
--- a/lulua/data/report/index.html
+++ b/lulua/data/report/index.html
@@ -96,6 +96,10 @@
<a href="https://play.google.com/store/apps/details?id=com.anysoftkeyboard.languagepack.arabic">Arabic for AnySoftKeyboard</a>
<dt>Linux</dt>
<dd>Run: <code>xmodmap <a href="ar-lulua.xmodmap">ar-lulua.xmodmap</a></code></dd>
+ <dt><a href="https://klavaro.sourceforge.io/en/index.html">Klavaro</a></dt>
+ <dd>A touch typing tutor. Copy the <a href="lulua_ar.kbd">custom
+ keyboard</a> to <code>~/.config/klavaro/</code> (Linux), select
+ Keyboard → (Custom), then lulua_ar.</dd>
</dl>
</div>
</div>
diff --git a/lulua/render.py b/lulua/render.py
index 08bc9bc..41a6bd5 100644
--- a/lulua/render.py
+++ b/lulua/render.py
@@ -551,6 +551,35 @@ def renderKeylayout (args):
fd.write (decl)
fd.write (ET.tostring (docroot, encoding='utf-8'))
+def renderKlavaro (args):
+ keyboard = defaultKeyboards[args.keyboard]
+ layout = defaultLayouts[args.layout].specialize (keyboard)
+
+ layers = [[], []]
+
+ for l, r in keyboard:
+ # exclude special buttons
+ buttons = list (filter (lambda x: isinstance (x, LetterButton), chain (l, r)))
+ if not buttons:
+ continue
+
+ for btn in buttons:
+ # cannot process multiple characters per button, thus find a
+ # composed version (NFC) if possible
+ buttonText = [unicodedata.normalize ('NFC', x) if x is not None else '' for x in layout.getButtonText (btn)]
+
+ # only two layers supported
+ for i in (0, 1):
+ # empty buttons must be spaces
+ layers[i].append (buttonText[i] or ' ')
+ for i in (0, 1):
+ layers[i].append ('\n')
+
+ with open (args.output, 'w') as fd:
+ for l in layers:
+ fd.write (''.join (l).strip ('\n'))
+ fd.write ('\n')
+
def yamlload (s):
try:
with open (s) as fd:
@@ -587,6 +616,8 @@ def render ():
sp.set_defaults (func=renderWinKbd)
sp = subparsers.add_parser('keylayout')
sp.set_defaults (func=renderKeylayout)
+ sp = subparsers.add_parser('klavaro')
+ sp.set_defaults (func=renderKlavaro)
parser.add_argument('output', metavar='FILE', help='Output file')
logging.basicConfig (level=logging.INFO)