mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2025-12-23 12:42:26 +01:00
Move bang/count to args.
This commit is contained in:
@@ -137,7 +137,7 @@ function Addressbook() //{{{
|
|||||||
|
|
||||||
commands.add(["contacts", "addr[essbook]"],
|
commands.add(["contacts", "addr[essbook]"],
|
||||||
"List or open multiple addresses",
|
"List or open multiple addresses",
|
||||||
function (args, special) { addressbook.list(args.string, special); },
|
function (args) { addressbook.list(args.string, args.bang); },
|
||||||
{ bang: true });
|
{ bang: true });
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////}}}
|
/////////////////////////////////////////////////////////////////////////////}}}
|
||||||
|
|||||||
@@ -289,14 +289,14 @@ function Bookmarks() //{{{
|
|||||||
|
|
||||||
commands.add(["bma[rk]"],
|
commands.add(["bma[rk]"],
|
||||||
"Add a bookmark",
|
"Add a bookmark",
|
||||||
function (args, special)
|
function (args)
|
||||||
{
|
{
|
||||||
var url = args.length == 0 ? buffer.URL : args[0];
|
var url = args.length == 0 ? buffer.URL : args[0];
|
||||||
var title = args["-title"] || (args.length == 0 ? buffer.title : null);
|
var title = args["-title"] || (args.length == 0 ? buffer.title : null);
|
||||||
var keyword = args["-keyword"] || null;
|
var keyword = args["-keyword"] || null;
|
||||||
var tags = args["-tags"] || [];
|
var tags = args["-tags"] || [];
|
||||||
|
|
||||||
if (bookmarks.add(false, title, url, keyword, tags, special))
|
if (bookmarks.add(false, title, url, keyword, tags, args.bang))
|
||||||
{
|
{
|
||||||
let extra = (title == url) ? "" : " (" + title + ")";
|
let extra = (title == url) ? "" : " (" + title + ")";
|
||||||
liberator.echo("Added bookmark: " + url + extra, commandline.FORCE_SINGLELINE);
|
liberator.echo("Added bookmark: " + url + extra, commandline.FORCE_SINGLELINE);
|
||||||
@@ -314,9 +314,9 @@ function Bookmarks() //{{{
|
|||||||
|
|
||||||
commands.add(["bmarks"],
|
commands.add(["bmarks"],
|
||||||
"List or open multiple bookmarks",
|
"List or open multiple bookmarks",
|
||||||
function (args, special)
|
function (args)
|
||||||
{
|
{
|
||||||
bookmarks.list(args.join(" "), args["-tags"] || [], special);
|
bookmarks.list(args.join(" "), args["-tags"] || [], args.bang);
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
bang: true,
|
bang: true,
|
||||||
@@ -616,11 +616,11 @@ function History() //{{{
|
|||||||
|
|
||||||
commands.add(["ba[ck]"],
|
commands.add(["ba[ck]"],
|
||||||
"Go back in the browser history",
|
"Go back in the browser history",
|
||||||
function (args, special, count)
|
function (args)
|
||||||
{
|
{
|
||||||
args = args.string;
|
args = args.string;
|
||||||
|
|
||||||
if (special)
|
if (args.bang)
|
||||||
{
|
{
|
||||||
history.goToStart();
|
history.goToStart();
|
||||||
}
|
}
|
||||||
@@ -641,7 +641,7 @@ function History() //{{{
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
history.stepTo(count > 0 ? -1 * count : -1);
|
history.stepTo(args.count > 0 ? -1 * args.count : -1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -668,11 +668,11 @@ function History() //{{{
|
|||||||
|
|
||||||
commands.add(["fo[rward]", "fw"],
|
commands.add(["fo[rward]", "fw"],
|
||||||
"Go forward in the browser history",
|
"Go forward in the browser history",
|
||||||
function (args, special, count)
|
function (args)
|
||||||
{
|
{
|
||||||
args = args.string;
|
args = args.string;
|
||||||
|
|
||||||
if (special)
|
if (args.bang)
|
||||||
{
|
{
|
||||||
history.goToEnd();
|
history.goToEnd();
|
||||||
}
|
}
|
||||||
@@ -693,7 +693,7 @@ function History() //{{{
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
history.stepTo(count > 0 ? count : 1);
|
history.stepTo(args.count > 0 ? args.count : 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -720,7 +720,7 @@ function History() //{{{
|
|||||||
|
|
||||||
commands.add(["hist[ory]", "hs"],
|
commands.add(["hist[ory]", "hs"],
|
||||||
"Show recently visited URLs",
|
"Show recently visited URLs",
|
||||||
function (args, special) { history.list(args.string, special); },
|
function (args) { history.list(args.string, args.bang); },
|
||||||
{
|
{
|
||||||
bang: true,
|
bang: true,
|
||||||
// completer: function (filter) completion.history(filter)
|
// completer: function (filter) completion.history(filter)
|
||||||
@@ -861,24 +861,22 @@ function QuickMarks() //{{{
|
|||||||
|
|
||||||
commands.add(["delqm[arks]"],
|
commands.add(["delqm[arks]"],
|
||||||
"Delete the specified QuickMarks",
|
"Delete the specified QuickMarks",
|
||||||
function (args, special)
|
function (args)
|
||||||
{
|
{
|
||||||
args = args.string;
|
|
||||||
|
|
||||||
// TODO: finish arg parsing - we really need a proper way to do this. :)
|
// TODO: finish arg parsing - we really need a proper way to do this. :)
|
||||||
if (!special && !args)
|
if (!args.bang && !args.string)
|
||||||
{
|
{
|
||||||
liberator.echoerr("E471: Argument required");
|
liberator.echoerr("E471: Argument required");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (special && args)
|
if (args.bang && args.string)
|
||||||
{
|
{
|
||||||
liberator.echoerr("E474: Invalid argument");
|
liberator.echoerr("E474: Invalid argument");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (special)
|
if (args.bang)
|
||||||
quickmarks.removeAll();
|
quickmarks.removeAll();
|
||||||
else
|
else
|
||||||
quickmarks.remove(args);
|
quickmarks.remove(args);
|
||||||
|
|||||||
@@ -468,14 +468,14 @@ function Buffer() //{{{
|
|||||||
|
|
||||||
commands.add(["ha[rdcopy]"],
|
commands.add(["ha[rdcopy]"],
|
||||||
"Print current document",
|
"Print current document",
|
||||||
function (args, special)
|
function (args)
|
||||||
{
|
{
|
||||||
var aps = options.getPref("print.always_print_silent");
|
var aps = options.getPref("print.always_print_silent");
|
||||||
var spp = options.getPref("print.show_print_progress");
|
var spp = options.getPref("print.show_print_progress");
|
||||||
|
|
||||||
liberator.echo("Sending to printer...");
|
liberator.echo("Sending to printer...");
|
||||||
options.setPref("print.always_print_silent", special);
|
options.setPref("print.always_print_silent", args.bang);
|
||||||
options.setPref("print.show_print_progress", !special);
|
options.setPref("print.show_print_progress", !args.bang);
|
||||||
|
|
||||||
getBrowser().contentWindow.print();
|
getBrowser().contentWindow.print();
|
||||||
|
|
||||||
@@ -519,7 +519,7 @@ function Buffer() //{{{
|
|||||||
|
|
||||||
commands.add(["re[load]"],
|
commands.add(["re[load]"],
|
||||||
"Reload current page",
|
"Reload current page",
|
||||||
function (args, special) { tabs.reload(getBrowser().mCurrentTab, special); },
|
function (args) { tabs.reload(getBrowser().mCurrentTab, args.bang); },
|
||||||
{
|
{
|
||||||
bang: true,
|
bang: true,
|
||||||
argCount: "0"
|
argCount: "0"
|
||||||
@@ -528,7 +528,7 @@ function Buffer() //{{{
|
|||||||
// TODO: we're prompted if download.useDownloadDir isn't set and no arg specified - intentional?
|
// TODO: we're prompted if download.useDownloadDir isn't set and no arg specified - intentional?
|
||||||
commands.add(["sav[eas]", "w[rite]"],
|
commands.add(["sav[eas]", "w[rite]"],
|
||||||
"Save current document to disk",
|
"Save current document to disk",
|
||||||
function (args, special)
|
function (args)
|
||||||
{
|
{
|
||||||
let doc = window.content.document;
|
let doc = window.content.document;
|
||||||
let chosenData = null;
|
let chosenData = null;
|
||||||
@@ -538,7 +538,7 @@ function Buffer() //{{{
|
|||||||
{
|
{
|
||||||
let file = io.getFile(filename);
|
let file = io.getFile(filename);
|
||||||
|
|
||||||
if (file.exists() && !special)
|
if (file.exists() && !args.bang)
|
||||||
{
|
{
|
||||||
liberator.echoerr("E13: File exists (add ! to override)");
|
liberator.echoerr("E13: File exists (add ! to override)");
|
||||||
return;
|
return;
|
||||||
@@ -577,7 +577,7 @@ function Buffer() //{{{
|
|||||||
|
|
||||||
commands.add(["vie[wsource]"],
|
commands.add(["vie[wsource]"],
|
||||||
"View source code of current document",
|
"View source code of current document",
|
||||||
function (args, special) { buffer.viewSource(args[0], special); },
|
function (args) { buffer.viewSource(args[0], args.bang); },
|
||||||
{
|
{
|
||||||
argCount: "?",
|
argCount: "?",
|
||||||
bang: true,
|
bang: true,
|
||||||
@@ -586,26 +586,24 @@ function Buffer() //{{{
|
|||||||
|
|
||||||
commands.add(["zo[om]"],
|
commands.add(["zo[om]"],
|
||||||
"Set zoom value of current web page",
|
"Set zoom value of current web page",
|
||||||
function (args, special)
|
function (args)
|
||||||
{
|
{
|
||||||
args = args.string;
|
|
||||||
|
|
||||||
let level;
|
let level;
|
||||||
|
|
||||||
if (!args)
|
if (!args.string)
|
||||||
{
|
{
|
||||||
level = 100;
|
level = 100;
|
||||||
}
|
}
|
||||||
else if (/^\d+$/.test(args))
|
else if (/^\d+$/.test(args.string))
|
||||||
{
|
{
|
||||||
level = parseInt(args, 10);
|
level = parseInt(args.string, 10);
|
||||||
}
|
}
|
||||||
else if (/^[+-]\d+$/.test(args))
|
else if (/^[+-]\d+$/.test(args.string))
|
||||||
{
|
{
|
||||||
if (special)
|
if (args.bang)
|
||||||
level = buffer.fullZoom + parseInt(args, 10);
|
level = buffer.fullZoom + parseInt(args.string, 10);
|
||||||
else
|
else
|
||||||
level = buffer.textZoom + parseInt(args, 10);
|
level = buffer.textZoom + parseInt(args.string, 10);
|
||||||
|
|
||||||
// relative args shouldn't take us out of range
|
// relative args shouldn't take us out of range
|
||||||
if (level < ZOOM_MIN)
|
if (level < ZOOM_MIN)
|
||||||
@@ -619,7 +617,7 @@ function Buffer() //{{{
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (special)
|
if (args.bang)
|
||||||
buffer.fullZoom = level;
|
buffer.fullZoom = level;
|
||||||
else
|
else
|
||||||
buffer.textZoom = level;
|
buffer.textZoom = level;
|
||||||
@@ -1474,9 +1472,10 @@ function Marks() //{{{
|
|||||||
|
|
||||||
commands.add(["delm[arks]"],
|
commands.add(["delm[arks]"],
|
||||||
"Delete the specified marks",
|
"Delete the specified marks",
|
||||||
function (args, special)
|
function (args)
|
||||||
{
|
{
|
||||||
args = args.string;
|
let special = args.bang;
|
||||||
|
let args = args.string;
|
||||||
|
|
||||||
if (!special && !args)
|
if (!special && !args)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -95,14 +95,24 @@ function Command(specs, description, action, extraInfo) //{{{
|
|||||||
|
|
||||||
Command.prototype = {
|
Command.prototype = {
|
||||||
|
|
||||||
execute: function (args, special, count, modifiers)
|
execute: function (args, bang, count, modifiers)
|
||||||
{
|
{
|
||||||
// XXX
|
// XXX
|
||||||
special = !!special;
|
bang = !!bang;
|
||||||
count = (count === undefined) ? -1 : count;
|
count = (count === undefined) ? -1 : count;
|
||||||
modifiers = modifiers || {};
|
modifiers = modifiers || {};
|
||||||
|
|
||||||
let self = this;
|
let self = this;
|
||||||
|
function exec(args)
|
||||||
|
{
|
||||||
|
// FIXME: Move to parseCommand?
|
||||||
|
args = self.parseArgs(args);
|
||||||
|
if (!args)
|
||||||
|
return;
|
||||||
|
args.count = count;
|
||||||
|
args.bang = bang;
|
||||||
|
self.action.call(self, args, bang, count, modifiers);
|
||||||
|
}
|
||||||
|
|
||||||
if (this.hereDoc)
|
if (this.hereDoc)
|
||||||
{
|
{
|
||||||
@@ -110,19 +120,12 @@ Command.prototype = {
|
|||||||
if (matches && matches[2])
|
if (matches && matches[2])
|
||||||
{
|
{
|
||||||
commandline.inputMultiline(new RegExp("^" + matches[2] + "$", "m"),
|
commandline.inputMultiline(new RegExp("^" + matches[2] + "$", "m"),
|
||||||
function (args)
|
function (args) { exec(matches[1] + "\n" + args) });
|
||||||
{
|
|
||||||
args = self.parseArgs(matches[1] + "\n" + args);
|
|
||||||
if (args)
|
|
||||||
self.action.call(self, args, special, count, modifiers);
|
|
||||||
});
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
args = this.parseArgs(args);
|
exec(args);
|
||||||
if (args)
|
|
||||||
this.action.call(this, args, special, count, modifiers);
|
|
||||||
},
|
},
|
||||||
|
|
||||||
// return true if the candidate name matches one of the command's aliases
|
// return true if the candidate name matches one of the command's aliases
|
||||||
@@ -745,12 +748,12 @@ function Commands() //{{{
|
|||||||
////////////////////// COMMANDS ////////////////////////////////////////////////
|
////////////////////// COMMANDS ////////////////////////////////////////////////
|
||||||
/////////////////////////////////////////////////////////////////////////////{{{
|
/////////////////////////////////////////////////////////////////////////////{{{
|
||||||
|
|
||||||
function userCommand(args, special, count, modifiers)
|
function userCommand(args, modifiers)
|
||||||
{
|
{
|
||||||
let tokens = {
|
let tokens = {
|
||||||
args: this.argCount && args.string,
|
args: this.argCount && args.string,
|
||||||
bang: this.bang && special ? "!" : "",
|
bang: this.bang && args.bang ? "!" : "",
|
||||||
count: this.count && count
|
count: this.count && args.count
|
||||||
};
|
};
|
||||||
|
|
||||||
liberator.execute(commands.replaceTokens(this.replacementText, tokens));
|
liberator.execute(commands.replaceTokens(this.replacementText, tokens));
|
||||||
@@ -773,7 +776,7 @@ function Commands() //{{{
|
|||||||
// specified - useful?
|
// specified - useful?
|
||||||
commandManager.add(["com[mand]"],
|
commandManager.add(["com[mand]"],
|
||||||
"List and define commands",
|
"List and define commands",
|
||||||
function (args, special)
|
function (args)
|
||||||
{
|
{
|
||||||
let cmd = args[0];
|
let cmd = args[0];
|
||||||
|
|
||||||
@@ -815,7 +818,7 @@ function Commands() //{{{
|
|||||||
completer: completeFunc,
|
completer: completeFunc,
|
||||||
replacementText: args.literalArg
|
replacementText: args.literalArg
|
||||||
},
|
},
|
||||||
special)
|
args.bang)
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
liberator.echoerr("E174: Command already exists: add ! to replace it");
|
liberator.echoerr("E174: Command already exists: add ! to replace it");
|
||||||
|
|||||||
@@ -1181,7 +1181,7 @@ function Completion() //{{{
|
|||||||
|
|
||||||
// if there is no space between the command name and the cursor
|
// if there is no space between the command name and the cursor
|
||||||
// then get completions of the command name
|
// then get completions of the command name
|
||||||
let [count, cmd, special, args] = commands.parseCommand(context.filter);
|
let [count, cmd, bang, args] = commands.parseCommand(context.filter);
|
||||||
let [, prefix, junk] = context.filter.match(/^(:*\d*)\w*(.?)/) || [];
|
let [, prefix, junk] = context.filter.match(/^(:*\d*)\w*(.?)/) || [];
|
||||||
context.advance(prefix.length)
|
context.advance(prefix.length)
|
||||||
if (!junk)
|
if (!junk)
|
||||||
@@ -1202,12 +1202,15 @@ function Completion() //{{{
|
|||||||
args = command.parseArgs(cmdContext.filter, argContext);
|
args = command.parseArgs(cmdContext.filter, argContext);
|
||||||
if (args)
|
if (args)
|
||||||
{
|
{
|
||||||
|
// FIXME: Move to parseCommand
|
||||||
|
args.count = count;
|
||||||
|
args.bang = bang;
|
||||||
if (!args.completeOpt && command.completer)
|
if (!args.completeOpt && command.completer)
|
||||||
{
|
{
|
||||||
cmdContext.advance(args.completeStart);
|
cmdContext.advance(args.completeStart);
|
||||||
cmdContext.quote = args.quote;
|
cmdContext.quote = args.quote;
|
||||||
cmdContext.filter = args.completeFilter;
|
cmdContext.filter = args.completeFilter;
|
||||||
compObject = command.completer.call(command, cmdContext, args, special, count);
|
compObject = command.completer.call(command, cmdContext, args);
|
||||||
if (compObject instanceof Array) // for now at least, let completion functions return arrays instead of objects
|
if (compObject instanceof Array) // for now at least, let completion functions return arrays instead of objects
|
||||||
compObject = { start: compObject[0], items: compObject[1] };
|
compObject = { start: compObject[0], items: compObject[1] };
|
||||||
if (compObject != null)
|
if (compObject != null)
|
||||||
|
|||||||
@@ -70,7 +70,7 @@ function AutoCommands() //{{{
|
|||||||
|
|
||||||
commands.add(["au[tocmd]"],
|
commands.add(["au[tocmd]"],
|
||||||
"Execute commands automatically on events",
|
"Execute commands automatically on events",
|
||||||
function (args, special)
|
function (args)
|
||||||
{
|
{
|
||||||
let [event, regex, cmd] = args;
|
let [event, regex, cmd] = args;
|
||||||
let events = null;
|
let events = null;
|
||||||
@@ -90,7 +90,7 @@ function AutoCommands() //{{{
|
|||||||
|
|
||||||
if (cmd) // add new command, possibly removing all others with the same event/pattern
|
if (cmd) // add new command, possibly removing all others with the same event/pattern
|
||||||
{
|
{
|
||||||
if (special)
|
if (args.bang)
|
||||||
autocommands.remove(event, regex);
|
autocommands.remove(event, regex);
|
||||||
autocommands.add(events, regex, cmd);
|
autocommands.add(events, regex, cmd);
|
||||||
}
|
}
|
||||||
@@ -98,7 +98,7 @@ function AutoCommands() //{{{
|
|||||||
{
|
{
|
||||||
if (event == "*")
|
if (event == "*")
|
||||||
event = null;
|
event = null;
|
||||||
if (special)
|
if (args.bang)
|
||||||
{
|
{
|
||||||
// TODO: "*" only appears to work in Vim when there is a {group} specified
|
// TODO: "*" only appears to work in Vim when there is a {group} specified
|
||||||
if (args[0] != "*" || regex)
|
if (args[0] != "*" || regex)
|
||||||
@@ -708,14 +708,12 @@ function Events() //{{{
|
|||||||
|
|
||||||
commands.add(["delmac[ros]"],
|
commands.add(["delmac[ros]"],
|
||||||
"Delete macros",
|
"Delete macros",
|
||||||
function (args, special)
|
function (args)
|
||||||
{
|
{
|
||||||
args = args.string;
|
if (args.bang)
|
||||||
|
args.string = ".*"; // XXX
|
||||||
|
|
||||||
if (special)
|
events.deleteMacros(args.string);
|
||||||
args = ".*"; // XXX
|
|
||||||
|
|
||||||
events.deleteMacros(args);
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
bang: true,
|
bang: true,
|
||||||
|
|||||||
@@ -241,13 +241,13 @@ function IO() //{{{
|
|||||||
// "mkv[imperatorrc]" or "mkm[uttatorrc]"
|
// "mkv[imperatorrc]" or "mkm[uttatorrc]"
|
||||||
commands.add([EXTENSION_NAME.replace(/(.)(.*)/, "mk$1[$2rc]")],
|
commands.add([EXTENSION_NAME.replace(/(.)(.*)/, "mk$1[$2rc]")],
|
||||||
"Write current key mappings and changed options to the config file",
|
"Write current key mappings and changed options to the config file",
|
||||||
function (args, special)
|
function (args)
|
||||||
{
|
{
|
||||||
// TODO: "E172: Only one file name allowed"
|
// TODO: "E172: Only one file name allowed"
|
||||||
let filename = args[0] || "~/" + (WINDOWS ? "_" : ".") + EXTENSION_NAME + "rc";
|
let filename = args[0] || "~/" + (WINDOWS ? "_" : ".") + EXTENSION_NAME + "rc";
|
||||||
let file = io.getFile(filename);
|
let file = io.getFile(filename);
|
||||||
|
|
||||||
if (file.exists() && !special)
|
if (file.exists() && !args.bang)
|
||||||
{
|
{
|
||||||
liberator.echoerr("E189: \"" + filename + "\" exists (add ! to override)");
|
liberator.echoerr("E189: \"" + filename + "\" exists (add ! to override)");
|
||||||
return;
|
return;
|
||||||
@@ -288,7 +288,7 @@ function IO() //{{{
|
|||||||
|
|
||||||
commands.add(["runt[ime]"],
|
commands.add(["runt[ime]"],
|
||||||
"Source the specified file from each directory in 'runtimepath'",
|
"Source the specified file from each directory in 'runtimepath'",
|
||||||
function (args, special) { io.sourceFromRuntimePath(args, special); },
|
function (args) { io.sourceFromRuntimePath(args, args.bang); },
|
||||||
{
|
{
|
||||||
argCount: "+",
|
argCount: "+",
|
||||||
bang: true
|
bang: true
|
||||||
@@ -308,10 +308,10 @@ function IO() //{{{
|
|||||||
|
|
||||||
commands.add(["so[urce]"],
|
commands.add(["so[urce]"],
|
||||||
"Read Ex commands from a file",
|
"Read Ex commands from a file",
|
||||||
function (args, special)
|
function (args)
|
||||||
{
|
{
|
||||||
// FIXME: "E172: Only one file name allowed"
|
// FIXME: "E172: Only one file name allowed"
|
||||||
io.source(args[0], special);
|
io.source(args[0], args.bang);
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
argCount: "1",
|
argCount: "1",
|
||||||
@@ -321,8 +321,9 @@ function IO() //{{{
|
|||||||
|
|
||||||
commands.add(["!", "run"],
|
commands.add(["!", "run"],
|
||||||
"Run a command",
|
"Run a command",
|
||||||
function (args, special)
|
function (args)
|
||||||
{
|
{
|
||||||
|
let special = args.bang;
|
||||||
args = args.string;
|
args = args.string;
|
||||||
|
|
||||||
// :!! needs to be treated specially as the command parser sets the
|
// :!! needs to be treated specially as the command parser sets the
|
||||||
|
|||||||
@@ -288,7 +288,7 @@ const liberator = (function () //{{{
|
|||||||
|
|
||||||
commands.add(["exu[sage]"],
|
commands.add(["exu[sage]"],
|
||||||
"List all Ex commands with a short description",
|
"List all Ex commands with a short description",
|
||||||
function (args, special) { showHelpIndex("ex-cmd-index", commands, special); },
|
function (args) { showHelpIndex("ex-cmd-index", commands, args.bang); },
|
||||||
{
|
{
|
||||||
argCount: "0",
|
argCount: "0",
|
||||||
bang: true
|
bang: true
|
||||||
@@ -296,9 +296,9 @@ const liberator = (function () //{{{
|
|||||||
|
|
||||||
commands.add(["h[elp]"],
|
commands.add(["h[elp]"],
|
||||||
"Display help",
|
"Display help",
|
||||||
function (args, special)
|
function (args)
|
||||||
{
|
{
|
||||||
if (special)
|
if (args.bang)
|
||||||
{
|
{
|
||||||
liberator.echoerr("E478: Don't panic!");
|
liberator.echoerr("E478: Don't panic!");
|
||||||
return;
|
return;
|
||||||
@@ -314,9 +314,9 @@ const liberator = (function () //{{{
|
|||||||
|
|
||||||
commands.add(["javas[cript]", "js"],
|
commands.add(["javas[cript]", "js"],
|
||||||
"Run a JavaScript command through eval()",
|
"Run a JavaScript command through eval()",
|
||||||
function (args, special)
|
function (args)
|
||||||
{
|
{
|
||||||
if (special) // open javascript console
|
if (args.bang) // open javascript console
|
||||||
{
|
{
|
||||||
liberator.open("chrome://global/content/console.xul",
|
liberator.open("chrome://global/content/console.xul",
|
||||||
(options["newtab"] && options.get("newtab").has("all", "javascript"))
|
(options["newtab"] && options.get("newtab").has("all", "javascript"))
|
||||||
@@ -347,7 +347,7 @@ const liberator = (function () //{{{
|
|||||||
|
|
||||||
commands.add(["norm[al]"],
|
commands.add(["norm[al]"],
|
||||||
"Execute Normal mode commands",
|
"Execute Normal mode commands",
|
||||||
function (args, special) { events.feedkeys(args.string, special); },
|
function (args) { events.feedkeys(args.string, args.bang); },
|
||||||
{
|
{
|
||||||
argCount: "+",
|
argCount: "+",
|
||||||
bang: true
|
bang: true
|
||||||
@@ -355,7 +355,7 @@ const liberator = (function () //{{{
|
|||||||
|
|
||||||
commands.add(["optionu[sage]"],
|
commands.add(["optionu[sage]"],
|
||||||
"List all options with a short description",
|
"List all options with a short description",
|
||||||
function (args, special) { showHelpIndex("option-index", options, special); },
|
function (args) { showHelpIndex("option-index", options, args.bang); },
|
||||||
{
|
{
|
||||||
argCount: "0",
|
argCount: "0",
|
||||||
bang: true
|
bang: true
|
||||||
@@ -363,12 +363,12 @@ const liberator = (function () //{{{
|
|||||||
|
|
||||||
commands.add(["q[uit]"],
|
commands.add(["q[uit]"],
|
||||||
liberator.has("tabs") ? "Quit current tab" : "Quit application",
|
liberator.has("tabs") ? "Quit current tab" : "Quit application",
|
||||||
function (args, special)
|
function (args)
|
||||||
{
|
{
|
||||||
if (liberator.has("tabs"))
|
if (liberator.has("tabs"))
|
||||||
tabs.remove(getBrowser().mCurrentTab, 1, false, 1);
|
tabs.remove(getBrowser().mCurrentTab, 1, false, 1);
|
||||||
else
|
else
|
||||||
liberator.quit(false, special);
|
liberator.quit(false, args.bang);
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
argCount: "0",
|
argCount: "0",
|
||||||
@@ -382,8 +382,10 @@ const liberator = (function () //{{{
|
|||||||
|
|
||||||
commands.add(["time"],
|
commands.add(["time"],
|
||||||
"Profile a piece of code or run a command multiple times",
|
"Profile a piece of code or run a command multiple times",
|
||||||
function (args, special, count)
|
function (args)
|
||||||
{
|
{
|
||||||
|
let count = args.count;
|
||||||
|
let special = args.bang;
|
||||||
args = args.string;
|
args = args.string;
|
||||||
|
|
||||||
if (args[0] == ":")
|
if (args[0] == ":")
|
||||||
@@ -477,9 +479,9 @@ const liberator = (function () //{{{
|
|||||||
|
|
||||||
commands.add(["ve[rsion]"],
|
commands.add(["ve[rsion]"],
|
||||||
"Show version information",
|
"Show version information",
|
||||||
function (args, special)
|
function (args)
|
||||||
{
|
{
|
||||||
if (special)
|
if (args.bang)
|
||||||
liberator.open("about:");
|
liberator.open("about:");
|
||||||
else
|
else
|
||||||
liberator.echo(":" + util.escapeHTML(commandline.getCommand()) + "\n" +
|
liberator.echo(":" + util.escapeHTML(commandline.getCommand()) + "\n" +
|
||||||
@@ -493,7 +495,7 @@ const liberator = (function () //{{{
|
|||||||
|
|
||||||
commands.add(["viu[sage]"],
|
commands.add(["viu[sage]"],
|
||||||
"List all mappings with a short description",
|
"List all mappings with a short description",
|
||||||
function (args, special) { showHelpIndex("normal-index", mappings, special); },
|
function (args) { showHelpIndex("normal-index", mappings, args.bang); },
|
||||||
{
|
{
|
||||||
argCount: "0",
|
argCount: "0",
|
||||||
bang: true
|
bang: true
|
||||||
|
|||||||
@@ -662,8 +662,9 @@ function Mail() //{{{
|
|||||||
|
|
||||||
commands.add(["go[to]"],
|
commands.add(["go[to]"],
|
||||||
"Select a folder",
|
"Select a folder",
|
||||||
function (args, special, count)
|
function (args)
|
||||||
{
|
{
|
||||||
|
let count = args.count;
|
||||||
args = args.string || "Inbox";
|
args = args.string || "Inbox";
|
||||||
count = count > 0 ? (count - 1) : 0;
|
count = count > 0 ? (count - 1) : 0;
|
||||||
|
|
||||||
@@ -732,7 +733,7 @@ function Mail() //{{{
|
|||||||
|
|
||||||
commands.add(["get[messages]"],
|
commands.add(["get[messages]"],
|
||||||
"Check for new messages",
|
"Check for new messages",
|
||||||
function (args, special) mail.getNewMessages(!special),
|
function (args) mail.getNewMessages(!args.bang),
|
||||||
{
|
{
|
||||||
argCount: "0",
|
argCount: "0",
|
||||||
bang: true,
|
bang: true,
|
||||||
|
|||||||
@@ -495,9 +495,9 @@ function Options() //{{{
|
|||||||
|
|
||||||
commands.add(["pref[erences]", "prefs"],
|
commands.add(["pref[erences]", "prefs"],
|
||||||
"Show " + config.hostApplication + " preferences",
|
"Show " + config.hostApplication + " preferences",
|
||||||
function (args, special)
|
function (args)
|
||||||
{
|
{
|
||||||
if (special) // open Firefox settings GUI dialog
|
if (args.bang) // open Firefox settings GUI dialog
|
||||||
{
|
{
|
||||||
liberator.open("about:config",
|
liberator.open("about:config",
|
||||||
(options["newtab"] && options.get("newtab").has("all", "prefs"))
|
(options["newtab"] && options.get("newtab").has("all", "prefs"))
|
||||||
@@ -515,16 +515,16 @@ function Options() //{{{
|
|||||||
|
|
||||||
commands.add(["setl[ocal]"],
|
commands.add(["setl[ocal]"],
|
||||||
"Set local option",
|
"Set local option",
|
||||||
function (args, special, count)
|
function (args)
|
||||||
{
|
{
|
||||||
commands.get("set").execute(args.string, special, count, { scope: options.OPTION_SCOPE_LOCAL });
|
commands.get("set").execute(args.string, args.bang, args.count, { scope: options.OPTION_SCOPE_LOCAL });
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
bang: true,
|
bang: true,
|
||||||
count: true,
|
count: true,
|
||||||
completer: function (context, args, special, count)
|
completer: function (context, args)
|
||||||
{
|
{
|
||||||
return commands.get("set").completer(context.filter, special, count, { scope: options.OPTION_SCOPE_LOCAL });
|
return commands.get("set").completer(context.filter, args.bang, args.count, { scope: options.OPTION_SCOPE_LOCAL });
|
||||||
},
|
},
|
||||||
literal: true
|
literal: true
|
||||||
}
|
}
|
||||||
@@ -532,16 +532,16 @@ function Options() //{{{
|
|||||||
|
|
||||||
commands.add(["setg[lobal]"],
|
commands.add(["setg[lobal]"],
|
||||||
"Set global option",
|
"Set global option",
|
||||||
function (args, special, count)
|
function (args)
|
||||||
{
|
{
|
||||||
commands.get("set").execute(args.string, special, count, { scope: options.OPTION_SCOPE_GLOBAL });
|
commands.get("set").execute(args.string, args.bang, args.count, { scope: options.OPTION_SCOPE_GLOBAL });
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
bang: true,
|
bang: true,
|
||||||
count: true,
|
count: true,
|
||||||
completer: function (context, args, special, count)
|
completer: function (context, args)
|
||||||
{
|
{
|
||||||
return commands.get("set").completer(context.filter, special, count, { scope: options.OPTION_SCOPE_GLOBAL });
|
return commands.get("set").completer(context.filter, args.bang, args.count, { scope: options.OPTION_SCOPE_GLOBAL });
|
||||||
},
|
},
|
||||||
literal: true
|
literal: true
|
||||||
}
|
}
|
||||||
@@ -550,11 +550,11 @@ function Options() //{{{
|
|||||||
// TODO: support setting multiple options at once
|
// TODO: support setting multiple options at once
|
||||||
commands.add(["se[t]"],
|
commands.add(["se[t]"],
|
||||||
"Set an option",
|
"Set an option",
|
||||||
function (args, special, count, modifiers)
|
function (args, modifiers)
|
||||||
{
|
{
|
||||||
|
let bang = args.bang;
|
||||||
args = args.string;
|
args = args.string;
|
||||||
|
if (bang)
|
||||||
if (special)
|
|
||||||
{
|
{
|
||||||
var onlyNonDefault = false;
|
var onlyNonDefault = false;
|
||||||
if (!args)
|
if (!args)
|
||||||
@@ -665,12 +665,12 @@ function Options() //{{{
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
bang: true,
|
bang: true,
|
||||||
completer: function (context, args, special, count, modifiers)
|
completer: function (context, args)
|
||||||
{
|
{
|
||||||
let filter = context.filter;
|
let filter = context.filter;
|
||||||
var optionCompletions = [];
|
var optionCompletions = [];
|
||||||
|
|
||||||
if (special) // list completions for about:config entries
|
if (args.bang) // list completions for about:config entries
|
||||||
{
|
{
|
||||||
if (filter[filter.length - 1] == "=")
|
if (filter[filter.length - 1] == "=")
|
||||||
{
|
{
|
||||||
@@ -779,20 +779,20 @@ function Options() //{{{
|
|||||||
|
|
||||||
commands.add(["unl[et]"],
|
commands.add(["unl[et]"],
|
||||||
"Delete a variable",
|
"Delete a variable",
|
||||||
function (args, special)
|
function (args)
|
||||||
{
|
{
|
||||||
//var names = args.split(/ /);
|
//var names = args.split(/ /);
|
||||||
//if (typeof names == "string") names = [names];
|
//if (typeof names == "string") names = [names];
|
||||||
|
|
||||||
//var length = names.length;
|
//var length = names.length;
|
||||||
//for (let i = 0, name = names[i]; i < length; name = names[++i])
|
//for (let i = 0, name = names[i]; i < length; name = names[++i])
|
||||||
for (let i = 0; i < args.length; i++)
|
for (let [,name] in Iterator(args))
|
||||||
{
|
{
|
||||||
var name = args[i];
|
var name = args[i];
|
||||||
var reference = liberator.variableReference(name);
|
var reference = liberator.variableReference(name);
|
||||||
if (!reference[0])
|
if (!reference[0])
|
||||||
{
|
{
|
||||||
if (!special)
|
if (!args.bang)
|
||||||
liberator.echoerr("E108: No such variable: " + name);
|
liberator.echoerr("E108: No such variable: " + name);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -399,7 +399,7 @@ liberator.registerObserver("load_commands", function ()
|
|||||||
|
|
||||||
commands.add(["sty[le]"],
|
commands.add(["sty[le]"],
|
||||||
"Add or list user styles",
|
"Add or list user styles",
|
||||||
function (args, special)
|
function (args)
|
||||||
{
|
{
|
||||||
let [filter, css] = args;
|
let [filter, css] = args;
|
||||||
let name = args["-name"];
|
let name = args["-name"];
|
||||||
@@ -426,7 +426,7 @@ liberator.registerObserver("load_commands", function ()
|
|||||||
css = sheet.css.replace(/;?\s*$/, "; " + css);
|
css = sheet.css.replace(/;?\s*$/, "; " + css);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
let err = styles.addSheet(name, filter, css, false, special);
|
let err = styles.addSheet(name, filter, css, false, args.bang);
|
||||||
if (err)
|
if (err)
|
||||||
liberator.echoerr(err);
|
liberator.echoerr(err);
|
||||||
}
|
}
|
||||||
@@ -434,7 +434,7 @@ liberator.registerObserver("load_commands", function ()
|
|||||||
{
|
{
|
||||||
argCount: 2,
|
argCount: 2,
|
||||||
bang: true,
|
bang: true,
|
||||||
completer: function (context, args, bang) {
|
completer: function (context, args) {
|
||||||
let compl = [];
|
let compl = [];
|
||||||
if (args.completeArg == 0)
|
if (args.completeArg == 0)
|
||||||
{
|
{
|
||||||
@@ -483,7 +483,7 @@ liberator.registerObserver("load_commands", function ()
|
|||||||
|
|
||||||
commands.add(["hi[ghlight]"],
|
commands.add(["hi[ghlight]"],
|
||||||
"Set the style of certain display elements",
|
"Set the style of certain display elements",
|
||||||
function (args, special)
|
function (args)
|
||||||
{
|
{
|
||||||
let style = <![CDATA[
|
let style = <![CDATA[
|
||||||
;
|
;
|
||||||
@@ -495,7 +495,7 @@ liberator.registerObserver("load_commands", function ()
|
|||||||
overflow: hidden !important;
|
overflow: hidden !important;
|
||||||
]]>;
|
]]>;
|
||||||
let [key, css] = args;
|
let [key, css] = args;
|
||||||
if (!css && !(key && special))
|
if (!css && !(key && args.bang))
|
||||||
{
|
{
|
||||||
let str = template.tabular(["Key", "Sample", "CSS"],
|
let str = template.tabular(["Key", "Sample", "CSS"],
|
||||||
["padding: 0 1em 0 0; vertical-align: top", "text-align: center"],
|
["padding: 0 1em 0 0; vertical-align: top", "text-align: center"],
|
||||||
@@ -507,7 +507,7 @@ liberator.registerObserver("load_commands", function ()
|
|||||||
commandline.echo(str, commandline.HL_NORMAL, commandline.FORCE_MULTILINE);
|
commandline.echo(str, commandline.HL_NORMAL, commandline.FORCE_MULTILINE);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
let error = highlight.set(key, css, special, "-append" in args);
|
let error = highlight.set(key, css, args.bang, "-append" in args);
|
||||||
if (error)
|
if (error)
|
||||||
liberator.echoerr(error);
|
liberator.echoerr(error);
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -310,8 +310,9 @@ function Tabs() //{{{
|
|||||||
|
|
||||||
commands.add(["bd[elete]", "bw[ipeout]", "bun[load]", "tabc[lose]"],
|
commands.add(["bd[elete]", "bw[ipeout]", "bun[load]", "tabc[lose]"],
|
||||||
"Delete current buffer",
|
"Delete current buffer",
|
||||||
function (args, special, count)
|
function (args)
|
||||||
{
|
{
|
||||||
|
let special = args.bang;
|
||||||
args = args.string;
|
args = args.string;
|
||||||
|
|
||||||
if (args)
|
if (args)
|
||||||
@@ -381,8 +382,9 @@ function Tabs() //{{{
|
|||||||
// TODO: "Zero count" if 0 specified as arg
|
// TODO: "Zero count" if 0 specified as arg
|
||||||
commands.add(["tabp[revious]", "tp[revious]", "tabN[ext]", "tN[ext]", "bp[revious]", "bN[ext]"],
|
commands.add(["tabp[revious]", "tp[revious]", "tabN[ext]", "tN[ext]", "bp[revious]", "bN[ext]"],
|
||||||
"Switch to the previous tab or go [count] tabs back",
|
"Switch to the previous tab or go [count] tabs back",
|
||||||
function (args, special, count)
|
function (args)
|
||||||
{
|
{
|
||||||
|
let count = args.count;
|
||||||
args = args.string;
|
args = args.string;
|
||||||
|
|
||||||
// count is ignored if an arg is specified, as per Vim
|
// count is ignored if an arg is specified, as per Vim
|
||||||
@@ -407,8 +409,9 @@ function Tabs() //{{{
|
|||||||
// TODO: "Zero count" if 0 specified as arg
|
// TODO: "Zero count" if 0 specified as arg
|
||||||
commands.add(["tabn[ext]", "tn[ext]", "bn[ext]"],
|
commands.add(["tabn[ext]", "tn[ext]", "bn[ext]"],
|
||||||
"Switch to the next or [count]th tab",
|
"Switch to the next or [count]th tab",
|
||||||
function (args, special, count)
|
function (args)
|
||||||
{
|
{
|
||||||
|
let count = args.count;
|
||||||
args = args.string;
|
args = args.string;
|
||||||
|
|
||||||
if (args || count > 0)
|
if (args || count > 0)
|
||||||
@@ -455,8 +458,10 @@ function Tabs() //{{{
|
|||||||
// TODO: "Zero count" if 0 specified as arg, multiple args and count ranges?
|
// TODO: "Zero count" if 0 specified as arg, multiple args and count ranges?
|
||||||
commands.add(["b[uffer]"],
|
commands.add(["b[uffer]"],
|
||||||
"Switch to a buffer",
|
"Switch to a buffer",
|
||||||
function (args, special, count)
|
function (args)
|
||||||
{
|
{
|
||||||
|
let count = args.count;
|
||||||
|
let special = args.special;
|
||||||
args = args.string;
|
args = args.string;
|
||||||
|
|
||||||
// if a numeric arg is specified any count is ignored; if a
|
// if a numeric arg is specified any count is ignored; if a
|
||||||
@@ -494,7 +499,7 @@ function Tabs() //{{{
|
|||||||
|
|
||||||
commands.add(["quita[ll]", "qa[ll]"],
|
commands.add(["quita[ll]", "qa[ll]"],
|
||||||
"Quit " + config.name,
|
"Quit " + config.name,
|
||||||
function (args, special) { liberator.quit(false, special); },
|
function (args) { liberator.quit(false, args.bang); },
|
||||||
{
|
{
|
||||||
argCount: "0",
|
argCount: "0",
|
||||||
bang: true
|
bang: true
|
||||||
@@ -502,7 +507,7 @@ function Tabs() //{{{
|
|||||||
|
|
||||||
commands.add(["reloada[ll]"],
|
commands.add(["reloada[ll]"],
|
||||||
"Reload all tab pages",
|
"Reload all tab pages",
|
||||||
function (args, special) { tabs.reloadAll(special); },
|
function (args) { tabs.reloadAll(args.bang); },
|
||||||
{
|
{
|
||||||
argCount: "0",
|
argCount: "0",
|
||||||
bang: true
|
bang: true
|
||||||
@@ -511,8 +516,9 @@ function Tabs() //{{{
|
|||||||
// TODO: add count support
|
// TODO: add count support
|
||||||
commands.add(["tabm[ove]"],
|
commands.add(["tabm[ove]"],
|
||||||
"Move the current tab after tab N",
|
"Move the current tab after tab N",
|
||||||
function (args, special)
|
function (args)
|
||||||
{
|
{
|
||||||
|
let special = args.bang;
|
||||||
args = args.string;
|
args = args.string;
|
||||||
|
|
||||||
// FIXME: tabmove! N should probably produce an error
|
// FIXME: tabmove! N should probably produce an error
|
||||||
@@ -536,8 +542,9 @@ function Tabs() //{{{
|
|||||||
|
|
||||||
commands.add(["tabopen", "t[open]", "tabnew", "tabe[dit]"],
|
commands.add(["tabopen", "t[open]", "tabnew", "tabe[dit]"],
|
||||||
"Open one or more URLs in a new tab",
|
"Open one or more URLs in a new tab",
|
||||||
function (args, special)
|
function (args)
|
||||||
{
|
{
|
||||||
|
let special = args.bang;
|
||||||
args = args.string;
|
args = args.string;
|
||||||
|
|
||||||
var where = special ? liberator.NEW_TAB : liberator.NEW_BACKGROUND_TAB;
|
var where = special ? liberator.NEW_TAB : liberator.NEW_BACKGROUND_TAB;
|
||||||
@@ -562,18 +569,15 @@ function Tabs() //{{{
|
|||||||
|
|
||||||
commands.add(["tabd[uplicate]"],
|
commands.add(["tabd[uplicate]"],
|
||||||
"Duplicate current tab",
|
"Duplicate current tab",
|
||||||
function (args, special, count)
|
function (args)
|
||||||
{
|
{
|
||||||
var tab = tabs.getTab();
|
var tab = tabs.getTab();
|
||||||
|
|
||||||
var activate = special ? true : false;
|
var activate = args.bang ? true : false;
|
||||||
if (/\btabopen\b/.test(options["activate"]))
|
if (/\btabopen\b/.test(options["activate"]))
|
||||||
activate = !activate;
|
activate = !activate;
|
||||||
|
|
||||||
if (count < 1)
|
for (let i in range(0, Math.max(1, args.count)))
|
||||||
count = 1;
|
|
||||||
|
|
||||||
for (let i = 0; i < count; i++)
|
|
||||||
tabs.cloneTab(tab, activate);
|
tabs.cloneTab(tab, activate);
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -588,8 +592,9 @@ function Tabs() //{{{
|
|||||||
// TODO: extract common functionality of "undoall"
|
// TODO: extract common functionality of "undoall"
|
||||||
commands.add(["u[ndo]"],
|
commands.add(["u[ndo]"],
|
||||||
"Undo closing of a tab",
|
"Undo closing of a tab",
|
||||||
function (args, special, count)
|
function (args)
|
||||||
{
|
{
|
||||||
|
let count = args.count;
|
||||||
args = args.string;
|
args = args.string;
|
||||||
|
|
||||||
if (count < 1)
|
if (count < 1)
|
||||||
|
|||||||
@@ -275,15 +275,13 @@ const config = { //{{{
|
|||||||
|
|
||||||
commands.add(["o[pen]", "e[dit]"],
|
commands.add(["o[pen]", "e[dit]"],
|
||||||
"Open one or more URLs in the current tab",
|
"Open one or more URLs in the current tab",
|
||||||
function (args, special)
|
function (args)
|
||||||
{
|
{
|
||||||
args = args.string;
|
if (args.string)
|
||||||
|
|
||||||
if (args)
|
|
||||||
{
|
{
|
||||||
liberator.open(args);
|
liberator.open(args.string);
|
||||||
}
|
}
|
||||||
else if (special)
|
else if (args.bang)
|
||||||
BrowserReloadSkipCache();
|
BrowserReloadSkipCache();
|
||||||
else
|
else
|
||||||
BrowserReload();
|
BrowserReload();
|
||||||
|
|||||||
Reference in New Issue
Block a user