Jonathan, I couldn't resist, and ended up trying this out myself:

On 19/02/2013, at 3:42 PM, Igor de Oliveira Couto <i...@semperuna.com> wrote:

> For an more polished user experience, you can try developing a script that is 
> more forgiving when the user mixes upper- and lower-case 'x's, like "Cx" and 
> "cX". You can also try to develop a script that would do the replacing on 
> 'textChanged' rather than on 'closeField', but you will then have to use 'the 
> selectedChunk' and some basic maths in order not to loose the user's 
> insertion point place in the text, as you replace the characters.

I managed to get a 'quick-and-dirty' version working, already. It will still 
need to be improved quite a bit, and cover cases I haven't thought of, but it 
seems to be a good starting point. Paste this in the script of a field:

on textChanged
   local tSel
   put the selectedChunk into tSel
   set the htmlText of me to xSystemToUnicode(the htmlText of me)
   select after tSel
end textChanged

function xSystemToUnicode pHTMLTxt
   replace "cx" with "&#265;" in pHTMLTxt
   replace "cX" with "&#265;" in pHTMLTxt
   replace "Cx" with "&#264;" in pHTMLTxt
   replace "CX" with "&#264;" in pHTMLTxt
   replace "gx" with "&#285;" in pHTMLTxt
   replace "gX" with "&#285;" in pHTMLTxt
   replace "Gx" with "&#284;" in pHTMLTxt
   replace "GX" with "&#284;" in pHTMLTxt
   replace "hx" with "&#293;" in pHTMLTxt
   replace "hX" with "&#293;" in pHTMLTxt
   replace "Hx" with "&#292;" in pHTMLTxt
   replace "HX" with "&#292;" in pHTMLTxt
   replace "jx" with "&#309;" in pHTMLTxt
   replace "jX" with "&#309;" in pHTMLTxt
   replace "Jx" with "&#308;" in pHTMLTxt
   replace "JX" with "&#308;" in pHTMLTxt
   replace "sx" with "&#349;" in pHTMLTxt
   replace "sX" with "&#349;" in pHTMLTxt
   replace "Sx" with "&#348;" in pHTMLTxt
   replace "SX" with "&#348;" in pHTMLTxt
   replace "uxx" with "&#365;" in pHTMLTxt -- we don't want to have problems
   replace "uxX" with "&#365;" in pHTMLTxt -- with English words like 
'auxiliary'...
   replace "uXX" with "&#365;" in pHTMLTxt
   replace "uXx" with "&#365;" in pHTMLTxt
   replace "Uxx" with "&#364;" in pHTMLTxt
   replace "UXx" with "&#364;" in pHTMLTxt
   replace "UxX" with "&#364;" in pHTMLTxt
   replace "UXX" with "&#364;" in pHTMLTxt
   return pHTMLTxt
end xSystemToUnicode

Then, try typing a sentence in Esperanto in the field, using the x-method, such 
as:

"Mi nomigxas Jocxjo!"

The letters should automagically convert from the x-system to the proper, 
accented characters, as you type. The function above also has built-in 
'forgiveness' for mismatching the case of the 'x' - if you type an uppercase 
'C' and a lowercase 'x', it will convert it to an uppercase 'Ĉ'.

I hope this helps!

--
Igor Couto
Sydney, Australia





_______________________________________________
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode

Reply via email to