/* Copyright (C) 2003, 2004, 2005 National Institute of Advanced Industrial Science and Technology (AIST) Registration Number H15PRO112 See the end for copying conditions. */ /***en @page mdbIM Input Method @section im-description DESCRIPTION The m17n library provides a driver for input methods that are dynamically loadable from the m17n database (see @ref m17nInputMethod @latexonly (P.\pageref{group__m17nInputMethod}) @endlatexonly). This section describes the data format that defines those input methods. @section im-format SYNTAX and SEMANTICS The following data format defines an input method. The driver loads a definition from a file, a stream, etc. The definition is converted into the form of plist in the driver. @verbatim INPUT-METHOD ::= IM-DECLARATION ? IM-DESCRIPTION ? TITLE ? VARIABLE-LIST ? COMMAND-LIST ? MODULE-LIST ? MACRO-LIST ? MAP-LIST ? STATE-LIST ? IM-DECLARATION ::= '(' 'input-method' LANGUAGE NAME EXTRA-ID ? VERSION ? ')' LANGUAGE ::= SYMBOL NAME ::= SYMBOL EXTRA-ID ::= SYMBOL VERSION ::= '(' 'version' VERSION-NUMBER ')' IM-DESCRIPTION ::= '(' 'description' DESCRIPTION ')' DESCRIPTION ::= MTEXT-OR-GETTEXT | 'nil' MTEXT-OR-GETTEXT ::= [ MTEXT | '(' '_' MTEXT ')'] TITLE ::= '(' 'title' TITLE-TEXT ')' TITLE-TEXT ::= MTEXT VARIABLE-LIST ::= '(' 'variable' VARIABLE-DECLARATION * ')' VARIABLE-DECLARATION ::= '(' VAR-NAME [ DESCRIPTION VALUE VALUE-CANDIDATE * ]')' VAR-NAME ::= SYMBOL VALUE ::= MTEXT | SYMBOL | INTEGER VALUE-CANDIDATE ::= VALUE | '(' RANGE-FROM RANGE-TO ')' RANGE-FROM ::= INTEGER RANGE-TO ::= INTEGER COMMAND-LIST ::= '(' 'command' COMMAND-DECLARATION * ')' COMMAND-DECLARATION ::= '(' CMD-NAME [ DESCRIPTION KEYSEQ * ] ')' CMD-NAME ::= SYMBOL @endverbatim @c IM-DECLARATION specifies the language and name of this input method. When @c LANGUAGE is @c t, the use of the input method is not limited to one language. When @c NAME is @c nil, the input method is not standalone, but is expected to be used in other input methods. In such cases, @c EXTRA-ID is required to identify the input method. @c VERSION specifies the required minimum version number of the m17n library. The format is "XX.YY.ZZ" where XX is a major version number, YY is a minor version number, and ZZ is a patch level. @c DESCRIPTION, if not nil, specifies the description text of an input method, a variable or a command. If @c MTEXT-OR-GETTEXT takes the second form, the text is translated according to the current locale by "gettext" (if the translation is provided). @c TITLE-TEXT is a text displayed on the screen when this input method is active. There is one special input method file "global.mim" that declares common variables and commands. The input method driver always loads this file and other input methods can inherit the variables and the commands. @c VARIABLE-DECLARATION declares a variable used in this input method. If a variable must be initialized to the default value, or is to be customized by a user, it must be declared here. The declaration can be used in two ways. One is to introduce a new variable. In that case, @c VALUE must not be omitted. Another is to inherit the variable from what declared in "global.mim", and to give the different default value and/or to make the variable customizable specially for the current input method. In the latter case, @c VALUE can be omitted. @c COMMAND-DECLARATION declares a command used in this input method. If a command must be bound to the default key sequence, or is to be customized by a user, it must be declared here. Like @c VARIABLE-DECLARATION, the declaration can be used in two ways. One is to introduce a new command. In that case, @c KEYSEQ must not be omitted. Another is to inherit the command from what declared in "global.mim", and to give the different key binding and/or to make the command customizable specially for the current input method. In the latter case, @c KEYSEQ can be omitted. @verbatim MODULE-LIST ::= '(' 'module' MODULE * ')' MODULE ::= '(' MODULE-NAME FUNCTION * ')' MODULE-NAME ::= SYMBOL FUNCTION ::= SYMBOL @endverbatim Each @c MODULE declares the name of an external module (i.e. dynamic library) and function names exported by the module. If a @c FUNCTION has name "init", it is called with only the default arguments (see the section about @c CALL) when an input context is created for the input method. If a @c FUNCTION has name "fini", it is called with only the default arguments when an input context is destroyed. @verbatim MACRO-LIST ::= MACRO-INCLUSION ? '(' 'macro' MACRO * ')' MACRO-INCLUSION ? MACRO ::= '(' MACRO-NAME MACRO-ACTION * ')' MACRO-NAME ::= SYMBOL MACRO-ACTION ::= ACTION TAGS ::= `(` LANGUAGE NAME EXTRA-ID ? `)` MACRO-INCLUSION ::= '(' 'include' TAGS 'macro' MACRO-NAME ? ')' @endverbatim @c MACRO-INCLUSION includes macros from another input method specified by @c TAGS. When @c MACRO-NAME is not given, all macros from the input method are included. @verbatim MAP-LIST ::= MAP-INCLUSION ? '(' 'map' MAP * ')' MAP-INCLUSION ? MAP ::= '(' MAP-NAME RULE * ')' MAP-NAME ::= SYMBOL RULE ::= '(' KEYSEQ MAP-ACTION * ')' KEYSEQ ::= MTEXT | '(' [ SYMBOL | INTEGER ] * ')' MAP-INCLUSION ::= '(' 'include' TAGS 'map' MAP-NAME ? ')' @endverbatim When an input method is never standalone and always included in another method, @c MAP-LIST can be omitted. @c SYMBOL in the definitions of @c MAP-NAME must not be @c t nor @c nil. @c MTEXT in the definition of @c KEYSEQ consists of characters that can be generated by a keyboard. Therefore @c MTEXT usually contains only ASCII characters. However, if the input method is intended to be used, for instance, with a West European keyboard, @c MTEXT may contain Latin-1 characters. @c SYMBOL in the definition of @c KEYSEQ must be the return value of the minput_event_to_key () function. Under the X window system, you can quickly check the value using the @c xev command. For example, the return key, the backspace key, and the 0 key on the keypad are represented as @c (Return) , @c (BackSpace) , and @c (KP_0) respectively. If the shift, control, meta, alt, super, and hyper modifiers are used, they are represented by the S- , C- , M- , A- , s- , and H- prefixes respectively in this order. Thus, "return with shift with meta with hyper" is @c (S-M-H-Return) . Note that "a with shift" .. "z with shift" are represented simply as A .. Z . Thus "a with shift with meta with hyper" is @c (M-H-A) . @c INTEGER in the definition of @c KEYSEQ must be a valid character code. @c MAP-INCLUSION includes maps from another input method specified by @c TAGS. When @c MAP-NAME is not given, all maps from the input method are included. @verbatim MAP-ACTION ::= ACTION ACTION ::= INSERT | DELETE | SELECT | MOVE | MARK | SHOW | HIDE | PUSHBACK | POP | UNDO | COMMIT | UNHANDLE | SHIFT | CALL | SET | IF | COND | '(' MACRO-NAME ')' PREDEFINED-SYMBOL ::= '@0' | '@1' | '@2' | '@3' | '@4' | '@5' | '@6' | '@7' | '@8' | '@9' | '@<' | '@=' | '@>' | '@-' | '@+' | '@[' | '@]' | '@@' | '@-0' | '@-N' | '@+N' @endverbatim @verbatim STATE-LIST ::= STATE-INCUSION ? '(' 'state' STATE * ')' STATE-INCUSION ? STATE ::= '(' STATE-NAME [ STATE-TITLE-TEXT ] BRANCH * ')' STATE-NAME ::= SYMBOL STATE-TITLE-TEXT ::= MTEXT BRANCH ::= '(' MAP-NAME BRANCH-ACTION * ')' | '(' 'nil' BRANCH-ACTION * ')' | '(' 't' BRANCH-ACTION * ')' STATE-INCLUSION ::= '(' 'include' TAGS 'state' STATE-NAME ? ')' @endverbatim When an input system is never standalone and always included in another system, @c STATE-LIST can be omitted. @c STATE-INCLUSION includes states from another input method specified by @c TAGS. When @c STATE-NAME is not given, all states from the input method are included. The optional @c STATE-TITLE-TEXT specifies a title text displayed on the screen when the input method is in this state. If @c STATE-TITLE-TEXT is omitted, @c TITLE-TEXT is used. In the first form of @c BRANCH, @c MAP-NAME must be an item that appears in @c MAP. In this case, if a key sequence matching one of @c KEYSEQs of @c MAP-NAME is typed, @c BRANCH-ACTIONs are executed. In the second form of @c BRANCH, @c BRANCH-ACTIONs are executed if a key sequence that doesn't match any of @c Branch's of the current state is typed. If there is no @c BRANCH beginning with @c nil and the typed key sequence does not match any of the current @c BRANCHs, the input method transits to the initial state. In the third form of @c BRANCH, @c BRANCH-ACTIONs are executed when shifted to the current state. If the current state is the initial state, @c BRANCH-ACTIONs are executed also when an input context of the input method is created. @verbatim BRANCH-ACTION ::= ACTION @endverbatim An input method has the following two lists of symbols. Each @c PREDEFINED-SYMBOL has a special meaning when used as a marker. Some of the @c PREDEFINED-SYMBOL has a special meaning when used as a candidate index in the @c SELECT action. And, this also has a special meaning. These are for supporting surround text handling.