mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2026-01-08 05:04:12 +01:00
Allow specifying a group: prefix for Ex commands.
This commit is contained in:
@@ -1129,7 +1129,9 @@ var Commands = Module("commands", {
|
|||||||
(?P<spec>
|
(?P<spec>
|
||||||
(?P<prespace> [:\s]*)
|
(?P<prespace> [:\s]*)
|
||||||
(?P<count> (?:\d+ | %)? )
|
(?P<count> (?:\d+ | %)? )
|
||||||
(?P<cmd> (?:<name> | !)? )
|
(?P<fullCmd>
|
||||||
|
(?: (?P<group> <name>) : )?
|
||||||
|
(?P<cmd> (?:<name> | !)? ))
|
||||||
(?P<bang> !?)
|
(?P<bang> !?)
|
||||||
(?P<space> \s*)
|
(?P<space> \s*)
|
||||||
)
|
)
|
||||||
@@ -1164,7 +1166,7 @@ var Commands = Module("commands", {
|
|||||||
if (!matches)
|
if (!matches)
|
||||||
return [];
|
return [];
|
||||||
|
|
||||||
let [, spec, prespace, count, cmd, bang, space, args] = matches;
|
let { spec, count, group, cmd, bang, space, args } = matches;
|
||||||
if (!cmd && bang)
|
if (!cmd && bang)
|
||||||
[cmd, bang] = [bang, cmd];
|
[cmd, bang] = [bang, cmd];
|
||||||
|
|
||||||
@@ -1177,13 +1179,17 @@ var Commands = Module("commands", {
|
|||||||
else
|
else
|
||||||
count = this.COUNT_NONE;
|
count = this.COUNT_NONE;
|
||||||
|
|
||||||
return [count, cmd, !!bang, args || "", spec.length];
|
return [count, cmd, !!bang, args || "", spec.length, group];
|
||||||
},
|
},
|
||||||
|
|
||||||
parseCommands: function (str, complete) {
|
parseCommands: function (str, complete) {
|
||||||
|
const { contexts } = this.modules;
|
||||||
do {
|
do {
|
||||||
let [count, cmd, bang, args, len] = commands.parseCommand(str);
|
let [count, cmd, bang, args, len, group] = commands.parseCommand(str);
|
||||||
let command = this.get(cmd || "");
|
if (!group)
|
||||||
|
var command = this.get(cmd || "");
|
||||||
|
else if (group = contexts.getGroup(group, "commands"))
|
||||||
|
command = group.get(cmd || "");
|
||||||
|
|
||||||
if (command == null) {
|
if (command == null) {
|
||||||
yield [null, { commandString: str }];
|
yield [null, { commandString: str }];
|
||||||
@@ -1274,12 +1280,15 @@ var Commands = Module("commands", {
|
|||||||
: ""](str)
|
: ""](str)
|
||||||
}, {
|
}, {
|
||||||
completion: function initCompletion(dactyl, modules, window) {
|
completion: function initCompletion(dactyl, modules, window) {
|
||||||
const { completion } = modules;
|
const { completion, contexts } = modules;
|
||||||
|
|
||||||
completion.command = function command(context) {
|
completion.command = function command(context, group) {
|
||||||
context.title = ["Command"];
|
context.title = ["Command"];
|
||||||
context.keys = { text: "longNames", description: "description" };
|
context.keys = { text: "longNames", description: "description" };
|
||||||
context.generate = function () modules.commands.hives.map(function (h) h._list).flatten();
|
if (group)
|
||||||
|
context.generate = function () group._list;
|
||||||
|
else
|
||||||
|
context.generate = function () modules.commands.hives.map(function (h) h._list).flatten();
|
||||||
};
|
};
|
||||||
|
|
||||||
// provides completions for ex commands, including their arguments
|
// provides completions for ex commands, including their arguments
|
||||||
@@ -1298,9 +1307,12 @@ var Commands = Module("commands", {
|
|||||||
if (!match)
|
if (!match)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (match.group)
|
||||||
|
context.advance(match.group.length + 1);
|
||||||
|
|
||||||
context.advance(match.prespace.length + match.count.length);
|
context.advance(match.prespace.length + match.count.length);
|
||||||
if (!(match.bang || match.space)) {
|
if (!(match.bang || match.space)) {
|
||||||
context.fork("", 0, this, "command");
|
context.fork("", 0, this, "command", match.group && contexts.getGroup(match.group, "commands"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1312,7 +1324,7 @@ var Commands = Module("commands", {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let cmdContext = context.fork(command.name, match.cmd.length + match.bang.length + match.space.length);
|
let cmdContext = context.fork(command.name, match.fullCmd.length + match.bang.length + match.space.length);
|
||||||
try {
|
try {
|
||||||
if (!cmdContext.waitingForTab) {
|
if (!cmdContext.waitingForTab) {
|
||||||
if (!args.completeOpt && command.completer && args.completeStart != null) {
|
if (!args.completeOpt && command.completer && args.completeStart != null) {
|
||||||
|
|||||||
Reference in New Issue
Block a user