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:
Robert Krahn 2013-02-19 15:15:03 -08:00
commit 50a6bd21af

View file

@ -56,7 +56,6 @@ var $formerLineStart;
exports.handler.attach = function(editor) {
if (!initialized) {
initialized = true;
dom.importCssString('\
.emacs-mode .ace_cursor{\
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("changeSession",$kbSessionChange);
editor.renderer.screenToTextCoordinates = screenToTextBlockCoordinates;
editor.setStyle("emacs-mode");
exports.handler.platform = editor.commands.platform;
};
exports.handler.detach = function(editor) {
delete editor.renderer.screenToTextCoordinates;
editor.session.$selectLongWords = $formerLongWords;
editor.session.$useEmacsStyleLineStart = $formerLineStart;
editor.removeEventListener("click",$resetMarkMode);
editor.removeEventListener("changeSession",$kbSessionChange);
editor.unsetStyle("emacs-mode");
};
@ -406,7 +397,6 @@ exports.handler.addCommands({
killLine: function(editor) {
exports.setMarkMode(null);
var pos = editor.getCursorPosition();
if (pos.column == 0 &&
editor.session.doc.getLine(pos.row).length == 0) {
// If an already empty line is killed, remove
@ -418,7 +408,6 @@ exports.handler.addCommands({
// the cursor)
editor.clearSelection();
editor.selection.selectLineEnd();
}
var range = editor.getSelectionRange();
var text = editor.session.getTextRange(range);
@ -434,7 +423,6 @@ exports.handler.addCommands({
yankRotate: function(editor) {
if (editor.keyBinding.$data.lastCommand != "yank")
return;
editor.undo();
editor.onPaste(exports.killRing.rotate());
editor.keyBinding.$data.lastCommand = "yank";