basic conversion to new command structure
This commit is contained in:
parent
01e9fdf772
commit
d074c6b279
4 changed files with 108 additions and 107 deletions
|
|
@ -39,156 +39,156 @@ define(function(require, exports, module) {
|
||||||
|
|
||||||
var PluginManager = require("ace/plugin_manager").PluginManager;
|
var PluginManager = require("ace/plugin_manager").PluginManager;
|
||||||
|
|
||||||
PluginManager.registerCommand("selectall", function(editor, selection) {
|
PluginManager.registerCommand("selectall", function(env, args, request) {
|
||||||
selection.selectAll();
|
env.selection.selectAll();
|
||||||
});
|
});
|
||||||
PluginManager.registerCommand("removeline", function(editor, selection) {
|
PluginManager.registerCommand("removeline", function(env, args, request) {
|
||||||
editor.removeLines();
|
env.editor.removeLines();
|
||||||
});
|
});
|
||||||
PluginManager.registerCommand("gotoline", function(editor, selection) {
|
PluginManager.registerCommand("gotoline", function(env, args, request) {
|
||||||
var line = parseInt(prompt("Enter line number:"));
|
var line = parseInt(prompt("Enter line number:"));
|
||||||
if (!isNaN(line)) {
|
if (!isNaN(line)) {
|
||||||
editor.gotoLine(line);
|
env.editor.gotoLine(line);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
PluginManager.registerCommand("togglecomment", function(editor, selection) {
|
PluginManager.registerCommand("togglecomment", function(env, args, request) {
|
||||||
editor.toggleCommentLines();
|
env.editor.toggleCommentLines();
|
||||||
});
|
});
|
||||||
PluginManager.registerCommand("findnext", function(editor, selection) {
|
PluginManager.registerCommand("findnext", function(env, args, request) {
|
||||||
editor.findNext();
|
env.editor.findNext();
|
||||||
});
|
});
|
||||||
PluginManager.registerCommand("findprevious", function(editor, selection) {
|
PluginManager.registerCommand("findprevious", function(env, args, request) {
|
||||||
editor.findPrevious();
|
env.editor.findPrevious();
|
||||||
});
|
});
|
||||||
PluginManager.registerCommand("find", function(editor, selection) {
|
PluginManager.registerCommand("find", function(env, args, request) {
|
||||||
var needle = prompt("Find:");
|
var needle = prompt("Find:");
|
||||||
editor.find(needle);
|
env.editor.find(needle);
|
||||||
});
|
});
|
||||||
PluginManager.registerCommand("undo", function(editor, selection) {
|
PluginManager.registerCommand("undo", function(env, args, request) {
|
||||||
editor.undo();
|
env.editor.undo();
|
||||||
});
|
});
|
||||||
PluginManager.registerCommand("redo", function(editor, selection) {
|
PluginManager.registerCommand("redo", function(env, args, request) {
|
||||||
editor.redo();
|
env.editor.redo();
|
||||||
});
|
});
|
||||||
PluginManager.registerCommand("redo", function(editor, selection) {
|
PluginManager.registerCommand("redo", function(env, args, request) {
|
||||||
editor.redo();
|
env.editor.redo();
|
||||||
});
|
});
|
||||||
PluginManager.registerCommand("overwrite", function(editor, selection) {
|
PluginManager.registerCommand("overwrite", function(env, args, request) {
|
||||||
editor.toggleOverwrite();
|
env.editor.toggleOverwrite();
|
||||||
});
|
});
|
||||||
PluginManager.registerCommand("copylinesup", function(editor, selection) {
|
PluginManager.registerCommand("copylinesup", function(env, args, request) {
|
||||||
editor.copyLinesUp();
|
env.editor.copyLinesUp();
|
||||||
});
|
});
|
||||||
PluginManager.registerCommand("movelinesup", function(editor, selection) {
|
PluginManager.registerCommand("movelinesup", function(env, args, request) {
|
||||||
editor.moveLinesUp();
|
env.editor.moveLinesUp();
|
||||||
});
|
});
|
||||||
PluginManager.registerCommand("selecttostart", function(editor, selection) {
|
PluginManager.registerCommand("selecttostart", function(env, args, request) {
|
||||||
selection.selectFileStart();
|
env.selection.selectFileStart();
|
||||||
});
|
});
|
||||||
PluginManager.registerCommand("gotostart", function(editor, selection) {
|
PluginManager.registerCommand("gotostart", function(env, args, request) {
|
||||||
editor.navigateFileStart();
|
env.editor.navigateFileStart();
|
||||||
});
|
});
|
||||||
PluginManager.registerCommand("selectup", function(editor, selection) {
|
PluginManager.registerCommand("selectup", function(env, args, request) {
|
||||||
selection.selectUp();
|
env.selection.selectUp();
|
||||||
});
|
});
|
||||||
PluginManager.registerCommand("golineup", function(editor, selection) {
|
PluginManager.registerCommand("golineup", function(env, args, request) {
|
||||||
editor.navigateUp();
|
env.editor.navigateUp();
|
||||||
});
|
});
|
||||||
PluginManager.registerCommand("copylinesdown", function(editor, selection) {
|
PluginManager.registerCommand("copylinesdown", function(env, args, request) {
|
||||||
editor.copyLinesDown();
|
env.editor.copyLinesDown();
|
||||||
});
|
});
|
||||||
PluginManager.registerCommand("movelinesdown", function(editor, selection) {
|
PluginManager.registerCommand("movelinesdown", function(env, args, request) {
|
||||||
editor.moveLinesDown();
|
env.editor.moveLinesDown();
|
||||||
});
|
});
|
||||||
PluginManager.registerCommand("selecttoend", function(editor, selection) {
|
PluginManager.registerCommand("selecttoend", function(env, args, request) {
|
||||||
selection.selectFileEnd();
|
env.selection.selectFileEnd();
|
||||||
});
|
});
|
||||||
PluginManager.registerCommand("gotoend", function(editor, selection) {
|
PluginManager.registerCommand("gotoend", function(env, args, request) {
|
||||||
editor.navigateFileEnd();
|
env.editor.navigateFileEnd();
|
||||||
});
|
});
|
||||||
PluginManager.registerCommand("selectdown", function(editor, selection) {
|
PluginManager.registerCommand("selectdown", function(env, args, request) {
|
||||||
selection.selectDown();
|
env.selection.selectDown();
|
||||||
});
|
});
|
||||||
PluginManager.registerCommand("godown", function(editor, selection) {
|
PluginManager.registerCommand("godown", function(env, args, request) {
|
||||||
editor.navigateDown();
|
env.editor.navigateDown();
|
||||||
});
|
});
|
||||||
PluginManager.registerCommand("selectwordleft", function(editor, selection) {
|
PluginManager.registerCommand("selectwordleft", function(env, args, request) {
|
||||||
selection.selectWordLeft();
|
env.selection.selectWordLeft();
|
||||||
});
|
});
|
||||||
PluginManager.registerCommand("gotowordleft", function(editor, selection) {
|
PluginManager.registerCommand("gotowordleft", function(env, args, request) {
|
||||||
editor.navigateWordLeft();
|
env.editor.navigateWordLeft();
|
||||||
});
|
});
|
||||||
PluginManager.registerCommand("selecttolinestart", function(editor, selection) {
|
PluginManager.registerCommand("selecttolinestart", function(env, args, request) {
|
||||||
selection.selectLineStart();
|
env.selection.selectLineStart();
|
||||||
});
|
});
|
||||||
PluginManager.registerCommand("gotolinestart", function(editor, selection) {
|
PluginManager.registerCommand("gotolinestart", function(env, args, request) {
|
||||||
editor.navigateLineStart();
|
env.editor.navigateLineStart();
|
||||||
});
|
});
|
||||||
PluginManager.registerCommand("selectleft", function(editor, selection) {
|
PluginManager.registerCommand("selectleft", function(env, args, request) {
|
||||||
selection.selectLeft();
|
env.selection.selectLeft();
|
||||||
});
|
});
|
||||||
PluginManager.registerCommand("gotoleft", function(editor, selection) {
|
PluginManager.registerCommand("gotoleft", function(env, args, request) {
|
||||||
editor.navigateLeft();
|
env.editor.navigateLeft();
|
||||||
});
|
});
|
||||||
PluginManager.registerCommand("selectwordright", function(editor, selection) {
|
PluginManager.registerCommand("selectwordright", function(env, args, request) {
|
||||||
selection.selectWordRight();
|
env.selection.selectWordRight();
|
||||||
});
|
});
|
||||||
PluginManager.registerCommand("gotowordright", function(editor, selection) {
|
PluginManager.registerCommand("gotowordright", function(env, args, request) {
|
||||||
editor.navigateWordRight();
|
env.editor.navigateWordRight();
|
||||||
});
|
});
|
||||||
PluginManager.registerCommand("selecttolineend", function(editor, selection) {
|
PluginManager.registerCommand("selecttolineend", function(env, args, request) {
|
||||||
selection.selectLineEnd();
|
env.selection.selectLineEnd();
|
||||||
});
|
});
|
||||||
PluginManager.registerCommand("gotolineend", function(editor, selection) {
|
PluginManager.registerCommand("gotolineend", function(env, args, request) {
|
||||||
editor.navigateLineEnd();
|
env.editor.navigateLineEnd();
|
||||||
});
|
});
|
||||||
PluginManager.registerCommand("selectright", function(editor, selection) {
|
PluginManager.registerCommand("selectright", function(env, args, request) {
|
||||||
selection.selectRight();
|
env.selection.selectRight();
|
||||||
});
|
});
|
||||||
PluginManager.registerCommand("gotoright", function(editor, selection) {
|
PluginManager.registerCommand("gotoright", function(env, args, request) {
|
||||||
editor.navigateRight();
|
env.editor.navigateRight();
|
||||||
});
|
});
|
||||||
PluginManager.registerCommand("selectpagedown", function(editor, selection) {
|
PluginManager.registerCommand("selectpagedown", function(env, args, request) {
|
||||||
editor.selectPageDown();
|
env.editor.selectPageDown();
|
||||||
});
|
});
|
||||||
PluginManager.registerCommand("pagedown", function(editor, selection) {
|
PluginManager.registerCommand("pagedown", function(env, args, request) {
|
||||||
editor.scrollPageDown();
|
env.editor.scrollPageDown();
|
||||||
});
|
});
|
||||||
PluginManager.registerCommand("gotopagedown", function(editor, selection) {
|
PluginManager.registerCommand("gotopagedown", function(env, args, request) {
|
||||||
editor.gotoPageDown();
|
env.editor.gotoPageDown();
|
||||||
});
|
});
|
||||||
PluginManager.registerCommand("selectpageup", function(editor, selection) {
|
PluginManager.registerCommand("selectpageup", function(env, args, request) {
|
||||||
editor.selectPageUp();
|
env.editor.selectPageUp();
|
||||||
});
|
});
|
||||||
PluginManager.registerCommand("pageup", function(editor, selection) {
|
PluginManager.registerCommand("pageup", function(env, args, request) {
|
||||||
editor.scrollPageUp();
|
env.editor.scrollPageUp();
|
||||||
});
|
});
|
||||||
PluginManager.registerCommand("gotopageup", function(editor, selection) {
|
PluginManager.registerCommand("gotopageup", function(env, args, request) {
|
||||||
editor.gotoPageUp();
|
env.editor.gotoPageUp();
|
||||||
});
|
});
|
||||||
PluginManager.registerCommand("selectlinestart", function(editor, selection) {
|
PluginManager.registerCommand("selectlinestart", function(env, args, request) {
|
||||||
selection.selectLineStart();
|
env.selection.selectLineStart();
|
||||||
});
|
});
|
||||||
PluginManager.registerCommand("gotolinestart", function(editor, selection) {
|
PluginManager.registerCommand("gotolinestart", function(env, args, request) {
|
||||||
editor.navigateLineStart();
|
env.editor.navigateLineStart();
|
||||||
});
|
});
|
||||||
PluginManager.registerCommand("selectlineend", function(editor, selection) {
|
PluginManager.registerCommand("selectlineend", function(env, args, request) {
|
||||||
selection.selectLineEnd();
|
env.selection.selectLineEnd();
|
||||||
});
|
});
|
||||||
PluginManager.registerCommand("gotolineend", function(editor, selection) {
|
PluginManager.registerCommand("gotolineend", function(env, args, request) {
|
||||||
editor.navigateLineEnd();
|
env.editor.navigateLineEnd();
|
||||||
});
|
});
|
||||||
PluginManager.registerCommand("del", function(editor, selection) {
|
PluginManager.registerCommand("del", function(env, args, request) {
|
||||||
editor.removeRight();
|
env.editor.removeRight();
|
||||||
});
|
});
|
||||||
PluginManager.registerCommand("backspace", function(editor, selection) {
|
PluginManager.registerCommand("backspace", function(env, args, request) {
|
||||||
editor.removeLeft();
|
env.editor.removeLeft();
|
||||||
});
|
});
|
||||||
PluginManager.registerCommand("outdent", function(editor, selection) {
|
PluginManager.registerCommand("outdent", function(env, args, request) {
|
||||||
editor.blockOutdent();
|
env.editor.blockOutdent();
|
||||||
});
|
});
|
||||||
PluginManager.registerCommand("indent", function(editor, selection) {
|
PluginManager.registerCommand("indent", function(env, args, request) {
|
||||||
editor.indent();
|
env.editor.indent();
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
@ -73,13 +73,13 @@ var Document = function(text, mode) {
|
||||||
return text.split(/\r\n|\r|\n/);
|
return text.split(/\r\n|\r|\n/);
|
||||||
};
|
};
|
||||||
|
|
||||||
this.setValue = function(text) {
|
this.setValue = function(text) {
|
||||||
var args = [0, this.lines.length];
|
var args = [0, this.lines.length];
|
||||||
args.push.apply(args, this.$split(text));
|
args.push.apply(args, this.$split(text));
|
||||||
this.lines.splice.apply(this.lines, args);
|
this.lines.splice.apply(this.lines, args);
|
||||||
this.modified = true;
|
this.modified = true;
|
||||||
this.fireChangeEvent(0);
|
this.fireChangeEvent(0);
|
||||||
};
|
};
|
||||||
|
|
||||||
this.toString = function() {
|
this.toString = function() {
|
||||||
return this.lines.join(this.$getNewLineCharacter());
|
return this.lines.join(this.$getNewLineCharacter());
|
||||||
|
|
|
||||||
|
|
@ -58,7 +58,8 @@ var KeyBinding = function(element, editor, config) {
|
||||||
var command = PluginManager.commands[commandName];
|
var command = PluginManager.commands[commandName];
|
||||||
|
|
||||||
if (command) {
|
if (command) {
|
||||||
command(editor, editor.getSelection());
|
var env = { editor: editor, selection: editor.getSelection() };
|
||||||
|
command(env);
|
||||||
return event.stopEvent(e);
|
return event.stopEvent(e);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -46,4 +46,4 @@ var PluginManager = {
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.PluginManager = PluginManager;
|
exports.PluginManager = PluginManager;
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue