K_TTY understands a language (or file format) closely related to that read by the Tavultesoft keyboard manager (KEYMAN), version 3.2 . The main difference is that K_TTY is a Linux driver, whereas Keyman works on MS Windows (and possibly other operating systems by now). Many of the other differences stem from the fact the programs are not at all related internally, as far as I know. I wrote K_TTY after using keyman some years ago and thinking that something similar for Linux would be very handy.
There are some differences in the strictness of the grammar beteen the two programs, some constructs used in keyman are silently ignored, and some new "instructions" have been added. The language that keyman uses is itself based on of SIL's "consistent changes", but with a very reduced instruction set. Some of K_TTY's extra instructions are inspired by a couple keyman's omissions.
The flavour of the language that K_TTY understands has zero or more header items, and one or more groups of pattern matching rules.
name keyboard name NLThe name of the keyboard, used to reference this keyboard as a unique entity to the kernel. If the name is changed, it is counted as a different keyboard. If an attempt is made to load a keyboard with a name that matches one already loaded, then the kernel will interpret this as an attempt to replace the currently loaded one, which will fail if the current one is in use. Limits: the compiler's binary file format has been defined with a maximum of 64 bytes for this value, and currently the kernel only uses the first 16 bytes of this value.
store (store_name) store_definition NLA store is a string (or sequence of bytes) referenced by store_name that may be used either for matching / translating input or as a predefined string that you might want to output from more than one rule. The second case may seem more space efficient, and certainly makes for a smaller keyboard definition and easier editing, but if caching is used then each new store adds to the memory needed by the kernel.
begin unicode > use(group name) NLThis file expects to be used on a console/terminal that uses unicode in UTF-8 format. Also, start processing using the group named, rather than the first one found in the file.
begin > use(group name) NLStart processing using the group named, rather than the first one found in the file.
hotkey [shiftstate key] NLThis command is used in keyman(TM) 3.2 to set a "hot key" combination for starting/stoping this keyboard. Later versions of keyman are believed to deprecate this command, as keyboard selection is done by the standard windows(TM) mechanisms.
At present, there is neither a "standard" linux mechanism for switching keyboards (other than running the right command), nor is it possible to obtain the shift state of a dumb terminal or a telnet/ssh session.
bitmaps string string NLThis is used by keyman 3.2 to specify a pair of bitmap icons to be displayed when the keyboard is in use or not, on windows.
version string NL
group (name)
group (name) using keysA group has one or more "rules", each of which contains three parts: a pattern; an action; and a "greater than" sign that separates the two. if the optional "using keys" is marked, then each match part in the group must finish with a "+" sign followed by a (possibly multi-byte) keystroke. The "+" sign is not optional in a "using keys" group, and is not permitted in group that does not use keys. Items marked with "*" are not acceptable to Keyman 3.2.
flags AND NN=NN, where NN is an int.
- isclear(NN)*
- Matches if
flags AND NN=0, where NN is an int.
- match
- This item may only occur as the final pattern (or penultimate if
followed by a nomatch pattern) and does not co-occur
with other pattern items. It's corresponding action is executed if any
previous rule in the group has been succesfully matched.
- nomatch
- This item may only occur as the final pattern (or penultimate if
followed by a match pattern) and does not co-occur
with other pattern items. It's corresponding action is executed if no
previous rule has matched. Beware that if a nomatch command is used it
overrides the default of outputing the key pressed. If you want to
output the key and do something else too, use the
matched_key command. This may differ from keyman's behaviour, since keyman
does not have the matched_key command.
- ( ITEM or ITEM )*
- A successful match on either the first or second ITEM will cause the
expression to be successful. Note that the "(" and ")" are required, and that
currently ITEM may not be another (...or...) sequence. i.e.
"or" statements do not currently nest, although the syntax has been designed to
cope with this, should the interpreter ever be rewritten so that it can.
Note that for the purposes of simply matching characters,
the any() instruction is more powerful. The statement is mainly intended to
be used with the flags commands, and possibly as a way of combining any()s.
flags AND NN
, where NN is an int.
flags AND NOT NN
, where NN is an int.
flags XOR NN
, where NN is an int.