| 1 |
About APL |
| 2 |
========= |
| 3 |
|
| 4 |
In addition to ASCII characters found on most keyboards, |
| 5 |
APL needs additional "APL characters". This README file |
| 6 |
explains how GNU APL works and how to enable APL characters |
| 7 |
on a number of platforms. |
| 8 |
|
| 9 |
1. How GNU APL works |
| 10 |
==================== |
| 11 |
|
| 12 |
The GNU APL binary is a standard process that receives its input (normally, |
| 13 |
but not necessarily from what you type on your keyboard). It reads a file |
| 14 |
descriptor called standard input (stdin) and prints its output on two other |
| 15 |
file descriptors called standard output (stdout) for normal APL output, and |
| 16 |
standard error (stderr) for additional diagnostic output. |
| 17 |
|
| 18 |
This means that the GNU APL binary has no concept of what a keyboard is, |
| 19 |
nor, on output is it concerned with fonts and the like. All the binary sees |
| 20 |
is a byte stream on input and all it produces is a byte stream on its |
| 21 |
output channels stdout and stderr. |
| 22 |
|
| 23 |
GNU APL expects that the byte sequences on stdin, stdout, and stderr are |
| 24 |
"UTF8-encoded". UTF8-encoding is an extension of ASCII encoding that is used |
| 25 |
in many places, including most Web pages. It is defined in the international |
| 26 |
standard STD 63 (aka. "RFC 3629 - UTF-8, a transformation format of ISO 10646") |
| 27 |
and is supported on most operating systems. |
| 28 |
|
| 29 |
A second standard - Unicode - describes how characters will appear on the |
| 30 |
terminal. This standard includes all the APL characters used by GNU APL. |
| 31 |
Normally Unicode characters are UTF8 encoded when transmitted over serial |
| 32 |
lines, file descriptors, in IP packets, or when displayed on web pages. |
| 33 |
|
| 34 |
There are many advantages to using UTF8-encoded Unicodes for APL: |
| 35 |
|
| 36 |
- You can copy/paste APL programs and expressions from web pages, |
| 37 |
- You can print them on modern printers, |
| 38 |
- You can telnet or ssh to remote computers that run APL, |
| 39 |
- You can redirect UTF8 encoded files into the APL interpreter, This redirection |
| 40 |
gives you access to scripts written in APL. |
| 41 |
- You can exchange such files with APL users using APL interpreters from other |
| 42 |
vendors, or copy APL code snippets into documents. |
| 43 |
|
| 44 |
The downside of UTF8-encoded Unicodes is that GNU APL cannot (and will not) |
| 45 |
take care of how your keyboard, screen, and printers work. You have to set that |
| 46 |
up yourself and outside GNU APL. |
| 47 |
|
| 48 |
There is no single standard way of setting things up for GNU APL. The rest of |
| 49 |
this README file describes a number of different methods to enable APL |
| 50 |
characters on your machine. The information that follows has made GNU APL work |
| 51 |
on most (but not all) machines and operating systems around. As different |
| 52 |
approaches were used these methods may conflict with each other. Use only one |
| 53 |
of them at a time. |
| 54 |
|
| 55 |
GNU APL includes a directory called "support-files". This directory |
| 56 |
contains various configuration files needed by the methods described below. |
| 57 |
|
| 58 |
Most of the problems in getting UTF8-encoded Unicodes working with the APL |
| 59 |
interpretor is with the input side (from the keyboard to GNU APL). The output |
| 60 |
side from APL is most often already working (thanks to Unicode). |
| 61 |
|
| 62 |
|
| 63 |
2. Structure of the support-files directory |
| 64 |
=========================================== |
| 65 |
|
| 66 |
At one time, there was only one keyboard layout assumed for GNU APL. At that |
| 67 |
time all support files for this keyboard layout (now called "old") were |
| 68 |
located in the included support-files directory. |
| 69 |
|
| 70 |
Then a number of different keyboard layouts were contributed by GNU APL users. |
| 71 |
|
| 72 |
As of GNU APL 1.4 there is now one directory for every keyboard interface |
| 73 |
option, currently: |
| 74 |
|
| 75 |
support-files/Dirk, |
| 76 |
support-files/Dyalog-Keyboard, |
| 77 |
support-files/Jürgen-Mint-19, |
| 78 |
support-files/Jürgen-Mint-21, |
| 79 |
support-files/old-Keyboard, |
| 80 |
support-files/OS-X-Keyboard, |
| 81 |
support-files/Unicomp-Keyboard, and |
| 82 |
support-files/WASD-Keyboard |
| 83 |
|
| 84 |
The file names mentioned in the following are generic (independent of a |
| 85 |
particular keyboard layout) whereas the support files provided, live in |
| 86 |
one or more of the keyboard layout directories. For example: |
| 87 |
|
| 88 |
support-files/old-Keyboard/apl.xmodmap and |
| 89 |
support-files/Dyalog-Keyboard/apl.xmodmap |
| 90 |
|
| 91 |
are the different instances of apl.xmodmap files for different keyboard |
| 92 |
layouts. |
| 93 |
|
| 94 |
If no support file exists for your actual combination of keyboard layout |
| 95 |
and method, then usually the support file of some other layout works or |
| 96 |
can be easily made to work. If you adapt support files, feel free |
| 97 |
to mail the changed file to [email protected] so that we can include it. |
| 98 |
|
| 99 |
Note: Not all support files are fully tested but they should work. The layouts |
| 100 |
change from time to time and given the number of methods and the number |
| 101 |
of layouts there is no easy way to track these changes for all methods and |
| 102 |
layouts. |
| 103 |
|
| 104 |
The standard layout assumed for GNU APL is that of the APL keyboards shipped |
| 105 |
by Dyalog. The standard method assumed for GNU APL is xmodmap. |
| 106 |
|
| 107 |
|
| 108 |
3. xmodmap |
| 109 |
========== |
| 110 |
|
| 111 |
If your operating system runs X (which is the case for most "Desktop" |
| 112 |
variants of GNU/Linux) then it is quite simple to make your keyboard produce |
| 113 |
APL characters. |
| 114 |
|
| 115 |
The program xmodmap comes with X, and is already installed on your machine. |
| 116 |
It defines a mapping between the keys you type and the character |
| 117 |
that is being produced (taking into account modifiers like Shift or Alt). |
| 118 |
|
| 119 |
There are two common physical hardware keyboards in common use. One is titled |
| 120 |
pc104 and the other, pc105. The pc104 is the standard USA keyboard. |
| 121 |
The pc105 has two additional keys and may contain more characters than are |
| 122 |
found on the pc104 keyboard.The pc105 has a font selection key. |
| 123 |
The APL character placement for the respective keyboards is shown below. |
| 124 |
|
| 125 |
There are four character cases with your X system. Lower case, Upper case, |
| 126 |
alt (ALT) case and shift-alt (shift-ALT) case. Usually the alt key is the |
| 127 |
one to the right of the space bar. However, depending on the keyboard |
| 128 |
xmod interface, the alt key may be the one to the left of the space bar. |
| 129 |
|
| 130 |
The file "support-files/Dyalog-Keyboard/apl.xmodmap" (that comes with GNU APL) |
| 131 |
provides such a mapping; the normal keys produce ASCII characters while the |
| 132 |
ALT (and Shift-ALT) cases contains all APL characters used by GNU APL. The |
| 133 |
mapping is enabled with the following command (we use "$ " to indicate the |
| 134 |
prompt of your shell): |
| 135 |
|
| 136 |
$ xmodmap support-files/Dyalog-Keyboard/apl.xmodmap |
| 137 |
|
| 138 |
After that execution, your keyboard will produce APL characters when |
| 139 |
the "Alt" key is held down. The keyboard layout defined in file |
| 140 |
"apl.xmodmap" is similar to the following for pc104 and pc105 layouts: |
| 141 |
|
| 142 |
PC104 USA Domestic APL Keyboard Layout |
| 143 |
===================================== |
| 144 |
╔════╦════╦════╦════╦════╦════╦════╦════╦════╦════╦════╦════╦════╦═════════╗ |
| 145 |
║ ~ ║ !⌶ ║ @⍫ ║ #⍒ ║ $⍋ ║ %⌽ ║ ^⍉ ║ &⊖ ║ *⍟ ║ (⍱ ║ )⍲ ║ _! ║ +⌹ ║ ║ |
| 146 |
║ `◊ ║ 1¨ ║ 2¯ ║ 3< ║ 4≤ ║ 5= ║ 6≥ ║ 7> ║ 8≠ ║ 9∨ ║ 0∧ ║ -× ║ =÷ ║ BACKSP ║ |
| 147 |
╠════╩══╦═╩══╦═╩══╦═╩══╦═╩══╦═╩══╦═╩══╦═╩══╦═╩══╦═╩══╦═╩══╦═╩══╦═╩══╦══════╣ |
| 148 |
║ ║ Q ║ W⍹ ║ E⋸ ║ R ║ T⍨ ║ Y¥ ║ U ║ I⍸ ║ O⍥ ║ P⍣ ║ {⍞ ║ }⍬ ║ |⊣ ║ |
| 149 |
║ TAB ║ q? ║ w⍵ ║ e∈ ║ r⍴ ║ t∼ ║ y↑ ║ u↓ ║ i⍳ ║ o○ ║ p⋆ ║ [← ║ ]→ ║ \⊢ ║ |
| 150 |
╠═══════╩═╦══╩═╦══╩═╦══╩═╦══╩═╦══╩═╦══╩═╦══╩═╦══╩═╦══╩═╦══╩═╦══╩═╦══╩══════╣ |
| 151 |
║ (CAPS ║ A⍶ ║ S« ║ D» ║ F ║ G ║ H ║ J⍤ ║ K ║ L⌷ ║ :≡ ║ "≢ ║ ║ |
| 152 |
║ LOCK) ║ a⍺ ║ s⌈ ║ d⌊ ║ f_ ║ g∇ ║ h∆ ║ j∘ ║ kλ ║ l⎕ ║ ;⍎ ║ '⍕ ║ RETURN ║ |
| 153 |
╠═════════╩═══╦╩═══╦╩═══╦╩═══╦╩═══╦╩═══╦╩═══╦╩═══╦╩═══╦╩═══╦╩═══╦╩═════════╣ |
| 154 |
║ ║ Z ║ Xχ ║ C¢ ║ V ║ B£ ║ N ║ M ║ <⍪ ║ >⍙ ║ ? ║ ║ |
| 155 |
║ SHIFT ║ z⊂ ║ x⊃ ║ c∩ ║ v∪ ║ b⊥ ║ n⊤ ║ m| ║ ,⍝ ║ .⍀ ║ /⌿ ║ SHIFT ║ |
| 156 |
╚═════════════╩════╩════╩════╩════╩════╩════╩════╩════╩════╩════╩══════════╝ |
| 157 |
|
| 158 |
PC105 USA and International Keyboards |
| 159 |
===================================== |
| 160 |
╔════╦════╦════╦════╦════╦════╦════╦════╦════╦════╦════╦════╦════╦════════════╗ |
| 161 |
║ ~ ║ !⌶ ║ @⍫ ║ #⍒ ║ $⍋ ║ %⌽ ║ ^⍉ ║ &⊖ ║ *⍟ ║ (⍱ ║ )⍲ ║ _! ║ +⌹ ║ ║ |
| 162 |
║ `◊ ║ 1¨ ║ 2¯ ║ 3< ║ 4≤ ║ 5= ║ 6≥ ║ 7> ║ 8≠ ║ 9∨ ║ 0∧ ║ -× ║ =÷ ║ BACKSP ║ |
| 163 |
╠════╩══╦═╩══╦═╩══╦═╩══╦═╩══╦═╩══╦═╩══╦═╩══╦═╩══╦═╩══╦═╩══╦═╩══╦═╩══╦═════════╣ |
| 164 |
║ ║ Q ║ W⍹ ║ E⍷ ║ R ║ T⍨ ║ Y¥ ║ U€ ║ I⍸ ║ O⍥ ║ P⍣ ║ {⍞ ║ }⍬ ║ ║ |
| 165 |
║ TAB ║ q? ║ w⍵ ║ e∈ ║ r⍴ ║ t∼ ║ y↑ ║ u↓ ║ i⍳ ║ o○ ║ p⋆ ║ [← ║ ]→ ║ RETURN ║ |
| 166 |
╠═══════╩═╦══╩═╦══╩═╦══╩═╦══╩═╦══╩═╦══╩═╦══╩═╦══╩═╦══╩═╦══╩═╦══╩═╦══╩═╗ ║ |
| 167 |
║ (CAPS ║ A⍶ ║ S« ║ D» ║ F ║ G ║ H ║ J⍤ ║ K ║ L⌷ ║ :≡ ║ "≢ ║ |⊣ ║ ║ |
| 168 |
║ LOCK) ║ a⍺ ║ s⌈ ║ d⌊ ║ f_ ║ g∇ ║ h∆ ║ j∘ ║ kλ ║ l⎕ ║ ;⍎ ║ '⍕ ║ \⊢ ║ ║ |
| 169 |
╠════════╦╩═══╦╩═══╦╩═══╦╩═══╦╩═══╦╩═══╦╩═══╦╩═══╦╩═══╦╩═══╦╩═══╦╩════╩═══════╣ |
| 170 |
║ ║ < ¦║ Z ║ Xχ ║ C¢ ║ V ║ B£ ║ N ║ M ║ <⍪ ║ >⍙ ║ ? ║ ║ |
| 171 |
║ SHIFT ║ > °║ z⊂ ║ x⊃ ║ c∩ ║ v∪ ║ b⊥ ║ n⊤ ║ m| ║ ,⍝ ║ .⍀ ║ /⌿ ║ SHIFT ║ |
| 172 |
╚════════╩════╩════╩════╩════╩════╩════╩════╩════╩════╩════╩════╩═════════════╝ |
| 173 |
|
| 174 |
Three files within "support-files/Dyalog-Keyboard/", keyboard.txt, |
| 175 |
keyboard1.txt and "support-files/105-key-International-Keyboard/keyboard1.txt" |
| 176 |
contain the above images. If you want to print it (keyboard1 is < 80 |
| 177 |
characters wide). |
| 178 |
|
| 179 |
If you don't like this particular layout, then you can modify "apl.xmodmap" |
| 180 |
to fit your preferences. |
| 181 |
|
| 182 |
If you are Finnish then you may want to have a look here: |
| 183 |
|
| 184 |
http://www.oksman.eu/apl/gnu_apl_installation_with_finnish_keyboard_layout.txt |
| 185 |
|
| 186 |
LATEST NEWS: as of Mint-19 xmodmap is no longer working (at least with the |
| 187 |
GNOME desktop). For those who used xmodmap with a Dyalog keyboard layout, |
| 188 |
a 1:1 replacement based on setxkbmap exists, see file README in directory |
| 189 |
support-files/Jürgen-Mint-19. This file is a hack that is somewhat easier |
| 190 |
to use than "proper" setxkbmap/xkbcomp setup explained in the next section. |
| 191 |
|
| 192 |
EVEN LATER NEWS: as of Mint-21 xmodmap is working again (at least with the |
| 193 |
GNOME desktop). See file support-files/Jürgen-Mint-21. |
| 194 |
|
| 195 |
4. setxkbmap/xkbcomp |
| 196 |
==================== |
| 197 |
|
| 198 |
Another program that can be used to make your keyboard produce APL |
| 199 |
characters is setxkbmap. Like xmodmap it requires that you are running X, |
| 200 |
and setxkbmap should not be mixed with xmodmap. |
| 201 |
|
| 202 |
setxkbmap is more modern and more powerful than xmodmap, but we had some |
| 203 |
problems with older GNU/Linux versions (a setxkbmap config file produced |
| 204 |
on a newer GNU/Linux did fix these problems). |
| 205 |
|
| 206 |
The file support-files/old-Keyboard/apl.xkm provides such a mapping (the |
| 207 |
file was kindly provided by David De La Harpe and produced with the command |
| 208 |
xkbcomp on his machine). |
| 209 |
|
| 210 |
The mapping is installed as follows: |
| 211 |
|
| 212 |
$ xkbcomp support-files/old-Keyboard/apl.xkm :0 |
| 213 |
|
| 214 |
Unlike the xmodmap approach, the APL characters are now produced with |
| 215 |
the AltGr modifier key but not with the Alt modifier key. This was to |
| 216 |
better support emacs which uses the Alt keys for other purposes. |
| 217 |
|
| 218 |
On those systems one of the following commands may do (the syntax and file |
| 219 |
names of setxkbmap appear to have changed over time): |
| 220 |
|
| 221 |
$ setxkbmap -layout "apl(sax)" |
| 222 |
$ setxkbmap -layout "apl" -variant ",sax" |
| 223 |
$ setxkbmap -layout "apl" -variant "sax" |
| 224 |
|
| 225 |
The file support-files/apl.xkb is the text file from which apl.xkm was |
| 226 |
generated. If you modify apl.xkb according to your preferences then you |
| 227 |
can generate your own apl.xkm file (see man pages for setxkbmap and xkbcomp). |
| 228 |
|
| 229 |
See also Blake's notes in support-files/Unicomp-Keyboard/apl.xkb.txt |
| 230 |
|
| 231 |
Another description (also using setxkbmap) and files supporting it was kindly |
| 232 |
provided by Dirk Laurie and is contained in directory support-files/Dirk. |
| 233 |
|
| 234 |
WARNING: the description above is merely the "Theory of Operation" for |
| 235 |
setxkbmap and friends (according to their man pages). Over the years, window |
| 236 |
managers have become increasingly intrusive (some call it "convenient") |
| 237 |
into the keyboard setup. There exist a number of descriptions below the |
| 238 |
directory support-files/ that may look contradictory and/or may not work on |
| 239 |
a given platform. These descriptions were, to the best of our knowledge, |
| 240 |
valid and working at the time when they were contributed, but may have stopped |
| 241 |
working on some platforms in the meantime. Therefore please consider them as |
| 242 |
mere ideas how keyboard layouts could be adapted to APL rather than fool-proof |
| 243 |
recipies. |
| 244 |
|
| 245 |
5. loadkeys |
| 246 |
=========== |
| 247 |
|
| 248 |
If you are not running X then the above methods will complain about |
| 249 |
"unable to open display". In that case you can use command "loadkeys" to |
| 250 |
set up the keyboard layout, and command "unicode_start" to set up an APL |
| 251 |
font. |
| 252 |
|
| 253 |
$ sudo loadkeys support-files/old-Keyboard/apl.loadkeys |
| 254 |
$ unicode_start Unifont-APL8x16.psf |
| 255 |
|
| 256 |
The console font Unifont-APL8x16.psf will be contained in the next official |
| 257 |
release of GNU Unifont (maintained by Paul Hardy). In the meantime it can |
| 258 |
be downloaded from: |
| 259 |
|
| 260 |
http://unifoundry.com |
| 261 |
|
| 262 |
|
| 263 |
6. The GNU APL ASCII keyboard driver |
| 264 |
==================================== |
| 265 |
|
| 266 |
On some platforms (read: Microdoft Windows) it has become more and more |
| 267 |
difficult to produce APL characters with the keyboard. In early windows |
| 268 |
versions versions one could modify the windows registry to support APL, but |
| 269 |
in recent versions this no longer works. |
| 270 |
|
| 271 |
Micorsoft offers a royalty-free product called PowerTools for download which |
| 272 |
contans a component called Keyboard Manager. This Keyboard Manager allows |
| 273 |
you, at least in principle, to map arbitrary input key-sequences to arbitrary |
| 274 |
output characters or even string. So you could, in theory, map the key |
| 275 |
combination ALT + R to the APL character ⍴. However: |
| 276 |
|
| 277 |
1. There is no configuration file by means of which you could enter an entire |
| 278 |
keyboard mapping (or to transfer a mapping from one machine to another). |
| 279 |
Instead you have to interactively enter the mapping key by key. Entering |
| 280 |
the mapping n the Keyboard Manager is somewhat tedious, but once you get |
| 281 |
used to it you may be able to enter an entire mapping in less than one hour. |
| 282 |
|
| 283 |
2. Unfortunately after having spent an hour with entering a keyboard mapping |
| 284 |
you will notice that not all windows programs will consider that mapping. |
| 285 |
For example, the gvim editor will produced APL characters (as long as the |
| 286 |
Keyboard Maanager is active) while the cmd.exe program (under which GNU |
| 287 |
APL normally runs) does not. Bad luck. |
| 288 |
|
| 289 |
Since Windows 10 or so Microsoft also offers a thing called IME (Input Method |
| 290 |
Editor). The IME can, for example, be used to enter Chineses characters. |
| 291 |
Unfortunately the IME is, like Windows itself, non-free softeare and, as a |
| 292 |
consequence, does not allow you to specify your own keyboard mapping. |
| 293 |
Fortunately the APL vendor Dyalog offers an IME with a keyboard layout |
| 294 |
that matches its own (US-) APL keyboard (als also the keyboard layout |
| 295 |
assumed by GNU APL). Unfortunately, however, the author was not able to |
| 296 |
make the Dyalog IME work togeteher with GNU APL on Windows 10 or 11. The |
| 297 |
reason for this is unknown (possibly the same as for the Keyboard Manager). |
| 298 |
|
| 299 |
To avoid all these problems under Windows, GNU APL comes with a built-in |
| 300 |
keyboardd driver that does not map keys to APL characters but ASCII |
| 301 |
characters to APL characters. As some of the readers may remember, APL |
| 302 |
terminals in the 1970 had SHIFT resp. SHIFT-LOCK keys to temporarily resp. |
| 303 |
permanently map lowercase ASCII characters to uppercase ASCII characters. |
| 304 |
On these terminals you coud send ASCI control characters SI (aka. ^O) and |
| 305 |
SO (aka. ^N) to toggle between an ASCII mode and an APL mode of the keyboard. |
| 306 |
|
| 307 |
GNU APL has adopted this old method in its built-in ASCII Keyboard driver. |
| 308 |
Tho enable this driver GNU APL has to be ./configured like so: |
| 309 |
|
| 310 |
./configure ALT_MAP_WANTED=1 <other configure options...> |
| 311 |
|
| 312 |
If GNU APL was configure like that, then: |
| 313 |
|
| 314 |
^A (ASCII SOH) maps the next character entered from ASCII to APL, and |
| 315 |
^N (ASCII SI) toggles between mapping and not mapping subsequent ASCII |
| 316 |
characters to APL. That is, ^N pretty much works like |
| 317 |
the SHIFT LOCK key for mapping lowercase to uppercase |
| 318 |
ASCII characters. |
| 319 |
|
| 320 |
The parameter 1 of the ALT_MAP_WANTED option is a profile number which defines |
| 321 |
the two ASCII characters(^A and ^N) that switch between ASCII and APL as well |
| 322 |
as the details of the mapping (which ASCII character is mapped to which APL |
| 323 |
character). Currently only one profile exists. The user may change these |
| 324 |
details in file src/LineInput.cc (search for cfg_ALT_MAP_WANTED in that file). |
| 325 |
|
| 326 |
|
| 327 |
7. Editing APL files |
| 328 |
==================== |
| 329 |
|
| 330 |
Instead of using APL interactively, you may, like the author, find it more |
| 331 |
convenient to write a text file (an APL script) with all APL function |
| 332 |
definitions and variable assignments and then run "apl -f" or "apl -s" |
| 333 |
with that file. |
| 334 |
|
| 335 |
The editor of choice for editing such files is vi (actually, vim). Recent |
| 336 |
versions of vim come with Unicode support and require no further changes |
| 337 |
to work with APL characters (assuming, of course, that one of the methods |
| 338 |
above is in place to make the keyboard generate APL characters). |
| 339 |
|
| 340 |
To further improve on that, there is a syntax file support-files/apl.vim |
| 341 |
that supports syntax coloring of vim. |
| 342 |
|
| 343 |
|
| 344 |
8. Emacs Mode |
| 345 |
============= |
| 346 |
|
| 347 |
Unlike vim, which runs out-of-the-box with APL characters, emacs needs |
| 348 |
a little more setup work. We cannot describe this here but would like to |
| 349 |
refer you to the web page of Elias Mårtenson who has put a lot of effort |
| 350 |
into developing an emacs mode for GNU APL. This is a must for every |
| 351 |
emacs user: |
| 352 |
|
| 353 |
https://github.com/lokedhs/gnu-apl-mode |
| 354 |
|
| 355 |
|
| 356 |
9. Vim Plugins |
| 357 |
============== |
| 358 |
|
| 359 |
If your favorite editor is vim, then you will like the following plugin |
| 360 |
for vim, written by Thomas Baruchel: |
| 361 |
|
| 362 |
http://www.vim.org/scripts/script.php?script_id=4887 |
| 363 |
|
| 364 |
Another useful vim plugin, also written by Thomas Baruchel, lets you |
| 365 |
pick APL characters from a menu inside vim. It is here: |
| 366 |
|
| 367 |
http://apl-adventures.tumblr.com/post/76528148239/an-apl-character-picker-for-vim |
| 368 |
|
| 369 |
|
| 370 |
10. The APL Keyboard Translator (akt) |
| 371 |
===================================== |
| 372 |
|
| 373 |
David Lamkins has written a keyboard translator called akt. You can |
| 374 |
use it for generating APL characters with your keyboard. In contrast to e.g. |
| 375 |
the xmodmap method, the mapping is on a per program basis so that other |
| 376 |
programs are not affected. Obtain a copy from: |
| 377 |
|
| 378 |
https://github.com/blakemcbride/akt |
| 379 |
|
| 380 |
David's akt program is simple to use. In its most useful form the line is |
| 381 |
|
| 382 |
akt apl <optional-apl-parameters> |
| 383 |
|
| 384 |
If you would like to write APL code using vim, doing so with akt is |
| 385 |
as simple as: |
| 386 |
|
| 387 |
akt vi or akt vi your-apltext |
| 388 |
|
| 389 |
The left alt key is used to provide the apl characters. |
| 390 |
|
| 391 |
Certain older terminal emulators may offer an "Alt sets MSB" option. This |
| 392 |
is incompatible with `akt`. |
| 393 |
|
| 394 |
|
| 395 |
11. Keyboard Wrapper |
| 396 |
==================== |
| 397 |
|
| 398 |
If the methods described above cannot be used for whatever reason then |
| 399 |
you can write your own program that reads keystrokes from the keyboard |
| 400 |
and produces UTF8 bytes sequences on its stdout. The program can then |
| 401 |
be 'piped' into GNU APL, We refer to such a program as a 'keyboard wrapper'. |
| 402 |
|
| 403 |
This technique is demonstrated by 3 programs called APL_keyboard_show, |
| 404 |
APL_keyboard_learn, and APL_keyboard, which are all located in the 'tools' |
| 405 |
subdirectory. |
| 406 |
|
| 407 |
11.1 Introduction to Defining your own layout. |
| 408 |
============================================= |
| 409 |
When you wish to use APL with your own keyboard and/or keyboard arrangement. |
| 410 |
|
| 411 |
Use these programs in succession as follows: |
| 412 |
|
| 413 |
o APL_keyboard_show to display the keycodes |
| 414 |
|
| 415 |
o APL_keyboard_learn to create a file with the keycodes |
| 416 |
|
| 417 |
o APL_keyboard to use the file from APL_keyboard_learn |
| 418 |
|
| 419 |
o make to transform output from learn to program |
| 420 |
|
| 421 |
Details follow in sections 10.2 through 10.4 below. |
| 422 |
|
| 423 |
11.2 APL_keyboard_show |
| 424 |
---------------------- |
| 425 |
|
| 426 |
APL_keyboard_show is a simple program that displays the byte sequences |
| 427 |
produced by your keyboard. The following sequences are, as an example, |
| 428 |
sent by an Ubuntu system without having xmodmap or any other method applied. |
| 429 |
The characters typed were 'qwerty' and then 'qwerty' with ALT held down: |
| 430 |
|
| 431 |
$ ./APL_keyboard_show |
| 432 |
|
| 433 |
hit key ^C to quit... |
| 434 |
|
| 435 |
key_seq_1(0x71)) |
| 436 |
key_seq_1(0x77)) |
| 437 |
key_seq_1(0x65)) |
| 438 |
key_seq_1(0x72)) |
| 439 |
key_seq_1(0x74)) |
| 440 |
key_seq_1(0x79)) |
| 441 |
key_seq_2(0xC3, 0xB1)) |
| 442 |
key_seq_2(0xC3, 0xB7)) |
| 443 |
key_seq_2(0xC3, 0xA5)) |
| 444 |
key_seq_2(0xC3, 0xB2)) |
| 445 |
key_seq_2(0xC3, 0xB4)) |
| 446 |
key_seq_2(0xC3, 0xB9)) |
| 447 |
|
| 448 |
After running support-files/Dyalog/apl.xmodmap the following byte |
| 449 |
sequences are sent: |
| 450 |
|
| 451 |
hit keys, ESC to quit... |
| 452 |
|
| 453 |
key_seq_1(0x71)) |
| 454 |
key_seq_1(0x77)) |
| 455 |
key_seq_1(0x65)) |
| 456 |
key_seq_1(0x72)) |
| 457 |
key_seq_1(0x74)) |
| 458 |
key_seq_1(0x79)) |
| 459 |
key_seq_1(0x3F)) |
| 460 |
key_seq_3(0xE2, 0x8D, 0xB5)) |
| 461 |
key_seq_3(0xE2, 0x88, 0x88)) |
| 462 |
key_seq_3(0xE2, 0x8D, 0xB4)) |
| 463 |
key_seq_3(0xE2, 0x88, 0xBC)) |
| 464 |
key_seq_3(0xE2, 0x86, 0x91)) |
| 465 |
|
| 466 |
The alert reader will have noticed that in both cases UTF8 encoded characters |
| 467 |
were sent; they were different and just wrong for APL before running xmodmap. |
| 468 |
|
| 469 |
11.3 APL_keyboard_learn |
| 470 |
----------------------- |
| 471 |
|
| 472 |
The next program is APL_keyboard_learn which is derived from APL_keyboard_show. |
| 473 |
|
| 474 |
APL_keyboard_learn asks you to hit the keys for all APL characters and writes |
| 475 |
them into file APL_keyboard.def. For example: |
| 476 |
|
| 477 |
./APL_keyboard_learn |
| 478 |
|
| 479 |
hit keys, ESC to quit... |
| 480 |
|
| 481 |
hit key (0 of 94) for APL character ◊ : 0xC3 0xA0 (2 bytes) |
| 482 |
hit key (1 of 94) for APL character ¨ : 0xC2 0xB1 (2 bytes) |
| 483 |
hit key (2 of 94) for APL character ¯ : 0xC2 0xB2 (2 bytes) |
| 484 |
hit key (3 of 94) for APL character < : 0xC2 0xB3 (2 bytes) |
| 485 |
hit key (4 of 94) for APL character ≤ : 0xC2 0xB4 (2 bytes) |
| 486 |
hit key (5 of 94) for APL character = : 0xC2 0xB5 (2 bytes) |
| 487 |
hit key (6 of 94) for APL character ≥ : |
| 488 |
|
| 489 |
... |
| 490 |
|
| 491 |
If a key shall produce the same APL character regardless of the state of |
| 492 |
the SHIFT key, then you will be asked twice: |
| 493 |
|
| 494 |
hit key (0 of 94) for APL character ◊ : 0xC3 0xA0 (2 bytes) |
| 495 |
hit key (13 of 94) for APL character ◊ (shift): 0xC3 0xBE (2 bytes) |
| 496 |
|
| 497 |
APL_keyboard_learn writes a file APL_keyboard.def which is needed by the |
| 498 |
third program, APL_keyboard. The order of the keys that you are asked for |
| 499 |
is defined in file APL_keyboard.orig.def (which is identical to |
| 500 |
APL_keyboard.def when GNU APL is installed). |
| 501 |
|
| 502 |
After running APL_keyboard_learn, you should do 'make' in the tools directory, |
| 503 |
in order incorporate the newly created APL_keyboard.def into the program |
| 504 |
APL_keyboard. |
| 505 |
|
| 506 |
11.4 APL_keyboard |
| 507 |
----------------- |
| 508 |
|
| 509 |
The keyboard wrapper itself is APL_keyboard. The file APL_keyboard.def is |
| 510 |
#included by APL_keyboard.cc and defines the mapping from byte sequences |
| 511 |
produced by your keyboard to UTF8 sequenced to be fed into GNU APL. |
| 512 |
|
| 513 |
Once APL_keyboard is made, you can start GNU APL like this: |
| 514 |
|
| 515 |
$ APL_keyboard | apl |
| 516 |
|
| 517 |
|
| 518 |
122 aplwrap |
| 519 |
=========== |
| 520 |
|
| 521 |
There is a cool GTK-based keyboard wrapper written by Chris Moller. |
| 522 |
You can reach it via the GNU APL Community web page: |
| 523 |
|
| 524 |
http://www.gnu.org/software/apl/Community.html |
| 525 |
|
| 526 |
When invoked, it opens the apl interpretor in a window. The left alt key |
| 527 |
is used to provide the apl characters. |
| 528 |
|
| 529 |
13. Remote Login |
| 530 |
================ |
| 531 |
|
| 532 |
Suppose GNU APL is started on machine A and you connect to it by means |
| 533 |
of ssh or telnet from machine B. In that case the keyboard setup |
| 534 |
discussed above is only needed on machine B, and not on machine A. |
| 535 |
|
| 536 |
The same applies if machine A is a web server using APL for CGI scripting; |
| 537 |
in this case machine B does not normally need the above setup because these |
| 538 |
days, browsers are aware of UTF8 encoding (which is a standard encoding for |
| 539 |
HTML pages). |
| 540 |
|
| 541 |
If you telnet to a machine A, then verify that 8-bit operation is enabled |
| 542 |
(-8 command line option) or else UTF8 encoding will not work. |
| 543 |
|
| 544 |
If you ssh, make sure that the TERM variable is properly set on machine A |
| 545 |
or else output coloring of GNU APL may send incorrect ESC sequences for |
| 546 |
switching between colors (or use apl -noColor). |
| 547 |
|
| 548 |
|
| 549 |
14. Pitfalls and Troubleshooting |
| 550 |
================================ |
| 551 |
|
| 552 |
There are other pieces of software that may intercept the byte stream on its |
| 553 |
way from the keyboard, via GNU APL, to the screen (or printer). A prime |
| 554 |
example is "locales" that can change the encoding of the byte streams involved. |
| 555 |
|
| 556 |
Locales interfere with APL characters in multiple ways: they can install new |
| 557 |
keyboard mappings, change encoding to something other than UTF8, and currently |
| 558 |
also impact the file format of saved workspaces, for example by changing the |
| 559 |
decimal point from . to , in the printf() functions. One way to avoid the |
| 560 |
latter is to run ./configure with --disable-nls. |
| 561 |
|
| 562 |
If you need to troubleshoot APL characters, proceed as follows: |
| 563 |
|
| 564 |
1. determine if the problem is on input (between the keyboard and GNU APL), |
| 565 |
or on output (between GNU APL and the screen (or printer), or both. |
| 566 |
|
| 567 |
2. To check the output, start GNU APL and issue the debug command: |
| 568 |
|
| 569 |
]KEYB |
| 570 |
|
| 571 |
In GNU APL there are the classical APL commands starting with ) like |
| 572 |
)FNS or )VARS, and debug commands starting with ] instead of ). |
| 573 |
If ]KEYB shows a keyboard layout like the one in the xmodmap section |
| 574 |
above, then the output is working. If not then something is wrong with |
| 575 |
either the encoding, or with your fonts. |
| 576 |
|
| 577 |
3. For the input you can use commands like "xev" to see which Unicodes are |
| 578 |
sent when you press a key. If the wrong Unicode is shown then your |
| 579 |
key mapping is wrong; otherwise the encoding is more likely to be |
| 580 |
the problem. |
| 581 |
|
| 582 |
|
| 583 |
15. APL Keyboards |
| 584 |
================= |
| 585 |
|
| 586 |
If you are new to APL or infrequently use it, then you may have |
| 587 |
problems remembering the locations of all the APL characters on your |
| 588 |
keyboard. In that situation an APL keyboard may be a great help. |
| 589 |
|
| 590 |
Technically, an APL keyboard is not different from a normal keyboard. It |
| 591 |
produces the same keycodes as a normal keyboard. It does therefore not |
| 592 |
replace the methods for setting up your keyboard that were discussed above. |
| 593 |
|
| 594 |
However, it has the common APL symbols engraved on its keycaps in addition to |
| 595 |
the normal ASCII characters. There are not many vendors around that sell APL |
| 596 |
keyboards (it took a while for the author to find one). Therefore it may be |
| 597 |
worthwhile to mention a few: |
| 598 |
|
| 599 |
a. www.dyalog.com (send an email to [email protected] to obtain a quote). |
| 600 |
b. www.wasdkeyboards.com |
| 601 |
c. www.unicomp.com seems to have APL keyboards every now and then. |
| 602 |
|
| 603 |
An inquiry sent to a. was answered promptly; an inquiry sent to c. never. |
| 604 |
|
| 605 |
Blake McBride has contributed a few files and installation instructions |
| 606 |
for c. (WASD keyboards) which are contained in the support-files/WASD |
| 607 |
directory. |
| 608 |
|
| 609 |
Stickers |
| 610 |
========== |
| 611 |
Stickers may be created by printing the keyboard1.txt file onto gummed |
| 612 |
paper, and subsequently cutting the stickers and peeling them onto the |
| 613 |
keytop. This is not a durable solution, but would help you to remember |
| 614 |
the APL key locations (adding clear tape to the stickers may improve |
| 615 |
their durability). |
| 616 |
|
| 617 |
Another help for those that keep forgetting the APL key locations of their |
| 618 |
keyboard is the ]KEYB command of GNU APL. It displays the layout of a standard |
| 619 |
US keyboard with APL characters. Under X, if your keyboard is not yet up |
| 620 |
and running properly in APL, you can run the ]KEYB command in one window and |
| 621 |
then copy-and-paste APL characters from that window to another one running APL |
| 622 |
with your mouse. This approach is not useful for normal programming work, but |
| 623 |
can be handy in special situations. |
| 624 |
|