Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Fix :eqw vim commands #1728

Merged
merged 4 commits into from

1 participant

Commits on Jun 19, 2012
  1. @nightwing

    fix multi-cursor 'cut'

    nightwing authored
  2. @nightwing
  3. @nightwing
  4. @nightwing

    cleanup

    nightwing authored
This page is out of date. Refresh to see the latest.
View
3  plugins-client/ext.clipboard/clipboard.js
@@ -107,7 +107,8 @@ module.exports = ext.register("ext/clipboard/clipboard", {
} catch(e) {}
aceClipboardText = ace.getCopyText() || aceClipboardText;
- ace.$nativeCommands.exec("cut", ace);
+ var cutCommand = ace.$nativeCommands.commands.cut;
+ ace.commands.exec(cutCommand, ace);
}
},
View
84 plugins-client/ext.vim/cli.js
@@ -8,12 +8,15 @@
define(function(require, exports, module) {
-var save;
+var filesystem = require("ext/filesystem/filesystem");
+var gotofile = require("ext/gotofile/gotofile");
+var editors = require("ext/editors/editors");
+var save = require("ext/save/save");
+var ide = require("core/ide");
+
+
var cliCmds = exports.cliCmds = {
w: function(editor, data) {
- if (!save)
- save = require("ext/save/save");
-
var page = tabEditors.getPage();
if (!page)
return;
@@ -32,6 +35,53 @@ var cliCmds = exports.cliCmds = {
console.log(page.name + " " + lines +"L, ##C written");
});
}
+ },
+ e: function(editor, data) {
+ var path = data.argv[1];
+ if (!path) {
+ gotofile.toggleDialog(1);
+ return false;
+ }
+ else {
+ path = (ide.davPrefix + "/" + path).replace(/\/+/, "/");
+ filesystem.exists(path, function(exists){
+ if (exists) {
+ editors.showFile(path);
+ }
+ else {
+ var node = editors.createFileNodeFromPath(path);
+ node.setAttribute("newfile", "1");
+ node.setAttribute("changed", "1");
+ node.setAttribute("cli", "1"); // blocks Save As dialog
+
+ var doc = ide.createDocument(node);
+ doc.cachedValue = "";
+
+ ide.dispatchEvent("openfile", {doc: doc, node: node});
+ }
+ });
+ }
+ },
+ wq: function(editor, data) {
+ cliCmds.w(editor, data);
+ cliCmds.q();
+ },
+ q: function(editor, data) {
+ var page = tabEditors.getPage();
+ var corrected = ide.dispatchEvent("beforeclosetab", {
+ page: page
+ });
+ if (corrected)
+ page = corrected;
+ if (data && data.force) {
+ var at = page.$at;
+ at.undo_ptr = at.$undostack[at.$undostack.length-1];
+ page.$doc.getNode().removeAttribute("changed");
+ }
+ editors.close(page);
+ },
+ "q!": function() {
+ cliCmds.q(null, {force: true})
}
};
@@ -50,27 +100,25 @@ exports.searchStore = {
}
};
+exports.focusCommandLine = function(val) {
+ txtConsoleInput.$editor.setValue(val, 1);
+ setTimeout(function() { txtConsoleInput.focus(); });
+}
exports.actions = {
":": {
fn: function(editor, range, count, param) {
- editor.blur();
- txtConsoleInput.focus();
- txtConsoleInput.setValue(":");
+ exports.focusCommandLine(":");
}
},
"/": {
fn: function(editor, range, count, param) {
- editor.blur();
- txtConsoleInput.focus();
- txtConsoleInput.setValue("/");
+ exports.focusCommandLine("/");
}
},
"?": {
fn: function(editor, range, count, param) {
- editor.blur();
- txtConsoleInput.focus();
- txtConsoleInput.setValue("?");
+ exports.focusCommandLine("?");
}
}
};
@@ -83,14 +131,14 @@ exports.addCommands = function(handler) {
}
exports.onConsoleCommand = function(e) {
- var cmd = e.data.command;
+ var cmd = e.data.command, success;
if ((typeof ceEditor !== "undefined") && cmd && typeof cmd === "string") {
var ed = ceEditor.$editor;
if (cmd[0] === ":") {
cmd = cmd.substr(1);
if (cliCmds[cmd]) {
- cliCmds[cmd](ed, e.data);
+ success = cliCmds[cmd](ed, e.data);
}
else if (cmd.match(/^\d+$/)) {
ed.gotoLine(cmd, 0);
@@ -100,7 +148,6 @@ exports.onConsoleCommand = function(e) {
console.log("Vim command '" + cmd + "' not implemented.");
}
- ceEditor.focus();
e.returnValue = false;
}
else if (cmd[0] === "/" || cmd[0] === "?") {
@@ -112,9 +159,12 @@ exports.onConsoleCommand = function(e) {
else
cmd = exports.searchStore.current;
ed.find(cmd, options);
- ceEditor.focus();
+ setTimeout(function(){ ed.focus(); });
e.returnValue = false;
}
+ // something blocks focusing without timeout
+ if (success !== false)
+ setTimeout(function(){ ceEditor.focus(); });
}
};
View
13 plugins-client/ext.vim/vim.js
@@ -22,6 +22,7 @@ var markupSettings = require("text!ext/vim/settings.xml");
var VIM_ENABLED = false;
var isLoading = false;
var vimHandler = null;
+var cliAutoOpened = null;
var _loadKeyboardHandler = function(path, callback) {
var _self = this;
@@ -72,7 +73,11 @@ var enableVim = function enableVim() {
editor.setKeyboardHandler(vimHandler);
editor.on("vimMode", vimHandler.$statusListener);
ide.dispatchEvent("track_action", {type: "vim", action: "enable", mode: "normal"});
- require("ext/console/console").showInput();
+ var cli = require("ext/console/console");
+ if (cli.hiddenInput) {
+ cli.showInput();
+ cliAutoOpened = true;
+ }
cliCmds.addCommands(vimHandler);
})
}
@@ -87,6 +92,12 @@ var disableVim = function() {
}
ide.dispatchEvent("track_action", { type: "vim", action: "disable" });
VIM_ENABLED = false;
+
+ var cli = require("ext/console/console");
+ if (!cli.hiddenInput && cliAutoOpened) {
+ cli.hideInput();
+ cliAutoOpened = false;
+ }
};
module.exports = ext.register("ext/vim/vim", {
Something went wrong with that request. Please try again.