Edit File by line

Deprecated: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in /home/sportsfever/public_html/filemanger/function.php on line 93

Warning: Undefined array key "page_file_edit_line" in /home/sportsfever/public_html/filemanger/edit_text_line.php on line 32
/home/sportsfe.../httpdocs/wp-conte.../plugins/wp-file-.../lib/codemirr.../lib
File: codemirror.js
if (cm.options.lineNumbers && (!markers || !markers["CodeMirror-linenumbers"]))
[1000] Fix | Delete
lineView.lineNumber = gutterWrap.appendChild(
[1001] Fix | Delete
elt("div", lineNumberFor(cm.options, lineN),
[1002] Fix | Delete
"CodeMirror-linenumber CodeMirror-gutter-elt",
[1003] Fix | Delete
"left: " + dims.gutterLeft["CodeMirror-linenumbers"] + "px; width: "
[1004] Fix | Delete
+ cm.display.lineNumInnerWidth + "px"));
[1005] Fix | Delete
if (markers) for (var k = 0; k < cm.options.gutters.length; ++k) {
[1006] Fix | Delete
var id = cm.options.gutters[k], found = markers.hasOwnProperty(id) && markers[id];
[1007] Fix | Delete
if (found)
[1008] Fix | Delete
gutterWrap.appendChild(elt("div", [found], "CodeMirror-gutter-elt", "left: " +
[1009] Fix | Delete
dims.gutterLeft[id] + "px; width: " + dims.gutterWidth[id] + "px"));
[1010] Fix | Delete
}
[1011] Fix | Delete
}
[1012] Fix | Delete
}
[1013] Fix | Delete
[1014] Fix | Delete
function updateLineWidgets(cm, lineView, dims) {
[1015] Fix | Delete
if (lineView.alignable) lineView.alignable = null;
[1016] Fix | Delete
for (var node = lineView.node.firstChild, next; node; node = next) {
[1017] Fix | Delete
var next = node.nextSibling;
[1018] Fix | Delete
if (node.className == "CodeMirror-linewidget")
[1019] Fix | Delete
lineView.node.removeChild(node);
[1020] Fix | Delete
}
[1021] Fix | Delete
insertLineWidgets(cm, lineView, dims);
[1022] Fix | Delete
}
[1023] Fix | Delete
[1024] Fix | Delete
// Build a line's DOM representation from scratch
[1025] Fix | Delete
function buildLineElement(cm, lineView, lineN, dims) {
[1026] Fix | Delete
var built = getLineContent(cm, lineView);
[1027] Fix | Delete
lineView.text = lineView.node = built.pre;
[1028] Fix | Delete
if (built.bgClass) lineView.bgClass = built.bgClass;
[1029] Fix | Delete
if (built.textClass) lineView.textClass = built.textClass;
[1030] Fix | Delete
[1031] Fix | Delete
updateLineClasses(lineView);
[1032] Fix | Delete
updateLineGutter(cm, lineView, lineN, dims);
[1033] Fix | Delete
insertLineWidgets(cm, lineView, dims);
[1034] Fix | Delete
return lineView.node;
[1035] Fix | Delete
}
[1036] Fix | Delete
[1037] Fix | Delete
// A lineView may contain multiple logical lines (when merged by
[1038] Fix | Delete
// collapsed spans). The widgets for all of them need to be drawn.
[1039] Fix | Delete
function insertLineWidgets(cm, lineView, dims) {
[1040] Fix | Delete
insertLineWidgetsFor(cm, lineView.line, lineView, dims, true);
[1041] Fix | Delete
if (lineView.rest) for (var i = 0; i < lineView.rest.length; i++)
[1042] Fix | Delete
insertLineWidgetsFor(cm, lineView.rest[i], lineView, dims, false);
[1043] Fix | Delete
}
[1044] Fix | Delete
[1045] Fix | Delete
function insertLineWidgetsFor(cm, line, lineView, dims, allowAbove) {
[1046] Fix | Delete
if (!line.widgets) return;
[1047] Fix | Delete
var wrap = ensureLineWrapped(lineView);
[1048] Fix | Delete
for (var i = 0, ws = line.widgets; i < ws.length; ++i) {
[1049] Fix | Delete
var widget = ws[i], node = elt("div", [widget.node], "CodeMirror-linewidget");
[1050] Fix | Delete
if (!widget.handleMouseEvents) node.setAttribute("cm-ignore-events", "true");
[1051] Fix | Delete
positionLineWidget(widget, node, lineView, dims);
[1052] Fix | Delete
cm.display.input.setUneditable(node);
[1053] Fix | Delete
if (allowAbove && widget.above)
[1054] Fix | Delete
wrap.insertBefore(node, lineView.gutter || lineView.text);
[1055] Fix | Delete
else
[1056] Fix | Delete
wrap.appendChild(node);
[1057] Fix | Delete
signalLater(widget, "redraw");
[1058] Fix | Delete
}
[1059] Fix | Delete
}
[1060] Fix | Delete
[1061] Fix | Delete
function positionLineWidget(widget, node, lineView, dims) {
[1062] Fix | Delete
if (widget.noHScroll) {
[1063] Fix | Delete
(lineView.alignable || (lineView.alignable = [])).push(node);
[1064] Fix | Delete
var width = dims.wrapperWidth;
[1065] Fix | Delete
node.style.left = dims.fixedPos + "px";
[1066] Fix | Delete
if (!widget.coverGutter) {
[1067] Fix | Delete
width -= dims.gutterTotalWidth;
[1068] Fix | Delete
node.style.paddingLeft = dims.gutterTotalWidth + "px";
[1069] Fix | Delete
}
[1070] Fix | Delete
node.style.width = width + "px";
[1071] Fix | Delete
}
[1072] Fix | Delete
if (widget.coverGutter) {
[1073] Fix | Delete
node.style.zIndex = 5;
[1074] Fix | Delete
node.style.position = "relative";
[1075] Fix | Delete
if (!widget.noHScroll) node.style.marginLeft = -dims.gutterTotalWidth + "px";
[1076] Fix | Delete
}
[1077] Fix | Delete
}
[1078] Fix | Delete
[1079] Fix | Delete
// POSITION OBJECT
[1080] Fix | Delete
[1081] Fix | Delete
// A Pos instance represents a position within the text.
[1082] Fix | Delete
var Pos = CodeMirror.Pos = function(line, ch) {
[1083] Fix | Delete
if (!(this instanceof Pos)) return new Pos(line, ch);
[1084] Fix | Delete
this.line = line; this.ch = ch;
[1085] Fix | Delete
};
[1086] Fix | Delete
[1087] Fix | Delete
// Compare two positions, return 0 if they are the same, a negative
[1088] Fix | Delete
// number when a is less, and a positive number otherwise.
[1089] Fix | Delete
var cmp = CodeMirror.cmpPos = function(a, b) { return a.line - b.line || a.ch - b.ch; };
[1090] Fix | Delete
[1091] Fix | Delete
function copyPos(x) {return Pos(x.line, x.ch);}
[1092] Fix | Delete
function maxPos(a, b) { return cmp(a, b) < 0 ? b : a; }
[1093] Fix | Delete
function minPos(a, b) { return cmp(a, b) < 0 ? a : b; }
[1094] Fix | Delete
[1095] Fix | Delete
// INPUT HANDLING
[1096] Fix | Delete
[1097] Fix | Delete
function ensureFocus(cm) {
[1098] Fix | Delete
if (!cm.state.focused) { cm.display.input.focus(); onFocus(cm); }
[1099] Fix | Delete
}
[1100] Fix | Delete
[1101] Fix | Delete
// This will be set to a {lineWise: bool, text: [string]} object, so
[1102] Fix | Delete
// that, when pasting, we know what kind of selections the copied
[1103] Fix | Delete
// text was made out of.
[1104] Fix | Delete
var lastCopied = null;
[1105] Fix | Delete
[1106] Fix | Delete
function applyTextInput(cm, inserted, deleted, sel, origin) {
[1107] Fix | Delete
var doc = cm.doc;
[1108] Fix | Delete
cm.display.shift = false;
[1109] Fix | Delete
if (!sel) sel = doc.sel;
[1110] Fix | Delete
[1111] Fix | Delete
var paste = cm.state.pasteIncoming || origin == "paste";
[1112] Fix | Delete
var textLines = doc.splitLines(inserted), multiPaste = null
[1113] Fix | Delete
// When pasing N lines into N selections, insert one line per selection
[1114] Fix | Delete
if (paste && sel.ranges.length > 1) {
[1115] Fix | Delete
if (lastCopied && lastCopied.text.join("\n") == inserted) {
[1116] Fix | Delete
if (sel.ranges.length % lastCopied.text.length == 0) {
[1117] Fix | Delete
multiPaste = [];
[1118] Fix | Delete
for (var i = 0; i < lastCopied.text.length; i++)
[1119] Fix | Delete
multiPaste.push(doc.splitLines(lastCopied.text[i]));
[1120] Fix | Delete
}
[1121] Fix | Delete
} else if (textLines.length == sel.ranges.length) {
[1122] Fix | Delete
multiPaste = map(textLines, function(l) { return [l]; });
[1123] Fix | Delete
}
[1124] Fix | Delete
}
[1125] Fix | Delete
[1126] Fix | Delete
// Normal behavior is to insert the new text into every selection
[1127] Fix | Delete
for (var i = sel.ranges.length - 1; i >= 0; i--) {
[1128] Fix | Delete
var range = sel.ranges[i];
[1129] Fix | Delete
var from = range.from(), to = range.to();
[1130] Fix | Delete
if (range.empty()) {
[1131] Fix | Delete
if (deleted && deleted > 0) // Handle deletion
[1132] Fix | Delete
from = Pos(from.line, from.ch - deleted);
[1133] Fix | Delete
else if (cm.state.overwrite && !paste) // Handle overwrite
[1134] Fix | Delete
to = Pos(to.line, Math.min(getLine(doc, to.line).text.length, to.ch + lst(textLines).length));
[1135] Fix | Delete
else if (lastCopied && lastCopied.lineWise && lastCopied.text.join("\n") == inserted)
[1136] Fix | Delete
from = to = Pos(from.line, 0)
[1137] Fix | Delete
}
[1138] Fix | Delete
var updateInput = cm.curOp.updateInput;
[1139] Fix | Delete
var changeEvent = {from: from, to: to, text: multiPaste ? multiPaste[i % multiPaste.length] : textLines,
[1140] Fix | Delete
origin: origin || (paste ? "paste" : cm.state.cutIncoming ? "cut" : "+input")};
[1141] Fix | Delete
makeChange(cm.doc, changeEvent);
[1142] Fix | Delete
signalLater(cm, "inputRead", cm, changeEvent);
[1143] Fix | Delete
}
[1144] Fix | Delete
if (inserted && !paste)
[1145] Fix | Delete
triggerElectric(cm, inserted);
[1146] Fix | Delete
[1147] Fix | Delete
ensureCursorVisible(cm);
[1148] Fix | Delete
cm.curOp.updateInput = updateInput;
[1149] Fix | Delete
cm.curOp.typing = true;
[1150] Fix | Delete
cm.state.pasteIncoming = cm.state.cutIncoming = false;
[1151] Fix | Delete
}
[1152] Fix | Delete
[1153] Fix | Delete
function handlePaste(e, cm) {
[1154] Fix | Delete
var pasted = e.clipboardData && e.clipboardData.getData("Text");
[1155] Fix | Delete
if (pasted) {
[1156] Fix | Delete
e.preventDefault();
[1157] Fix | Delete
if (!cm.isReadOnly() && !cm.options.disableInput)
[1158] Fix | Delete
runInOp(cm, function() { applyTextInput(cm, pasted, 0, null, "paste"); });
[1159] Fix | Delete
return true;
[1160] Fix | Delete
}
[1161] Fix | Delete
}
[1162] Fix | Delete
[1163] Fix | Delete
function triggerElectric(cm, inserted) {
[1164] Fix | Delete
// When an 'electric' character is inserted, immediately trigger a reindent
[1165] Fix | Delete
if (!cm.options.electricChars || !cm.options.smartIndent) return;
[1166] Fix | Delete
var sel = cm.doc.sel;
[1167] Fix | Delete
[1168] Fix | Delete
for (var i = sel.ranges.length - 1; i >= 0; i--) {
[1169] Fix | Delete
var range = sel.ranges[i];
[1170] Fix | Delete
if (range.head.ch > 100 || (i && sel.ranges[i - 1].head.line == range.head.line)) continue;
[1171] Fix | Delete
var mode = cm.getModeAt(range.head);
[1172] Fix | Delete
var indented = false;
[1173] Fix | Delete
if (mode.electricChars) {
[1174] Fix | Delete
for (var j = 0; j < mode.electricChars.length; j++)
[1175] Fix | Delete
if (inserted.indexOf(mode.electricChars.charAt(j)) > -1) {
[1176] Fix | Delete
indented = indentLine(cm, range.head.line, "smart");
[1177] Fix | Delete
break;
[1178] Fix | Delete
}
[1179] Fix | Delete
} else if (mode.electricInput) {
[1180] Fix | Delete
if (mode.electricInput.test(getLine(cm.doc, range.head.line).text.slice(0, range.head.ch)))
[1181] Fix | Delete
indented = indentLine(cm, range.head.line, "smart");
[1182] Fix | Delete
}
[1183] Fix | Delete
if (indented) signalLater(cm, "electricInput", cm, range.head.line);
[1184] Fix | Delete
}
[1185] Fix | Delete
}
[1186] Fix | Delete
[1187] Fix | Delete
function copyableRanges(cm) {
[1188] Fix | Delete
var text = [], ranges = [];
[1189] Fix | Delete
for (var i = 0; i < cm.doc.sel.ranges.length; i++) {
[1190] Fix | Delete
var line = cm.doc.sel.ranges[i].head.line;
[1191] Fix | Delete
var lineRange = {anchor: Pos(line, 0), head: Pos(line + 1, 0)};
[1192] Fix | Delete
ranges.push(lineRange);
[1193] Fix | Delete
text.push(cm.getRange(lineRange.anchor, lineRange.head));
[1194] Fix | Delete
}
[1195] Fix | Delete
return {text: text, ranges: ranges};
[1196] Fix | Delete
}
[1197] Fix | Delete
[1198] Fix | Delete
function disableBrowserMagic(field, spellcheck) {
[1199] Fix | Delete
field.setAttribute("autocorrect", "off");
[1200] Fix | Delete
field.setAttribute("autocapitalize", "off");
[1201] Fix | Delete
field.setAttribute("spellcheck", !!spellcheck);
[1202] Fix | Delete
}
[1203] Fix | Delete
[1204] Fix | Delete
// TEXTAREA INPUT STYLE
[1205] Fix | Delete
[1206] Fix | Delete
function TextareaInput(cm) {
[1207] Fix | Delete
this.cm = cm;
[1208] Fix | Delete
// See input.poll and input.reset
[1209] Fix | Delete
this.prevInput = "";
[1210] Fix | Delete
[1211] Fix | Delete
// Flag that indicates whether we expect input to appear real soon
[1212] Fix | Delete
// now (after some event like 'keypress' or 'input') and are
[1213] Fix | Delete
// polling intensively.
[1214] Fix | Delete
this.pollingFast = false;
[1215] Fix | Delete
// Self-resetting timeout for the poller
[1216] Fix | Delete
this.polling = new Delayed();
[1217] Fix | Delete
// Tracks when input.reset has punted to just putting a short
[1218] Fix | Delete
// string into the textarea instead of the full selection.
[1219] Fix | Delete
this.inaccurateSelection = false;
[1220] Fix | Delete
// Used to work around IE issue with selection being forgotten when focus moves away from textarea
[1221] Fix | Delete
this.hasSelection = false;
[1222] Fix | Delete
this.composing = null;
[1223] Fix | Delete
};
[1224] Fix | Delete
[1225] Fix | Delete
function hiddenTextarea() {
[1226] Fix | Delete
var te = elt("textarea", null, null, "position: absolute; bottom: -1em; padding: 0; width: 1px; height: 1em; outline: none");
[1227] Fix | Delete
var div = elt("div", [te], null, "overflow: hidden; position: relative; width: 3px; height: 0px;");
[1228] Fix | Delete
// The textarea is kept positioned near the cursor to prevent the
[1229] Fix | Delete
// fact that it'll be scrolled into view on input from scrolling
[1230] Fix | Delete
// our fake cursor out of view. On webkit, when wrap=off, paste is
[1231] Fix | Delete
// very slow. So make the area wide instead.
[1232] Fix | Delete
if (webkit) te.style.width = "1000px";
[1233] Fix | Delete
else te.setAttribute("wrap", "off");
[1234] Fix | Delete
// If border: 0; -- iOS fails to open keyboard (issue #1287)
[1235] Fix | Delete
if (ios) te.style.border = "1px solid black";
[1236] Fix | Delete
disableBrowserMagic(te);
[1237] Fix | Delete
return div;
[1238] Fix | Delete
}
[1239] Fix | Delete
[1240] Fix | Delete
TextareaInput.prototype = copyObj({
[1241] Fix | Delete
init: function(display) {
[1242] Fix | Delete
var input = this, cm = this.cm;
[1243] Fix | Delete
[1244] Fix | Delete
// Wraps and hides input textarea
[1245] Fix | Delete
var div = this.wrapper = hiddenTextarea();
[1246] Fix | Delete
// The semihidden textarea that is focused when the editor is
[1247] Fix | Delete
// focused, and receives input.
[1248] Fix | Delete
var te = this.textarea = div.firstChild;
[1249] Fix | Delete
display.wrapper.insertBefore(div, display.wrapper.firstChild);
[1250] Fix | Delete
[1251] Fix | Delete
// Needed to hide big blue blinking cursor on Mobile Safari (doesn't seem to work in iOS 8 anymore)
[1252] Fix | Delete
if (ios) te.style.width = "0px";
[1253] Fix | Delete
[1254] Fix | Delete
on(te, "input", function() {
[1255] Fix | Delete
if (ie && ie_version >= 9 && input.hasSelection) input.hasSelection = null;
[1256] Fix | Delete
input.poll();
[1257] Fix | Delete
});
[1258] Fix | Delete
[1259] Fix | Delete
on(te, "paste", function(e) {
[1260] Fix | Delete
if (signalDOMEvent(cm, e) || handlePaste(e, cm)) return
[1261] Fix | Delete
[1262] Fix | Delete
cm.state.pasteIncoming = true;
[1263] Fix | Delete
input.fastPoll();
[1264] Fix | Delete
});
[1265] Fix | Delete
[1266] Fix | Delete
function prepareCopyCut(e) {
[1267] Fix | Delete
if (signalDOMEvent(cm, e)) return
[1268] Fix | Delete
if (cm.somethingSelected()) {
[1269] Fix | Delete
lastCopied = {lineWise: false, text: cm.getSelections()};
[1270] Fix | Delete
if (input.inaccurateSelection) {
[1271] Fix | Delete
input.prevInput = "";
[1272] Fix | Delete
input.inaccurateSelection = false;
[1273] Fix | Delete
te.value = lastCopied.text.join("\n");
[1274] Fix | Delete
selectInput(te);
[1275] Fix | Delete
}
[1276] Fix | Delete
} else if (!cm.options.lineWiseCopyCut) {
[1277] Fix | Delete
return;
[1278] Fix | Delete
} else {
[1279] Fix | Delete
var ranges = copyableRanges(cm);
[1280] Fix | Delete
lastCopied = {lineWise: true, text: ranges.text};
[1281] Fix | Delete
if (e.type == "cut") {
[1282] Fix | Delete
cm.setSelections(ranges.ranges, null, sel_dontScroll);
[1283] Fix | Delete
} else {
[1284] Fix | Delete
input.prevInput = "";
[1285] Fix | Delete
te.value = ranges.text.join("\n");
[1286] Fix | Delete
selectInput(te);
[1287] Fix | Delete
}
[1288] Fix | Delete
}
[1289] Fix | Delete
if (e.type == "cut") cm.state.cutIncoming = true;
[1290] Fix | Delete
}
[1291] Fix | Delete
on(te, "cut", prepareCopyCut);
[1292] Fix | Delete
on(te, "copy", prepareCopyCut);
[1293] Fix | Delete
[1294] Fix | Delete
on(display.scroller, "paste", function(e) {
[1295] Fix | Delete
if (eventInWidget(display, e) || signalDOMEvent(cm, e)) return;
[1296] Fix | Delete
cm.state.pasteIncoming = true;
[1297] Fix | Delete
input.focus();
[1298] Fix | Delete
});
[1299] Fix | Delete
[1300] Fix | Delete
// Prevent normal selection in the editor (we handle our own)
[1301] Fix | Delete
on(display.lineSpace, "selectstart", function(e) {
[1302] Fix | Delete
if (!eventInWidget(display, e)) e_preventDefault(e);
[1303] Fix | Delete
});
[1304] Fix | Delete
[1305] Fix | Delete
on(te, "compositionstart", function() {
[1306] Fix | Delete
var start = cm.getCursor("from");
[1307] Fix | Delete
if (input.composing) input.composing.range.clear()
[1308] Fix | Delete
input.composing = {
[1309] Fix | Delete
start: start,
[1310] Fix | Delete
range: cm.markText(start, cm.getCursor("to"), {className: "CodeMirror-composing"})
[1311] Fix | Delete
};
[1312] Fix | Delete
});
[1313] Fix | Delete
on(te, "compositionend", function() {
[1314] Fix | Delete
if (input.composing) {
[1315] Fix | Delete
input.poll();
[1316] Fix | Delete
input.composing.range.clear();
[1317] Fix | Delete
input.composing = null;
[1318] Fix | Delete
}
[1319] Fix | Delete
});
[1320] Fix | Delete
},
[1321] Fix | Delete
[1322] Fix | Delete
prepareSelection: function() {
[1323] Fix | Delete
// Redraw the selection and/or cursor
[1324] Fix | Delete
var cm = this.cm, display = cm.display, doc = cm.doc;
[1325] Fix | Delete
var result = prepareSelection(cm);
[1326] Fix | Delete
[1327] Fix | Delete
// Move the hidden textarea near the cursor to prevent scrolling artifacts
[1328] Fix | Delete
if (cm.options.moveInputWithCursor) {
[1329] Fix | Delete
var headPos = cursorCoords(cm, doc.sel.primary().head, "div");
[1330] Fix | Delete
var wrapOff = display.wrapper.getBoundingClientRect(), lineOff = display.lineDiv.getBoundingClientRect();
[1331] Fix | Delete
result.teTop = Math.max(0, Math.min(display.wrapper.clientHeight - 10,
[1332] Fix | Delete
headPos.top + lineOff.top - wrapOff.top));
[1333] Fix | Delete
result.teLeft = Math.max(0, Math.min(display.wrapper.clientWidth - 10,
[1334] Fix | Delete
headPos.left + lineOff.left - wrapOff.left));
[1335] Fix | Delete
}
[1336] Fix | Delete
[1337] Fix | Delete
return result;
[1338] Fix | Delete
},
[1339] Fix | Delete
[1340] Fix | Delete
showSelection: function(drawn) {
[1341] Fix | Delete
var cm = this.cm, display = cm.display;
[1342] Fix | Delete
removeChildrenAndAdd(display.cursorDiv, drawn.cursors);
[1343] Fix | Delete
removeChildrenAndAdd(display.selectionDiv, drawn.selection);
[1344] Fix | Delete
if (drawn.teTop != null) {
[1345] Fix | Delete
this.wrapper.style.top = drawn.teTop + "px";
[1346] Fix | Delete
this.wrapper.style.left = drawn.teLeft + "px";
[1347] Fix | Delete
}
[1348] Fix | Delete
},
[1349] Fix | Delete
[1350] Fix | Delete
// Reset the input to correspond to the selection (or to be empty,
[1351] Fix | Delete
// when not typing and nothing is selected)
[1352] Fix | Delete
reset: function(typing) {
[1353] Fix | Delete
if (this.contextMenuPending) return;
[1354] Fix | Delete
var minimal, selected, cm = this.cm, doc = cm.doc;
[1355] Fix | Delete
if (cm.somethingSelected()) {
[1356] Fix | Delete
this.prevInput = "";
[1357] Fix | Delete
var range = doc.sel.primary();
[1358] Fix | Delete
minimal = hasCopyEvent &&
[1359] Fix | Delete
(range.to().line - range.from().line > 100 || (selected = cm.getSelection()).length > 1000);
[1360] Fix | Delete
var content = minimal ? "-" : selected || cm.getSelection();
[1361] Fix | Delete
this.textarea.value = content;
[1362] Fix | Delete
if (cm.state.focused) selectInput(this.textarea);
[1363] Fix | Delete
if (ie && ie_version >= 9) this.hasSelection = content;
[1364] Fix | Delete
} else if (!typing) {
[1365] Fix | Delete
this.prevInput = this.textarea.value = "";
[1366] Fix | Delete
if (ie && ie_version >= 9) this.hasSelection = null;
[1367] Fix | Delete
}
[1368] Fix | Delete
this.inaccurateSelection = minimal;
[1369] Fix | Delete
},
[1370] Fix | Delete
[1371] Fix | Delete
getField: function() { return this.textarea; },
[1372] Fix | Delete
[1373] Fix | Delete
supportsTouch: function() { return false; },
[1374] Fix | Delete
[1375] Fix | Delete
focus: function() {
[1376] Fix | Delete
if (this.cm.options.readOnly != "nocursor" && (!mobile || activeElt() != this.textarea)) {
[1377] Fix | Delete
try { this.textarea.focus(); }
[1378] Fix | Delete
catch (e) {} // IE8 will throw if the textarea is display: none or not in DOM
[1379] Fix | Delete
}
[1380] Fix | Delete
},
[1381] Fix | Delete
[1382] Fix | Delete
blur: function() { this.textarea.blur(); },
[1383] Fix | Delete
[1384] Fix | Delete
resetPosition: function() {
[1385] Fix | Delete
this.wrapper.style.top = this.wrapper.style.left = 0;
[1386] Fix | Delete
},
[1387] Fix | Delete
[1388] Fix | Delete
receivedFocus: function() { this.slowPoll(); },
[1389] Fix | Delete
[1390] Fix | Delete
// Poll for input changes, using the normal rate of polling. This
[1391] Fix | Delete
// runs as long as the editor is focused.
[1392] Fix | Delete
slowPoll: function() {
[1393] Fix | Delete
var input = this;
[1394] Fix | Delete
if (input.pollingFast) return;
[1395] Fix | Delete
input.polling.set(this.cm.options.pollInterval, function() {
[1396] Fix | Delete
input.poll();
[1397] Fix | Delete
if (input.cm.state.focused) input.slowPoll();
[1398] Fix | Delete
});
[1399] Fix | Delete
},
[1400] Fix | Delete
[1401] Fix | Delete
// When an event has just come in that is likely to add or change
[1402] Fix | Delete
// something in the input textarea, we poll faster, to ensure that
[1403] Fix | Delete
// the change appears on the screen quickly.
[1404] Fix | Delete
fastPoll: function() {
[1405] Fix | Delete
var missed = false, input = this;
[1406] Fix | Delete
input.pollingFast = true;
[1407] Fix | Delete
function p() {
[1408] Fix | Delete
var changed = input.poll();
[1409] Fix | Delete
if (!changed && !missed) {missed = true; input.polling.set(60, p);}
[1410] Fix | Delete
else {input.pollingFast = false; input.slowPoll();}
[1411] Fix | Delete
}
[1412] Fix | Delete
input.polling.set(20, p);
[1413] Fix | Delete
},
[1414] Fix | Delete
[1415] Fix | Delete
// Read input from the textarea, and update the document to match.
[1416] Fix | Delete
// When something is selected, it is present in the textarea, and
[1417] Fix | Delete
// selected (unless it is huge, in which case a placeholder is
[1418] Fix | Delete
// used). When nothing is selected, the cursor sits after previously
[1419] Fix | Delete
// seen text (can be empty), which is stored in prevInput (we must
[1420] Fix | Delete
// not reset the textarea when typing, because that breaks IME).
[1421] Fix | Delete
poll: function() {
[1422] Fix | Delete
var cm = this.cm, input = this.textarea, prevInput = this.prevInput;
[1423] Fix | Delete
// Since this is called a *lot*, try to bail out as cheaply as
[1424] Fix | Delete
// possible when it is clear that nothing happened. hasSelection
[1425] Fix | Delete
// will be the case when there is a lot of text in the textarea,
[1426] Fix | Delete
// in which case reading its value would be expensive.
[1427] Fix | Delete
if (this.contextMenuPending || !cm.state.focused ||
[1428] Fix | Delete
(hasSelection(input) && !prevInput && !this.composing) ||
[1429] Fix | Delete
cm.isReadOnly() || cm.options.disableInput || cm.state.keySeq)
[1430] Fix | Delete
return false;
[1431] Fix | Delete
[1432] Fix | Delete
var text = input.value;
[1433] Fix | Delete
// If nothing changed, bail.
[1434] Fix | Delete
if (text == prevInput && !cm.somethingSelected()) return false;
[1435] Fix | Delete
// Work around nonsensical selection resetting in IE9/10, and
[1436] Fix | Delete
// inexplicable appearance of private area unicode characters on
[1437] Fix | Delete
// some key combos in Mac (#2689).
[1438] Fix | Delete
if (ie && ie_version >= 9 && this.hasSelection === text ||
[1439] Fix | Delete
mac && /[\uf700-\uf7ff]/.test(text)) {
[1440] Fix | Delete
cm.display.input.reset();
[1441] Fix | Delete
return false;
[1442] Fix | Delete
}
[1443] Fix | Delete
[1444] Fix | Delete
if (cm.doc.sel == cm.display.selForContextMenu) {
[1445] Fix | Delete
var first = text.charCodeAt(0);
[1446] Fix | Delete
if (first == 0x200b && !prevInput) prevInput = "\u200b";
[1447] Fix | Delete
if (first == 0x21da) { this.reset(); return this.cm.execCommand("undo"); }
[1448] Fix | Delete
}
[1449] Fix | Delete
// Find the part of the input that is actually new
[1450] Fix | Delete
var same = 0, l = Math.min(prevInput.length, text.length);
[1451] Fix | Delete
while (same < l && prevInput.charCodeAt(same) == text.charCodeAt(same)) ++same;
[1452] Fix | Delete
[1453] Fix | Delete
var self = this;
[1454] Fix | Delete
runInOp(cm, function() {
[1455] Fix | Delete
applyTextInput(cm, text.slice(same), prevInput.length - same,
[1456] Fix | Delete
null, self.composing ? "*compose" : null);
[1457] Fix | Delete
[1458] Fix | Delete
// Don't leave long text in the textarea, since it makes further polling slow
[1459] Fix | Delete
if (text.length > 1000 || text.indexOf("\n") > -1) input.value = self.prevInput = "";
[1460] Fix | Delete
else self.prevInput = text;
[1461] Fix | Delete
[1462] Fix | Delete
if (self.composing) {
[1463] Fix | Delete
self.composing.range.clear();
[1464] Fix | Delete
self.composing.range = cm.markText(self.composing.start, cm.getCursor("to"),
[1465] Fix | Delete
{className: "CodeMirror-composing"});
[1466] Fix | Delete
}
[1467] Fix | Delete
});
[1468] Fix | Delete
return true;
[1469] Fix | Delete
},
[1470] Fix | Delete
[1471] Fix | Delete
ensurePolled: function() {
[1472] Fix | Delete
if (this.pollingFast && this.poll()) this.pollingFast = false;
[1473] Fix | Delete
},
[1474] Fix | Delete
[1475] Fix | Delete
onKeyPress: function() {
[1476] Fix | Delete
if (ie && ie_version >= 9) this.hasSelection = null;
[1477] Fix | Delete
this.fastPoll();
[1478] Fix | Delete
},
[1479] Fix | Delete
[1480] Fix | Delete
onContextMenu: function(e) {
[1481] Fix | Delete
var input = this, cm = input.cm, display = cm.display, te = input.textarea;
[1482] Fix | Delete
var pos = posFromMouse(cm, e), scrollPos = display.scroller.scrollTop;
[1483] Fix | Delete
if (!pos || presto) return; // Opera is difficult.
[1484] Fix | Delete
[1485] Fix | Delete
// Reset the current text selection only if the click is done outside of the selection
[1486] Fix | Delete
// and 'resetSelectionOnContextMenu' option is true.
[1487] Fix | Delete
var reset = cm.options.resetSelectionOnContextMenu;
[1488] Fix | Delete
if (reset && cm.doc.sel.contains(pos) == -1)
[1489] Fix | Delete
operation(cm, setSelection)(cm.doc, simpleSelection(pos), sel_dontScroll);
[1490] Fix | Delete
[1491] Fix | Delete
var oldCSS = te.style.cssText, oldWrapperCSS = input.wrapper.style.cssText;
[1492] Fix | Delete
input.wrapper.style.cssText = "position: absolute"
[1493] Fix | Delete
var wrapperBox = input.wrapper.getBoundingClientRect()
[1494] Fix | Delete
te.style.cssText = "position: absolute; width: 30px; height: 30px; top: " + (e.clientY - wrapperBox.top - 5) +
[1495] Fix | Delete
"px; left: " + (e.clientX - wrapperBox.left - 5) + "px; z-index: 1000; background: " +
[1496] Fix | Delete
(ie ? "rgba(255, 255, 255, .05)" : "transparent") +
[1497] Fix | Delete
"; outline: none; border-width: 0; outline: none; overflow: hidden; opacity: .05; filter: alpha(opacity=5);";
[1498] Fix | Delete
if (webkit) var oldScrollY = window.scrollY; // Work around Chrome issue (#2712)
[1499] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function