Typing glyphs: Difference between revisions

Jump to navigation Jump to search
635 bytes added ,  13:35, 13 January 2021
m
m (Fix broken Wikipedia links)
(25 intermediate revisions by 4 users not shown)
Line 1: Line 1:
APL uses a large range of [[glyphs|special graphic symbols]] to represent most functions and operators. While keyboard mappings become memorized over time, entering APL characters can frustrate the beginner. However, a study involving high school students found that typing and using APL characters did not hinder the students in any measurable way. There are several convenient ways to enter the glyphs.
APL uses a large range of [[glyphs|special graphic symbols]] to represent most functions and operators. While keyboard mappings become memorized over time, entering APL characters can frustrate the beginner. However, a study involving high school students found that typing and using APL characters did not hinder the students in any measurable way. There are several convenient ways to enter the glyphs.


== How to Set up an APL Keyboard ==
[[File:Dyalog US keyboard.jpg|thumb|right|US keyboard with [[Dyalog APL]] glyphs]]
== Hardware ==


=== Android ===
A couple of keyboards are being sold with APL symbols pre-printed onto the key caps:


Dzaima's [https://github.com/dzaima/hackerskeyboard Hacker's Keyboard + APL language] uses a [[wikipedia:Pointing_device_gesture#Touchpad_and_touchscreen_gestures|long-press]] to access APL glyphs.
* Dyalog sells [https://www.dyalog.com/apl-font-keyboard.htm#mainContent US English, UK English, and Danish keyboards].


=== Linux ===
* Unicomp sells both [https://www.amazon.com/Unicomp-Classic-Buckling-Spring-Keyboard/dp/B01M7V3M61/ref=sr_1_8 entire keyboards] and [https://www.pckeyboard.com/page/product/USAPLSET separate key caps] for their keyboard range.


[[Geoff Streeter]] authored a paper, [https://www.dyalog.com/uploads/conference/dyalog10/presentations/P19_Streeter_Keyboards.pdf Supporting APL keyboards on Linux], which was presented at the [https://aplwiki.com/wiki/Dyalog_user_meeting#Dyalog_.2710 Dyalog '10] user meeting. In this paper, Geoff details how APL keyboards can be supported in [[wikipedia:X_Window_System|X11]] using <code>xkb</code>, the [https://www.x.org/wiki/XKB/ X Keyboard Extension].
Note that these devices only are visual modifications on regular keyboards; they do not automatically enable entry of APL glyphs into software. For this, one of the below methods is required.


Most Linux distributions released after mid-2012 have [https://forums.dyalog.com/viewtopic.php?f=20&t=210 Dyalog keyboard support] included with the distribution.
== By platform ==


==== setxkbmap ====
[[File:Adám Brudzewsky's in-browser language bar.png|thumb|right|The in-browser language bar]]
=== Web ===


The simplest way to set up an APL keyboard on Linux is with the following <code>setxkbmap</code> command. Enter the following in your terminal emulator of choice:
[[Adám Brudzewsky]]'s [https://abrudz.github.io/lb/apl  in-browser language bar] adds APL keyboard functionality to most web pages on demand.


<pre>
=== Text editors ===
setxkbmap -layout us,apl -variant ,dyalog -option grp:switch
</pre>


An explanation:
Keyboard layout extensions exist for several popular [[text editors]] like VS Code, Emacs and Vim. This can be an alternative, or complementary, to system-wide settings.


* <code>-layout us,apl</code> assigns <code>us</code> ([[wikipedia:American_English|U.S. English]]) to be the primary layout, whereas <code>apl</code> is secondary
=== Linux ===
{{Main|Typing glyphs on Linux}}


* <code>-option grp:switch</code> assigns <kbd>Right Alt</kbd> to switch to the secondary <code>apl</code> layout when it is pressed, otherwise <code>us</code> is used
Most Linux distributions released after mid-2012 have Dyalog keyboard support included with the distribution.


* <code>-variant ,dyalog</code> assigns the [[Dyalog APL]] variant to the <code>apl</code> layout which contains modifiations unique to the Dyalog language ('''Note the preceding comma''')
[[File:Hacker's Keyboard + APL language.png|thumb|right|Hacker's Keyboard + APL language]]
 
=== Android ===
A full list of keys that can be used to switch layouts is included in <code>/usr/share/X11/xkb/rules/evdev.lst</code> under the <code>option</code> category.


 
dzaima's [https://github.com/dzaima/hackerskeyboard Hacker's Keyboard + APL language] uses a [[wikipedia:Pointing_device_gesture#Touchpad_and_touchscreen_gestures|long-press]] to access APL glyphs.
'''Note:''' these changes are not permanent; the user will have to select one of a myriad of methods to run the command on startup. Alternatively, if they use one of the [[wikipedia:Desktop_environment|desktop environments]] listed below, they can follow those instructions.
 
==== LXDE ====
 
Prepend an <code>@</code> to the <code>setxkbmap</code> command from above, like shown:
 
<pre>
@setxkbmap -layout us,apl -variant ,dyalog -option grp:switch
</pre>
 
and add it as a line in your user's LXDE <code>auostart</code> file, located at:
 
<pre>
~/.config/lxsession/LXDE/autostart
</pre>
 
For Lubuntu versions up to and including 18.04 (before the LXQt split), the location of <code>autostart</code> is <code>~/.config/lxsession/Lubuntu/autostart</code>.
 
==== LXQt ====
 
===== GUI =====
 
From your LXQt panel, navigate to ''Preferences'' → ''LXQt Settings'' → ''Session Settings''; alternatively, enter <code>lxqt-config-session</code> in your terminal emulator. You will be greeted with the following window:
 
[[File:Lxqt-session-settings.png|frameless|LXQt Autostart menu of Session Settings window]]
 
Select the <code>LXQt Autostart</code> dropdown (it will be highlighted as shown above) and click the <code>Add</code> button to display the following pop-up window:
 
[[File:Lxqt-add-autostart.png|frameless|LXQt add a new autostart menu item]]
 
Name it whatever you want, and enter a <code>setxkbmap</code> command that suits your taste. Shown above is the same command as detailed [[Typing glyphs#setxkbmap| in the setxkbmap section]].
 
===== Terminal =====
 
The above GUI approach merely creates a <code>.desktop</code> file in the user's <code>~/.config/autostart</code>. Create your own file in the <code>autostart</code> directory whose contents are as follows, to replicate the functionality achieved through the GUI:
 
<pre>
[Desktop Entry]
Exec=setxkbmap -layout us,apl -variant ,dyalog -option grp:switch
Name=apl-keyboard
OnlyShowIn=LXQt;
Type=Application
Version=1.0
</pre>
 
==== Xfce ====
 
A tutorial specific to Xfce's config files can be found [https://github.com/hashslingrz/apl-keyboard-xfce at this GitHub repository].
 
=== Text editors ===
 
Keyboard layout extensions exist for several popular [[text editors]] like VS Code, Emacs and Vim. This can be an alternative, or complementary, to system-wide settings.
 
=== Web ===
 
[[Adám Brudzewsky]]'s [https://abrudz.github.io/lb/apl  in-browser language bar] adds APL keyboard functionality to most web pages on demand.


=== Windows ===
=== Windows ===


* [[Adám Brudzewsky]]'s [https://github.com/abrudz/Kbd keyboard layouts for Windows], which uses <kbd>AltGr</kbd>.
* [[Adám Brudzewsky]] has [https://github.com/abrudz/Kbd various keyboard English layouts for Windows], which allow <kbd>AltGr</kbd> as shifting key, <kbd>`</kbd> as prefix key, or ASCII symbol composition.


* The [https://www.dyalog.com/apl-font-keyboard.htm#tab-1 Dyalog Unicode IME] uses <kbd>Ctrl</kbd>. It is also possible to install the [[wikipedia:Input_method|IME]] alongside a regular [[Dyalog APL]] installation:
* The [https://www.dyalog.com/apl-font-keyboard.htm#tab-1 Dyalog Unicode IME] uses <kbd>Ctrl</kbd>. Unless unselected, this [[wikipedia:Input_method|IME]] is installed by default with [[Dyalog APL]]:<br>[[File:Dyalog_APL_Installer.png|frameless|Dyalog APL IME selected in installer]]
[[File:Dyalog_APL_Installer.png|frameless|Dyalog APL IME selected in installer]]


== Approaches to Layout and Input ==
== By method ==


Most of today's APLs use a mapping which derives from the original [[APL\360]] terminals' keyboard layout. For example, Dyalog APL's standard US English layout for is as follows:
Most of today's APLs use a mapping which derives from the original [[APL\360]] terminals' keyboard layout. For example, Dyalog APL's standard US English layout for is as follows:
Line 138: Line 81:
* [[Adám Brudzewsky]]'s [https://abrudz.github.io/lb/apl in-browser language bar] recognises all the following as prefix keys: <kbd>`</kbd>, <kbd>½</kbd>, <kbd>²</kbd>, <kbd>^</kbd>, <kbd><s>º</s></kbd>, <kbd>§</kbd>, <kbd>ù</kbd>, <kbd>µ</kbd>, <kbd>°</kbd>.
* [[Adám Brudzewsky]]'s [https://abrudz.github.io/lb/apl in-browser language bar] recognises all the following as prefix keys: <kbd>`</kbd>, <kbd>½</kbd>, <kbd>²</kbd>, <kbd>^</kbd>, <kbd><s>º</s></kbd>, <kbd>§</kbd>, <kbd>ù</kbd>, <kbd>µ</kbd>, <kbd>°</kbd>.


[[File:Dyalog US keyboard.jpg|thumb|right|US keyboard with [[Dyalog APL]] glyphs]]
[[File:RIDE keyword lookup.png|thumb|right|RIDE keyword lookup]]
 
=== Long-press ===
 
dzaima's [https://github.com/dzaima/hackerskeyboard Hacker's Keyboard + APL language] reacts to a [[wikipedia:Pointing_device_gesture#Touchpad_and_touchscreen_gestures|long-press]], popping up a palette that allows selecting any of the APL glyphs associated with that button.


=== Keyword look-up ===
=== Keyword look-up ===
Line 144: Line 91:
* The [https://github.com/Dyalog/ride/releases/latest Dyalog RIDE] (Remote Integrated Development Environment) allows hitting the prefix key (<kbd>`</kbd> by default, but configurable) twice, followed by the (beginning of the) name of a symbol or a functionality. It then displays a drop-down of choices with arrow keys to indicate choice and the Tab key to insert the symbol. E.g. <kbd>`</kbd>,<kbd>`</kbd>,<kbd>d</kbd>,<kbd>i</kbd>,<kbd>v</kbd>,<kbd>Tab↹</kbd> inserts <source lang=apl inline>÷</source>.
* The [https://github.com/Dyalog/ride/releases/latest Dyalog RIDE] (Remote Integrated Development Environment) allows hitting the prefix key (<kbd>`</kbd> by default, but configurable) twice, followed by the (beginning of the) name of a symbol or a functionality. It then displays a drop-down of choices with arrow keys to indicate choice and the Tab key to insert the symbol. E.g. <kbd>`</kbd>,<kbd>`</kbd>,<kbd>d</kbd>,<kbd>i</kbd>,<kbd>v</kbd>,<kbd>Tab↹</kbd> inserts <source lang=apl inline>÷</source>.


=== ASCII symbol combination ===
=== ASCII symbol composition ===


* Many APL glyphs can be approximated by overlaying or juxtaposing two ASCII characters. [[ngn/apl]]'s scripted demo interface and [https://abrudz.github.io/lb/apl Adám Brudzewsky's in-browser language bar] allow such a pair of characters and hitting the Tab key to replace them with the corresponding APL character. For example, <kbd><</kbd>,<kbd>-</kbd>,<kbd>Tab↹</kbd> will insert <source lang=apl inline>←</source> and <kbd>T</kbd>,<kbd>o</kbd>,<kbd>Tab↹</kbd> will insert <source lang=apl inline>⍕</source>.
* Many APL glyphs can be approximated by overlaying or juxtaposing two ASCII characters. [[ngn/apl]]'s scripted demo interface and [https://abrudz.github.io/lb/apl Adám Brudzewsky's in-browser language bar] allow such a pair of characters and hitting the <kbd>Tab↹</kbd> key to replace them with the corresponding APL character. For example, <kbd><</kbd>,<kbd>-</kbd>,<kbd>Tab↹</kbd> will insert <source lang=apl inline>←</source> and <kbd>T</kbd>,<kbd>o</kbd>,<kbd>Tab↹</kbd> will insert <source lang=apl inline>⍕</source>.


[[File:NARS2000 language bar.png|thumb|right|NARS2000 language bar]]
=== On-screen language bar ===
=== On-screen language bar ===


Line 154: Line 102:
* [[Dyalog APL]], [[NARS2000]], [[APL2]] and [[ngn/apl]]'s scripted demo interface  all have this feature.
* [[Dyalog APL]], [[NARS2000]], [[APL2]] and [[ngn/apl]]'s scripted demo interface  all have this feature.


== Hardware ==
=== LaTeX ===
A couple of keyboards are being sold with APL symbols pre-printed onto the key caps:
 
In order to typeset APL using LaTeX, you need to be sure your LaTeX engine has full Unicode support. At the time of writing, LuaLaTeX and XeLaTeX are two of the most popular such alternatives, both included with TeX Live.
 
After ensuring you have a LaTeX engine that is Unicode capable, you need to make sure your .tex document is using a [[Fonts|font]] that has the APL glyphs you want to type. One way to do this is through the fontspec package, as seen in the example template below.
 
To check your setup is fully functional you can try compiling the following template:
[[File:LaTeX APL template.png|thumb|right|Screenshot of the typeset document]]
<source lang=latex>
\documentclass[11pt]{article}
 
\usepackage{fontspec}
\setmainfont{APL385 Unicode}
\setmonofont{APL385 Unicode}[Scale=MatchLowercase]
 
\begin{document}
 
I just want some ← +-×÷*⍟⌹○!? |⌈⌊⊥⊤⊣⊢ =≠≤<>≥≡≢ ∨∧⍲⍱ ↑↓⊂⊃⊆⌷⍋⍒ ⍳⍸∊⍷∪∩~ /\textbackslash⌿⍀ ,⍪⍴⌽⊖⍉ ¨⍨⍣.∘⍤⍥@ ⍞⎕⍠⌸⌺⌶⍎⍕ ⋄⍝→⍵⍺∇\& ¯⍬
 
\texttt{The ``setmonofont'' was needed because of this, otherwise ⍺⌊¯→⍬ wouldn't show properly}.
 
\end{document}
</source>
 
Depending on whether you want the whole document to use the APL font or not, you may remove the command to set the main font. If you do so, APL glyphs will be rendered correctly inside code listings and similar environments, but not in the main body of the document.


* Dyalog sells [https://www.dyalog.com/apl-font-keyboard.htm#mainContent US English, UK English, and Danish keyboards].
==== Listings ====


* Unicomp sells both [https://www.amazon.com/Unicomp-Classic-Buckling-Spring-Keyboard/dp/B01M7V3M61/ref=sr_1_8 entire keyboards] and [https://www.pckeyboard.com/page/product/USAPLSET separate key caps] for their keyboard range.
LuaLaTeX and XeLaTeX can use the [https://en.wikibooks.org/wiki/LaTeX/Source_Code_Listings ''listings'' package] to include APL source with the following document preamble:<ref>Baker, John D. [https://analyzethedatanotthedrivel.org/2011/08/15/typesetting-utf8-apl-code-with-the-latex-lstlisting-package/ Typesetting UTF8 APL code with the LaTeX lstlisting package]. Analyze the Data not the Drivel. August 15, 2011.</ref>
<source lang=latex>
% set lstlisting to accept UTF8 APL text
\makeatletter
\lst@InputCatcodes
\def\lst@DefEC{%
\lst@CCECUse \lst@ProcessLetter
  ^^80^^81^^82^^83^^84^^85^^86^^87^^88^^89^^8a^^8b^^8c^^8d^^8e^^8f%
  ^^90^^91^^92^^93^^94^^95^^96^^97^^98^^99^^9a^^9b^^9c^^9d^^9e^^9f%
  ^^a0^^a1^^a2^^a3^^a4^^a5^^a6^^a7^^a8^^a9^^aa^^ab^^ac^^ad^^ae^^af%
  ^^b0^^b1^^b2^^b3^^b4^^b5^^b6^^b7^^b8^^b9^^ba^^bb^^bc^^bd^^be^^bf%
  ^^c0^^c1^^c2^^c3^^c4^^c5^^c6^^c7^^c8^^c9^^ca^^cb^^cc^^cd^^ce^^cf%
  ^^d0^^d1^^d2^^d3^^d4^^d5^^d6^^d7^^d8^^d9^^da^^db^^dc^^dd^^de^^df%
  ^^e0^^e1^^e2^^e3^^e4^^e5^^e6^^e7^^e8^^e9^^ea^^eb^^ec^^ed^^ee^^ef%
  ^^f0^^f1^^f2^^f3^^f4^^f5^^f6^^f7^^f8^^f9^^fa^^fb^^fc^^fd^^fe^^ff%
  ^^^^20ac^^^^0153^^^^0152%
  ^^^^20a7^^^^2190^^^^2191^^^^2192^^^^2193^^^^2206^^^^2207^^^^220a%
  ^^^^2218^^^^2228^^^^2229^^^^222a^^^^2235^^^^223c^^^^2260^^^^2261%
  ^^^^2262^^^^2264^^^^2265^^^^2282^^^^2283^^^^2296^^^^22a2^^^^22a3%
  ^^^^22a4^^^^22a5^^^^22c4^^^^2308^^^^230a^^^^2336^^^^2337^^^^2339%
  ^^^^233b^^^^233d^^^^233f^^^^2340^^^^2342^^^^2347^^^^2348^^^^2349%
  ^^^^234b^^^^234e^^^^2350^^^^2352^^^^2355^^^^2357^^^^2359^^^^235d%
  ^^^^235e^^^^235f^^^^2361^^^^2362^^^^2363^^^^2364^^^^2365^^^^2368%
  ^^^^236a^^^^236b^^^^236c^^^^2371^^^^2372^^^^2373^^^^2374^^^^2375%
  ^^^^2377^^^^2378^^^^237a^^^^2395^^^^25af^^^^25ca^^^^25cb%
  ^^00}
\lst@RestoreCatcodes
\makeatother
</source>


== References ==
<references/>
{{APL development}}
{{APL development}}
{{APL glyphs}}
{{APL glyphs}}
[[Category:APL character set]]
[[Category:APL character set]][[Category:Lists]]

Navigation menu