X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=src%2Forg%2Fxwt%2Fbuiltin%2Fedit_lib.xwt;fp=src%2Forg%2Fxwt%2Fbuiltin%2Fedit_lib.xwt;h=0000000000000000000000000000000000000000;hb=3591b88b94a6bb378af3d4abe6eb5233ce583104;hp=abcc8eb137da886fba2dad0e01a67ecb62159a84;hpb=de378041d5ca2aca1a2b5a31ef15ae90a86c977f;p=org.ibex.core.git diff --git a/src/org/xwt/builtin/edit_lib.xwt b/src/org/xwt/builtin/edit_lib.xwt deleted file mode 100644 index abcc8eb..0000000 --- a/src/org/xwt/builtin/edit_lib.xwt +++ /dev/null @@ -1,680 +0,0 @@ - - - - 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; } } - } - - // Returns the number of characters the pixel position pos is into text t. end is the pixel with of t. - // t : string -- basis for character counting. - // pxpos : int -- pixel position on the text from string t. - // pxlen : int -- pixel width of text t (known in form of box length, so passed for speed). - // tfont : string -- name of font used for width of text. - var getpos = function(t, pxpos, pxlen, tfont) { - // Short circuit extremes. - if (0 >= pxpos) return 0; - 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)); - - 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)); - 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)); - } - guessch--; // Round down. - } - - return guessch; - } - - - - -