|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--guk.editIM.AssignObject
Helper class to represent keystroke sequence to glyph sequence assignments. Supports various import/export formats and is the main cleverness part for highlighting and file read write functionality. 2003 by Eric Auer.
Field Summary | |
static int |
ASCII_HTML
As UNICODE_HTML, but only uses ISO-8859-1 characters. |
static int |
ASCII_HUMAN
As UNICODE_HUMAN, but only uses ISO-8859-1 characters. |
(package private) static java.awt.Canvas |
canvas
key events need some non-null component as origin, we use this canvas for that. |
(package private) java.lang.String |
comments
Here we store comments |
static boolean |
FONTbyTAG
set to true to enable the use of HTML font name tags |
static int |
GIM_FILE
THE important format for importing and exporting .gim files (GUK IM keymaps). |
(package private) java.lang.String |
glyphs
Here we keep our glyph sequence |
(package private) java.lang.String |
htmlFooter
|
(package private) java.lang.String |
htmlHeader
Used for creating HTML locally. |
(package private) KeyStrokeParser |
htmlizer
used as an HTML highlighting helper for the HTML modes. |
(package private) java.util.List |
keys
Here we keep our keystroke sequence |
static int |
U8_FILE
The ad-hoc file format that MPI IM keymaps use. |
static int |
UNICODE_HTML
Basically as UNICODE_HUMAN, but uses HTML for highlighting. |
static int |
UNICODE_HUMAN
Ad hoc format for human readers. |
static int |
XGIM_FILE
A possible future expansion of GIM where \\k+pressed HOME+ and similar things are allowed. |
static int |
YUDIT_FILE
The keymap data format of Yudit. |
Constructor Summary | |
AssignObject()
The constructor creates a new empty object. |
|
AssignObject(java.awt.Font font)
The constructor creates a new empty object (now with Font setting, which affects the HTML generation, if the FONTbyTAG flag is on). |
Method Summary | |
static java.util.List |
escapedStringToKeys(java.lang.String str,
boolean xgim)
Helper method to generate a List of KeyEvents from a String describing them. |
static java.lang.String |
escapeGlyph(char ch)
Helper method to convert a char to an escaped \\u1234 string. |
static java.lang.String |
escapeString(java.lang.String str,
boolean html)
Obvious function returning the string with all non- ASCII-printables replaced by \\u1234 form or \\n. |
static java.lang.String |
escapeToHTML(char ch)
Helper to convert a char to HTML only when needed. |
java.lang.String |
exportGlyphs(int format)
Export the glyph part in a certain format. |
java.lang.String |
exportKeys(int format)
Export the key part in a certain format. |
java.lang.String |
exportString(int format)
Export the whole object in a certain format. |
java.lang.String |
getComments()
obvious function returning the comments |
java.lang.String |
getGlyphs()
obvious function returning the glyphs |
java.util.Collection |
getKeys()
obvious function returning Iterator for keys |
void |
importGlyphs(java.lang.String str,
int format)
Import glyphs (no multiple choice! no GIM digit toggle!) in given format. |
void |
importKeys(java.lang.String str,
int format)
Import keys from string in given format, including COMMENTS if at end of line. |
void |
importString(java.lang.String str,
int format)
Main method to read one line of data from a file. |
static java.lang.String |
keyToString(java.awt.event.KeyEvent key,
boolean escapeUnicode)
Helper function to convert a key event into a string. |
static java.lang.String |
parseYuditEscapes(java.lang.String str)
Helper method to replace all numbers by their glyphs (hex, octal and dec) and removes whitespace. |
void |
setComments(java.lang.String comS)
obvious function setting the comments |
void |
setGlyphs(java.lang.String glyS)
obvious function setting the glyphs |
void |
setKeys(java.util.Collection keyColl)
obvious function setting the keys |
static java.util.List |
stringToKeys(java.lang.String str)
Helper method to translate a String into something that will type that String, in form of a KeyEvent Vector. |
static java.lang.String |
toHex(int i)
Helper method to convert an int to an 0x1234 fixed length string. |
java.lang.String |
toString()
We override toString(), of course. |
static java.awt.event.KeyEvent |
typedKeyEvent(char ch,
int modifiers)
Helper method to create simple typed KeyEvents. |
static java.lang.String |
unEscape(java.lang.String str)
Helper method to replace all \\u1234 by their glyphs and all \\\\ and \\r and \\n and \\- as well. |
Methods inherited from class java.lang.Object |
|
Field Detail |
public static final int UNICODE_HUMAN
public static final int ASCII_HUMAN
public static final int UNICODE_HTML
public static final int ASCII_HTML
public static final int GIM_FILE
public static final int XGIM_FILE
public static final int U8_FILE
public static final int YUDIT_FILE
KeyStrokeParser htmlizer
public static final boolean FONTbyTAG
java.lang.String htmlHeader
java.lang.String htmlFooter
java.util.List keys
static java.awt.Canvas canvas
java.lang.String glyphs
java.lang.String comments
Constructor Detail |
public AssignObject()
public AssignObject(java.awt.Font font)
font
- A Font to be mentioned in a font
name HTML tag if FONTbyTAG is configured as true.Method Detail |
public java.lang.String getGlyphs()
public java.util.Collection getKeys()
public java.lang.String getComments()
public void setComments(java.lang.String comS)
public void setGlyphs(java.lang.String glyS)
public void setKeys(java.util.Collection keyColl)
public static java.lang.String escapeGlyph(char ch)
public static java.lang.String escapeToHTML(char ch)
ch
- An arbitrary Unicode character.public static java.lang.String toHex(int i)
public static java.lang.String escapeString(java.lang.String str, boolean html)
str
- The string to be escapedhtml
- If true, create HTML Ӓ escapes,
otherwise create \\u1234 escapes visible to the user.
Also escapes HTML chars (quotes, lt, gt, amp) in HTML
mode.public static java.lang.String keyToString(java.awt.event.KeyEvent key, boolean escapeUnicode)
key
- A key event that should be stringified.escapeUnicode
- Set this if you want characters beyond
ISO-8859-1 to be escaped.public java.lang.String toString()
toString
in class java.lang.Object
public java.lang.String exportString(int format) throws java.lang.UnsupportedOperationException
format
- One of the constant values of this class.
Some formats may not allow all features to be exported.java.lang.UnsupportedOperationException
- Whenever some
feature cannot be exported, an exception is thrown (and
nothing is returned). The exception contains the error message.public java.lang.String exportGlyphs(int format) throws java.lang.UnsupportedOperationException
format
- One of the constant values of this class.
Some formats may not allow all features to be exported.java.lang.UnsupportedOperationException
- Whenever some
feature cannot be exported, an exception is thrown (and
nothing is returned). The exception contains the error message.public java.lang.String exportKeys(int format) throws java.lang.UnsupportedOperationException
format
- One of the constant values of this class.
Some formats may not allow all features to be exported.java.lang.UnsupportedOperationException
- Whenever some
feature cannot be exported, an exception is thrown (and
nothing is returned). The exception contains the error message.
Only GIM can handle Ctrl and Alt, and only XGIM can handle
even more complicated key events.public static java.lang.String unEscape(java.lang.String str)
str
- A string possibly containing escapes.public static java.lang.String parseYuditEscapes(java.lang.String str)
A
- string with text and numbers, separated by
whitespace.public static java.util.List stringToKeys(java.lang.String str)
str
- An Unicode string for which key events will be
generated.public static java.awt.event.KeyEvent typedKeyEvent(char ch, int modifiers) throws java.lang.UnsupportedOperationException
ch
- The character which the event should type.modifiers
- The modifiers, as defined for KeyEvent objects,
representing things like shift states.java.lang.UnsupportedOperationException
- If no translation into
a key event can be found, an exception is thrown (which will
contain a simple error message).public static java.util.List escapedStringToKeys(java.lang.String str, boolean xgim)
str
- A string of glyphs, possibly enriched with special
escapes like the C- prefix for Ctrl. See the other parsing
methods for details.xgim
- Only when this is true, XGIM style escapes are
allowed.java.lang.UnsupportedOperationException
- When the string cannot
be parsed or contains XGIM escapes while xgim is false, an
exception with a detailed error message is thrown.public void importString(java.lang.String str, int format) throws java.lang.UnsupportedOperationException
str
- A string, typically a line of text from the body of
a keymap file in the selected format.format
- One of the format constants of this class,
selecting which file format the parser has to process.java.lang.UnsupportedOperationException
- Whenever something turns
out to be unparseable or unstorable here or in one of the helper
methods, an exception with a detailed error message is thrown.public void importGlyphs(java.lang.String str, int format) throws java.lang.UnsupportedOperationException
str
- A string containing only one glyph string and no
comments, in the selected format. When there are choices
like U8 choice lists or GIM digit (choice between 2), you
have to split them into several single values yourself
before calling this.format
- One of the format constants of this class,
selecting which file format the parser has to process.java.lang.UnsupportedOperationException
- Whenever something turns
out to be unparseable or unstorable here or in one of the helper
methods, an exception with a detailed error message is thrown.public void importKeys(java.lang.String str, int format) throws java.lang.UnsupportedOperationException
str
- A string containing a key sequence description
in the selected format. No keywords or quotes are allowed, and
this is not recommended to use this for FILES. However,
this IS recommended for importing user input that should
become a new key sequence. Notice that no error will be
thrown if you accidentally include additional text like
keywords or quotes: It will become part of the key sequence.format
- One of the format constants of this class,
selecting which file format the parser has to process.java.lang.UnsupportedOperationException
- Whenever something turns
out to be unparseable or unstorable here or in one of the helper
methods, an exception with a detailed error message is thrown.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |