WJG (8th June, 2005) I recently found details of a better way to input romanised Sanskrit and Pali using a unicode compliant font. So, here's the revised version of this code. Rather than using unique codes, it creates compounds by stacking elements. So the long semi-vowel R would be input as "r <Alt>. <Alt>-".
# -------------------------------------------------------------
# skt_input_0.1b.tcl
# Written by William J Giddings, 2005
# -------------------------------------------------------------
# Usage:
# skt_input <widget>
#
# Purpose:
# --------
# To provide text editing application with an easy access to the
# specialist characters required in romanising the Indic languages.
#
# User operation:
# ---------------
# Use combination of "Letter + Alt-Key" to obtain letters with diacritics.
#
# Notes:
# ------
# This version now uses the character stacking extensions used in Gentium.
#
# References:
# ----------
# Obtain suitable fonts from:
# http://scripts.sil.org/cms/scripts/page.php?site_id=nrsi&item_id=Gentium
#
# Extra information and resources including the excellent BabelMap Unicode viewer:
# http://www.babelstone.co.uk
#
# -------------------------------------------------------------
# Reminders
# What input method is most convenient?
# -------------------------------------------------------------
# setup custome bindings to handle input of Sanksrit
# -------------------------------------------------------------
proc {skt_input} {txt} {
bind $txt <Alt-Key-.> {
puts "%k %K"
if {[regexp [%W get insert-1char insert] {S s T t D d R r L l M m N n H h} ]} {
%W insert insert \u0323
}
}
bind $txt <Alt-Key-~> {
if {[regexp [%W get insert-1char insert] {N n} ]} {
%W insert insert \u0303
}
}
# it's a lot easier just to press the hash key
bind $txt <Alt-Key-#> {
if {[regexp [%W get insert-1char insert] {N n} ]} {
%W insert insert \u0303
}
}
bind $txt <Alt-Key-'> {
if {[regexp [%W get insert-1char insert] {S s} ]} {
%W insert insert \u0301
}
}
bind $txt <Alt-Key--> {
if {[regexp [%W get insert-1char insert] {A a I i O o U u} ]} {
%W insert insert \u0304
return
}
if {[regexp [%W get insert-2char insert-1char] {l L r R} ]} {
%W insert insert \u0304
}
}
}
# -------------------------------------------------------------
# test the code
# -------------------------------------------------------------
proc demo {} {
package require Tk
text .txt -font {{Gentium} 14}
pack .txt -fill both -expand 1
skt_input .txt
}
demoWJG (04/02/06) Just added a couple of fixes. There was no equivalent for visarga (ITRANS H) and its always a fiddle to press the shift key to get the tilde. So, added a binding for the hash to place a tilde over n (ITRANS ~N).