//----------------------------------------------------------------------------
// COMPONENT NAME: LPEX Editor
//
// © Copyright IBM Corporation 2008
// All Rights Reserved.
//
// DESCRIPTION:
// ComposeHebrewAction - sample user-defined action (composeHebrew)
//----------------------------------------------------------------------------
package com.ibm.lpex.samples;
import com.ibm.lpex.core.LpexAction;
import com.ibm.lpex.core.LpexCommand;
import com.ibm.lpex.core.LpexStringTokenizer;
import com.ibm.lpex.core.LpexView;
/**
* Sample action <b>composeHebrew</b> - enter Hebrew characters.
* Use this action to enter Hebrew characters into a document using
* a non-Hebrew keyboard. For example, enter alef by typing a.
* The mapping table used is a quirky, very rough transliteration.
*
* <p>Here is the ComposeHebrewAction
* <a href="doc-files/ComposeHebrewAction.java.html">source code</a>.</p>
*
* <p>To run this sample:
* <ul>
* <li>Define this user action via an editor preference page, where available,
* or from the editor command line:
* <pre>set actionClass.composeHebrew com.ibm.lpex.samples.ComposeHebrewAction</pre></li>
* <li>Run it from the editor command line:
* <pre>action composeHebrew</pre>
* or associate it with a key (here, <b>Alt+F1</b> in the text and command area):
* <pre>set keyAction.a-f1.t.c composeHebrew</pre></li>
* </ul></p>
* See the <a href="doc-files/ComposeHebrewAction.java.html#line47">source code</a>
* for the character mapping. To see these characters in the document, you may need
* a Hebrew-locale or Unicode font installed on your system. The document must be
* saved to an encoding which supports Hebrew characters.
*
* @see com.ibm.lpex.samples All the samples
*/
public class ComposeHebrewAction extends ComposeAction
{
private static final String[] _composeHebrew =
/*-----------------------------------------------------------*/
/* Hebrew characters supported and their compose sequences */
/*-----------------------------------------------------------*/
// Hebrew letter Latin
// ============= =====
{"\u05D0", "a", // alef a
"\u05E2", "A", // ayin A
"\u05D1", "b", // bet b
"\u05D1", "B", // bet B
"\u05DB", "c", // kaf c
"\u05DA", "C", // final kaf C
"\u05D3", "d", // dalet d
"\u05D3", "D", // dalet D
"\u05D0", "e", // alef e
"\u05D0", "E", // alef E
"\u05E4", "f", // pe f
"\u05E3", "F", // final pe F
"\u05D2", "g", // gimel g
"\u05D2", "G", // gimel G
"\u05D4", "h", // he h
"\u05D7", "H", // het H
"\u05D9", "i", // yod i
"\u05D9", "I", // yod I
"\u05D9", "j", // yod j
"\u05D9", "J", // yod J
"\u05DB", "k", // kaf k
"\u05DA", "K", // final kaf K
"\u05DC", "l", // lamed l
"\u05DC", "L", // lamed L
"\u05DE", "m", // mem m
"\u05DD", "M", // final mem M
"\u05E0", "n", // nun n
"\u05DF", "N", // final nun N
"\u05D5", "o", // vav o
"\u05D5", "O", // vav O
"\u05E4", "p", // pe p
"\u05E3", "P", // final pe P
"\u05E7", "q", // qof q
"\u05E7", "Q", // qof Q
"\u05E8", "r", // resh r
"\u05E8", "R", // resh R
"\u05E1", "s", // samekh s
"\u05E1", "S", // samekh S
"\u05EA", "t", // tav t
"\u05D8", "T", // tet T
"\u05D5", "u", // vav u
"\u05D5", "U", // vav U
"\u05D5", "v", // vav v
"\u05D5", "V", // vav V
"\u05E9", "w", // shin w
"\u05E9", "W", // shin W
"\u05D7", "x", // het x
"\u05D7", "X", // het X
"\u05E6", "y", // tsadi y
"\u05E5", "Y", // final tsadi Y
"\u05D6", "z", // zayin z
"\u05D6", "Z", // zayin Z
// Hebrew point compose sequence
"\\","\\\\", // ============ ================
"\u05B7", "\\a", // patah BACKSLASH (\) + a
"\u05B7", "\\-", // patah BACKSLASH (\) + MINUS (-)
"\u05B8", "\\A", // qamats [gadol] BACKSLASH (\) + A
"\u05B8", "\\t", // qamats [gadol] BACKSLASH (\) + t
"\u05B8", "\\T", // qamats [gadol] BACKSLASH (\) + T
"\u05BC", "\\d", // dagesh (shuruq) BACKSLASH (\) + d
"\u05BC", "\\D", // dagesh (shuruq) BACKSLASH (\) + D
"\u05B5", "\\e", // tsere BACKSLASH (\) + e
"\u05B6", "\\E", // segol BACKSLASH (\) + E
"\u05B4", "\\i", // hiriq BACKSLASH (\) + i
"\u05B4", "\\I", // hiriq BACKSLASH (\) + I
"\u05B4", "\\.", // hiriq BACKSLASH (\) + PERIOD (.)
"\u05B9", "\\o", // holam BACKSLASH (\) + o
"\u05BA", "\\O", // holam haser for vav BACKSLASH (\) + O
"\u05BB", "\\u", // qubuts BACKSLASH (\) + u
"\u05BB", "\\U", // qubuts BACKSLASH (\) + U
"\u05C1", "\\w", // shin dot BACKSLASH (\) + w
"\u05C2", "\\W", // sin dot BACKSLASH (\) + W
"\u05B0", "\\:", // shva BACKSLASH (\) + COLON (:)
"\u05B0", "\\;" // shva BACKSLASH (\) + SEMICOLON (;)
};
// NOTES: points usually modify the preceding letter; the escaped backslash allows
// to enter normal backslashes in the sequence text (it's found before all others).
/**
* Command to map regular Latin characters to Hebrew characters. Called by the
* <b>input</b> editor command when prompting for the sequence to 'transliterate'.
*/
public static LpexCommand composeHebrewCommand = new LpexCommand() {
public boolean doCommand(LpexView lpexView, String parameters) {
return doComposeCommand(lpexView, parameters, _composeHebrew, "composeHebrew", true);
}
};
/**
* Runs the action.
* Prompts the user for a sequence to 'transliterate', then enters the (mapped
* Hebrew) character(s) into the document. Uses the <b>input</b> default editor
* command, and the <b>composeHebrew</b> command defined in here.
*/
public void doAction(LpexView lpexView)
{
// ensure command to handle composition is defined in the view this action runs
if (lpexView.command("composeHebrew") != composeHebrewCommand)
{
lpexView.defineCommand("composeHebrew", composeHebrewCommand);
}
// prompt user for the text, insert 'transliterated' result
promptForCompose(lpexView, "composeHebrew");
}
}