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
option("workTime", 100);
[5500] Fix | Delete
option("workDelay", 100);
[5501] Fix | Delete
option("flattenSpans", true, resetModeState, true);
[5502] Fix | Delete
option("addModeClass", false, resetModeState, true);
[5503] Fix | Delete
option("pollInterval", 100);
[5504] Fix | Delete
option("undoDepth", 200, function(cm, val){cm.doc.history.undoDepth = val;});
[5505] Fix | Delete
option("historyEventDelay", 1250);
[5506] Fix | Delete
option("viewportMargin", 10, function(cm){cm.refresh();}, true);
[5507] Fix | Delete
option("maxHighlightLength", 10000, resetModeState, true);
[5508] Fix | Delete
option("moveInputWithCursor", true, function(cm, val) {
[5509] Fix | Delete
if (!val) cm.display.input.resetPosition();
[5510] Fix | Delete
});
[5511] Fix | Delete
[5512] Fix | Delete
option("tabindex", null, function(cm, val) {
[5513] Fix | Delete
cm.display.input.getField().tabIndex = val || "";
[5514] Fix | Delete
});
[5515] Fix | Delete
option("autofocus", null);
[5516] Fix | Delete
[5517] Fix | Delete
// MODE DEFINITION AND QUERYING
[5518] Fix | Delete
[5519] Fix | Delete
// Known modes, by name and by MIME
[5520] Fix | Delete
var modes = CodeMirror.modes = {}, mimeModes = CodeMirror.mimeModes = {};
[5521] Fix | Delete
[5522] Fix | Delete
// Extra arguments are stored as the mode's dependencies, which is
[5523] Fix | Delete
// used by (legacy) mechanisms like loadmode.js to automatically
[5524] Fix | Delete
// load a mode. (Preferred mechanism is the require/define calls.)
[5525] Fix | Delete
CodeMirror.defineMode = function(name, mode) {
[5526] Fix | Delete
if (!CodeMirror.defaults.mode && name != "null") CodeMirror.defaults.mode = name;
[5527] Fix | Delete
if (arguments.length > 2)
[5528] Fix | Delete
mode.dependencies = Array.prototype.slice.call(arguments, 2);
[5529] Fix | Delete
modes[name] = mode;
[5530] Fix | Delete
};
[5531] Fix | Delete
[5532] Fix | Delete
CodeMirror.defineMIME = function(mime, spec) {
[5533] Fix | Delete
mimeModes[mime] = spec;
[5534] Fix | Delete
};
[5535] Fix | Delete
[5536] Fix | Delete
// Given a MIME type, a {name, ...options} config object, or a name
[5537] Fix | Delete
// string, return a mode config object.
[5538] Fix | Delete
CodeMirror.resolveMode = function(spec) {
[5539] Fix | Delete
if (typeof spec == "string" && mimeModes.hasOwnProperty(spec)) {
[5540] Fix | Delete
spec = mimeModes[spec];
[5541] Fix | Delete
} else if (spec && typeof spec.name == "string" && mimeModes.hasOwnProperty(spec.name)) {
[5542] Fix | Delete
var found = mimeModes[spec.name];
[5543] Fix | Delete
if (typeof found == "string") found = {name: found};
[5544] Fix | Delete
spec = createObj(found, spec);
[5545] Fix | Delete
spec.name = found.name;
[5546] Fix | Delete
} else if (typeof spec == "string" && /^[\w\-]+\/[\w\-]+\+xml$/.test(spec)) {
[5547] Fix | Delete
return CodeMirror.resolveMode("application/xml");
[5548] Fix | Delete
} else if (typeof spec == "string" && /^[\w\-]+\/[\w\-]+\+json$/.test(spec)) {
[5549] Fix | Delete
return CodeMirror.resolveMode("application/json");
[5550] Fix | Delete
}
[5551] Fix | Delete
if (typeof spec == "string") return {name: spec};
[5552] Fix | Delete
else return spec || {name: "null"};
[5553] Fix | Delete
};
[5554] Fix | Delete
[5555] Fix | Delete
// Given a mode spec (anything that resolveMode accepts), find and
[5556] Fix | Delete
// initialize an actual mode object.
[5557] Fix | Delete
CodeMirror.getMode = function(options, spec) {
[5558] Fix | Delete
var spec = CodeMirror.resolveMode(spec);
[5559] Fix | Delete
var mfactory = modes[spec.name];
[5560] Fix | Delete
if (!mfactory) return CodeMirror.getMode(options, "text/plain");
[5561] Fix | Delete
var modeObj = mfactory(options, spec);
[5562] Fix | Delete
if (modeExtensions.hasOwnProperty(spec.name)) {
[5563] Fix | Delete
var exts = modeExtensions[spec.name];
[5564] Fix | Delete
for (var prop in exts) {
[5565] Fix | Delete
if (!exts.hasOwnProperty(prop)) continue;
[5566] Fix | Delete
if (modeObj.hasOwnProperty(prop)) modeObj["_" + prop] = modeObj[prop];
[5567] Fix | Delete
modeObj[prop] = exts[prop];
[5568] Fix | Delete
}
[5569] Fix | Delete
}
[5570] Fix | Delete
modeObj.name = spec.name;
[5571] Fix | Delete
if (spec.helperType) modeObj.helperType = spec.helperType;
[5572] Fix | Delete
if (spec.modeProps) for (var prop in spec.modeProps)
[5573] Fix | Delete
modeObj[prop] = spec.modeProps[prop];
[5574] Fix | Delete
[5575] Fix | Delete
return modeObj;
[5576] Fix | Delete
};
[5577] Fix | Delete
[5578] Fix | Delete
// Minimal default mode.
[5579] Fix | Delete
CodeMirror.defineMode("null", function() {
[5580] Fix | Delete
return {token: function(stream) {stream.skipToEnd();}};
[5581] Fix | Delete
});
[5582] Fix | Delete
CodeMirror.defineMIME("text/plain", "null");
[5583] Fix | Delete
[5584] Fix | Delete
// This can be used to attach properties to mode objects from
[5585] Fix | Delete
// outside the actual mode definition.
[5586] Fix | Delete
var modeExtensions = CodeMirror.modeExtensions = {};
[5587] Fix | Delete
CodeMirror.extendMode = function(mode, properties) {
[5588] Fix | Delete
var exts = modeExtensions.hasOwnProperty(mode) ? modeExtensions[mode] : (modeExtensions[mode] = {});
[5589] Fix | Delete
copyObj(properties, exts);
[5590] Fix | Delete
};
[5591] Fix | Delete
[5592] Fix | Delete
// EXTENSIONS
[5593] Fix | Delete
[5594] Fix | Delete
CodeMirror.defineExtension = function(name, func) {
[5595] Fix | Delete
CodeMirror.prototype[name] = func;
[5596] Fix | Delete
};
[5597] Fix | Delete
CodeMirror.defineDocExtension = function(name, func) {
[5598] Fix | Delete
Doc.prototype[name] = func;
[5599] Fix | Delete
};
[5600] Fix | Delete
CodeMirror.defineOption = option;
[5601] Fix | Delete
[5602] Fix | Delete
var initHooks = [];
[5603] Fix | Delete
CodeMirror.defineInitHook = function(f) {initHooks.push(f);};
[5604] Fix | Delete
[5605] Fix | Delete
var helpers = CodeMirror.helpers = {};
[5606] Fix | Delete
CodeMirror.registerHelper = function(type, name, value) {
[5607] Fix | Delete
if (!helpers.hasOwnProperty(type)) helpers[type] = CodeMirror[type] = {_global: []};
[5608] Fix | Delete
helpers[type][name] = value;
[5609] Fix | Delete
};
[5610] Fix | Delete
CodeMirror.registerGlobalHelper = function(type, name, predicate, value) {
[5611] Fix | Delete
CodeMirror.registerHelper(type, name, value);
[5612] Fix | Delete
helpers[type]._global.push({pred: predicate, val: value});
[5613] Fix | Delete
};
[5614] Fix | Delete
[5615] Fix | Delete
// MODE STATE HANDLING
[5616] Fix | Delete
[5617] Fix | Delete
// Utility functions for working with state. Exported because nested
[5618] Fix | Delete
// modes need to do this for their inner modes.
[5619] Fix | Delete
[5620] Fix | Delete
var copyState = CodeMirror.copyState = function(mode, state) {
[5621] Fix | Delete
if (state === true) return state;
[5622] Fix | Delete
if (mode.copyState) return mode.copyState(state);
[5623] Fix | Delete
var nstate = {};
[5624] Fix | Delete
for (var n in state) {
[5625] Fix | Delete
var val = state[n];
[5626] Fix | Delete
if (val instanceof Array) val = val.concat([]);
[5627] Fix | Delete
nstate[n] = val;
[5628] Fix | Delete
}
[5629] Fix | Delete
return nstate;
[5630] Fix | Delete
};
[5631] Fix | Delete
[5632] Fix | Delete
var startState = CodeMirror.startState = function(mode, a1, a2) {
[5633] Fix | Delete
return mode.startState ? mode.startState(a1, a2) : true;
[5634] Fix | Delete
};
[5635] Fix | Delete
[5636] Fix | Delete
// Given a mode and a state (for that mode), find the inner mode and
[5637] Fix | Delete
// state at the position that the state refers to.
[5638] Fix | Delete
CodeMirror.innerMode = function(mode, state) {
[5639] Fix | Delete
while (mode.innerMode) {
[5640] Fix | Delete
var info = mode.innerMode(state);
[5641] Fix | Delete
if (!info || info.mode == mode) break;
[5642] Fix | Delete
state = info.state;
[5643] Fix | Delete
mode = info.mode;
[5644] Fix | Delete
}
[5645] Fix | Delete
return info || {mode: mode, state: state};
[5646] Fix | Delete
};
[5647] Fix | Delete
[5648] Fix | Delete
// STANDARD COMMANDS
[5649] Fix | Delete
[5650] Fix | Delete
// Commands are parameter-less actions that can be performed on an
[5651] Fix | Delete
// editor, mostly used for keybindings.
[5652] Fix | Delete
var commands = CodeMirror.commands = {
[5653] Fix | Delete
selectAll: function(cm) {cm.setSelection(Pos(cm.firstLine(), 0), Pos(cm.lastLine()), sel_dontScroll);},
[5654] Fix | Delete
singleSelection: function(cm) {
[5655] Fix | Delete
cm.setSelection(cm.getCursor("anchor"), cm.getCursor("head"), sel_dontScroll);
[5656] Fix | Delete
},
[5657] Fix | Delete
killLine: function(cm) {
[5658] Fix | Delete
deleteNearSelection(cm, function(range) {
[5659] Fix | Delete
if (range.empty()) {
[5660] Fix | Delete
var len = getLine(cm.doc, range.head.line).text.length;
[5661] Fix | Delete
if (range.head.ch == len && range.head.line < cm.lastLine())
[5662] Fix | Delete
return {from: range.head, to: Pos(range.head.line + 1, 0)};
[5663] Fix | Delete
else
[5664] Fix | Delete
return {from: range.head, to: Pos(range.head.line, len)};
[5665] Fix | Delete
} else {
[5666] Fix | Delete
return {from: range.from(), to: range.to()};
[5667] Fix | Delete
}
[5668] Fix | Delete
});
[5669] Fix | Delete
},
[5670] Fix | Delete
deleteLine: function(cm) {
[5671] Fix | Delete
deleteNearSelection(cm, function(range) {
[5672] Fix | Delete
return {from: Pos(range.from().line, 0),
[5673] Fix | Delete
to: clipPos(cm.doc, Pos(range.to().line + 1, 0))};
[5674] Fix | Delete
});
[5675] Fix | Delete
},
[5676] Fix | Delete
delLineLeft: function(cm) {
[5677] Fix | Delete
deleteNearSelection(cm, function(range) {
[5678] Fix | Delete
return {from: Pos(range.from().line, 0), to: range.from()};
[5679] Fix | Delete
});
[5680] Fix | Delete
},
[5681] Fix | Delete
delWrappedLineLeft: function(cm) {
[5682] Fix | Delete
deleteNearSelection(cm, function(range) {
[5683] Fix | Delete
var top = cm.charCoords(range.head, "div").top + 5;
[5684] Fix | Delete
var leftPos = cm.coordsChar({left: 0, top: top}, "div");
[5685] Fix | Delete
return {from: leftPos, to: range.from()};
[5686] Fix | Delete
});
[5687] Fix | Delete
},
[5688] Fix | Delete
delWrappedLineRight: function(cm) {
[5689] Fix | Delete
deleteNearSelection(cm, function(range) {
[5690] Fix | Delete
var top = cm.charCoords(range.head, "div").top + 5;
[5691] Fix | Delete
var rightPos = cm.coordsChar({left: cm.display.lineDiv.offsetWidth + 100, top: top}, "div");
[5692] Fix | Delete
return {from: range.from(), to: rightPos };
[5693] Fix | Delete
});
[5694] Fix | Delete
},
[5695] Fix | Delete
undo: function(cm) {cm.undo();},
[5696] Fix | Delete
redo: function(cm) {cm.redo();},
[5697] Fix | Delete
undoSelection: function(cm) {cm.undoSelection();},
[5698] Fix | Delete
redoSelection: function(cm) {cm.redoSelection();},
[5699] Fix | Delete
goDocStart: function(cm) {cm.extendSelection(Pos(cm.firstLine(), 0));},
[5700] Fix | Delete
goDocEnd: function(cm) {cm.extendSelection(Pos(cm.lastLine()));},
[5701] Fix | Delete
goLineStart: function(cm) {
[5702] Fix | Delete
cm.extendSelectionsBy(function(range) { return lineStart(cm, range.head.line); },
[5703] Fix | Delete
{origin: "+move", bias: 1});
[5704] Fix | Delete
},
[5705] Fix | Delete
goLineStartSmart: function(cm) {
[5706] Fix | Delete
cm.extendSelectionsBy(function(range) {
[5707] Fix | Delete
return lineStartSmart(cm, range.head);
[5708] Fix | Delete
}, {origin: "+move", bias: 1});
[5709] Fix | Delete
},
[5710] Fix | Delete
goLineEnd: function(cm) {
[5711] Fix | Delete
cm.extendSelectionsBy(function(range) { return lineEnd(cm, range.head.line); },
[5712] Fix | Delete
{origin: "+move", bias: -1});
[5713] Fix | Delete
},
[5714] Fix | Delete
goLineRight: function(cm) {
[5715] Fix | Delete
cm.extendSelectionsBy(function(range) {
[5716] Fix | Delete
var top = cm.charCoords(range.head, "div").top + 5;
[5717] Fix | Delete
return cm.coordsChar({left: cm.display.lineDiv.offsetWidth + 100, top: top}, "div");
[5718] Fix | Delete
}, sel_move);
[5719] Fix | Delete
},
[5720] Fix | Delete
goLineLeft: function(cm) {
[5721] Fix | Delete
cm.extendSelectionsBy(function(range) {
[5722] Fix | Delete
var top = cm.charCoords(range.head, "div").top + 5;
[5723] Fix | Delete
return cm.coordsChar({left: 0, top: top}, "div");
[5724] Fix | Delete
}, sel_move);
[5725] Fix | Delete
},
[5726] Fix | Delete
goLineLeftSmart: function(cm) {
[5727] Fix | Delete
cm.extendSelectionsBy(function(range) {
[5728] Fix | Delete
var top = cm.charCoords(range.head, "div").top + 5;
[5729] Fix | Delete
var pos = cm.coordsChar({left: 0, top: top}, "div");
[5730] Fix | Delete
if (pos.ch < cm.getLine(pos.line).search(/\S/)) return lineStartSmart(cm, range.head);
[5731] Fix | Delete
return pos;
[5732] Fix | Delete
}, sel_move);
[5733] Fix | Delete
},
[5734] Fix | Delete
goLineUp: function(cm) {cm.moveV(-1, "line");},
[5735] Fix | Delete
goLineDown: function(cm) {cm.moveV(1, "line");},
[5736] Fix | Delete
goPageUp: function(cm) {cm.moveV(-1, "page");},
[5737] Fix | Delete
goPageDown: function(cm) {cm.moveV(1, "page");},
[5738] Fix | Delete
goCharLeft: function(cm) {cm.moveH(-1, "char");},
[5739] Fix | Delete
goCharRight: function(cm) {cm.moveH(1, "char");},
[5740] Fix | Delete
goColumnLeft: function(cm) {cm.moveH(-1, "column");},
[5741] Fix | Delete
goColumnRight: function(cm) {cm.moveH(1, "column");},
[5742] Fix | Delete
goWordLeft: function(cm) {cm.moveH(-1, "word");},
[5743] Fix | Delete
goGroupRight: function(cm) {cm.moveH(1, "group");},
[5744] Fix | Delete
goGroupLeft: function(cm) {cm.moveH(-1, "group");},
[5745] Fix | Delete
goWordRight: function(cm) {cm.moveH(1, "word");},
[5746] Fix | Delete
delCharBefore: function(cm) {cm.deleteH(-1, "char");},
[5747] Fix | Delete
delCharAfter: function(cm) {cm.deleteH(1, "char");},
[5748] Fix | Delete
delWordBefore: function(cm) {cm.deleteH(-1, "word");},
[5749] Fix | Delete
delWordAfter: function(cm) {cm.deleteH(1, "word");},
[5750] Fix | Delete
delGroupBefore: function(cm) {cm.deleteH(-1, "group");},
[5751] Fix | Delete
delGroupAfter: function(cm) {cm.deleteH(1, "group");},
[5752] Fix | Delete
indentAuto: function(cm) {cm.indentSelection("smart");},
[5753] Fix | Delete
indentMore: function(cm) {cm.indentSelection("add");},
[5754] Fix | Delete
indentLess: function(cm) {cm.indentSelection("subtract");},
[5755] Fix | Delete
insertTab: function(cm) {cm.replaceSelection("\t");},
[5756] Fix | Delete
insertSoftTab: function(cm) {
[5757] Fix | Delete
var spaces = [], ranges = cm.listSelections(), tabSize = cm.options.tabSize;
[5758] Fix | Delete
for (var i = 0; i < ranges.length; i++) {
[5759] Fix | Delete
var pos = ranges[i].from();
[5760] Fix | Delete
var col = countColumn(cm.getLine(pos.line), pos.ch, tabSize);
[5761] Fix | Delete
spaces.push(spaceStr(tabSize - col % tabSize));
[5762] Fix | Delete
}
[5763] Fix | Delete
cm.replaceSelections(spaces);
[5764] Fix | Delete
},
[5765] Fix | Delete
defaultTab: function(cm) {
[5766] Fix | Delete
if (cm.somethingSelected()) cm.indentSelection("add");
[5767] Fix | Delete
else cm.execCommand("insertTab");
[5768] Fix | Delete
},
[5769] Fix | Delete
transposeChars: function(cm) {
[5770] Fix | Delete
runInOp(cm, function() {
[5771] Fix | Delete
var ranges = cm.listSelections(), newSel = [];
[5772] Fix | Delete
for (var i = 0; i < ranges.length; i++) {
[5773] Fix | Delete
var cur = ranges[i].head, line = getLine(cm.doc, cur.line).text;
[5774] Fix | Delete
if (line) {
[5775] Fix | Delete
if (cur.ch == line.length) cur = new Pos(cur.line, cur.ch - 1);
[5776] Fix | Delete
if (cur.ch > 0) {
[5777] Fix | Delete
cur = new Pos(cur.line, cur.ch + 1);
[5778] Fix | Delete
cm.replaceRange(line.charAt(cur.ch - 1) + line.charAt(cur.ch - 2),
[5779] Fix | Delete
Pos(cur.line, cur.ch - 2), cur, "+transpose");
[5780] Fix | Delete
} else if (cur.line > cm.doc.first) {
[5781] Fix | Delete
var prev = getLine(cm.doc, cur.line - 1).text;
[5782] Fix | Delete
if (prev)
[5783] Fix | Delete
cm.replaceRange(line.charAt(0) + cm.doc.lineSeparator() +
[5784] Fix | Delete
prev.charAt(prev.length - 1),
[5785] Fix | Delete
Pos(cur.line - 1, prev.length - 1), Pos(cur.line, 1), "+transpose");
[5786] Fix | Delete
}
[5787] Fix | Delete
}
[5788] Fix | Delete
newSel.push(new Range(cur, cur));
[5789] Fix | Delete
}
[5790] Fix | Delete
cm.setSelections(newSel);
[5791] Fix | Delete
});
[5792] Fix | Delete
},
[5793] Fix | Delete
newlineAndIndent: function(cm) {
[5794] Fix | Delete
runInOp(cm, function() {
[5795] Fix | Delete
var len = cm.listSelections().length;
[5796] Fix | Delete
for (var i = 0; i < len; i++) {
[5797] Fix | Delete
var range = cm.listSelections()[i];
[5798] Fix | Delete
cm.replaceRange(cm.doc.lineSeparator(), range.anchor, range.head, "+input");
[5799] Fix | Delete
cm.indentLine(range.from().line + 1, null, true);
[5800] Fix | Delete
}
[5801] Fix | Delete
ensureCursorVisible(cm);
[5802] Fix | Delete
});
[5803] Fix | Delete
},
[5804] Fix | Delete
openLine: function(cm) {cm.replaceSelection("\n", "start")},
[5805] Fix | Delete
toggleOverwrite: function(cm) {cm.toggleOverwrite();}
[5806] Fix | Delete
};
[5807] Fix | Delete
[5808] Fix | Delete
[5809] Fix | Delete
// STANDARD KEYMAPS
[5810] Fix | Delete
[5811] Fix | Delete
var keyMap = CodeMirror.keyMap = {};
[5812] Fix | Delete
[5813] Fix | Delete
keyMap.basic = {
[5814] Fix | Delete
"Left": "goCharLeft", "Right": "goCharRight", "Up": "goLineUp", "Down": "goLineDown",
[5815] Fix | Delete
"End": "goLineEnd", "Home": "goLineStartSmart", "PageUp": "goPageUp", "PageDown": "goPageDown",
[5816] Fix | Delete
"Delete": "delCharAfter", "Backspace": "delCharBefore", "Shift-Backspace": "delCharBefore",
[5817] Fix | Delete
"Tab": "defaultTab", "Shift-Tab": "indentAuto",
[5818] Fix | Delete
"Enter": "newlineAndIndent", "Insert": "toggleOverwrite",
[5819] Fix | Delete
"Esc": "singleSelection"
[5820] Fix | Delete
};
[5821] Fix | Delete
// Note that the save and find-related commands aren't defined by
[5822] Fix | Delete
// default. User code or addons can define them. Unknown commands
[5823] Fix | Delete
// are simply ignored.
[5824] Fix | Delete
keyMap.pcDefault = {
[5825] Fix | Delete
"Ctrl-A": "selectAll", "Ctrl-D": "deleteLine", "Ctrl-Z": "undo", "Shift-Ctrl-Z": "redo", "Ctrl-Y": "redo",
[5826] Fix | Delete
"Ctrl-Home": "goDocStart", "Ctrl-End": "goDocEnd", "Ctrl-Up": "goLineUp", "Ctrl-Down": "goLineDown",
[5827] Fix | Delete
"Ctrl-Left": "goGroupLeft", "Ctrl-Right": "goGroupRight", "Alt-Left": "goLineStart", "Alt-Right": "goLineEnd",
[5828] Fix | Delete
"Ctrl-Backspace": "delGroupBefore", "Ctrl-Delete": "delGroupAfter", "Ctrl-S": "save", "Ctrl-F": "find",
[5829] Fix | Delete
"Ctrl-G": "findNext", "Shift-Ctrl-G": "findPrev", "Shift-Ctrl-F": "replace", "Shift-Ctrl-R": "replaceAll",
[5830] Fix | Delete
"Ctrl-[": "indentLess", "Ctrl-]": "indentMore",
[5831] Fix | Delete
"Ctrl-U": "undoSelection", "Shift-Ctrl-U": "redoSelection", "Alt-U": "redoSelection",
[5832] Fix | Delete
fallthrough: "basic"
[5833] Fix | Delete
};
[5834] Fix | Delete
// Very basic readline/emacs-style bindings, which are standard on Mac.
[5835] Fix | Delete
keyMap.emacsy = {
[5836] Fix | Delete
"Ctrl-F": "goCharRight", "Ctrl-B": "goCharLeft", "Ctrl-P": "goLineUp", "Ctrl-N": "goLineDown",
[5837] Fix | Delete
"Alt-F": "goWordRight", "Alt-B": "goWordLeft", "Ctrl-A": "goLineStart", "Ctrl-E": "goLineEnd",
[5838] Fix | Delete
"Ctrl-V": "goPageDown", "Shift-Ctrl-V": "goPageUp", "Ctrl-D": "delCharAfter", "Ctrl-H": "delCharBefore",
[5839] Fix | Delete
"Alt-D": "delWordAfter", "Alt-Backspace": "delWordBefore", "Ctrl-K": "killLine", "Ctrl-T": "transposeChars",
[5840] Fix | Delete
"Ctrl-O": "openLine"
[5841] Fix | Delete
};
[5842] Fix | Delete
keyMap.macDefault = {
[5843] Fix | Delete
"Cmd-A": "selectAll", "Cmd-D": "deleteLine", "Cmd-Z": "undo", "Shift-Cmd-Z": "redo", "Cmd-Y": "redo",
[5844] Fix | Delete
"Cmd-Home": "goDocStart", "Cmd-Up": "goDocStart", "Cmd-End": "goDocEnd", "Cmd-Down": "goDocEnd", "Alt-Left": "goGroupLeft",
[5845] Fix | Delete
"Alt-Right": "goGroupRight", "Cmd-Left": "goLineLeft", "Cmd-Right": "goLineRight", "Alt-Backspace": "delGroupBefore",
[5846] Fix | Delete
"Ctrl-Alt-Backspace": "delGroupAfter", "Alt-Delete": "delGroupAfter", "Cmd-S": "save", "Cmd-F": "find",
[5847] Fix | Delete
"Cmd-G": "findNext", "Shift-Cmd-G": "findPrev", "Cmd-Alt-F": "replace", "Shift-Cmd-Alt-F": "replaceAll",
[5848] Fix | Delete
"Cmd-[": "indentLess", "Cmd-]": "indentMore", "Cmd-Backspace": "delWrappedLineLeft", "Cmd-Delete": "delWrappedLineRight",
[5849] Fix | Delete
"Cmd-U": "undoSelection", "Shift-Cmd-U": "redoSelection", "Ctrl-Up": "goDocStart", "Ctrl-Down": "goDocEnd",
[5850] Fix | Delete
fallthrough: ["basic", "emacsy"]
[5851] Fix | Delete
};
[5852] Fix | Delete
keyMap["default"] = mac ? keyMap.macDefault : keyMap.pcDefault;
[5853] Fix | Delete
[5854] Fix | Delete
// KEYMAP DISPATCH
[5855] Fix | Delete
[5856] Fix | Delete
function normalizeKeyName(name) {
[5857] Fix | Delete
var parts = name.split(/-(?!$)/), name = parts[parts.length - 1];
[5858] Fix | Delete
var alt, ctrl, shift, cmd;
[5859] Fix | Delete
for (var i = 0; i < parts.length - 1; i++) {
[5860] Fix | Delete
var mod = parts[i];
[5861] Fix | Delete
if (/^(cmd|meta|m)$/i.test(mod)) cmd = true;
[5862] Fix | Delete
else if (/^a(lt)?$/i.test(mod)) alt = true;
[5863] Fix | Delete
else if (/^(c|ctrl|control)$/i.test(mod)) ctrl = true;
[5864] Fix | Delete
else if (/^s(hift)$/i.test(mod)) shift = true;
[5865] Fix | Delete
else throw new Error("Unrecognized modifier name: " + mod);
[5866] Fix | Delete
}
[5867] Fix | Delete
if (alt) name = "Alt-" + name;
[5868] Fix | Delete
if (ctrl) name = "Ctrl-" + name;
[5869] Fix | Delete
if (cmd) name = "Cmd-" + name;
[5870] Fix | Delete
if (shift) name = "Shift-" + name;
[5871] Fix | Delete
return name;
[5872] Fix | Delete
}
[5873] Fix | Delete
[5874] Fix | Delete
// This is a kludge to keep keymaps mostly working as raw objects
[5875] Fix | Delete
// (backwards compatibility) while at the same time support features
[5876] Fix | Delete
// like normalization and multi-stroke key bindings. It compiles a
[5877] Fix | Delete
// new normalized keymap, and then updates the old object to reflect
[5878] Fix | Delete
// this.
[5879] Fix | Delete
CodeMirror.normalizeKeyMap = function(keymap) {
[5880] Fix | Delete
var copy = {};
[5881] Fix | Delete
for (var keyname in keymap) if (keymap.hasOwnProperty(keyname)) {
[5882] Fix | Delete
var value = keymap[keyname];
[5883] Fix | Delete
if (/^(name|fallthrough|(de|at)tach)$/.test(keyname)) continue;
[5884] Fix | Delete
if (value == "...") { delete keymap[keyname]; continue; }
[5885] Fix | Delete
[5886] Fix | Delete
var keys = map(keyname.split(" "), normalizeKeyName);
[5887] Fix | Delete
for (var i = 0; i < keys.length; i++) {
[5888] Fix | Delete
var val, name;
[5889] Fix | Delete
if (i == keys.length - 1) {
[5890] Fix | Delete
name = keys.join(" ");
[5891] Fix | Delete
val = value;
[5892] Fix | Delete
} else {
[5893] Fix | Delete
name = keys.slice(0, i + 1).join(" ");
[5894] Fix | Delete
val = "...";
[5895] Fix | Delete
}
[5896] Fix | Delete
var prev = copy[name];
[5897] Fix | Delete
if (!prev) copy[name] = val;
[5898] Fix | Delete
else if (prev != val) throw new Error("Inconsistent bindings for " + name);
[5899] Fix | Delete
}
[5900] Fix | Delete
delete keymap[keyname];
[5901] Fix | Delete
}
[5902] Fix | Delete
for (var prop in copy) keymap[prop] = copy[prop];
[5903] Fix | Delete
return keymap;
[5904] Fix | Delete
};
[5905] Fix | Delete
[5906] Fix | Delete
var lookupKey = CodeMirror.lookupKey = function(key, map, handle, context) {
[5907] Fix | Delete
map = getKeyMap(map);
[5908] Fix | Delete
var found = map.call ? map.call(key, context) : map[key];
[5909] Fix | Delete
if (found === false) return "nothing";
[5910] Fix | Delete
if (found === "...") return "multi";
[5911] Fix | Delete
if (found != null && handle(found)) return "handled";
[5912] Fix | Delete
[5913] Fix | Delete
if (map.fallthrough) {
[5914] Fix | Delete
if (Object.prototype.toString.call(map.fallthrough) != "[object Array]")
[5915] Fix | Delete
return lookupKey(key, map.fallthrough, handle, context);
[5916] Fix | Delete
for (var i = 0; i < map.fallthrough.length; i++) {
[5917] Fix | Delete
var result = lookupKey(key, map.fallthrough[i], handle, context);
[5918] Fix | Delete
if (result) return result;
[5919] Fix | Delete
}
[5920] Fix | Delete
}
[5921] Fix | Delete
};
[5922] Fix | Delete
[5923] Fix | Delete
// Modifier key presses don't count as 'real' key presses for the
[5924] Fix | Delete
// purpose of keymap fallthrough.
[5925] Fix | Delete
var isModifierKey = CodeMirror.isModifierKey = function(value) {
[5926] Fix | Delete
var name = typeof value == "string" ? value : keyNames[value.keyCode];
[5927] Fix | Delete
return name == "Ctrl" || name == "Alt" || name == "Shift" || name == "Mod";
[5928] Fix | Delete
};
[5929] Fix | Delete
[5930] Fix | Delete
// Look up the name of a key as indicated by an event object.
[5931] Fix | Delete
var keyName = CodeMirror.keyName = function(event, noShift) {
[5932] Fix | Delete
if (presto && event.keyCode == 34 && event["char"]) return false;
[5933] Fix | Delete
var base = keyNames[event.keyCode], name = base;
[5934] Fix | Delete
if (name == null || event.altGraphKey) return false;
[5935] Fix | Delete
if (event.altKey && base != "Alt") name = "Alt-" + name;
[5936] Fix | Delete
if ((flipCtrlCmd ? event.metaKey : event.ctrlKey) && base != "Ctrl") name = "Ctrl-" + name;
[5937] Fix | Delete
if ((flipCtrlCmd ? event.ctrlKey : event.metaKey) && base != "Cmd") name = "Cmd-" + name;
[5938] Fix | Delete
if (!noShift && event.shiftKey && base != "Shift") name = "Shift-" + name;
[5939] Fix | Delete
return name;
[5940] Fix | Delete
};
[5941] Fix | Delete
[5942] Fix | Delete
function getKeyMap(val) {
[5943] Fix | Delete
return typeof val == "string" ? keyMap[val] : val;
[5944] Fix | Delete
}
[5945] Fix | Delete
[5946] Fix | Delete
// FROMTEXTAREA
[5947] Fix | Delete
[5948] Fix | Delete
CodeMirror.fromTextArea = function(textarea, options) {
[5949] Fix | Delete
options = options ? copyObj(options) : {};
[5950] Fix | Delete
options.value = textarea.value;
[5951] Fix | Delete
if (!options.tabindex && textarea.tabIndex)
[5952] Fix | Delete
options.tabindex = textarea.tabIndex;
[5953] Fix | Delete
if (!options.placeholder && textarea.placeholder)
[5954] Fix | Delete
options.placeholder = textarea.placeholder;
[5955] Fix | Delete
// Set autofocus to true if this textarea is focused, or if it has
[5956] Fix | Delete
// autofocus and no other element is focused.
[5957] Fix | Delete
if (options.autofocus == null) {
[5958] Fix | Delete
var hasFocus = activeElt();
[5959] Fix | Delete
options.autofocus = hasFocus == textarea ||
[5960] Fix | Delete
textarea.getAttribute("autofocus") != null && hasFocus == document.body;
[5961] Fix | Delete
}
[5962] Fix | Delete
[5963] Fix | Delete
function save() {textarea.value = cm.getValue();}
[5964] Fix | Delete
if (textarea.form) {
[5965] Fix | Delete
on(textarea.form, "submit", save);
[5966] Fix | Delete
// Deplorable hack to make the submit method do the right thing.
[5967] Fix | Delete
if (!options.leaveSubmitMethodAlone) {
[5968] Fix | Delete
var form = textarea.form, realSubmit = form.submit;
[5969] Fix | Delete
try {
[5970] Fix | Delete
var wrappedSubmit = form.submit = function() {
[5971] Fix | Delete
save();
[5972] Fix | Delete
form.submit = realSubmit;
[5973] Fix | Delete
form.submit();
[5974] Fix | Delete
form.submit = wrappedSubmit;
[5975] Fix | Delete
};
[5976] Fix | Delete
} catch(e) {}
[5977] Fix | Delete
}
[5978] Fix | Delete
}
[5979] Fix | Delete
[5980] Fix | Delete
options.finishInit = function(cm) {
[5981] Fix | Delete
cm.save = save;
[5982] Fix | Delete
cm.getTextArea = function() { return textarea; };
[5983] Fix | Delete
cm.toTextArea = function() {
[5984] Fix | Delete
cm.toTextArea = isNaN; // Prevent this from being ran twice
[5985] Fix | Delete
save();
[5986] Fix | Delete
textarea.parentNode.removeChild(cm.getWrapperElement());
[5987] Fix | Delete
textarea.style.display = "";
[5988] Fix | Delete
if (textarea.form) {
[5989] Fix | Delete
off(textarea.form, "submit", save);
[5990] Fix | Delete
if (typeof textarea.form.submit == "function")
[5991] Fix | Delete
textarea.form.submit = realSubmit;
[5992] Fix | Delete
}
[5993] Fix | Delete
};
[5994] Fix | Delete
};
[5995] Fix | Delete
[5996] Fix | Delete
textarea.style.display = "none";
[5997] Fix | Delete
var cm = CodeMirror(function(node) {
[5998] Fix | Delete
textarea.parentNode.insertBefore(node, textarea.nextSibling);
[5999] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function