var func = domain.GetFunc (fname);
var vari;
attr = node.attributes['vname'];
- vari = attr != undefined ? domain.GetVarCreate (attr.nodeValue) : false;
+ vari = attr != undefined ? domain.GetVarCreate (attr.nodeValue) : null;
var args = Xex.Term.Parse (domain, node.firstElement (), null);
return new Xex.Funcall (func, vari, args);
}
proto.Clone = function () { return new Xex.StrTerm (this.val); }
proto.Parser = function (domain, node)
{
- return new Xex.StrTerm (node.firstChild.nodeValue);
+ return new Xex.StrTerm (node.firstChild ? node.firstChild.nodeValue : '');
}
Xex.StrTerm.prototype = proto;
}) ();
return args[0];
}
+ function Fnot (domain, vari, args)
+ {
+ return (args[0].IsTrue () ? Xex.Zero : Xex.One);
+ }
+
function maybe_set_intvar (vari, n)
{
var term = new Xex.IntTerm (n);
return maybe_set_intvar (vari, n);
}
+ function Flogand (domain, vari, args)
+ {
+ var n, i;
+ if (vari == null)
+ {
+ Xex.Log ("logand arg args[0]" + args[0]);
+ n = args[0].Intval ()
+ i = 1;
+ }
+ else
+ {
+ Xex.Log ("logand arg var " + vari);
+ n = vari.val.Intval ();
+ i = 0;
+ }
+ while (n > 0 && i < args.length)
+ {
+ Xex.Log ("logand arg " + args[i]);
+ n &= args[i++].val;
+ }
+ return maybe_set_intvar (vari, n);
+ }
+
+ function Flsh (domain, vari, args)
+ {
+ return maybe_set_intvar (vari, args[0].Intval () << args[1].Intval ());
+ }
+
+ function Frsh (domain, vari, args)
+ {
+ return maybe_set_intvar (vari, args[0].Intval () >> args[1].Intval ());
+ }
+
function Fand (domain, vari, args)
{
var len = args.length;
return Xex.One;
}
+ function Fnoteq (domain, vari, args)
+ {
+ return (Feq (domain, vari, args) == Xex.One ? Xex.Zero : Xex.One);
+ }
+
function Flt (domain, vari, args)
{
- var n = args[0].Intval;
+ var n = args[0].Intval ();
for (var i = 1; i < args.length; i++)
{
- var n1 = args[i].Intval;
+ var n1 = args[i].Intval ();
if (n >= n1)
return Xex.Zero;
n = n1;
function Fle (domain, vari, args)
{
- var n = args[0].Intval;
+ var n = args[0].Intval ();
for (var i = 1; i < args.length; i++)
{
- var n1 = args[i].Intval;
+ var n1 = args[i].Intval ();
if (n > n1)
return Xex.Zero;
n = n1;
function Fgt (domain, vari, args)
{
- var n = args[0].Intval;
+ var n = args[0].Intval ();
for (var i = 1; i < args.length; i++)
{
- var n1 = args[i].Intval;
+ var n1 = args[i].Intval ();
if (n <= n1)
return Xex.Zero;
n = n1;
function Fge (domain, vari, args)
{
- var n = args[0].Intval;
+ var n = args[0].Intval ();
for (var i = 1; i < args.Length; i++)
{
- var n1 = args[i].Intval;
+ var n1 = args[i].Intval ();
if (n < n1)
return Xex.Zero;
n = n1;
basic.DefSubr (Fset, "set", true, 1, 1);
basic.DefAlias ("=", "set");
- //basic.DefSubr (Fnot, "not", false, 1, 1);
- //basic.DefAlias ("!", "not");
+ basic.DefSubr (Fnot, "not", false, 1, 1);
+ basic.DefAlias ("!", "not");
basic.DefSubr (Fadd, "add", true, 1, -1);
basic.DefSubr (Fmul, "mul", true, 1, -1);
basic.DefAlias ("*", "mul");
basic.DefAlias ("%", "mod");
basic.DefSubr (Flogior, "logior", true, 1, -1);
basic.DefAlias ('|', "logior");
- //basic.DefSubr (Flogand, "logand", true, 1, -1);
- //basic.DefAlias ("&", "logand");
- //basic.DefSubr (Flsh, "lsh", true, 1, 2);
- //basic.DefAlias ("<<", "lsh");
- //basic.DefSubr (Frsh, "rsh", true, 1, 2);
- //basic.DefAlias (">>", "rsh");
+ basic.DefSubr (Flogand, "logand", true, 1, -1);
+ basic.DefAlias ("&", "logand");
+ basic.DefSubr (Flsh, "lsh", true, 1, 2);
+ basic.DefAlias ("<<", "lsh");
+ basic.DefSubr (Frsh, "rsh", true, 1, 2);
+ basic.DefAlias (">>", "rsh");
basic.DefSubr (Feq, "eq", false, 2, -1);
basic.DefAlias ("==", "eq");
- //basic.DefSubr (Fnoteq, "noteq", false, 2, 2);
- //basic.DefAlias ("!=", "noteq");
+ basic.DefSubr (Fnoteq, "noteq", false, 2, 2);
+ basic.DefAlias ("!=", "noteq");
basic.DefSubr (Flt, "lt", false, 2, -1);
basic.DefAlias ("<", "lt");
basic.DefSubr (Fle, "le", false, 2, -1);
{
this.key;
this.has_modifier = false;
- if (typeof val == 'string' || val instanceof String)
+ if (val instanceof Xex.Term)
+ this.key = val.val;
+ else if (typeof val == 'string' || val instanceof String)
{
this.key = decode_keysym (val);
if (! this.key)
var len = seq.val.length;
for (var i = 0; i < len; i++)
{
- var v = seq.val[i];
- if (v.type != 'string' && v.type != 'integer'
- && v.type != 'symbol')
+ var v = seq.val[i], key;
+ if (v.type == 'symbol' || v.type == 'string')
+ key = new MIM.Key (v);
+ else if (v.type == 'integer')
+ key = new MIM.Key (v.val);
+ else
throw new Xex.ErrTerm (MIM.Error.ParseError,
"Invalid key: " + v);
- var key = new MIM.Key (v.val);
this.val.push (key);
if (key.has_modifier)
this.has_modifier = true;
var n = predefined[name];
if (n)
return n;
- if (name.charAt (1) == '-')
+ if (name.charAt (1) == '-' || name.charAt (1) == '+')
return new MIM.SurroundMarker (name);
throw new Xex.ErrTerm (MIM.Error.ParseError,
"Invalid marker: " + name);
{
var ic = domain.context;
var gsize = domain.variables['candidates_group_size'];
- var candidates = new MIM.Candidates (args, gsize ? gsize.Intval : 0);
+ var candidates = new MIM.Candidates (args, gsize ? gsize.Intval () : 0);
ic.ins (candidates.Current (), candidates);
return args[0];
}
function Fdelete (domain, vari, args)
{
var ic = domain.context;
- var pos = args[0].IsInt ? args[0].Intval : args[0].Position (ic);
+ var pos = args[0].IsInt ? args[0].Intval () : args[0].Position (ic);
return new Xex.IntTerm (ic.del (pos));
}
return args[0];
}
+ function Fshow (domain, vari, args)
+ {
+ domain.context.candidate_show = true;
+ domain.context.changed |= MIM.ChangedStatus.CandidateShow;
+ return Xex.nil;
+ }
+
+ function Fhide (domain, vari, args)
+ {
+ domain.context.candidate_show = false;
+ domain.context.changed |= MIM.ChangedStatus.CandidateShow;
+ return Xex.nil;
+ }
+
function Fchar_at (domain, vari, args)
{
return new Xex.IntTerm (args[0].CharAt (domain.context));
return args[0];
}
+ function Fpop (domain, vari, args)
+ {
+ var ic = domain.context;
+ if (ic.key_head < ic.keys.val.length)
+ ic.keys.val.splice (ic.keys_head, 1);
+ return Xex.nil;
+ }
+
function Fundo (domain, vari, args)
{
var ic = domain.context;
return args[0];
}
+ function Fshiftback (domain, vari, args)
+ {
+ domain.context.shift (null);
+ return Xex.nil;
+ }
+
+ function Fkey_count (domain, vari, args)
+ {
+ return new Xex.IntTerm (domain.context.key_head);
+ }
+
function Fsurrounding_flag (domain, vari, args)
{
return new Xex.IntTerm (-1);
im_domain.DefSubr (Finsert_candidates, "insert-candidates", false, 1, 1);
im_domain.DefSubr (Fdelete, "delete", false, 1, 1);
im_domain.DefSubr (Fselect, "select", false, 1, 1);
- //im_domain.DefSubr (Fshow, "show-candidates", false, 0, 0);
- //im_domain.DefSubr (Fhide, "hide-candidates", false, 0, 0);
+ im_domain.DefSubr (Fshow, "show-candidates", false, 0, 0);
+ im_domain.DefSubr (Fhide, "hide-candidates", false, 0, 0);
im_domain.DefSubr (Fmove, "move", false, 1, 1);
im_domain.DefSubr (Fmark, "mark", false, 1, 1);
im_domain.DefSubr (Fpushback, "pushback", false, 1, 1);
- //im_domain.DefSubr (Fpop, "pop", false, 0, 0);
+ im_domain.DefSubr (Fpop, "pop", false, 0, 0);
im_domain.DefSubr (Fundo, "undo", false, 0, 1);
im_domain.DefSubr (Fcommit, "commit", false, 0, 0);
im_domain.DefSubr (Funhandle, "unhandle", false, 0, 0);
im_domain.DefSubr (Fshift, "shift", false, 1, 1);
- //im_domain.DefSubr (Fshiftback, "shiftback", false, 0, 0);
+ im_domain.DefSubr (Fshiftback, "shiftback", false, 0, 0);
im_domain.DefSubr (Fchar_at, "char-at", false, 1, 1);
- //im_domain.DefSubr (Fkey_count, "key-count", false, 0, 0);
+ im_domain.DefSubr (Fkey_count, "key-count", false, 0, 0);
im_domain.DefSubr (Fsurrounding_flag, "surrounding-text-flag", false, 0, 0);
}) ();
ic.candidate_table.clear ();
ic.candidates = null;
ic.changed |= (MIM.ChangedStatus.Preedit | MIM.ChangedStatus.CursorPos
- | ChangedStatus.CandidateList
- | ChangedStatus.CandidateIndex
- | ChangedStatus.CandidateShow);
+ | MIM.ChangedStatus.CandidateList
+ | MIM.ChangedStatus.CandidateIndex
+ | MIM.ChangedStatus.CandidateShow);
}
function set_cursor (prefix, pos)
proto = {
reset: function ()
{
+ Xex.Log ('reseting ' + this.im.lang);
this.cursor_pos = 0;
this.candidate_show = false;
this.prev_state = null;
else if (key.match(/^U\+([0-9A-Z]+)$/))
{
if (mod.length == 0)
- return;
+ return false;
key = String.fromCharCode (parseInt (RegExp.$1, 16));
}
else
if (ic.key)
{
Xex.Log ("filtering " + ic.key);
- var result = ic.Filter (ic.key);
+ try {
+ var result = ic.Filter (ic.key);
+ } catch (e) {
+ Xex.Log ('Error;' + e);
+ throw (e);
+ }
MIM.update (target, ic);
if (! ic.key_unhandled)
event.preventDefault ();
}
Xex.Log ("filtering " + ic.key);
- var result = ic.Filter (ic.key);
+ try {
+ var result = ic.Filter (ic.key);
+ } catch (e) {
+ Xex.Log ('Error;' + e);
+ throw (e);
+ }
MIM.update (target, ic);
if (! ic.key_unhandled)
event.preventDefault ();