From eaa950234798a1b221dab6248e7a7e123385e035 Mon Sep 17 00:00:00 2001 From: Alnotz Date: Wed, 19 Jun 2024 22:32:11 +0200 Subject: [PATCH] Ergo-L ISO keyboard schema --- Ergo-L/.gitignore | 1 + Ergo-L/Ergo-L.js | 59 ++++++++++++ Ergo-L/Ergo-L.sh | 239 ++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 299 insertions(+) create mode 100644 Ergo-L/.gitignore create mode 100644 Ergo-L/Ergo-L.js create mode 100644 Ergo-L/Ergo-L.sh diff --git a/Ergo-L/.gitignore b/Ergo-L/.gitignore new file mode 100644 index 0000000..d637977 --- /dev/null +++ b/Ergo-L/.gitignore @@ -0,0 +1 @@ +Ergo-L.svg diff --git a/Ergo-L/Ergo-L.js b/Ergo-L/Ergo-L.js new file mode 100644 index 0000000..c8e9746 --- /dev/null +++ b/Ergo-L/Ergo-L.js @@ -0,0 +1,59 @@ +'strict'; +const ROWS = 40 ; +const COLUMNS = 30; +const DELTA = 40; +let corps = document.querySelector('svg defs'); +const NS = 'http://www.w3.org/2000/svg'; + +//():Element, string, string, object, Array => void +const addElement = function(parent, ns, type, attributes, classes) { + const element = document.createElementNS(ns, type); + for (const ATTRIBUTE in attributes) { + element.setAttribute(ATTRIBUTE, attributes[ATTRIBUTE]); + } + parent.appendChild(element); +}; + +const lineAttrs = { + id: 'verBase', + stroke: 'gray', + 'stroke-size': 0.1, + x1: 0, + y1: 0, + x2: 0, + y2: DELTA*COLUMNS +}; +addElement(corps, NS, 'line', lineAttrs, []); + +lineAttrs.id = 'horBase'; +lineAttrs.x2 = DELTA*ROWS; +lineAttrs.y2 = 0; +addElement(corps, NS, 'line', lineAttrs, []); + +corps = document.querySelector('svg'); +const draw = function(size, angle) { + if (angle === 'vertical') { + for (let i=0; i<=size; i++) { + const useAttrs = { + x: i*DELTA, + y: 0, + href: '#verBase', + }; + addElement(corps, NS, 'use', useAttrs, ['ver']); + } + } else if (angle === 'horizontal') { + for (let i=0; i<=size; i++) { + const useAttrs = { + x: 0, + y: i*DELTA, + href: '#horBase', + }; + addElement(corps, NS, 'use', useAttrs, ['hor']); + } + } else { + throw new Error('vertical or horizontal angles only !'); + } +}; + +draw(ROWS, 'vertical'); +draw(COLUMNS, 'horizontal'); diff --git a/Ergo-L/Ergo-L.sh b/Ergo-L/Ergo-L.sh new file mode 100644 index 0000000..fa51788 --- /dev/null +++ b/Ergo-L/Ergo-L.sh @@ -0,0 +1,239 @@ +#!/usr/bin/bash +declare -r SVG='./Ergo-L.svg' +declare -ri DELTA=40 +declare -ri WIDTH=1920 +declare -ri HEIGHT=1080 + +# use-key ID X Y +function use-key() ( + echo ' ' >>$SVG +) + +# use-symbol X Y CHAR [CHAR…] +# ---- +# |2 4| +# | | +# |1 3| +# ---- +function use-symbol() ( + declare -r X0=$1 Y0=$2 + echo "0=> $#" + shift 2 + echo "1=> $#" + while [ $# -gt 0 ] + do + echo ' '"$1"'' >>$SVG + shift 1 + echo "2=> $#" + done +) + +echo ' + + Disposition de clavier ISO Ergo-L + Un schéma qui décrit la disposition Ergo-L dans un clavier. +Le clavier est de forme ISO. +Les caractères de contrôle suivent la norme ISO/IEC 9995-7. +Voir https://ergol.org/ . + + + + + + + + + + + + + + + ' >$SVG + use-key '#fn-btn' 0 0 + use-symbol $((x+DELTA)) $((3*DELTA)) '⎋' + +# draw-any-key KEY_TYPE SYMBOL X0 Y0 +function draw-any-key() ( + declare -r KTYPE=$1 SYMBOL=$2 + declare -ri X0=$3 Y0=$4 + use-key "$KTYPE" $((X0*DELTA)) $((Y0*DELTA)) + use-symbol $(( (X0+1)*DELTA )) $(( (Y0+4)*DELTA )) "$SYMBOL" +) + +declare -i bloc=0 nbr=0 x=$((6*DELTA)) xres=0 fnn=0 +while [ $bloc -lt 3 ] +do + while [ $nbr -lt 4 ] + do + fnn=$((fnn+1)) + use-key '#fn-btn' "$x" 0 + use-symbol $((x+DELTA))'.'$((xres+DELTA)) $((3*DELTA)) "Fn${fnn}" + nbr=$((nbr+1)) + x=$((x+3*DELTA)) + done + nbr=0 + bloc=$((bloc+1)) + x=$((x+30*DELTA/2/10)) + xres=$((xres+30*DELTA/2%10)) +done +unset bloc + +# draw-basic-keys INITIAL_X INITIAL_Y KEY_SYMBOL [KEY_SYMBOL…] +function draw-basic-keys() ( + declare -i x=0 + declare -ri X0=$1 Y0=$2 + shift 2 + while [ "$#" -gt 0 ] + do + fnn=$((fnn+1)) + use-key '#btn' $((x+X0*DELTA)) $((Y0*DELTA)) + use-symbol $((x+(X0+1)*DELTA)) $(( (4+Y0)*DELTA )) "$1" + shift 1 + x=$((x+3*DELTA)) + done +) + +declare -ra ROW1_1=("q" "" "" "" ""\ + "" "" "" "" ""\ + "" "" "") +declare -ra ROW1_2=("q" "" "" "" ""\ + "" "" "" "" ""\ + "" "" "") +declare -ra ROW1_3=("q" "" "" "" ""\ + "" "" "" "" ""\ + "" "" "") +declare -ra ROW1_4=("q" "" "" "" ""\ + "" "" "" "" ""\ + "" "" "") +declare -ra ROW2_1=("" "" "" "" ""\ + "" "" "" "" ""\ + "" "") +declare -ra ROW2_2=("" "" "" "" ""\ + "" "" "" "" ""\ + "" "") +declare -ra ROW2_3=("" "" "" "" ""\ + "" "" "" "" ""\ + "" "") +declare -ra ROW2_4=("" "" "" "" ""\ + "" "" "" "" ""\ + "" "") +declare -ra ROW3_1=("" "" "" "" ""\ + "" "" "" "" ""\ + "" "") +declare -ra ROW3_2=("" "" "" "" ""\ + "" "" "" "" ""\ + "" "") +declare -ra ROW3_3=("" "" "" "" ""\ + "" "" "" "" ""\ + "" "") +declare -ra ROW3_4=("" "" "" "" ""\ + "" "" "" "" ""\ + "" "") +declare -ra ROW4_1=("" "" "" "" ""\ + "" "" "" "" ""\ + "") +declare -ra ROW4_2=("" "" "" "" ""\ + "" "" "" "" ""\ + "") +declare -ra ROW4_3=("" "" "" "" ""\ + "" "" "" "" ""\ + "") +declare -ra ROW4_4=("" "" "" "" ""\ + "" "" "" "" ""\ + "") + + +draw-basic-keys 0 3 ${ROW1[@]} +draw-basic-keys 5 6 ${ROW2[@]} +draw-basic-keys 6 9 ${ROW3[@]} +draw-basic-keys 4 12 ${ROW4[@]} + +draw-any-key '#big-btn' "↹" 0 6 +draw-any-key '#huge-btn' "⇬" 0 9 +draw-any-key '#medium-btn' "⇧" 0 12 +draw-any-key '#big-btn' "⎈" 0 15 +draw-any-key '#medium-btn' "⌘" 5 15 +draw-any-key '#medium-btn' "⎇" 9 15 +draw-any-key '#space-btn' "␣" 13 15 +draw-any-key '#medium-btn' "⇮" 28 15 +draw-any-key '#medium-btn' "⌘" 32 15 +draw-any-key '#medium-btn' "▤" 36 15 +draw-any-key '#big-btn' "⎈" 40 15 +draw-any-key '#rshift-btn' "⇧" 37 12 + +use-key '#enter-btn' $((42*DELTA)) $((7*DELTA)) +use-symbol $((42*DELTA)) $((10*DELTA)) '⮠' +use-symbol $((43*DELTA)) $((13*DELTA)) '⎆' + +draw-any-key '#huge-btn' "⌫" 39 3 + +echo '' >>$SVG +cat $SVG