add platform attribute to emacs handler to allow platform-specific keybindings
usage like:
editor.getKeyboardHandler().addCommand({
name: "...",
bindKey: {win: "...", mac: "..."},
exec: function(e) { ... }
});
This commit is contained in:
parent
fa1a88eb7f
commit
50a6bd21af
1 changed files with 1 additions and 13 deletions
|
|
@ -56,7 +56,6 @@ var $formerLineStart;
|
||||||
exports.handler.attach = function(editor) {
|
exports.handler.attach = function(editor) {
|
||||||
if (!initialized) {
|
if (!initialized) {
|
||||||
initialized = true;
|
initialized = true;
|
||||||
|
|
||||||
dom.importCssString('\
|
dom.importCssString('\
|
||||||
.emacs-mode .ace_cursor{\
|
.emacs-mode .ace_cursor{\
|
||||||
border: 2px rgba(50,250,50,0.8) solid!important;\
|
border: 2px rgba(50,250,50,0.8) solid!important;\
|
||||||
|
|
@ -101,26 +100,18 @@ exports.handler.attach = function(editor) {
|
||||||
}
|
}
|
||||||
|
|
||||||
editor.on("click",$resetMarkMode);
|
editor.on("click",$resetMarkMode);
|
||||||
|
|
||||||
editor.on("changeSession",$kbSessionChange);
|
editor.on("changeSession",$kbSessionChange);
|
||||||
|
|
||||||
editor.renderer.screenToTextCoordinates = screenToTextBlockCoordinates;
|
editor.renderer.screenToTextCoordinates = screenToTextBlockCoordinates;
|
||||||
|
|
||||||
editor.setStyle("emacs-mode");
|
editor.setStyle("emacs-mode");
|
||||||
|
exports.handler.platform = editor.commands.platform;
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.handler.detach = function(editor) {
|
exports.handler.detach = function(editor) {
|
||||||
|
|
||||||
delete editor.renderer.screenToTextCoordinates;
|
delete editor.renderer.screenToTextCoordinates;
|
||||||
|
|
||||||
editor.session.$selectLongWords = $formerLongWords;
|
editor.session.$selectLongWords = $formerLongWords;
|
||||||
editor.session.$useEmacsStyleLineStart = $formerLineStart;
|
editor.session.$useEmacsStyleLineStart = $formerLineStart;
|
||||||
|
|
||||||
|
|
||||||
editor.removeEventListener("click",$resetMarkMode);
|
editor.removeEventListener("click",$resetMarkMode);
|
||||||
editor.removeEventListener("changeSession",$kbSessionChange);
|
editor.removeEventListener("changeSession",$kbSessionChange);
|
||||||
|
|
||||||
editor.unsetStyle("emacs-mode");
|
editor.unsetStyle("emacs-mode");
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -406,7 +397,6 @@ exports.handler.addCommands({
|
||||||
killLine: function(editor) {
|
killLine: function(editor) {
|
||||||
exports.setMarkMode(null);
|
exports.setMarkMode(null);
|
||||||
var pos = editor.getCursorPosition();
|
var pos = editor.getCursorPosition();
|
||||||
|
|
||||||
if (pos.column == 0 &&
|
if (pos.column == 0 &&
|
||||||
editor.session.doc.getLine(pos.row).length == 0) {
|
editor.session.doc.getLine(pos.row).length == 0) {
|
||||||
// If an already empty line is killed, remove
|
// If an already empty line is killed, remove
|
||||||
|
|
@ -418,7 +408,6 @@ exports.handler.addCommands({
|
||||||
// the cursor)
|
// the cursor)
|
||||||
editor.clearSelection();
|
editor.clearSelection();
|
||||||
editor.selection.selectLineEnd();
|
editor.selection.selectLineEnd();
|
||||||
|
|
||||||
}
|
}
|
||||||
var range = editor.getSelectionRange();
|
var range = editor.getSelectionRange();
|
||||||
var text = editor.session.getTextRange(range);
|
var text = editor.session.getTextRange(range);
|
||||||
|
|
@ -434,7 +423,6 @@ exports.handler.addCommands({
|
||||||
yankRotate: function(editor) {
|
yankRotate: function(editor) {
|
||||||
if (editor.keyBinding.$data.lastCommand != "yank")
|
if (editor.keyBinding.$data.lastCommand != "yank")
|
||||||
return;
|
return;
|
||||||
|
|
||||||
editor.undo();
|
editor.undo();
|
||||||
editor.onPaste(exports.killRing.rotate());
|
editor.onPaste(exports.killRing.rotate());
|
||||||
editor.keyBinding.$data.lastCommand = "yank";
|
editor.keyBinding.$data.lastCommand = "yank";
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue