Skip to content

Commit

Permalink
Remove unused function from codemirror.js
Browse files Browse the repository at this point in the history
  • Loading branch information
marijnh committed Aug 23, 2012
1 parent 805b5a4 commit 24eb80b
Showing 1 changed file with 0 additions and 29 deletions.
29 changes: 0 additions & 29 deletions lib/codemirror.js
Expand Up @@ -1654,35 +1654,6 @@ window.CodeMirror = (function() {
markerClass: marker && marker.style, lineClass: line.className, bgClass: line.bgClassName};
}

// These are used to go from pixel positions to character
// positions, taking varying character widths into account.
function charFromX(line, x) {
if (x <= 0) return 0;
var lineObj = getLine(line), text = lineObj.text;
function getX(len) {
return measureLine(lineObj, len).left;
}
var from = 0, fromX = 0, to = text.length, toX;
// Guess a suitable upper bound for our search.
var estimated = Math.min(to, Math.ceil(x / charWidth()));
for (;;) {
var estX = getX(estimated);
if (estX <= x && estimated < to) estimated = Math.min(to, Math.ceil(estimated * 1.2));
else {toX = estX; to = estimated; break;}
}
if (x > toX) return to;
// Try to guess a suitable lower bound as well.
estimated = Math.floor(to * 0.8); estX = getX(estimated);
if (estX < x) {from = estimated; fromX = estX;}
// Do a binary search between these bounds.
for (;;) {
if (to - from <= 1) return (toX - x > x - fromX) ? from : to;
var middle = Math.ceil((from + to) / 2), middleX = getX(middle);
if (middleX > x) {to = middle; toX = middleX;}
else {from = middle; fromX = middleX;}
}
}

function measureLine(line, ch) {
if (ch == 0) return {top: 0, left: 0};
var wbr = options.lineWrapping && ch < line.text.length &&
Expand Down

0 comments on commit 24eb80b

Please sign in to comment.