From: handa Date: Tue, 2 Mar 2010 13:14:51 +0000 (+0000) Subject: *** empty log message *** X-Git-Tag: ALPHA~36 X-Git-Url: http://git.chise.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=520c20497c67242950596e965ca6e611347da144;p=m17n%2Fm17n-lib-js.git *** empty log message *** --- diff --git a/xex.js b/xex.js index 38068d5..78b1223 100644 --- a/xex.js +++ b/xex.js @@ -8,7 +8,7 @@ var Xex = { return; var str = ''; if (indent != undefined) - for (var i = 0; i < indent; i++) + for (var i = 0; i <= indent; i++) str += ' '; Xex.LogNode.value = str + arg + "\n" + Xex.LogNode.value; } @@ -711,8 +711,12 @@ Xex.Funcall = function (func, vari, args) str += ' vname="' + this.vari.name + '"'; if (len == 0) return str + '/>'; - for (var i = 0; i < len; i++) - arglist += '.'; //this.args[i].toString (); + if (this.func instanceof Xex.Subrountine) + for (var i = 0; i < len; i++) + arglist += this.args[i].toString (); + else + for (var i = 0; i < len; i++) + arglist += '.'; return str + '>' + arglist + ''; } @@ -1433,19 +1437,11 @@ var MIM = { return ic.preedit.charCodeAt (p); } - MIM.NamedMarker = function (name) { this.val = name; } - MIM.NamedMarker.prototype = new MIM.Marker (); - MIM.NamedMarker.prototype.Position = function (ic) - { - var p = ic.marker_positions[this.val]; - if (p == undefined) - Xex.Log ('no position of ' + this.val); - return (p == undefined ? 0 : p); - } - MIM.NamedMarker.prototype.Mark = function (ic) - { - ic.marker_positions[this.val] = ic.cursor_pos; - } + MIM.FloatingMarker = function (name) { this.val = name; }; + var proto = new MIM.Marker (); + MIM.FloatingMarker.prototype = proto; + proto.Position = function (ic) { return ic.marker_positions[this.val]; }; + proto.Mark = function (ic) { ic.marker_positions[this.val] = ic.cursor_pos; }; MIM.PredefinedMarker = function (name) { this.val = name; } MIM.PredefinedMarker.prototype = new MIM.Marker (); @@ -1530,7 +1526,7 @@ var MIM = { throw new Xex.ErrTerm (MIM.Error.ParseError, "Invalid marker: " + name); } - return new MIM.NamedMarker (name); + return new MIM.FloatingMarker (name);; } }) (); @@ -2010,7 +2006,7 @@ MIM.im_domain.DefType (MIM.State.prototype); ic.rep (old_text, new_text, can); } else - Xex.Log ('no candidates'); + Xex.Log ('no candidates at ' + ic.cursor_pos + ' of ' + ic.candidate_table.table.length); return args[0]; } @@ -2286,7 +2282,7 @@ MIM.im_domain.DefType (MIM.State.prototype); this.state = null; this.initial_state = this.im.initial_state; this.keys = new MIM.KeySeq (); - this.marker_positions = {}; + this.marker_positions = new Array (); this.candidate_table = new MIM.CandidateTable (); this.reset (); } @@ -2296,12 +2292,12 @@ MIM.im_domain.DefType (MIM.State.prototype); this.table = new Array (); } - MIM.CandidateTable.prototype.get = function (from) + MIM.CandidateTable.prototype.get = function (pos) { for (var i = 0; i < this.table.length; i++) { var elt = this.table[i]; - if (elt.from <= from && elt.to > from) + if (elt.from < pos && pos <= elt.to) return elt.val; } } @@ -2311,8 +2307,7 @@ MIM.im_domain.DefType (MIM.State.prototype); for (var i = 0; i < this.table.length; i++) { var elt = this.table[i]; - if (elt.from >= from && elt.from < to - || elt.to >= from && elt.to < to) + if (elt.from < to && elt.to > from) { elt.from = from; elt.to = to; @@ -2326,6 +2321,8 @@ MIM.im_domain.DefType (MIM.State.prototype); MIM.CandidateTable.prototype.adjust = function (from, to, inserted) { var diff = inserted - (to - from); + if (diff == 0) + return; for (var i = 0; i < this.table.length; i++) { var elt = this.table[i]; @@ -2355,10 +2352,7 @@ MIM.im_domain.DefType (MIM.State.prototype); function set_cursor (prefix, pos) { this.cursor_pos = pos; - if (pos > 0) - this.candidates = this.candidate_table.get (pos - 1); - else - this.candidates = null; + this.candidates = this.candidate_table.get (pos); } function save_state () @@ -2453,7 +2447,6 @@ MIM.im_domain.DefType (MIM.State.prototype); reset: function () { this.cursor_pos = 0; - this.candidates = null; this.candidate_show = false; this.prev_state = null; this.title = this.initial_state.title; @@ -2542,21 +2535,15 @@ MIM.im_domain.DefType (MIM.State.prototype); { var diff = inserted - (to - from); - for (var m in this.marker_positions) + for (var name in this.marker_positions) { - var pos = this.marker_positions[m]; + var pos = this.marker_positions[name]; if (pos > from) { if (pos >= to) - { - this.marker_positions[m] = pos + diff; - Xex.Log ('Marker ' + m + ' = ' + this.marker_positions[m]); - } + this.marker_positions[name] += diff; else if (pos > from) - { - this.marker_positions[m] = from; - Xex.Log ('Marker ' + m + ' = ' + this.marker_positions[m]); - } + this.marker_positions[name] = from; } } if (this.cursor_pos >= to)