Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

APL Keymapping on Linux (GNU APL)

Tags:

apl

My Grandfather was an APL programmer at IBM back in the 60s/70s. He has recently started using Linux and I have been helping him to setup and use GNU APL (http://www.gnu.org/software/apl/).

The biggest headache for me at the moment is the keymapping. At the moment I have installed the aplwrap GTK+ (https://github.com/ChrisMoller/aplwrap) editor which works alright but it isn't brilliant. I would like to setup a global keymap for the APL characters which work when clicking LALT + key or LALT + Shift + key. I have fiddled around with the xmodmap files provided in the GNU APL source code but it screws up everything when you try get it to run on startup automatically.

So, I have two questions:

  1. Is it possible to have the APL keymapping global and also run on startup so it doesn't have to be manually turned on?

  2. If the first question is not possible then is it possible to setup a keymap per application? For example, Gnome Terminal and gEdit would use the LALT keymapping for the APL characters but the rest of the system would work as normal.

Thanks very much.

like image 339
theamoeba Avatar asked Jan 14 '15 20:01

theamoeba


4 Answers

I will plug my own solution and suggest the use of Emacs. I wrote the Emacs mode for GNU APL, and it's currently available through MELPA (it will eventually go to the standard ELPA repository). You can also find the source here: https://github.com/lokedhs/gnu-apl-mode

The Emacs mode provides two different methods of inputting APL symbols. The first uses the Super key together with the usual keys. So for example, you press s-e to generate the symbol.

The other method is a standard Quail input method, which is useful if you don't have a super key available (for example, you are using Emacs in a terminal). You enable it using C-\ and selecting APL-Z. Once you have done this, the period (.) is used as a prefix char, so you press, for example, . e to generate the symbol.

like image 113
Elias Mårtenson Avatar answered Nov 17 '22 12:11

Elias Mårtenson


You are in luck, because Linux (actually Xorg) has the most versatile and powerful keyboard configuration system of all major OSes. You can choose from a number of APL symbol dispositions and add them to your own national keyboard layout. You can even choose which key to use to switch between regular letters and APL, and apply this choice all over the system.

If you open your distribution's internationalization or keyboard layout settings (it could be in a control panel-like GUI, or it could be a settings file, for example /etc/default/keyboard in Debian) you will be able to add the apl keyboard layout to your existing national layout. The APL layout includes the basic APL symbols in a somewhat standard position and provides a number of variants that select additional symbols or different dispositions, including those of commercially available hardware keyboards: unified, sax, apl2, aplplusII, aplx, dyalog.

Please note that the APL layout is meant to be added to your existing national layout, alongside a choice of key to switch or toggle between the two. If you replace your national layout with APL, you won't be able to type standard letters anymore!

To test a combination of layouts, variants, and options, you can use a graphical control panel-thingy if you have it, or you can use the setxkbmap command.

For example, this selects the us layout, adds the apl one, in its default variant, and designates the Windows key as the switch between the two, so that Win+A gives ⍺, etc.

setxkbmap us,apl -option grp:win_switch

Protip: you might want to keep another terminal open with some default command ready, for example setxkbmap us, so that you can easily press Enter inside it and reset your layout, if you render your keyboard unusable. If you can't even press Enter anymore, you can copy+paste a line break to execute the command.

After you are happy with your combination of layouts, variants, and options, you will have to put them into the global configuration file, or use the control panel button that makes them a permanent choice.

If you are having trouble with some specific combination of options, you might want to look over the XKB documentation wiki, chat on one of the many Linux IRC channels, or post a more specific question here on StackExchange, although I would suggest using Super User, Unix & Linux, or Ask Ubuntu, instead of StackOverflow.

like image 21
Tobia Avatar answered Nov 17 '22 12:11

Tobia


I have GNU APL as well as Dyalog APL working nicely in the following conditions; first I don't use a graphical server because I don't really like it (this will certainly make my solution not very interesting for your own case, but who knows?). You can use both software as long as you enable a compliant font on the console; you can achieve it by two ways:

  • using the devoted font from Unifoundry (a description here) and enabling it with setfont
  • using a framebuffer terminal (what I do myself) like fbterm; just install it and type fbterm in the console; this will allow you to use the full Unicode range on the console;

Then you have to hack some keymap font; it is not too difficult; you have either to make a copy from the current one or find some ready to use file (I strongly suggest you to hack your own one; there will be one hour work on it but nothing to difficult with a text editor): have a look here.

Once this is done, using APL in the Linux console is very easy.

like image 5
Thomas Baruchel Avatar answered Nov 17 '22 14:11

Thomas Baruchel


I have the Dyalog font installed, (also,this only works with Xorg) and I run this script. It allows the meta-key (windows key), to act as the APL modifier key (like how holding shift lets you type in capital letters):

#!/bin/bash

if [ "$DISPLAY" >> /dev/null ]
then
        ## We are running Xorg
        if ! [ `setxkbmap -query | awk '/layout/ {print $2}' | grep "apl"` ]
        then
                ## We have no APL layout - so lets set one up - we're going to use the Windows Key.
                ## Setup keyboard map
                XKBRULES=`setxkbmap -query | awk '/rules/ {print $2}'` 2>/dev/null
                XKBMODEL=`setxkbmap -query | awk '/model/ {print $2}'` 2>/dev/null
                XKBLAYOUT=`setxkbmap -query | awk '/layout/ {print $2}'` 2>/dev/null
                XKBVARIANT=`setxkbmap -query | awk '/variant/ {print $2}'` 2>/dev/null
                XKBOPTIONS=`setxkbmap -query | awk '/options/ {print $2}'` 2>/dev/null
                setxkbmap -rules ${XKBRULES} -model ${XKBMODEL} -layout "${XKBLAYOUT},apl" \
                        -variant "${XKBVARIANT},dyalog" \
                        -option "${XKBOPTIONS},grp:win_switch" 2>/dev/null
        fi
fi

If this script works for you, then, then I guess getting it to run on start-up is really dependent on your operating system.

like image 2
alexweiner Avatar answered Nov 17 '22 12:11

alexweiner