Giter Site home page Giter Site logo

ibus-apl-input's Introduction

Setup of ibus-based input method for APL

Introduction

I learned about APL the other day. You know, that language with the really weird character set? If you don’t know about it, go look it up. Anyhow, I needed to create a file that would allow me to input APL characters whenever I was typing into the GNU APL or Dyalog interpreter. It needed to work with ibus, because I already had several other character sets set up for my system.

I’m a Dvorak user, and the instructions for setting up APL input usually indicate using setxkbmap with the system-provided APL keyboard mapping, either using the Dyalog variant, or some other apl variant. Those instructions all assume a QWERTY keyboard as the basis for conversions so that the r key comes up as ⍴ and the i key would emit ⍳. As I’m not a QWERTY keyboard user, and most of the setxkbmap instructions assume a QWERTY layout, I’d hit the i key to get ⍳ and get ∇ instead, or I’d hit p to get ⍴ and get ○ instead. Not ideal if I want to use transliteration-based input. Even the q key would give me ⊃ instead of ?, which isn’t much use!

So I did something about it.

Getting Started

I set these instructions up purely for ibus and not setxkbmap, as there are already excellent instructions for using setxkbmap up, as long as you have a QWERTY keyboard layout or near relative. My setup doesn’t care what keyboard layout you have, as long as you’ve already installed ibus. You’ll also need to install ibus-table to make the custom IME.

There are two files to create for this little project, first the text file (which I’ve provided here) to feed into ibus-table-createdb, the second is the SVG (or PNG, both will work) icon file. Some artistic skills with inkscape (to create the svg file for the icon) might be a good idea until there’s an official APL icon that looks worthwhile. I created an apl.svg file from one posted as a sample to the Discord chat, but it’s not the official logo. If you check the page for logos on the APL wiki, you’ll find several ideas.

My APL file

This file got munged from a version first posted to studymongolian.net (yes, that’s correct), though I tailored the table to provide APL characters instead. I’m grateful to the author of that article, he made it understandable so I could set this file up. I didn’t create the original version of this file, that comes from the ibus-table project.

Edit this example file, changing the UUID to something unique, usually running the uuidgen command in a shell will give you one that you can use.

If needed, you’ll also want to change the author name inside the file, just in case you want to shuffle some stuff around. You really need to save this file with a UTF-8 encoding, or things might not work out right. Most editors will handle this seamlessly for you. I’ve provided the file separately (as en-US-APL.txt) so you don’t have to cut-and-paste from inside this, but the file should look the same as the example shown here, except for the changed UUID and Author fields.

### File header must not be modified
### This file must be encoded into UTF-8.
### This table under LGPL
### comments start with ### not single #
### Derive from the format of SCIM Table, so you can modify the table from
### scim-tables' table
SCIM_Generic_Table_Phrase_Library_TEXT
VERSION_1_0

### Begin Table definition.
BEGIN_DEFINITION

### License
LICENSE = LGPL

### An unique id to distinguish this table among others.
### Use uuidgen to generate this kind of id.
UUID = 049bc7a3-9fd6-443e-b598-f6813395403e

### A unique number indicates the version of this file.
### For example the last modified date of this file.
### This number must be less than 2^32.
### Just make your table version-able
SERIAL_NUMBER = 20211125

### ICON can be any format as long as your pygtk can recognized
### the most widely ones are "png" and "svg", letter one is recommended
ICON = apl.svg

### The symbol to be displayed in IM switchers
SYMBOL = APL

### The default name of this table, this is needed
NAME = English (US, APLInput)

### The local names of this table, this is optional


### Description
DESCRIPTION = This is an APL input method.

### Supported languages of this table
### sigle "zh_CN" just be recognized as zh_CN,
### but "zh_CN, zh_HK" or more zh_XX will be recognized as zh;
### and "en_US, zh_CN" will be just ignored.
### LANGUAGES = zh_CN,zh_SG,zh_TW,zh_HK
LANGUAGES = en_US

### The author of this table
AUTHOR = metheuser  <[email protected]> 

### Prompt string to be displayed in the status area, CN will be replaced by
### the gettext tools in runtime as 中.
STATUS_PROMPT = A

### Valid input chars. Needs the == at the front so we can stick a = into the real string.
### Only works because this is a Unicode file.
VALID_INPUT_CHARS== =abcdefghijklmnopqrstuvwxyzEIJKLOPTZ1234567890[](){}!@#$%^&/?|-_;:&\'",.<>+~`*

### Layout
LAYOUT = default

### The max number of input keys for every phrase or character.
MAX_KEY_LENGTH = 2

### Use auto_commit mode as default
AUTO_COMMIT = TRUE

### Automatically selects the first phrase when typing
AUTO_SELECT = FALSE

### Use full width punctuation by default
### DEF_FULL_WIDTH_PUNCT = TRUE
### Not use full width letter by default
### DEF_FULL_WIDTH_LETTER = FALSE

### Whether user are allow to define phrase, default is true
### You have to define the word construction rules below.
### For input methods which do not input phrases, set this to False
USER_CAN_DEFINE_PHRASE = FALSE

### Whether support PinYin Mode, default is true.
### this feature is just for Chinese, set it to False if your IM is not
### Chinese.
PINYIN_MODE = FALSE

### If true then the phrases' frequencies will be adjusted dynamically
### according your using frequency.
DYNAMIC_ADJUST = FALSE 

### Some characters whose frequencies should be fix all the time, e.g. 
### some punctuations
### NO_CHECK_CHARS = 

### The key strokes to page up the lookup table.
### PAGE_UP_KEYS = Page_Up,KP_Page_Up,minus,comma

### The key strokes to page down.
### PAGE_DOWN_KEYS = Page_Down,KP_Page_Down,equal,period

### The key strokes to select candidiate phrases.
### Usually "1,2,3,4,5,6,7,8,9" but if this conflicts with
### characters one wants to use for input one can also
### use something like “F1,F2,F3,F4,F5,F6,F7,F8,F9”
SELECT_KEYS = "F1,F2,F3,F4,F5,F6,F7,F8,F9"

### The default orientation of the candidate list
### TRUE means the candidate list is vertical, FALSE means it is vertical
ORIENTATION=TRUE

END_DEFINITION

### Begin Table data.
### Format of every line whose formated in "input_keys\tphrase\tfreq\n" is an
### entry.
### From left to right, the 1st column are the input key combination that you
### entered via keyboard; the 2nd column are presented character or phrase of
### the key combination you want; the 3rd column are frequency of the character
### or phrase.

BEGIN_TABLE
a	⍺	1
b	⊥	1
c	∩	1
d	⌊	1
e	∊	1
f	_	1
g	∇	1
h	∆	1
i	⍳	1
j	∘	1
k	'	1
l	⎕	1
m	|	1
n	⊤	1
o	○	1
p	*	1
q	?	1
r	⍴	1
s	⌈	1
t	~	1
u	↓	1
v	∪	1
w	⍵	1
x	⊃	1
y	↑	1
z	⊂	1
E	⍷	1
I	⍸	1
J	⍤	1
K	⌸	1
L	⌷	1
O	⍥	1
P	⍣	1
T	⍨	1
Z	⊆	1
`	⋄	1
1	¨	1
2	¯	1
3	<	1
4	≤	1
5	=	1
6	≥	1
7	>	1
8	≠	1
9	∨	1
0	∧	1
~	⌺	1
!	⌶	1
@	⍫	1
#	⍒	1
$	⍋	1
%	⌽	1
^	⍉	1
&	⊖	1
*	⍟ 	1
(	⍱	1
)	⍲	1
[	←	1
]	→	1
{	⍞	1
}	⍬	1
'	⍕	1
"	≢	1
,	⍝	1
.	⍀	1
<	⍪	1
>	⍙	1
;	⍎	1
:	≡	1
/	⌿	1
A	÷	1
=	÷	1
\	⊢	1
?	⍠	1
+	⌹	1
|	⊣	1
-	×	1
_	!	1
END_TABlE


Compiling the file

You’ll need to feed that file into ibus-table-createdb, and then copy the result into place on the file system. The createdb program can do this all in one step if you can use sudo.

$ sudo ibus-table-createdb -n /usr/share/ibus-table/tables/apl.db -s en-US-APL.txt

Once you’ve created your icon file, you can also copy this into place like this:

$ sudo cp apl.svg /usr/share/ibus-table/icons/

Testing with an existing ibus setup

This should get your existing input restarted with the new files available for selection.

$ ibus-daemon -drx

Right-click on the keyboard icon in your system tray, you should then see a menu that includes “Preferences”. Select that, then in the window that turns up, choose the Input Method tab. You’ll see a list of the methods you’ve already installed, or perhaps only one if you haven’t (the English, English US method). Add a new method with the Add button to the right. Select “English”, and scroll down the list until you find “English, (US APLinput)” and choose it. You may also want to choose a key to switch input methods in the General tab, and it shouldn’t interfere with anything else you’ve got set up in the system.

Start up gnu apl inside a terminal that supports ibus input (perhaps gnome-terminal), or start up the RIDE interface to Dyalog (assuming you’ve installed both RIDE and Dyalog). You can then switch layouts with the keyboard shortcut you chose (I chose Win-Alt-Spacebar) until English (US, APLinput) turns up.

You may see a new tab bar turn up with a checkbox and APL next to it. You’ll usually see “Switch input (Left Shift)” when you put the mouse pointer over it. If your checkbox is checked, then congratulations! You can now type APL characters directly. To switch back out of APL mode into normal mode to type normal letters, hit the left shift. If the checkbox doesn’t go away, switch to an application that you have to enter text into, then hit Left Shift again—a browser with an input field selected, Discord client, or gnome-terminal are examples that work for me.

Testing without ibus installed

For this, all I can suggest is that you can get ibus installed and working for you. If you’re in a position that ibus isn’t a good fit for your system (i.e. you’re using fcitx or some other input method already), then you have to figure out how to convert from these instructions to the input methods you’re using. I lack the experience to help out on this front. As I gain some more experience I may flesh this document out with further instructions that may include other input methods.

Further notes

Programs such as xterm, urxvt, emacs (though with a note), and some other applications haven’t been hooked up to ibus, so they will ignore any signals to either select or switch keyboard layout. I keep a Discord client around to help out in this circumstance, but it’s not a universal solution as I’ve found that even if I leave Discord with the APL keyboard input selected, xterm and friends will only see US ASCII input. I haven’t found a good fix for this problem yet, so it’s hard to figure out what I need to do to fix this. Anyhow, I hope this helps you out.

Cheers for now, brickviking.

ibus-apl-input's People

Contributors

brickviking avatar

Stargazers

Kyoung Seo avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.