kopia lustrzana https://github.com/c9/core
commit
eb710ca024
|
@ -18,6 +18,7 @@ define(function(require, exports, module) {
|
||||||
var tabManager = imports.tabManager;
|
var tabManager = imports.tabManager;
|
||||||
var ace = imports.ace;
|
var ace = imports.ace;
|
||||||
|
|
||||||
|
var Vim = require('ace/keyboard/vim').Vim;
|
||||||
var Editor = require("ace/editor").Editor;
|
var Editor = require("ace/editor").Editor;
|
||||||
var lang = require("ace/lib/lang");
|
var lang = require("ace/lib/lang");
|
||||||
var pathLib = require("path");
|
var pathLib = require("path");
|
||||||
|
@ -187,6 +188,18 @@ define(function(require, exports, module) {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
cliCmds[':'].reCommands = {
|
||||||
|
/**
|
||||||
|
* @see {@link http://vim.wikia.com/wiki/Search_and_replace|Vim wiki - sed}
|
||||||
|
*/
|
||||||
|
'sed': {
|
||||||
|
regex: /^(%|'<,'>|(?:\d+|\.),(?:\+?\d+|\$|\.))?s(\/|#)(.*?)\2(.*?)\2([giIc]*)$/,
|
||||||
|
action: function (editor, cmd, data) {
|
||||||
|
Vim.handleEx(editor.state.cm, cmd);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
cliCmds[":"].commands = {
|
cliCmds[":"].commands = {
|
||||||
w: function(editor, data, callback) {
|
w: function(editor, data, callback) {
|
||||||
var tab = tabManager.focussedTab;
|
var tab = tabManager.focussedTab;
|
||||||
|
@ -357,10 +370,10 @@ define(function(require, exports, module) {
|
||||||
cmd += last.value;
|
cmd += last.value;
|
||||||
cmd = cmd.substr(1).trim();
|
cmd = cmd.substr(1).trim();
|
||||||
var args = cmd.split(/\s+/);
|
var args = cmd.split(/\s+/);
|
||||||
cmd = args[0];
|
var firstCmd = args[0];
|
||||||
|
|
||||||
if (this.commands[cmd]) {
|
if (this.commands[firstCmd]) {
|
||||||
cmd = this.commands[cmd];
|
cmd = this.commands[firstCmd];
|
||||||
if (typeof cmd == "string")
|
if (typeof cmd == "string")
|
||||||
return commands.exec(cmd, null, { argv: args });
|
return commands.exec(cmd, null, { argv: args });
|
||||||
else if (typeof cmd == "function")
|
else if (typeof cmd == "function")
|
||||||
|
@ -368,15 +381,26 @@ define(function(require, exports, module) {
|
||||||
else if (cmd.exec)
|
else if (cmd.exec)
|
||||||
return cmd.exec(ed, { argv: args });
|
return cmd.exec(ed, { argv: args });
|
||||||
}
|
}
|
||||||
else if (commands.commands[cmd]) {
|
else if (commands.commands[firstCmd]) {
|
||||||
commands.exec(cmd, null, { argv: args });
|
commands.exec(firstCmd, null, { argv: args });
|
||||||
}
|
}
|
||||||
else if (/^\d+$/.test(cmd)) {
|
else if (/^\d+$/.test(cmd)) {
|
||||||
ed.gotoLine(cmd, 0, true);
|
ed.gotoLine(cmd, 0, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
ed.cmdLine.setTimedMessage("Vim command '"
|
for (var key in this.reCommands) {
|
||||||
+ cmd + "' not implemented.", 1500);
|
var reCmd = this.reCommands[key];
|
||||||
|
var match = reCmd.regex.exec(cmd);
|
||||||
|
if (match) {
|
||||||
|
return reCmd.action(ed, cmd, {
|
||||||
|
match: match,
|
||||||
|
argv: cmd.split(match[0], 1).slice(-1)[0].split(/\s+/)
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ed.cmdLine.setTimedMessage(
|
||||||
|
'Vim command "' + cmd + '" not implemented.', 3500);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Ładowanie…
Reference in New Issue