summaryrefslogtreecommitdiff
path: root/public/vendor/codemirror/lib
diff options
context:
space:
mode:
authorWu Cheng-Han2016-11-28 01:20:23 +0800
committerWu Cheng-Han2016-11-28 01:20:23 +0800
commit3a305b8258782797b328f2ce46e8bb74e9603594 (patch)
tree0385241ed28f03030985da63a0cafb0438cd3ed5 /public/vendor/codemirror/lib
parentbd3d4958e43a8437e45113354059cf41dacda995 (diff)
Update editor other cursor classes and adding option for other cursors features in CodeMirror
Diffstat (limited to '')
-rw-r--r--public/vendor/codemirror/lib/codemirror.css14
-rw-r--r--public/vendor/codemirror/lib/codemirror.js26
2 files changed, 29 insertions, 11 deletions
diff --git a/public/vendor/codemirror/lib/codemirror.css b/public/vendor/codemirror/lib/codemirror.css
index 18b0bf70..255de91a 100644
--- a/public/vendor/codemirror/lib/codemirror.css
+++ b/public/vendor/codemirror/lib/codemirror.css
@@ -86,6 +86,12 @@
/* Can style cursor different in overwrite (non-insert) mode */
.CodeMirror-overwrite .CodeMirror-cursor {}
+.CodeMirror-other-cursor {
+ width: 0px;
+ position: absolute;
+ border-right: none;
+}
+
.cm-tab { display: inline-block; text-decoration: inherit; }
.CodeMirror-rulers {
@@ -316,6 +322,11 @@ div.CodeMirror-dragcursors {
visibility: visible;
}
+div.CodeMirror-other-cursors {
+ position:relative;
+ z-index:3;
+}
+
.CodeMirror-selected { background: #d9d9d9; }
.CodeMirror-focused .CodeMirror-selected { background: #d7d4f0; }
.CodeMirror-crosshair { cursor: crosshair; }
@@ -338,6 +349,9 @@ div.CodeMirror-dragcursors {
.CodeMirror div.CodeMirror-cursors {
visibility: hidden;
}
+ .CodeMirror div.CodeMirror-other-cursors {
+ visibility: hidden;
+ }
}
/* See issue #2901 */
diff --git a/public/vendor/codemirror/lib/codemirror.js b/public/vendor/codemirror/lib/codemirror.js
index b77c1518..feaee981 100644
--- a/public/vendor/codemirror/lib/codemirror.js
+++ b/public/vendor/codemirror/lib/codemirror.js
@@ -2330,7 +2330,7 @@
for (var i = 0; i < doc.sel.ranges.length; i++) {
if (primary === false && i == doc.sel.primIndex) continue;
var range = doc.sel.ranges[i];
- //if (range.from().line >= cm.display.viewTo || range.to().line < cm.display.viewFrom) continue;
+ if (!cm.options.otherCursors && (range.from().line >= cm.display.viewTo || range.to().line < cm.display.viewFrom)) continue;
var collapsed = range.empty();
if (collapsed || cm.options.showCursorWhenSelecting)
drawSelectionCursor(cm, range.head, curFragment);
@@ -2357,16 +2357,20 @@
otherCursor.style.top = pos.other.top + "px";
otherCursor.style.height = (pos.other.bottom - pos.other.top) * .85 + "px";
}
-
- $('.other-cursor').each(function(key, value) {
- var line = parseInt($(value).attr('data-line'));
- var ch = parseInt($(value).attr('data-ch'));
- var offsetLeft = parseFloat($(value).attr('data-offset-left'));
- var offsetTop = parseFloat($(value).attr('data-offset-top'));
- var coord = cm.charCoords({line: line, ch: ch}, 'windows');
- $(value)[0].style.left = coord.left + offsetLeft + 'px';
- $(value)[0].style.top = coord.top + offsetTop + 'px';
- });
+
+ if (cm.options.otherCursors) {
+ var others = cm.display.lineSpace.getElementsByClassName('CodeMirror-other-cursor');
+ for (var i = 0, l = others.length; i < l; i++) {
+ var other = others[i];
+ var line = parseInt(other.getAttribute('data-line'));
+ var ch = parseInt(other.getAttribute('data-ch'));
+ var offsetLeft = parseFloat(other.getAttribute('data-offset-left'));
+ var offsetTop = parseFloat(other.getAttribute('data-offset-top'));
+ var coord = cm.charCoords({line: line, ch: ch}, 'windows');
+ other.style.left = coord.left + offsetLeft + 'px';
+ other.style.top = coord.top + offsetTop + 'px';
+ }
+ }
}
// Draws the given range as a highlighted selection