mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2025-12-21 10:57:58 +01:00
Add some basic (but in some cases rather broken) completion to the ex namespace.
This commit is contained in:
@@ -373,9 +373,8 @@ const Command = Class("Command", {
|
|||||||
|
|
||||||
// Prototype.
|
// Prototype.
|
||||||
const ex = {
|
const ex = {
|
||||||
__noSuchMethod__: function (meth, args) {
|
_args: function (cmd, args) {
|
||||||
let cmd = commands.get(meth);
|
args = Array.slice(args);
|
||||||
dactyl.assert(cmd, "No such command");
|
|
||||||
|
|
||||||
let res = cmd.newArgs();
|
let res = cmd.newArgs();
|
||||||
if (isObject(args[0]))
|
if (isObject(args[0]))
|
||||||
@@ -393,11 +392,31 @@ const ex = {
|
|||||||
}
|
}
|
||||||
for (let [i, val] in array.iterItems(args))
|
for (let [i, val] in array.iterItems(args))
|
||||||
res[i] = String(val);
|
res[i] = String(val);
|
||||||
|
return res;
|
||||||
|
},
|
||||||
|
|
||||||
res.verify();
|
_complete: function (cmd)
|
||||||
|
function _complete(context, func, obj, args) {
|
||||||
|
args = ex._args(cmd, args);
|
||||||
|
args.completeArg = args.length - 1;
|
||||||
|
if (cmd.completer && args.length)
|
||||||
|
return cmd.completer(context, args);
|
||||||
|
},
|
||||||
|
|
||||||
return cmd.execute(res);
|
_run: function (name) {
|
||||||
}
|
let cmd = commands.get(name);
|
||||||
|
dactyl.assert(cmd, "No such command");
|
||||||
|
|
||||||
|
return update(function exCommand(options) {
|
||||||
|
let args = this._args(cmd, arguments);
|
||||||
|
args.verify();
|
||||||
|
return cmd.execute(args);
|
||||||
|
}, {
|
||||||
|
dactylCompleter: this._complete(cmd)
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
__noSuchMethod__: function (meth, args) this._run(meth).apply(this, args)
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -439,9 +458,11 @@ const Commands = Module("commands", {
|
|||||||
if (!replace || !(args[3] && args[3].user))
|
if (!replace || !(args[3] && args[3].user))
|
||||||
dactyl.assert(!names.some(function (name) name in this._exMap, this),
|
dactyl.assert(!names.some(function (name) name in this._exMap, this),
|
||||||
"Not replacing command " + args[0]);
|
"Not replacing command " + args[0]);
|
||||||
for (let name in values(names))
|
for (let name in values(names)) {
|
||||||
|
ex.__defineGetter__(name, function () this._run(name));
|
||||||
if (name in this._exMap)
|
if (name in this._exMap)
|
||||||
commands.removeUserCommand(name);
|
commands.removeUserCommand(name);
|
||||||
|
}
|
||||||
|
|
||||||
let name = names[0];
|
let name = names[0];
|
||||||
let closure = function () commands._exMap[name];
|
let closure = function () commands._exMap[name];
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ BUGS:
|
|||||||
(recent Mercurial regressions):
|
(recent Mercurial regressions):
|
||||||
|
|
||||||
FEATURES:
|
FEATURES:
|
||||||
|
8 registers
|
||||||
8 Document Caret and Visual modes.
|
8 Document Caret and Visual modes.
|
||||||
8 replace global variables with plugin scoped user options
|
8 replace global variables with plugin scoped user options
|
||||||
8 fix local options
|
8 fix local options
|
||||||
@@ -53,9 +54,6 @@ FEATURES:
|
|||||||
7 :grep support (needs location list)
|
7 :grep support (needs location list)
|
||||||
6 :mksession
|
6 :mksession
|
||||||
6 add [count] support to :b* and :tab* commands where missing
|
6 add [count] support to :b* and :tab* commands where missing
|
||||||
6 registers
|
|
||||||
Here, unlike Vim, y and "*y would be equivalent. That is, the pasteboard would
|
|
||||||
always be the default register. --Ted
|
|
||||||
6 check/correct spellings in insert mode with some mappings
|
6 check/correct spellings in insert mode with some mappings
|
||||||
6 add more autocommands (TabClose, TabOpen, TabChanged etc)
|
6 add more autocommands (TabClose, TabOpen, TabChanged etc)
|
||||||
6 Use ctrl-w+j/k/w to switch between sidebar, content, preview window
|
6 Use ctrl-w+j/k/w to switch between sidebar, content, preview window
|
||||||
|
|||||||
Reference in New Issue
Block a user