Mike Maxwell wrote:
> We would like to have some keyboard macros for inserting certain Unicode
> characters (they happen to be in the IPA and Bengali areas of Unicode,
> but later on we'll have other needs).  We're aware of the Character
> Tool, but for frequently used characters it would be useful to have
> keystrokes.

There is also command "insertCharByName", which is handy but it requires
having character entities defined in the DTD.

See
http://www.xmlmind.com/xmleditor/_distrib/doc/commands/insertCharByName.html



> As far as I can see, there isn't any existing macro for this, nor
> examples of exactly this sort of macro.  We can figure out how to do it,
> I suspect, but before taking that step wanted to see if anyone else had
> already done something like this that we could use as a starting point.
> 
> There are two ways this could be done, and both would probably be
> useful.  One way would be s.t. like Microsoft Word allows, where you
> type in the Unicode code point (s.t. like '0x9A4'), and with the cursor
> in or immediately after this, hit a key that triggers a macro to convert
> the 0x string into the corresponding Unicode character.

Here it is. Note that you really need to press F4 with the caret just
*after* something like '0x9A4'.

---
<command name="replaceCodePoint">
  <macro>
    <sequence>
      <command name="search" parameter="[bix] 0x"/>
      <get expression="xu:unescapeXML(concat('&amp;#x',
substring($selectedChars, 3), ';'))"
           xmlns:xu="java:com.xmlmind.xmledit.xmlutil.XMLUtil" />
      <command name="insertString" parameter="%_" />
    </sequence>
  </macro>
</command>

<binding>
  <keyPressed code="F4" />
  <command name="replaceCodePoint" />
</binding>
---

This macro, which requires latest version of XXE, could be made easier
to use and more robust by rewriting it in Java[tm].

If you are curious to understand how it works, see:

http://www.xmlmind.com/xmleditor/_distrib/doc/commands/search.html

http://www.xmlmind.com/xmleditor/_distrib/doc/commands/xpath_get.html

http://www.xmlmind.com/xmleditor/_distrib/doc/commands/xpath_vars.html

<TRICKY_PART>
http://www.xmlmind.com/xmleditor/_distrib/doc/commands/xpathextfunc_java.html
http://www.xmlmind.com/xmleditor/_distrib/doc/api/com/xmlmind/xmledit/xmlutil/XMLUtil.html#unescapeXML(java.lang.String)
</TRICKY_PART>

http://www.xmlmind.com/xmleditor/_distrib/doc/commands/insertString.html



> The other would be to bind a key to a particular Unicode character, so
> that Shift-Alt-T, say, inserts the 'Bengali Letter TA'.

This is very easy to implement but may be you'll quickly run out of
keystrokes. (Moreover you'll have to choose keystrokes that are not
already used by default bindings and by menu shortcuts.)

---
<binding>
  <keyPressed code="T" modifiers="shift alt" />
  <command name="insertString" parameter="&#x09A4;" />
</binding>
---

See http://www.xmlmind.com/xmleditor/_distrib/doc/commands/insertString.html


Reply via email to