summaryrefslogtreecommitdiff
path: root/public/vendor/codemirror/keymap
diff options
context:
space:
mode:
authorWu Cheng-Han2016-01-17 14:28:04 -0600
committerWu Cheng-Han2016-01-17 14:28:04 -0600
commiteaa8ccaccb1091820d0a8d1223996a6dd057347d (patch)
tree6b4aaa3b3d1a2fed68147510142663222533775a /public/vendor/codemirror/keymap
parentce65e58096d57ace02723d11a125673f9d48c293 (diff)
Upgrade CodeMirror to 5.10.1 and now support fullscreen, jump-to-line in editor
Diffstat (limited to 'public/vendor/codemirror/keymap')
-rw-r--r--[-rwxr-xr-x]public/vendor/codemirror/keymap/emacs.js2
-rw-r--r--[-rwxr-xr-x]public/vendor/codemirror/keymap/sublime.js44
-rw-r--r--[-rwxr-xr-x]public/vendor/codemirror/keymap/vim.js35
3 files changed, 49 insertions, 32 deletions
diff --git a/public/vendor/codemirror/keymap/emacs.js b/public/vendor/codemirror/keymap/emacs.js
index c4135237..3eec1e57 100755..100644
--- a/public/vendor/codemirror/keymap/emacs.js
+++ b/public/vendor/codemirror/keymap/emacs.js
@@ -377,7 +377,7 @@
getInput(cm, "Goto line", function(str) {
var num;
- if (str && !isNaN(num = Number(str)) && num == num|0 && num > 0)
+ if (str && !isNaN(num = Number(str)) && num == (num|0) && num > 0)
cm.setCursor(num - 1);
});
},
diff --git a/public/vendor/codemirror/keymap/sublime.js b/public/vendor/codemirror/keymap/sublime.js
index 4f7a6f31..e0d0e92b 100755..100644
--- a/public/vendor/codemirror/keymap/sublime.js
+++ b/public/vendor/codemirror/keymap/sublime.js
@@ -55,7 +55,9 @@
cmds[map["Alt-Left"] = "goSubwordLeft"] = function(cm) { moveSubword(cm, -1); };
cmds[map["Alt-Right"] = "goSubwordRight"] = function(cm) { moveSubword(cm, 1); };
- cmds[map[ctrl + "Up"] = "scrollLineUp"] = function(cm) {
+ var scrollLineCombo = mac ? "Ctrl-Alt-" : "Ctrl-";
+
+ cmds[map[scrollLineCombo + "Up"] = "scrollLineUp"] = function(cm) {
var info = cm.getScrollInfo();
if (!cm.somethingSelected()) {
var visibleBottomLine = cm.lineAtHeight(info.top + info.clientHeight, "local");
@@ -64,7 +66,7 @@
}
cm.scrollTo(null, info.top - cm.defaultTextHeight());
};
- cmds[map[ctrl + "Down"] = "scrollLineDown"] = function(cm) {
+ cmds[map[scrollLineCombo + "Down"] = "scrollLineDown"] = function(cm) {
var info = cm.getScrollInfo();
if (!cm.somethingSelected()) {
var visibleTopLine = cm.lineAtHeight(info.top, "local")+1;
@@ -106,6 +108,7 @@
map["Shift-" + ctrl + "K"] = "deleteLine";
function insertLine(cm, above) {
+ if (cm.isReadOnly()) return CodeMirror.Pass
cm.operation(function() {
var len = cm.listSelections().length, newSelection = [], last = -1;
for (var i = 0; i < len; i++) {
@@ -121,9 +124,9 @@
});
}
- cmds[map[ctrl + "Enter"] = "insertLineAfter"] = function(cm) { insertLine(cm, false); };
+ cmds[map[ctrl + "Enter"] = "insertLineAfter"] = function(cm) { return insertLine(cm, false); };
- cmds[map["Shift-" + ctrl + "Enter"] = "insertLineBefore"] = function(cm) { insertLine(cm, true); };
+ cmds[map["Shift-" + ctrl + "Enter"] = "insertLineBefore"] = function(cm) { return insertLine(cm, true); };
function wordAt(cm, pos) {
var start = pos.ch, end = start, line = cm.getLine(pos.line);
@@ -190,6 +193,7 @@
var swapLineCombo = mac ? "Cmd-Ctrl-" : "Shift-Ctrl-";
cmds[map[swapLineCombo + "Up"] = "swapLineUp"] = function(cm) {
+ if (cm.isReadOnly()) return CodeMirror.Pass
var ranges = cm.listSelections(), linesToMove = [], at = cm.firstLine() - 1, newSels = [];
for (var i = 0; i < ranges.length; i++) {
var range = ranges[i], from = range.from().line - 1, to = range.to().line;
@@ -216,6 +220,7 @@
};
cmds[map[swapLineCombo + "Down"] = "swapLineDown"] = function(cm) {
+ if (cm.isReadOnly()) return CodeMirror.Pass
var ranges = cm.listSelections(), linesToMove = [], at = cm.lastLine() + 1;
for (var i = ranges.length - 1; i >= 0; i--) {
var range = ranges[i], from = range.to().line + 1, to = range.from().line;
@@ -238,7 +243,9 @@
});
};
- map[ctrl + "/"] = "toggleComment";
+ cmds[map[ctrl + "/"] = "toggleCommentIndented"] = function(cm) {
+ cm.toggleComment({ indent: true });
+ }
cmds[map[ctrl + "J"] = "joinLines"] = function(cm) {
var ranges = cm.listSelections(), joined = [];
@@ -258,7 +265,7 @@
var actual = line - offset;
if (line == obj.end) head = Pos(actual, cm.getLine(actual).length + 1);
if (actual < cm.lastLine()) {
- cm.replaceRange(" ", Pos(actual), Pos(actual + 1, /^\s*/.exec(cm.getLine(actual + 1))[0].length), "+joinLines");
+ cm.replaceRange(" ", Pos(actual), Pos(actual + 1, /^\s*/.exec(cm.getLine(actual + 1))[0].length));
++offset;
}
}
@@ -274,9 +281,9 @@
for (var i = 0; i < rangeCount; i++) {
var range = cm.listSelections()[i];
if (range.empty())
- cm.replaceRange(cm.getLine(range.head.line) + "\n", Pos(range.head.line, 0), null, "+duplicateLine");
+ cm.replaceRange(cm.getLine(range.head.line) + "\n", Pos(range.head.line, 0));
else
- cm.replaceRange(cm.getRange(range.from(), range.to()), range.from(), null, "+duplicateLine");
+ cm.replaceRange(cm.getRange(range.from(), range.to()), range.from());
}
cm.scrollIntoView();
});
@@ -285,6 +292,7 @@
map[ctrl + "T"] = "transposeChars";
function sortLines(cm, caseSensitive) {
+ if (cm.isReadOnly()) return CodeMirror.Pass
var ranges = cm.listSelections(), toSort = [], selected;
for (var i = 0; i < ranges.length; i++) {
var range = ranges[i];
@@ -311,7 +319,7 @@
if (au != bu) { a = au; b = bu; }
return a < b ? -1 : a == b ? 0 : 1;
});
- cm.replaceRange(lines, start, end, "+sortLines");
+ cm.replaceRange(lines, start, end);
if (selected) ranges.push({anchor: start, head: end});
}
if (selected) cm.setSelections(ranges, 0);
@@ -402,7 +410,7 @@
if (at && CodeMirror.cmpPos(range.head, at) > 0) continue;
var word = wordAt(cm, range.head);
at = word.from;
- cm.replaceRange(mod(word.word), word.from, word.to, "case");
+ cm.replaceRange(mod(word.word), word.from, word.to);
}
});
}
@@ -415,11 +423,19 @@
var cursor = cm.getCursor();
var toStartOfLine = cm.getRange({line: cursor.line, ch: 0}, cursor);
var column = CodeMirror.countColumn(toStartOfLine, null, cm.getOption("tabSize"));
+ var indentUnit = cm.getOption("indentUnit");
+
+ if (toStartOfLine && !/\S/.test(toStartOfLine) && column % indentUnit == 0) {
+ var prevIndent = new Pos(cursor.line,
+ CodeMirror.findColumn(toStartOfLine, column - indentUnit, indentUnit));
- if (toStartOfLine && !/\S/.test(toStartOfLine) && column % cm.getOption("indentUnit") == 0)
- return cm.indentSelection("subtract");
- else
+ // If no smart delete is happening (due to tab sizing) just do a regular delete
+ if (prevIndent.ch == cursor.ch) return CodeMirror.Pass;
+
+ return cm.replaceRange("", prevIndent, cursor, "+delete");
+ } else {
return CodeMirror.Pass;
+ }
};
cmds[map[cK + ctrl + "K"] = "delLineRight"] = function(cm) {
@@ -452,7 +468,7 @@
var from = cm.getCursor(), to = found;
if (CodeMirror.cmpPos(from, to) > 0) { var tmp = to; to = from; from = tmp; }
cm.state.sublimeKilled = cm.getRange(from, to);
- cm.replaceRange("", from, to, "+delete");
+ cm.replaceRange("", from, to);
}
};
cmds[map[cK + ctrl + "X"] = "swapWithSublimeMark"] = function(cm) {
diff --git a/public/vendor/codemirror/keymap/vim.js b/public/vendor/codemirror/keymap/vim.js
index d50cc4af..0548b75b 100755..100644
--- a/public/vendor/codemirror/keymap/vim.js
+++ b/public/vendor/codemirror/keymap/vim.js
@@ -292,12 +292,7 @@
// Keypress character binding of format "'a'"
return key.charAt(1);
}
- var pieces = key.split('-');
- if (/-$/.test(key)) {
- // If the - key was typed, split will result in 2 extra empty strings
- // in the array. Replace them with 1 '-'.
- pieces.splice(-2, 2, '-');
- }
+ var pieces = key.split(/-(?!$)/);
var lastPiece = pieces[pieces.length - 1];
if (pieces.length == 1 && pieces[0].length == 1) {
// No-modifier bindings use literal character bindings above. Skip.
@@ -1959,13 +1954,21 @@
text = text.slice(0, - match[0].length);
}
}
- var wasLastLine = head.line - 1 == cm.lastLine();
- cm.replaceRange('', anchor, head);
- if (args.linewise && !wasLastLine) {
+ var prevLineEnd = new Pos(anchor.line - 1, Number.MAX_VALUE);
+ var wasLastLine = cm.firstLine() == cm.lastLine();
+ if (head.line > cm.lastLine() && args.linewise && !wasLastLine) {
+ cm.replaceRange('', prevLineEnd, head);
+ } else {
+ cm.replaceRange('', anchor, head);
+ }
+ if (args.linewise) {
// Push the next line back down, if there is a next line.
- CodeMirror.commands.newlineAndIndent(cm);
- // null ch so setCursor moves to end of line.
- anchor.ch = null;
+ if (!wasLastLine) {
+ cm.setCursor(prevLineEnd);
+ CodeMirror.commands.newlineAndIndent(cm);
+ }
+ // make sure cursor ends up at the end of the line.
+ anchor.ch = Number.MAX_VALUE;
}
finalHead = anchor;
} else {
@@ -2144,9 +2147,7 @@
switch (actionArgs.position) {
case 'center': y = y - (height / 2) + lineHeight;
break;
- case 'bottom': y = y - height + lineHeight*1.4;
- break;
- case 'top': y = y + lineHeight*0.4;
+ case 'bottom': y = y - height + lineHeight;
break;
}
cm.scrollTo(null, y);
@@ -3208,7 +3209,7 @@
return cur;
}
- /*
+ /**
* Returns the boundaries of the next word. If the cursor in the middle of
* the word, then returns the boundaries of the current word, starting at
* the cursor. If the cursor is at the start/end of a word, and we are going
@@ -4308,7 +4309,7 @@
if (decimal + hex + octal > 1) { return 'Invalid arguments'; }
number = decimal && 'decimal' || hex && 'hex' || octal && 'octal';
}
- if (args.eatSpace() && args.match(/\/.*\//)) { 'patterns not supported'; }
+ if (args.match(/\/.*\//)) { return 'patterns not supported'; }
}
}
var err = parseArgs();