var Xex = {};
-Xex.Alist = function ()
-{
- this.count = 0;
-}
-
-Xex.Alist.prototype.put = function (key, val)
-{
- this.count++;
- return (this[key] = val);
-}
-Xex.Alist.prototype.clone = function ()
-{
- var alist = new Xex.Alist ();
- for (key in this)
- alist[key] = this[key];
- return alist;
-}
-Xex.Alist.prototype.toString = function ()
-{
- var str = 'alist:';
- for (key in this)
- str += '"' + key + '"';
- return str;
-}
-
-// Xex.alist = new Xex.Alist ();
-// Xex.alist.put ('abc', "ABC");
-// alert (Xex.alist['abc']);
-
Xex.Error = {
UnknownError: "unknown-error",
WrongArgument: "wrong-argument",
},
Defvar: function (name)
{
+ if (name instanceof Xex.Variable)
+ {
+ name = name.Clone (this);
+ this.variables[name.name] = name;
+ return name;
+ }
var vari = this.variables[name];
if (vari)
{
{
var ic = domain.context;
var candidates = new Candidates (args, column);
- var candidate = candidates.Current ();
-
- if (
-
+ ic.insert (candidates.Current (), candidates);
+ return args[0];
}
im_domain.DefSubr (Finsert, "insert", false, 1, 1);
{
this.description = node.firstChild.nodeValue;
}
+ parses['variable-list'] = function (node)
+ {
+ for (node = node.firstChild; node; node = node.nextSibling)
+ {
+ if (node.nodeType != 1)
+ continue;
+ var name = node.attributes['vname'].nodeValue;
+ var vari = get_global_bar (name);
+ if (vari != null)
+ domain.Defvar (name);
+ Xex.Parse (domain, node);
+ }
+ }
parsers['title'] = function (node)
{
this.title = node.firstChild.nodeValue;
{
if (this.column > 0)
{
- var nitems = this.group.length;
- var start = this.index - (this.index % nitems);
+ var start = this.index - (this.index % this.column);
return (start + this.column <= this.total ? this.column
: this.total - start);
}
else
{
this.row = this.row > 0 ? this.row - 1 : this.blocks.length - 1;
- nitems = this.blocks[this.row].Count;
+ nitems = this.blocks[this.row].Count ();
this.index = (this.blocks[this.row].Index
+ (col < nitems ? col : nitems - 1));
}
else
{
this.row = this.row < this.blocks.length - 1 ? this.row + 1 : 0;
- nitems = this.blocks[this.row].Count;
+ nitems = this.blocks[this.row].Count ();
this.index = (this.blocks[this.row].Index
+ (col < nitems ? col : nitems - 1));
}
Candidates.prototype.Prev = function ()
{
- var col = this.Column ();
-
- if (col == 0)
+ if (this.index == 0)
{
- int nitems = this.PrevGroup ();
- this.index += col < nitems - 1 ? col : nitems - 1;
+ this.index = this.total - 1;
+ this.row = this.blocks.length - 1;
}
else
- this.index--;
- }
+ {
+ this.index--;
+ if (this.blocks[this.row].Index > this.index)
+ this.row--;
+ }
+ }
Candidates.prototype.Next = function ()
{
- int col = this.Column ();
- int nitems = this.GroupLength ();
-
- if (col == nitems - 1)
+ this.index++;
+ if (this.index == this.total)
{
- nitems = this.NextGroup ();
- this.index -= this.Column ();
+ this.index = 0;
+ this.row = 0;
}
else
- this.index++;
+ {
+ var b = this.blocks[this.row];
+ if (this.index == b.Index + b.Count ())
+ this.row++;
+ }
}
- Candidates.prototype.First = function () { this.index -= this.Column (); }
+ Candidates.prototype.First = function ()
+ {
+ this.index -= this.Column ();
+ while (this.blocks[this.row].Index > this.index)
+ this.row--;
+ }
Candidates.prototype.Last = function ()
{
- this.index += this.GroupLength () - (this.Column + 1);
+ var b = this.blocks[this.row];
+ if (this.column > 0)
+ {
+ if (this.index + 1 < this.total)
+ {
+ this.index += this.column - this.Column () + 1;
+ while (b.Index + b.Count () <= this.index)
+ b = this.blocks[++this.row];
+ }
+ else
+ this.index = b.Index + b.Count () - 1;
}
Candidates.prototype.Select = funciton (selector)
}
return this.Current ();
}
- var maxcol = this.GroupLength () - 1;
- if (selector > maxcol)
- selector = maxcol;
- this.index = this.index - this.Column () + selector;
+ var col, start, end
+ if (this.column > 0)
+ {
+ col = this.index % this.column;
+ start = this.index - col;
+ end = start + this.column;
+ }
+ else
+ {
+ start = this.blocks[this.row].Index;
+ col = this.index - start;
+ end = start + this.blocks[this.row].Count;
+ }
+ if (end > this.total)
+ end = this.total;
+ this.index += selector - col;
+ if (this.index >= end)
+ this.index = end - 1;
+ if (this.column > 0)
+ {
+ if (selector > col)
+ while (this.blocks[this.row].Index + this.blocks[this.row].Count
+ < this.index)
+ this.row++;
+ else
+ while (this.blocks[this.row].Index > this.index)
+ this.row--;
+ }
return this.Current ();
}