diff options
| author | Marshall Lochbaum <mwlochbaum@gmail.com> | 2022-05-25 18:09:56 -0400 |
|---|---|---|
| committer | Marshall Lochbaum <mwlochbaum@gmail.com> | 2022-05-25 18:10:17 -0400 |
| commit | fbfc6a871589e123a9ca1ad4c5d22b4421801a10 (patch) | |
| tree | 3fbe8f7b27e3e4da8f3341ce00c3f4e5d5bdf204 | |
| parent | 59597672ee48f89703f7a0097c871cc50795d135 (diff) | |
Add key remapping script with dvorak support (closes #68)
| -rw-r--r-- | docs/editors/index.html | 5 | ||||
| -rw-r--r-- | editors/README.md | 8 | ||||
| -rwxr-xr-x | editors/remap.bqn | 52 |
3 files changed, 63 insertions, 2 deletions
diff --git a/docs/editors/index.html b/docs/editors/index.html index 8aa9bb6e..0268e6ac 100644 --- a/docs/editors/index.html +++ b/docs/editors/index.html @@ -6,7 +6,7 @@ <div class="nav">(<a href="https://github.com/mlochbaum/BQN">github</a>) / <a href="../index.html">BQN</a></div> <h1 id="editor-support"><a class="header" href="#editor-support">Editor support</a></h1> <style>.Comment,.Function,.Number,.String { color: inherit; }</style> -<p>Editor plugins and other tools for allowing BQN input are in <a href="https://github.com/mlochbaum/BQN/tree/master/editors">this folder</a>. Input always uses the layout shown <a href="https://mlochbaum.github.io/BQN/keymap.html">here</a>, and is usually performed with a backslash <code><span class='Value'>\</span></code> prefix, but sometimes with a modifier key such as alt. To type an actual backslash, hit the backslash key twice.</p> +<p>Editor plugins and other tools for allowing BQN input are in <a href="https://github.com/mlochbaum/BQN/tree/master/editors">this folder</a>. Input always uses the layout shown <a href="https://mlochbaum.github.io/BQN/keymap.html">here</a> (<a href="#alternate-layouts">want another?</a>), and is usually performed with a backslash <code><span class='Value'>\</span></code> prefix, but sometimes with a modifier key such as alt. To type an actual backslash, hit the backslash key twice.</p> <p><a href="https://abrudz.github.io/lb/bqn">This bookmarklet</a> enables BQN input in any webpage in your <strong>browser</strong>.</p> <p><a href="https://gist.github.com/dzaima/35ca0ce12b5e215a62460f00e693984f">This userscript</a> highlights BQN code on <strong>GitHub</strong>.</p> <p>For <strong>Android</strong>, <a href="https://github.com/dzaima/hackerskeyboard/releases/latest">this fork</a> adds APL and BQN to Hacker's Keyboard.</p> @@ -55,3 +55,6 @@ <p>See <a href="https://github.com/razetime/bqn-vscode">this repository</a>, or install directly through <a href="https://marketplace.visualstudio.com/items?itemName=razetime.bqn-language&ssr=false#overview">Visual Studio Marketplace</a> or <a href="https://open-vsx.org/extension/razetime/bqn-language">Open VSX Registry</a>.</p> <h3 id="kakoune"><a class="header" href="#kakoune">Kakoune</a></h3> <p>Copy or symlink <code><span class='Value'>kak</span><span class='Function'>/</span><span class='Value'>autoload</span><span class='Function'>/</span><span class='Value'>filetype</span><span class='Function'>/</span><span class='Value'>bqn.kak</span></code> into <code><span class='Value'>autoload</span><span class='Function'>/</span><span class='Value'>filetype</span></code> in your Kakoune config directory (probably <code><span class='Value'>.config</span><span class='Function'>/</span><span class='Value'>kak</span><span class='Function'>/</span></code>).</p> +<h2 id="alternate-layouts"><a class="header" href="#alternate-layouts">Alternate layouts</a></h2> +<p>All files here use the BQN layout designed for qwerty, which will generally be jumbled in another layout (for example the key for <code><span class='Value'>r</span></code> will still type <code><span class='Function'>↑</span></code>, but it may not be above <code><span class='Value'>c</span></code>, which types <code><span class='Function'>↓</span></code>). The <a href="https://github.com/mlochbaum/BQN/blob/master/editors/remap.bqn">remap.bqn</a> script allows you to remap some files in this repository to a new layout. See <code><span class='Value'>$</span> <span class='Value'>remap.bqn</span> <span class='Function'>-</span><span class='Value'>h</span></code> for usage. Support for a new layout can be added in the <code><span class='Value'>keys</span></code> array of the script, but do watch for string alignment with the doubled quote character.</p> +<p>(If you haven't installed CBQN but have Node.js, <code><span class='Value'>$</span> <span class='Value'>bqn.js</span> <span class='Value'>editors</span><span class='Function'>/</span><span class='Value'>remap.bqn…</span></code> from the repository root will work too)</p> diff --git a/editors/README.md b/editors/README.md index 50a52e2b..2be61443 100644 --- a/editors/README.md +++ b/editors/README.md @@ -6,7 +6,7 @@ "style" Enc ".Comment,.Function,.Number,.String { color: inherit; }" --> -Editor plugins and other tools for allowing BQN input are in [this folder](https://github.com/mlochbaum/BQN/tree/master/editors). Input always uses the layout shown [here](https://mlochbaum.github.io/BQN/keymap.html), and is usually performed with a backslash `\` prefix, but sometimes with a modifier key such as alt. To type an actual backslash, hit the backslash key twice. +Editor plugins and other tools for allowing BQN input are in [this folder](https://github.com/mlochbaum/BQN/tree/master/editors). Input always uses the layout shown [here](https://mlochbaum.github.io/BQN/keymap.html) ([want another?](#alternate-layouts)), and is usually performed with a backslash `\` prefix, but sometimes with a modifier key such as alt. To type an actual backslash, hit the backslash key twice. [This bookmarklet](https://abrudz.github.io/lb/bqn) enables BQN input in any webpage in your **browser**. @@ -83,3 +83,9 @@ See [this repository](https://github.com/razetime/bqn-vscode), or install direct ### Kakoune Copy or symlink `kak/autoload/filetype/bqn.kak` into `autoload/filetype` in your Kakoune config directory (probably `.config/kak/`). + +## Alternate layouts + +All files here use the BQN layout designed for qwerty, which will generally be jumbled in another layout (for example the key for `r` will still type `↑`, but it may not be above `c`, which types `↓`). The [remap.bqn](remap.bqn) script allows you to remap some files in this repository to a new layout. See `$ remap.bqn -h` for usage. Support for a new layout can be added in the `keys` array of the script, but do watch for string alignment with the doubled quote character. + +(If you haven't installed CBQN but have Node.js, `$ bqn.js editors/remap.bqn…` from the repository root will work too) diff --git a/editors/remap.bqn b/editors/remap.bqn new file mode 100755 index 00000000..8927d5e3 --- /dev/null +++ b/editors/remap.bqn @@ -0,0 +1,52 @@ +#! /usr/bin/env bqn + +help ← 1↓" +Remap a BQN keyboard file from qwerty. Options: + -h, --help: Print this message and exit + -k: Output keyboard layout + -i: Input file(s) in editors/ + -o: Output file(s); uses stdout if not given" + +o ← "-h"‿"--help"‿"-k"‿"-i"‿"-o" +oo ← (≠o) = oi ← o ⊐ ar←•args +•Exit∘•Out∘help⍟(∨´2⊸>) oi +key‿inp‿out ← 2↓o≠⊸↑ ar ⊔˜ (¬-˜⊢× oi⊏˜ ↕∘≠⌈`∘׬)oo + +A ← {𝕩?@; •Out 𝕨 ⋄ •Exit 1} +"Can only specify one keyboard layout at a time!" A 1≥≠key +"No inputs!" A 0<≠inp +"Requires one output file for each input, or one input and no output to use stdout" A inp=⟜(⊢+0⊸=)○≠out + +Map ← {𝕩⊏˜𝕨⊐⊢} +_sl_ ← {𝔽_𝕣_⟨a,b⟩: 𝔽∘((a↓b↓⊢)¨)⊸((a⊸↑∾⊣∾b⊸↑)¨)} + +# Key layouts +qwerty ← "`1234567890-=~!@#$%^&*()_+qwertyuiop[]QWERTYUIOP{}asdfghjkl;'ASDFGHJKL:""|zxcvbnm,./ZXCVBNM<>? " +keys ← ⟨ + "dvorak"‿"`1234567890[]~!@#$%^&*(){}',.pyfgcrl/=""<>PYFGCRL?+aoeuidhtns-AOEUIDHTNS_|;qjkxbmwvz:QJKXBMWVZ " +⟩ + +# 2-modifier: source keymap as 𝕗 and target as 𝕘, file contents 𝕩 +files ← ⟨ + "inputrc"‿{ + m ← 𝕗 Map○('"'⊸=◶⟨⥊,"\"⊸∾⟩¨) 𝕘 + { + c‿d ← ¯6‿¯2 + ((=´c‿d⊸⊏)¨𝕩) (c⌾(d⊸⊑)↕∘≠)⊸⊏∘⊢⍟⊣¨ M _sl_ 3‿¯5 𝕩 + }⌾(9⊸↓) + } + "XCompose"‿{ + xc ← Map´ c‿l ← (⊑¨⋈1↓¨⊢) (¯1+`<⟜'a'∨'z'⊸<)⊸⊔ "`grave-minus=equal~asciitilde!exclam@at#numbersign$dollar%percent^circumflex&ersand*asterisk(parenleft)parenright_underscore+plus[bracketleft]bracketright{braceleft}braceright:colon;semicolon""quotedbl,comma.period/slash<less>greater?question space'apostrophe" + (𝕗 Map○{⥊¨XC⌾((𝕩∊c)⊸/)𝕩} 𝕘) _sl_ 25‿¯7⌾(4⊸↓) + } +⟩ + +_lookup_ ← { + opt‿res ← <˘⍉>𝕗 + err ← ∾"Invalid "‿𝕘‿"; options:"∾" "⊸∾¨opt + res ⊏˜ ·(err A ·∧´(≠opt)⊸>)⊸⊢ opt⊸⊐ +} +k ← ⊑ keys _lookup_ "key layout (-k)" 1↑key∾⟨"dvorak"⟩ +conv ← files _lookup_ "keymap file (-i)" inp +write ← ∾⟜⟨•Out¨⟩⍟(0=≠) {(•wdpath•file.At𝕩)⊸•file.Lines}¨out +{𝕊w‿c‿i: W qwerty _c_ k •file.Lines i}˘ ⍉>write‿conv‿inp |
