diff --git a/.gitignore b/.gitignore index f91c241f20..37956129f8 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,4 @@ *.swp .idea *.iml +/nbproject \ No newline at end of file diff --git a/lib/codemirror.css b/lib/codemirror.css index 1067b3ee6b..a6c082889e 100644 --- a/lib/codemirror.css +++ b/lib/codemirror.css @@ -84,7 +84,14 @@ } /* Can style cursor different in overwrite (non-insert) mode */ -.CodeMirror-overwrite .CodeMirror-cursor {} +.CodeMirror-overwrite .CodeMirror-cursor { + width: auto; + background-color: black; + color: white; + border-left: 0; + line-height: normal; + white-space: pre; +} .cm-tab { display: inline-block; text-decoration: inherit; } diff --git a/lib/codemirror.js b/lib/codemirror.js index 98163e645a..af354b3211 100644 --- a/lib/codemirror.js +++ b/lib/codemirror.js @@ -2321,15 +2321,22 @@ // Draws a cursor for the given range function drawSelectionCursor(cm, head, output) { var pos = cursorCoords(cm, head, "div", null, null, !cm.options.singleCursorHeightPerLine); - - var cursor = output.appendChild(elt("div", "\u00a0", "CodeMirror-cursor")); + var content = "\u00a0"; + if (cm.state.overwrite) { + var lineObj = getLine(cm.doc, head.line); + var order = getOrder(lineObj); + var part = getBidiPartAt(order, head.ch); + var next = movePos(cm.doc, head, part % 2 ? -1 : 1, 0); + content = next ? (getBetween(cm.doc, part % 2 ? next : head, part % 2 ? head : next)[0] || content) : content; + } + var cursor = output.appendChild(elt("div", content, "CodeMirror-cursor")); cursor.style.left = pos.left + "px"; cursor.style.top = pos.top + "px"; cursor.style.height = Math.max(0, pos.bottom - pos.top) * cm.options.cursorHeight + "px"; if (pos.other) { // Secondary cursor, shown when on a 'jump' in bi-directional text - var otherCursor = output.appendChild(elt("div", "\u00a0", "CodeMirror-cursor CodeMirror-secondarycursor")); + var otherCursor = output.appendChild(elt("div", content, "CodeMirror-cursor CodeMirror-secondarycursor")); otherCursor.style.display = ""; otherCursor.style.left = pos.other.left + "px"; otherCursor.style.top = pos.other.top + "px"; @@ -5241,7 +5248,7 @@ addClass(this.display.cursorDiv, "CodeMirror-overwrite"); else rmClass(this.display.cursorDiv, "CodeMirror-overwrite"); - + updateSelection(this); signal(this, "overwriteToggle", this, this.state.overwrite); }, hasFocus: function() { return this.display.input.getField() == activeElt(); },