From 24eb80b317a7b36899bb6dbb35b6d7a940554226 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Thu, 23 Aug 2012 13:15:00 +0200 Subject: [PATCH] Remove unused function from codemirror.js --- lib/codemirror.js | 29 ----------------------------- 1 file changed, 29 deletions(-) diff --git a/lib/codemirror.js b/lib/codemirror.js index 552cc4ae01..091b9104e7 100644 --- a/lib/codemirror.js +++ b/lib/codemirror.js @@ -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 &&