From f286818107e7862a6257d095a4111dfd6d4801c2 Mon Sep 17 00:00:00 2001 From: handa Date: Sun, 28 Feb 2010 23:37:16 +0000 Subject: [PATCH] *** empty log message *** --- xex.js | 83 +++++++++++++++++++++++++++------------------------------------- 1 file changed, 35 insertions(+), 48 deletions(-) diff --git a/xex.js b/xex.js index f3d5088..f810cfb 100644 --- a/xex.js +++ b/xex.js @@ -2,13 +2,14 @@ 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; } }; @@ -85,7 +86,7 @@ Xex.Subrountine = function (builtin, name, with_var, min_args, max_args) 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); @@ -620,7 +621,7 @@ Xex.Varref = function (vname) { 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; } @@ -676,12 +677,12 @@ Xex.Funcall = function (func, vari, args) 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; } @@ -709,7 +710,7 @@ Xex.Funcall = function (func, vari, args) 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 + ''; } @@ -852,19 +853,6 @@ Xex.LstTerm = function (list) { this.val = list; }; 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'); @@ -1653,13 +1641,12 @@ MIM.Keymap = function () { 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; @@ -1680,16 +1667,17 @@ MIM.Keymap = function () 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) { @@ -1731,10 +1719,8 @@ MIM.State = function (name) { 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') @@ -1989,6 +1975,7 @@ MIM.im_domain.DefType (MIM.State.prototype); else text = args[0].val; domain.context.insert (text, null); + return args[0]; } function Finsert_candidates (domain, vari, args) @@ -2291,8 +2278,8 @@ MIM.im_domain.DefType (MIM.State.prototype); 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 () @@ -2384,21 +2371,20 @@ MIM.im_domain.DefType (MIM.State.prototype); { 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) @@ -2416,7 +2402,7 @@ MIM.im_domain.DefType (MIM.State.prototype); 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) @@ -2429,10 +2415,10 @@ MIM.im_domain.DefType (MIM.State.prototype); 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; } @@ -2505,7 +2491,6 @@ MIM.im_domain.DefType (MIM.State.prototype); 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); @@ -2555,7 +2540,7 @@ MIM.im_domain.DefType (MIM.State.prototype); 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) @@ -2637,13 +2622,10 @@ MIM.im_domain.DefType (MIM.State.prototype); { 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) { @@ -2931,6 +2913,8 @@ MIM.reset_ic = function (event) MIM.keydown = function (event) { var target = event.target; + if (target.id == 'log') + return; if (! (target.type == "text" || target.type == "textarea")) return; @@ -2951,10 +2935,13 @@ MIM.keydown = function (event) 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 { @@ -2970,7 +2957,7 @@ MIM.keypress = function (event) 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 { -- 1.7.10.4