()
| 1322 | return resized; |
| 1323 | } |
| 1324 | function updateSelection() { |
| 1325 | var collapsed = posEq(sel.from, sel.to); |
| 1326 | var fromPos = localCoords(sel.from, true); |
| 1327 | var toPos = collapsed ? fromPos : localCoords(sel.to, true); |
| 1328 | var headPos = sel.inverted ? fromPos : toPos, th = textHeight(); |
| 1329 | var wrapOff = eltOffset(wrapper), lineOff = eltOffset(lineDiv); |
| 1330 | inputDiv.style.top = Math.max(0, Math.min(scroller.offsetHeight, headPos.y + lineOff.top - wrapOff.top)) + "px"; |
| 1331 | inputDiv.style.left = Math.max(0, Math.min(scroller.offsetWidth, headPos.x + lineOff.left - wrapOff.left)) + "px"; |
| 1332 | if (collapsed) { |
| 1333 | cursor.style.top = headPos.y + "px"; |
| 1334 | cursor.style.left = (options.lineWrapping ? Math.min(headPos.x, lineSpace.offsetWidth) : headPos.x) + "px"; |
| 1335 | cursor.style.display = ""; |
| 1336 | selectionDiv.style.display = "none"; |
| 1337 | } else { |
| 1338 | var sameLine = fromPos.y == toPos.y, html = ""; |
| 1339 | var clientWidth = lineSpace.clientWidth || lineSpace.offsetWidth; |
| 1340 | var clientHeight = lineSpace.clientHeight || lineSpace.offsetHeight; |
| 1341 | function add(left, top, right, height) { |
| 1342 | var rstyle = quirksMode ? "width: " + (!right ? clientWidth : clientWidth - right - left) + "px" |
| 1343 | : "right: " + right + "px"; |
| 1344 | html += '<div class="CodeMirror-selected" style="position: absolute; left: ' + left + |
| 1345 | 'px; top: ' + top + 'px; ' + rstyle + '; height: ' + height + 'px"></div>'; |
| 1346 | } |
| 1347 | if (sel.from.ch && fromPos.y >= 0) { |
| 1348 | var right = sameLine ? clientWidth - toPos.x : 0; |
| 1349 | add(fromPos.x, fromPos.y, right, th); |
| 1350 | } |
| 1351 | var middleStart = Math.max(0, fromPos.y + (sel.from.ch ? th : 0)); |
| 1352 | var middleHeight = Math.min(toPos.y, clientHeight) - middleStart; |
| 1353 | if (middleHeight > 0.2 * th) |
| 1354 | add(0, middleStart, 0, middleHeight); |
| 1355 | if ((!sameLine || !sel.from.ch) && toPos.y < clientHeight - .5 * th) |
| 1356 | add(0, toPos.y, clientWidth - toPos.x, th); |
| 1357 | selectionDiv.innerHTML = html; |
| 1358 | cursor.style.display = "none"; |
| 1359 | selectionDiv.style.display = ""; |
| 1360 | } |
| 1361 | } |
| 1362 | |
| 1363 | function setShift(val) { |
| 1364 | if (val) shiftSelecting = shiftSelecting || (sel.inverted ? sel.to : sel.from); |
no test coverage detected