(cm)
| 780 | // SELECTION / CURSOR |
| 781 | |
| 782 | function updateSelection(cm) { |
| 783 | var display = cm.display; |
| 784 | var collapsed = posEq(cm.doc.sel.from, cm.doc.sel.to); |
| 785 | if (collapsed || cm.options.showCursorWhenSelecting) |
| 786 | updateSelectionCursor(cm); |
| 787 | else |
| 788 | display.cursor.style.display = display.otherCursor.style.display = "none"; |
| 789 | if (!collapsed) |
| 790 | updateSelectionRange(cm); |
| 791 | else |
| 792 | display.selectionDiv.style.display = "none"; |
| 793 | |
| 794 | // Move the hidden textarea near the cursor to prevent scrolling artifacts |
| 795 | if (cm.options.moveInputWithCursor) { |
| 796 | var headPos = cursorCoords(cm, cm.doc.sel.head, "div"); |
| 797 | var wrapOff = getRect(display.wrapper), lineOff = getRect(display.lineDiv); |
| 798 | display.inputDiv.style.top = Math.max(0, Math.min(display.wrapper.clientHeight - 10, |
| 799 | headPos.top + lineOff.top - wrapOff.top)) + "px"; |
| 800 | display.inputDiv.style.left = Math.max(0, Math.min(display.wrapper.clientWidth - 10, |
| 801 | headPos.left + lineOff.left - wrapOff.left)) + "px"; |
| 802 | } |
| 803 | } |
| 804 | |
| 805 | // No selection, plain cursor |
| 806 | function updateSelectionCursor(cm) { |
no test coverage detected