<!-- Copyright 2002 NeuronForge Pty Ltd, see COPYING file for licensing [LGPL] -->
-<xwt>
+<ibex>
<static>
var cursors = [];
var worddivider = [' ', '-'];
- xwt.thread = function() {
- while (true) { xwt.sleep(1000); for (var i=0; cursors.length > i; i++) { cursors[i].blink = !cursors[i].blink; } }
+ ibex.thread = function() {
+ while (true) { ibex.sleep(1000); for (var i=0; cursors.length > i; i++) { cursors[i].blink = !cursors[i].blink; } }
}
// Returns the number of characters the pixel position pos is into text t. end is the pixel with of t.
if (pxpos >= pxlen) return t.length;
// Inital guess based on average character width.
- var guessch = xwt.math.min(t.length, xwt.math.floor(pxpos / (pxlen / t.length)));
- var guesspx = xwt.textwidth(tfont, t.substring(0, guessch));
+ var guessch = ibex.math.min(t.length, ibex.math.floor(pxpos / (pxlen / t.length)));
+ var guesspx = ibex.textwidth(tfont, t.substring(0, guessch));
if (guesspx > pxpos) {
while (guesspx > pxpos) {
// Textwidth of individual character must account for font kerning.
- guesspx -= xwt.textwidth(tfont, t.substring(guessch -1, guessch +1)) - xwt.textwidth(tfont, t.charAt(guessch));
+ guesspx -= ibex.textwidth(tfont, t.substring(guessch -1, guessch +1)) - ibex.textwidth(tfont, t.charAt(guessch));
guessch--;
}
} else if (pxpos > guesspx) {
while (pxpos > guesspx) {
guessch++;
if (guessch >= t.length) break;
- guesspx += xwt.textwidth(tfont, t.substring(guessch -1, guessch+1)) - xwt.textwidth(tfont, t.charAt(guessch));
+ guesspx += ibex.textwidth(tfont, t.substring(guessch -1, guessch+1)) - ibex.textwidth(tfont, t.charAt(guessch));
}
guessch--; // Round down.
}
_wrap = function(v) {
// Used on _SizeChange if wrap needs to know.
var resize = function() {
- xwt.thread = function() {
+ ibex.thread = function() {
// TODO: Only run this change if the width is different.
for (var i = 0; content.numchildren > i; i++) { content[i].fulltext = content[i].fulltext; }
};
if (multiline and v == "line") {
content.vshrink = true;
content.hshrink = false;
- content.maxwidth = xwt.maxdim; // Must reset maxwidth after shrink = true.
+ content.maxwidth = ibex.maxdim; // Must reset maxwidth after shrink = true.
ref_fulltext = fulltext_linewrap;
_SizeChange = resize;
} else if (multiline and v == "word") {
content.vshrink = true;
content.hshrink = false;
- content.maxwidth = xwt.maxdim;
+ content.maxwidth = ibex.maxdim;
ref_fulltext = fulltext_wordwrap;
_SizeChange = resize;
_selecttextcolor = function(v) { sel1.textcolor = sel2.textcolor = v; }
_font = function(f) {
- lineheight = xwt.textheight(f);
+ lineheight = ibex.textheight(f);
if (lineheight > 0) { minheight = content.minheight = linecount * lineheight; }
for (var i=0; content.numchildren > i; i++) { content[i].font = f; }
sel1.font = sel2.font = curs.font = f;
// Limit checking.
if (limit > 0 and length + t.length > limit) {
- xwt.println("WARNING: Limit applied on inserted text.");
+ ibex.println("WARNING: Limit applied on inserted text.");
t = t.substring(0, limit - length);
}
moveCursor(cl + newT.length - 1, newT[newT.length -1].length);
} else {
- xwt.println("WARNING: Single line edit, ignoring all text after the carrige return.");
+ ibex.println("WARNING: Single line edit, ignoring all text after the carrige return.");
content[0].fulltext = content[0].fulltext.substring(0, cx) + newT[0] + content[0].fulltext.substring(cx);
moveCursor(0, cx + newT[0].length);
if (sel1.cl == cl1) {
for (var i=sel1.cy+1; cy1 >= i; i++) { content[cl1][i].selected = false; }
} else if (cl1 > sel1.cl) {
- for (var i=xwt.math.max(0, sel1.cl); cl1 >= i; i++) { content[i].selected = false; }
+ for (var i=ibex.math.max(0, sel1.cl); cl1 >= i; i++) { content[i].selected = false; }
}
if (sel2.cl == cl2) {
for (var i=sel2.cy-1; i >= cy2; i--) { content[cl2][i].selected = false; }
} else if (sel2.cl > cl2) {
- for (var i=xwt.math.max(0, sel2.cl); i >= cl2; i--) { content[i].selected = false; }
+ for (var i=ibex.math.max(0, sel2.cl); i >= cl2; i--) { content[i].selected = false; }
}
// Store point data.
// Place first select box.
sel1.y = content[cl1].y + content[cl1][cy1].y;
- sel1.x = xwt.textwidth(font, content[cl1][cy1].text.substring(0, px1));
+ sel1.x = ibex.textwidth(font, content[cl1][cy1].text.substring(0, px1));
if (cl1 == cl2 and cy1 == cy2) {
// Only the first select box is required.
// Move the cursor.
curs.cl = cl; curs.cx = cx; curs.cy = cy; curs.px = px;
curs.y = content.y + content[cl].y + (lineheight * cy);
- curs.x = content.x + xwt.textwidth(font, content[cl][cy].text.substring(0, px)) -1;
+ curs.x = content.x + ibex.textwidth(font, content[cl][cy].text.substring(0, px)) -1;
curs.blink = false;
// Speed Hack: As the cursor has values that match the names used by the focusarea variable, we
// Returns a box ready to be a full line, armed with the current fulltext trap.
var newLine = function() {
- var b = xwt.newBox();
+ var b = ibex.newBox();
b.color = color;
b.align = "topleft";
// Returns a box ready to be a soft line; one of the components of a line.
var newSoftline = function() {
- var b = xwt.newBox();
+ var b = ibex.newBox();
b._selected = function(s) {
arguments.trapee.color = s ? selectcolor : color;
if (i == arguments.trapee.numchildren) { arguments.trapee[i] = newSoftline(); }
// TODO: Switch to getpos
- var nl = static.getpos(t, cw, xwt.textwidth(font, t), font);
+ var nl = static.getpos(t, cw, ibex.textwidth(font, t), font);
arguments.trapee[i].text = t.substring(0, nl);
t = t.substring(nl);
}
for (; t.length > 0; i++) {
if (i == arguments.trapee.numchildren) { arguments.trapee[i] = newSoftline(); }
- var nl = static.getpos(t, cw, xwt.textwidth(font, t), font);
+ var nl = static.getpos(t, cw, ibex.textwidth(font, t), font);
var rl = nl;
if (t.length > nl) {
root._Move = function() {
// Update Selection.
- var linediff = xwt.math.floor((content.mousey - (content[sel.cl].y + content[sel.cl][sel.cy].y)) / lineheight);
+ var linediff = ibex.math.floor((content.mousey - (content[sel.cl].y + content[sel.cl][sel.cy].y)) / lineheight);
var cl = sel.cl;
var cy = sel.cy;
// Set selection root position.
clearSelection();
sel.cl = content.indexof(refline);
- sel.cy = xwt.math.floor(refline.mousey / lineheight);
+ sel.cy = ibex.math.floor(refline.mousey / lineheight);
if (sel.cy >= refline.numchildren) sel.cy = refline.numchildren -1;
else if (0 > sel.cy) sel.cy = 0;
content[curs.cl +1] = newLine();
content[curs.cl +1].fulltext = content[curs.cl].fulltext.substring(curs.cx);
content[curs.cl].fulltext = content[curs.cl].fulltext.substring(0, curs.cx);
- xwt.thread = function() { moveCursor(curs.cl +1, 0); }
+ ibex.thread = function() { moveCursor(curs.cl +1, 0); }
}
key_back_space = function() {
} else {
content[curs.cl].fulltext = content[curs.cl].fulltext.substring(0, curs.cx)
+ k + content[curs.cl].fulltext.substring(curs.cx);
- xwt.thread = function() { moveCursor(curs.cl, curs.cx+1); }
+ ibex.thread = function() { moveCursor(curs.cl, curs.cx+1); }
textChanged = true;
}
}
</template>
-</xwt>
+</ibex>