var Xex = {
LogNode: null,
- Log: function (indent, arg)
+ Log: function (arg, indent)
{
if (! Xex.LogNode)
return;
var str = '';
- for (var i = 0; i < indent; i++)
- str += ' ';
+ if (indent != undefined)
+ for (var i = 0; i < indent; i++)
+ str += ' ';
Xex.LogNode.value = str + arg + "\n" + Xex.LogNode.value;
}
};
Xex.Subrountine.prototype.Call = function (domain, vari, args)
{
- newargs = new Array ();
+ var newargs = new Array ();
for (var i = 0; i < args.length; i++)
{
newargs[i] = args[i].Eval (domain);
{
if (! this.vari || this.vari.domain != domain)
this.vari = domain.GetVarCreate (this.val);
- Xex.Log (domain.depth, this.ToString () + '=>' + this.vari.val);
+ Xex.Log (this.ToString () + '=>' + this.vari.val, domain.depth);
return this.vari.val;
}
proto.Eval = function (domain)
{
- Xex.Log (domain.depth++, this);
+ Xex.Log (this, domain.depth++);
var result;
try {
result = this.func.Call (domain, this.vari, this.args);
} finally {
- Xex.Log (--domain.depth, this + ' => ' + result);
+ Xex.Log (this + ' => ' + result, --domain.depth);
}
return result;
}
if (len == 0)
return str + '/>';
for (var i = 0; i < len; i++)
- arglist += this.args[i].toString ();
+ arglist += '.'; //this.args[i].toString ();
return str + '>' + arglist + '</' + this.func.name + '>';
}
function Fset (domain, vari, args)
{
- return vari.SetValue (args[0]);
- }
-
- function maybe_set_intvar (vari, n)
- {
- var term = new Xex.IntTerm (n);
- if (vari != null)
- vari.SetValue (term);
- return term;
- }
-
- function Fset (domain, vari, args)
- {
if (! vari)
throw new Xex.ErrTerm (Xex.Error.NoVariableName,
'No variable name to set');
{
this.name = 'TOP';
this.submaps = null;
- this.actions = null;
};
(function () {
var proto = {};
- function add_rule (keymap, rule)
+ function add_rule (keymap, rule, branch_actions)
{
var keyseq = rule.keyseq;
var len = keyseq.val.length;
keymap = sub;
keymap.name = name;
}
- keymap.actions = rule.actions;
+ keymap.map_actions = rule.actions;
+ keymap.branch_actions = branch_actions;
}
- proto.Add = function (map)
+ proto.Add = function (map, branch_actions)
{
var rules = map.rules;
var len = rules.length;
for (var i = 0; i < len; i++)
- add_rule (this, rules[i]);
+ add_rule (this, rules[i], branch_actions);
}
proto.Lookup = function (keys, index)
{
{
var n = node.firstElement ();
if (node.nodeName == 'branch')
- {
- state.keymap.Add (map_list[node.attributes['mname'].nodeValue]);
- state.keymap.actions = Xex.Term.Parse (domain, n, null);
- }
+ state.keymap.Add (map_list[node.attributes['mname'].nodeValue],
+ Xex.Term.Parse (domain, n, null));
else if (node.nodeName == 'state-hook')
state.enter_actions = Xex.Term.Parse (domain, n, null);
else if (node.nodeName == 'catch-all-branch')
else
text = args[0].val;
domain.context.insert (text, null);
+ return args[0];
}
function Finsert_candidates (domain, vari, args)
this.target = target;
this.domain = new Xex.Domain ('context', im.domain, this);
this.active = true;
- this.reset ();
this.spot = 0;
+ this.reset ();
}
MIM.CandidateTable = function ()
{
var out = this.keymap.Lookup (this.keys, this.key_head);
var sub = out.map;
- var branch_actions = this.state.keymap.actions;
Xex.Log ('handling ' + this.keys.val[this.key_head]
- + ' in ' + this.state.name + ':' + this.keymap.name + "\n");
+ + ' in ' + this.state.name + ':' + this.keymap.name);
this.key_head = out.index;
if (sub != this.keymap)
{
restore_state.call (this);
this.keymap = sub;
- Xex.Log ('submap found\n');
- if (this.keymap.actions)
+ Xex.Log ('submap found');
+ if (this.keymap.map_actions)
{
- Xex.Log ('taking map actions:\n');
- if (! this.take_actions (this.keymap.actions))
+ Xex.Log ('taking map actions:');
+ if (! this.take_actions (this.keymap.map_actions))
return false;
}
else if (this.keymap.submaps)
if (this.keymap.branch_actions != null)
{
Xex.Log ('branch actions:');
- if (! this.take_actions (branch_actions))
+ if (! this.take_actions (this.keymap.branch_actions))
return false;
}
if (this.keymap != this.state.keymap)
var current_state = this.state;
var map = this.keymap;
- if (branch_actions)
+ if (map.branch_actions)
{
Xex.Log ('branch actions');
- if (! this.take_actions (this.keymap.branch_actions))
+ if (! this.take_actions (map.branch_actions))
return false;
}
GetSurroundingChar: function (pos)
{
pos += this.spot;
- Xex.Log (0, 'getting char at ' + pos);
if (pos < 0 || pos >= this.target.value.length)
return 0;
return this.target.value.charCodeAt (pos);
pos = this.preedit.length;
}
if (pos < this.cursor_pos)
- this.preedit = (this.predit.substring (0, pos)
+ this.preedit = (this.preedit.substring (0, pos)
+ this.preedit.substring (this.cursor_pos));
else
this.preedit = (this.preedit.substring (0, this.cursor_pos)
{
if (state == null)
{
- Xex.Log ("shifting back to previous");
if (this.prev_state == null)
return;
state = this.prev_state;
}
- else
- Xex.Log ("shifting to " + state.name);
if (state == this.initial_state)
{
MIM.keydown = function (event)
{
var target = event.target;
+ if (target.id == 'log')
+ return;
if (! (target.type == "text" || target.type == "textarea"))
return;
MIM.keypress = function (event)
{
- if (! (event.target.type == "text" || event.target.type == "textarea"))
+ var target = event.target;
+ if (target.id == 'log')
+ return;
+ if (! (target.type == "text" || target.type == "textarea"))
return;
- var ic = event.target.mim_ic;
+ var ic = target.mim_ic;
var i;
try {
Xex.Log ("filtering " + ic.key);
var result = ic.Filter (ic.key);
- MIM.update (event.target, ic);
+ MIM.update (target, ic);
if (! ic.key_unhandled)
event.preventDefault ();
} finally {