1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2025-12-23 13:52:26 +01:00

add bangAllowed property to Command's extraInfo to specify whether the bang

version of the command is available
This commit is contained in:
Doug Kearns
2008-10-04 09:00:36 +00:00
parent 690ce8d8e2
commit 156fa5d56f
16 changed files with 166 additions and 171 deletions

View File

@@ -126,15 +126,16 @@ liberator.Addressbook = function () //{{{
}, },
{ {
argCount: "+",
options: [[["-firstname", "-f"], liberator.commands.OPTION_STRING], options: [[["-firstname", "-f"], liberator.commands.OPTION_STRING],
[["-lastname", "-l"], liberator.commands.OPTION_STRING], [["-lastname", "-l"], liberator.commands.OPTION_STRING],
[["-name", "-n"], liberator.commands.OPTION_STRING]], [["-name", "-n"], liberator.commands.OPTION_STRING]]
argCount: "+"
}); });
liberator.commands.add(["contacts", "addr[essbook]"], liberator.commands.add(["contacts", "addr[essbook]"],
"List or open multiple addresses", "List or open multiple addresses",
function (args, special) { liberator.addressbook.list(args, special); }); function (args, special) liberator.addressbook.list(args, special),
{ bangAllowed: true });
/////////////////////////////////////////////////////////////////////////////}}} /////////////////////////////////////////////////////////////////////////////}}}
////////////////////// PUBLIC SECTION ////////////////////////////////////////// ////////////////////// PUBLIC SECTION //////////////////////////////////////////

View File

@@ -261,10 +261,10 @@ liberator.Bookmarks = function () //{{{
liberator.echoerr("Exxx: Could not add bookmark `" + title + "'", liberator.commandline.FORCE_SINGLELINE); liberator.echoerr("Exxx: Could not add bookmark `" + title + "'", liberator.commandline.FORCE_SINGLELINE);
}, },
{ {
argCount: "?",
options: [[["-title", "-t"], liberator.commands.OPTION_STRING], options: [[["-title", "-t"], liberator.commands.OPTION_STRING],
[["-tags", "-T"], liberator.commands.OPTION_LIST], [["-tags", "-T"], liberator.commands.OPTION_LIST],
[["-keyword", "-k"], liberator.commands.OPTION_STRING, function (arg) { return /\w/.test(arg); }]], [["-keyword", "-k"], liberator.commands.OPTION_STRING, function (arg) { return /\w/.test(arg); }]]
argCount: "?"
}); });
liberator.commands.add(["bmarks"], liberator.commands.add(["bmarks"],
@@ -274,13 +274,14 @@ liberator.Bookmarks = function () //{{{
liberator.bookmarks.list(args.arguments.join(" "), args["-tags"] || [], special); liberator.bookmarks.list(args.arguments.join(" "), args["-tags"] || [], special);
}, },
{ {
bangAllowed: true,
completer: function (filter) [0, liberator.bookmarks.get(filter)], completer: function (filter) [0, liberator.bookmarks.get(filter)],
options: [[["-tags", "-T"], liberator.commands.OPTION_LIST]] options: [[["-tags", "-T"], liberator.commands.OPTION_LIST]]
}); });
liberator.commands.add(["delbm[arks]"], liberator.commands.add(["delbm[arks]"],
"Delete a bookmark", "Delete a bookmark",
function (args, special) function (args)
{ {
var url = args; var url = args;
if (!url) if (!url)
@@ -289,9 +290,7 @@ liberator.Bookmarks = function () //{{{
var deletedCount = liberator.bookmarks.remove(url); var deletedCount = liberator.bookmarks.remove(url);
liberator.echo(deletedCount + " bookmark(s) with url `" + url + "' deleted", liberator.commandline.FORCE_SINGLELINE); liberator.echo(deletedCount + " bookmark(s) with url `" + url + "' deleted", liberator.commandline.FORCE_SINGLELINE);
}, },
{ { completer: function (filter) [0, liberator.bookmarks.get(filter)] });
completer: function (filter) [0, liberator.bookmarks.get(filter)]
});
/////////////////////////////////////////////////////////////////////////////}}} /////////////////////////////////////////////////////////////////////////////}}}
////////////////////// PUBLIC SECTION ////////////////////////////////////////// ////////////////////// PUBLIC SECTION //////////////////////////////////////////
@@ -602,6 +601,7 @@ liberator.History = function () //{{{
} }
}, },
{ {
bangAllowed: true,
completer: function (filter) completer: function (filter)
{ {
var sh = getWebNavigation().sessionHistory; var sh = getWebNavigation().sessionHistory;
@@ -648,6 +648,7 @@ liberator.History = function () //{{{
} }
}, },
{ {
bangAllowed: true,
completer: function (filter) completer: function (filter)
{ {
var sh = getWebNavigation().sessionHistory; var sh = getWebNavigation().sessionHistory;
@@ -666,8 +667,9 @@ liberator.History = function () //{{{
liberator.commands.add(["hist[ory]", "hs"], liberator.commands.add(["hist[ory]", "hs"],
"Show recently visited URLs", "Show recently visited URLs",
function (args, special) { liberator.history.list(args, special); }, function (args, special) liberator.history.list(args, special),
{ {
bangAllowed: true,
completer: function (filter) [0, liberator.history.get(filter)] completer: function (filter) [0, liberator.history.get(filter)]
}); });
@@ -849,7 +851,8 @@ liberator.QuickMarks = function () //{{{
liberator.quickmarks.removeAll(); liberator.quickmarks.removeAll();
else else
liberator.quickmarks.remove(args); liberator.quickmarks.remove(args);
}); },
{ bangAllowed: true });
liberator.commands.add(["qma[rk]"], liberator.commands.add(["qma[rk]"],
"Mark a URL with a letter for quick access", "Mark a URL with a letter for quick access",

View File

@@ -289,16 +289,12 @@ liberator.Buffer = function () //{{{
"stringlist", "\\bprev|previous\\b,^<$,^(<<|«)$,^(<|«),(<|«)$"); "stringlist", "\\bprev|previous\\b,^<$,^(<<|«)$,^(<|«),(<|«)$");
liberator.options.add(["pageinfo", "pa"], "Desired info on :pa[geinfo]", "charlist", "gfm", liberator.options.add(["pageinfo", "pa"], "Desired info on :pa[geinfo]", "charlist", "gfm",
{ { completer: function (filter) [0, [[k, v[1]] for ([k, v] in Iterator(pageInfo))]] });
completer: function (filter) [0, [[k, v[1]] for ([k, v] in Iterator(pageInfo))]]
});
liberator.options.add(["scroll", "scr"], liberator.options.add(["scroll", "scr"],
"Number of lines to scroll with <C-u> and <C-d> commands", "Number of lines to scroll with <C-u> and <C-d> commands",
"number", 0, "number", 0,
{ { validator: function (value) value >= 0 });
validator: function (value) value >= 0
});
liberator.options.add(["showstatuslinks", "ssli"], liberator.options.add(["showstatuslinks", "ssli"],
"Show the destination of the link under the cursor in the status bar", "Show the destination of the link under the cursor in the status bar",
@@ -607,14 +603,12 @@ liberator.Buffer = function () //{{{
liberator.options.setPref("print.always_print_silent", aps); liberator.options.setPref("print.always_print_silent", aps);
liberator.options.setPref("print.show_print_progress", spp); liberator.options.setPref("print.show_print_progress", spp);
liberator.echo("Print job sent."); liberator.echo("Print job sent.");
}); },
{ bangAllowed: true });
liberator.commands.add(["pa[geinfo]"], liberator.commands.add(["pa[geinfo]"],
"Show various page information", "Show various page information",
function () function () liberator.buffer.showPageInfo(true),
{
liberator.buffer.showPageInfo(true);
},
{ argCount: "0" }); { argCount: "0" });
liberator.commands.add(["pagest[yle]"], liberator.commands.add(["pagest[yle]"],
@@ -634,17 +628,15 @@ liberator.Buffer = function () //{{{
stylesheetSwitchAll(window.content, args); stylesheetSwitchAll(window.content, args);
}, },
{ { completer: function (filter) liberator.completion.stylesheet(filter) });
completer: function (filter) liberator.completion.stylesheet(filter)
});
liberator.commands.add(["re[load]"], liberator.commands.add(["re[load]"],
"Reload current page", "Reload current page",
function (args, special) function (args, special) liberator.tabs.reload(getBrowser().mCurrentTab, special),
{ {
liberator.tabs.reload(getBrowser().mCurrentTab, special); bangAllowed: true,
}, argCount: "0"
{ argCount: "0" }); });
liberator.commands.add(["sav[eas]", "w[rite]"], liberator.commands.add(["sav[eas]", "w[rite]"],
"Save current document to disk", "Save current document to disk",
@@ -660,19 +652,17 @@ liberator.Buffer = function () //{{{
//} //}
//else //else
saveDocument(window.content.document, special); saveDocument(window.content.document, special);
}); },
{ bangAllowed: true, });
liberator.commands.add(["st[op]"], liberator.commands.add(["st[op]"],
"Stop loading", "Stop loading",
function () function () BrowserStop(),
{
BrowserStop();
},
{ argCount: "0" }); { argCount: "0" });
liberator.commands.add(["sty[le]"], liberator.commands.add(["sty[le]"],
"Add or list user styles", "Add or list user styles",
function (args, special) function (args)
{ {
let [, filter, css] = args.match(/(\S+)\s*((?:.|\n)*)/) || []; let [, filter, css] = args.match(/(\S+)\s*((?:.|\n)*)/) || [];
if (!css) if (!css)
@@ -702,7 +692,7 @@ liberator.Buffer = function () //{{{
liberator.commands.add(["dels[tyle]"], liberator.commands.add(["dels[tyle]"],
"Remove a user stylesheet", "Remove a user stylesheet",
function (args, special) styles.removeSheet(parseInt(args.arguments[0])), function (args) styles.removeSheet(parseInt(args.arguments[0])),
{ {
completer: function (filter) [0, [[i, s[0] + ": " + s[1].replace("\n", "\\n")] for ([i, s] in styles)]], completer: function (filter) [0, [[i, s[0] + ": " + s[1].replace("\n", "\\n")] for ([i, s] in styles)]],
argCount: 1 argCount: 1
@@ -710,7 +700,8 @@ liberator.Buffer = function () //{{{
liberator.commands.add(["vie[wsource]"], liberator.commands.add(["vie[wsource]"],
"View source code of current document", "View source code of current document",
function (args, special) { liberator.buffer.viewSource(args, special); }); function (args, special) liberator.buffer.viewSource(args, special),
{ bangAllowed: true });
liberator.commands.add(["zo[om]"], liberator.commands.add(["zo[om]"],
"Set zoom value of current web page", "Set zoom value of current web page",
@@ -749,7 +740,8 @@ liberator.Buffer = function () //{{{
liberator.buffer.fullZoom = level; liberator.buffer.fullZoom = level;
else else
liberator.buffer.textZoom = level; liberator.buffer.textZoom = level;
}); },
{ bangAllowed: true });
/////////////////////////////////////////////////////////////////////////////}}} /////////////////////////////////////////////////////////////////////////////}}}
////////////////////// PAGE INFO /////////////////////////////////////////////// ////////////////////// PAGE INFO ///////////////////////////////////////////////
@@ -1663,7 +1655,8 @@ liberator.Marks = function () //{{{
} }
liberator.marks.remove(args, special); liberator.marks.remove(args, special);
}); },
{ bangAllowed: true });
liberator.commands.add(["ma[rk]"], liberator.commands.add(["ma[rk]"],
"Mark current location within the web page", "Mark current location within the web page",

View File

@@ -74,10 +74,11 @@ liberator.Command = function (specs, description, action, extraInfo) //{{{
this.names = expandedSpecs.names; // return all command name aliases this.names = expandedSpecs.names; // return all command name aliases
this.description = description || ""; this.description = description || "";
this.action = action; this.action = action;
this.completer = extraInfo.completer || null;
this.options = extraInfo.options || [];
this.argCount = extraInfo.argCount || ""; this.argCount = extraInfo.argCount || "";
this.completer = extraInfo.completer || null;
this.hereDoc = extraInfo.hereDoc || false; this.hereDoc = extraInfo.hereDoc || false;
this.options = extraInfo.options || [];
this.bangAllowed = extraInfo.bangAllowed || false;
this.isUserCommand = extraInfo.isUserCommand || false; this.isUserCommand = extraInfo.isUserCommand || false;
this.replacementText = extraInfo.replacementText || null; this.replacementText = extraInfo.replacementText || null;
@@ -699,7 +700,12 @@ liberator.Commands = function () //{{{
liberator.execute(replaced); liberator.execute(replaced);
}, },
{ replacementText: rep }, special)) {
bangAllowed: true, // FIXME: until we implement -bang
replacementText: rep
},
special)
)
{ {
liberator.echoerr("E174: Command already exists: add ! to replace it"); liberator.echoerr("E174: Command already exists: add ! to replace it");
} }
@@ -723,10 +729,11 @@ liberator.Commands = function () //{{{
} }
}, },
{ {
bangAllowed: true,
completer: function (filter) liberator.completion.userCommand(filter)
/*options: [[["-nargs"], OPTION_STRING, function (arg) { return /^(0|1|\*|\?|\+)$/.test(arg); }], /*options: [[["-nargs"], OPTION_STRING, function (arg) { return /^(0|1|\*|\?|\+)$/.test(arg); }],
[["-bang"], OPTION_NOARG], [["-bang"], OPTION_NOARG],
[["-bar"], OPTION_NOARG]] */ [["-bar"], OPTION_NOARG]] */
completer: function (filter) liberator.completion.userCommand(filter)
}); });
commandManager.add(["comc[lear]"], commandManager.add(["comc[lear]"],

View File

@@ -174,14 +174,11 @@ liberator.Editor = function () //{{{
liberator.commands.add([ch ? ch + "una[bbrev]" : "una[bbreviate]"], liberator.commands.add([ch ? ch + "una[bbrev]" : "una[bbreviate]"],
"Remove an abbreviation" + modeDescription, "Remove an abbreviation" + modeDescription,
function (args) { liberator.editor.removeAbbreviation(mode, args); }); function (args) liberator.editor.removeAbbreviation(mode, args));
liberator.commands.add([ch + "abc[lear]"], liberator.commands.add([ch + "abc[lear]"],
"Remove all abbreviations" + modeDescription, "Remove all abbreviations" + modeDescription,
function () function () liberator.editor.removeAllAbbreviations(mode),
{
liberator.editor.removeAllAbbreviations(mode);
},
{ argCount: "0" }); { argCount: "0" });
} }

View File

@@ -112,6 +112,7 @@ liberator.AutoCommands = function () //{{{
} }
}, },
{ {
bangAllowed: true,
completer: function (filter) completer: function (filter)
{ {
return [0, liberator.completion.filter(liberator.config.autocommands || [], filter)]; return [0, liberator.completion.filter(liberator.config.autocommands || [], filter)];
@@ -658,9 +659,7 @@ liberator.Events = function () //{{{
else else
liberator.events.deleteMacros(args); liberator.events.deleteMacros(args);
}, },
{ { completer: function (filter) liberator.completion.macro(filter) });
completer: function (filter) liberator.completion.macro(filter)
});
liberator.commands.add(["macros"], liberator.commands.add(["macros"],
"List all macros", "List all macros",
@@ -670,9 +669,7 @@ liberator.Events = function () //{{{
var str = liberator.template.tabular(["Macro", "Keys"], [], liberator.events.getMacros(args)); var str = liberator.template.tabular(["Macro", "Keys"], [], liberator.events.getMacros(args));
liberator.echo(str, liberator.commandline.FORCE_MULTILINE); liberator.echo(str, liberator.commandline.FORCE_MULTILINE);
}, },
{ { completer: function (filter) liberator.completion.macro(filter) });
completer: function (filter) liberator.completion.macro(filter)
});
liberator.commands.add(["pl[ay]"], liberator.commands.add(["pl[ay]"],
"Replay a recorded macro", "Replay a recorded macro",
@@ -683,9 +680,7 @@ liberator.Events = function () //{{{
else else
liberator.events.playMacro(args); liberator.events.playMacro(args);
}, },
{ { completer: function (filter) liberator.completion.macro(filter) });
completer: function (filter) liberator.completion.macro(filter)
});
/////////////////////////////////////////////////////////////////////////////}}} /////////////////////////////////////////////////////////////////////////////}}}
////////////////////// PUBLIC SECTION ////////////////////////////////////////// ////////////////////// PUBLIC SECTION //////////////////////////////////////////

View File

@@ -305,10 +305,7 @@ liberator.Search = function () //{{{
liberator.commands.add(["noh[lsearch]"], liberator.commands.add(["noh[lsearch]"],
"Remove the search highlighting", "Remove the search highlighting",
function () function () liberator.search.clear(),
{
liberator.search.clear();
},
{ argCount: "0" }); { argCount: "0" });
/////////////////////////////////////////////////////////////////////////////}}} /////////////////////////////////////////////////////////////////////////////}}}

View File

@@ -567,9 +567,7 @@ liberator.Hints = function () //{{{
liberator.options.add(["hinttimeout", "hto"], liberator.options.add(["hinttimeout", "hto"],
"Automatically follow non unique numerical hint", "Automatically follow non unique numerical hint",
"number", 0, "number", 0,
{ { validator: function (value) value >= 0 });
validator: function (value) value >= 0
});
liberator.options.add(["linkfgcolor", "lfc"], liberator.options.add(["linkfgcolor", "lfc"],
"Foreground color of a link during hint mode", "Foreground color of a link during hint mode",

View File

@@ -180,9 +180,7 @@ liberator.IO = function () //{{{
} }
} }
}, },
{ { completer: function (filter) liberator.completion.file(filter, true) });
completer: function (filter) liberator.completion.file(filter, true)
});
liberator.commands.add(["fini[sh]"], liberator.commands.add(["fini[sh]"],
"Stop sourcing a script file", "Stop sourcing a script file",
@@ -195,10 +193,7 @@ liberator.IO = function () //{{{
liberator.commands.add(["pw[d]"], liberator.commands.add(["pw[d]"],
"Print the current directory name", "Print the current directory name",
function () function () liberator.echo(liberator.io.getCurrentDirectory()),
{
liberator.echo(liberator.io.getCurrentDirectory());
},
{ argCount: "0" }); { argCount: "0" });
// mkv[imperatorrc] or mkm[uttatorrc] // mkv[imperatorrc] or mkm[uttatorrc]
@@ -273,6 +268,7 @@ liberator.IO = function () //{{{
} }
}, },
{ {
bangAllowed: true,
completer: function (filter) liberator.completion.file(filter, true) completer: function (filter) liberator.completion.file(filter, true)
}); });
@@ -313,7 +309,10 @@ liberator.IO = function () //{{{
if (!found) if (!found)
liberator.echomsg("not found in 'runtimepath': \"" + paths.join(" ") + "\"", 1); // FIXME: should use original arg string liberator.echomsg("not found in 'runtimepath': \"" + paths.join(" ") + "\"", 1); // FIXME: should use original arg string
}, },
{ argCount: "+" } {
argCount: "+",
bangAllowed: true
}
); );
liberator.commands.add(["scrip[tnames]"], liberator.commands.add(["scrip[tnames]"],
@@ -339,6 +338,7 @@ liberator.IO = function () //{{{
liberator.io.source(args, special); liberator.io.source(args, special);
}, },
{ {
bangAllowed: true,
completer: function (filter) liberator.completion.file(filter, true) completer: function (filter) liberator.completion.file(filter, true)
}); });
@@ -361,7 +361,8 @@ liberator.IO = function () //{{{
liberator.echo(command + liberator.util.escapeHTML(output)); liberator.echo(command + liberator.util.escapeHTML(output));
liberator.autocommands.trigger("ShellCmdPost", ""); liberator.autocommands.trigger("ShellCmdPost", "");
}); },
{ bangAllowed: true });
/////////////////////////////////////////////////////////////////////////////}}} /////////////////////////////////////////////////////////////////////////////}}}
////////////////////// PUBLIC SECTION ////////////////////////////////////////// ////////////////////// PUBLIC SECTION //////////////////////////////////////////

View File

@@ -104,9 +104,7 @@ const liberator = (function () //{{{
liberator.options.add(["verbose", "vbs"], liberator.options.add(["verbose", "vbs"],
"Define which info messages are displayed", "Define which info messages are displayed",
"number", 0, "number", 0,
{ { validator: function (value) value >= 0 && value <= 15 });
validator: function (value) value >= 0 && value <= 15
});
liberator.options.add(["visualbell", "vb"], liberator.options.add(["visualbell", "vb"],
"Use visual bell instead of beeping on errors", "Use visual bell instead of beeping on errors",
@@ -158,15 +156,12 @@ const liberator = (function () //{{{
liberator.commands.add(["beep"], liberator.commands.add(["beep"],
"Play a system beep", "Play a system beep",
function () function () liberator.beep(),
{
liberator.beep();
},
{ argCount: "0" }); { argCount: "0" });
liberator.commands.add(["dia[log]"], liberator.commands.add(["dia[log]"],
"Open a " + liberator.config.name + " dialog", "Open a " + liberator.config.name + " dialog",
function (args, special) function (args)
{ {
try try
{ {
@@ -188,7 +183,8 @@ const liberator = (function () //{{{
{ {
return [0, liberator.completion.filter(liberator.config.dialogs || [], filter)]; return [0, liberator.completion.filter(liberator.config.dialogs || [], filter)];
} }
}); },
{ bangAllowed: true });
// TODO: move this // TODO: move this
function getMenuItems() function getMenuItems()
@@ -294,7 +290,10 @@ const liberator = (function () //{{{
liberator.echo(usage, liberator.commandline.FORCE_MULTILINE); liberator.echo(usage, liberator.commandline.FORCE_MULTILINE);
} }
}, },
{ argCount: "0" }); {
argCount: "0",
bangAllowed: true
});
liberator.commands.add(["h[elp]"], liberator.commands.add(["h[elp]"],
"Display help", "Display help",
@@ -309,6 +308,7 @@ const liberator = (function () //{{{
liberator.help(args); liberator.help(args);
}, },
{ {
bangAllowed: true,
completer: function (filter) getHelpCompletions(filter) completer: function (filter) getHelpCompletions(filter)
}); });
@@ -336,17 +336,18 @@ const liberator = (function () //{{{
} }
}, },
{ {
bangAllowed: true,
completer: function (filter) liberator.completion.javascript(filter), completer: function (filter) liberator.completion.javascript(filter),
hereDoc: true, hereDoc: true,
}); });
liberator.commands.add(["norm[al]"], liberator.commands.add(["norm[al]"],
"Execute Normal mode commands", "Execute Normal mode commands",
function (args, special) function (args, special) liberator.events.feedkeys(args.string, special),
{ {
liberator.events.feedkeys(args.string, special); argCount: "+",
}, bangAllowed: true
{ argCount: "+" }); });
liberator.commands.add(["q[uit]"], liberator.commands.add(["q[uit]"],
liberator.has("tabs") ? "Quit current tab" : "Quit application", liberator.has("tabs") ? "Quit current tab" : "Quit application",
@@ -357,14 +358,14 @@ const liberator = (function () //{{{
else else
liberator.quit(false, special); liberator.quit(false, special);
}, },
{ argCount: "0" }); {
argCount: "0",
bangAllowed: true
});
liberator.commands.add(["res[tart]"], liberator.commands.add(["res[tart]"],
"Force " + liberator.config.name + " to restart", "Force " + liberator.config.name + " to restart",
function () function () liberator.restart(),
{
liberator.restart();
},
{ argCount: "0" }); { argCount: "0" });
liberator.commands.add(["time"], liberator.commands.add(["time"],
@@ -452,6 +453,7 @@ const liberator = (function () //{{{
} }
}, },
{ {
bangAllowed: true,
completer: function (filter) completer: function (filter)
{ {
if (/^:/.test(filter)) if (/^:/.test(filter))
@@ -472,7 +474,10 @@ const liberator = (function () //{{{
liberator.config.name + " " + liberator.version + liberator.config.name + " " + liberator.version +
" running on:\n" + navigator.userAgent); " running on:\n" + navigator.userAgent);
}, },
{ argCount: "0" }); {
argCount: "0",
bangAllowed: true
});
liberator.commands.add(["viu[sage]"], liberator.commands.add(["viu[sage]"],
"List all mappings with a short description", "List all mappings with a short description",
@@ -497,7 +502,10 @@ const liberator = (function () //{{{
liberator.echo(usage, liberator.commandline.FORCE_MULTILINE); liberator.echo(usage, liberator.commandline.FORCE_MULTILINE);
} }
}, },
{ argCount: "0" }); {
argCount: "0",
bangAllowed: true
});
} }
function getHelpCompletions(filter) function getHelpCompletions(filter)
@@ -637,7 +645,7 @@ const liberator = (function () //{{{
return eval("with (liberator) {" + str + "}"); return eval("with (liberator) {" + str + "}");
}, },
// Execute an ex command like str=":zoom 300" // Execute an Ex command like str=":zoom 300"
execute: function (str, modifiers) execute: function (str, modifiers)
{ {
// skip comments and blank lines // skip comments and blank lines
@@ -664,6 +672,12 @@ const liberator = (function () //{{{
return; return;
} }
if (special && !command.bangAllowed)
{
liberator.echoerr("E477: No ! allowed");
return;
}
// valid command, call it: // valid command, call it:
command.execute(args, special, count, modifiers); command.execute(args, special, count, modifiers);
}, },

View File

@@ -672,9 +672,7 @@ liberator.Mail = function () //{{{
else else
SelectFolder(folder.URI); SelectFolder(folder.URI);
}, },
{ { completer: function (filter) getFolderCompletions(filter) });
completer: function (filter) getFolderCompletions(filter)
});
liberator.commands.add(["m[essage]"], liberator.commands.add(["m[essage]"],
"Write a new message", "Write a new message",
@@ -713,33 +711,26 @@ liberator.Mail = function () //{{{
liberator.commands.add(["copy[to]"], liberator.commands.add(["copy[to]"],
"Copy selected messages", "Copy selected messages",
function (args, special) { moveOrCopy(true, args); }, function (args) moveOrCopy(true, args),
{ { completer: function (filter) getFolderCompletions(filter) });
completer: function (filter) getFolderCompletions(filter)
});
liberator.commands.add(["move[to]"], liberator.commands.add(["move[to]"],
"Move selected messages", "Move selected messages",
function (args, special) { moveOrCopy(false, args); }, function (args) moveOrCopy(false, args),
{ { completer: function (filter) getFolderCompletions(filter) });
completer: function (filter) getFolderCompletions(filter)
});
liberator.commands.add(["empty[trash]"], liberator.commands.add(["empty[trash]"],
"Empty trash of the current account", "Empty trash of the current account",
function () function () goDoCommand("cmd_emptyTrash"),
{
goDoCommand("cmd_emptyTrash");
},
{ argCount: "0" }); { argCount: "0" });
liberator.commands.add(["get[messages]"], liberator.commands.add(["get[messages]"],
"Check for new messages", "Check for new messages",
function (args, special) function (args, special) liberator.mail.getNewMessages(!special),
{ {
liberator.mail.getNewMessages(!special); argCount: "0",
}, bangAllowed: true,
{ argCount: "0" }); });
/////////////////////////////////////////////////////////////////////////////}}} /////////////////////////////////////////////////////////////////////////////}}}
////////////////////// PUBLIC SECTION ////////////////////////////////////////// ////////////////////// PUBLIC SECTION //////////////////////////////////////////

View File

@@ -202,14 +202,12 @@ liberator.Mappings = function () //{{{
liberator.commands.add([ch ? ch + "m[ap]" : "map"], liberator.commands.add([ch ? ch + "m[ap]" : "map"],
"Map a key sequence" + modeDescription, "Map a key sequence" + modeDescription,
function (args) { map(args, modes, false); }, function (args) map(args, modes, false),
{ { completer: function (filter) liberator.completion.userMapping(filter, modes) });
completer: function (filter) liberator.completion.userMapping(filter, modes)
});
liberator.commands.add([ch + "no[remap]"], liberator.commands.add([ch + "no[remap]"],
"Map a key sequence without remapping keys" + modeDescription, "Map a key sequence without remapping keys" + modeDescription,
function (args) { map(args, modes, true); }); function (args) map(args, modes, true));
liberator.commands.add([ch + "mapc[lear]"], liberator.commands.add([ch + "mapc[lear]"],
"Remove all mappings" + modeDescription, "Remove all mappings" + modeDescription,
@@ -242,9 +240,7 @@ liberator.Mappings = function () //{{{
if (!found) if (!found)
liberator.echoerr("E31: No such mapping"); liberator.echoerr("E31: No such mapping");
}, },
{ { completer: function (filter) liberator.completion.userMapping(filter, modes) });
completer: function (filter) liberator.completion.userMapping(filter, modes)
});
} }
/////////////////////////////////////////////////////////////////////////////}}} /////////////////////////////////////////////////////////////////////////////}}}

View File

@@ -366,7 +366,10 @@ liberator.Options = function () //{{{
openPreferences(); openPreferences();
} }
}, },
{ argCount: "0" }); {
argCount: "0",
bangAllowed: true,
});
liberator.commands.add(["setl[ocal]"], liberator.commands.add(["setl[ocal]"],
"Set local option", "Set local option",
@@ -375,6 +378,7 @@ liberator.Options = function () //{{{
liberator.commands.get("set").execute(args, special, count, { scope: liberator.options.OPTION_SCOPE_LOCAL }); liberator.commands.get("set").execute(args, special, count, { scope: liberator.options.OPTION_SCOPE_LOCAL });
}, },
{ {
bangAllowed: true,
completer: function (filter, special, count) completer: function (filter, special, count)
{ {
return liberator.commands.get("set").completer(filter, special, count, { scope: liberator.options.OPTION_SCOPE_LOCAL }); return liberator.commands.get("set").completer(filter, special, count, { scope: liberator.options.OPTION_SCOPE_LOCAL });
@@ -389,6 +393,7 @@ liberator.Options = function () //{{{
liberator.commands.get("set").execute(args, special, count, { scope: liberator.options.OPTION_SCOPE_GLOBAL }); liberator.commands.get("set").execute(args, special, count, { scope: liberator.options.OPTION_SCOPE_GLOBAL });
}, },
{ {
bangAllowed: true,
completer: function (filter, special, count) completer: function (filter, special, count)
{ {
return liberator.commands.get("set").completer(filter, special, count, { scope: liberator.options.OPTION_SCOPE_GLOBAL }); return liberator.commands.get("set").completer(filter, special, count, { scope: liberator.options.OPTION_SCOPE_GLOBAL });
@@ -701,6 +706,7 @@ liberator.Options = function () //{{{
} }
}, },
{ {
bangAllowed: true,
completer: function (filter, special, count, modifiers) completer: function (filter, special, count, modifiers)
{ {
var optionCompletions = []; var optionCompletions = [];
@@ -839,7 +845,10 @@ liberator.Options = function () //{{{
delete reference[0][reference[1]]; delete reference[0][reference[1]];
} }
}, },
{ argCount: "+" }); {
argCount: "+",
bangAllowed: true
});
/////////////////////////////////////////////////////////////////////////////}}} /////////////////////////////////////////////////////////////////////////////}}}
////////////////////// PUBLIC SECTION ////////////////////////////////////////// ////////////////////// PUBLIC SECTION //////////////////////////////////////////

View File

@@ -344,6 +344,7 @@ liberator.Tabs = function () //{{{
liberator.tabs.remove(getBrowser().mCurrentTab, count > 0 ? count : 1, special, 0); liberator.tabs.remove(getBrowser().mCurrentTab, count > 0 ? count : 1, special, 0);
}, },
{ {
bangAllowed: true,
completer: function (filter) liberator.completion.buffer(filter) completer: function (filter) liberator.completion.buffer(filter)
}); });
@@ -356,16 +357,11 @@ liberator.Tabs = function () //{{{
liberator.execute(args); liberator.execute(args);
liberator.forceNewTab = false; liberator.forceNewTab = false;
}, },
{ { completer: function (filter) liberator.completion.ex(filter) });
completer: function (filter) liberator.completion.ex(filter)
});
liberator.commands.add(["tabl[ast]", "bl[ast]"], liberator.commands.add(["tabl[ast]", "bl[ast]"],
"Switch to the last tab", "Switch to the last tab",
function () function () liberator.tabs.select("$", false),
{
liberator.tabs.select("$", false);
},
{ argCount: "0" }); { argCount: "0" });
// TODO: "Zero count" if 0 specified as arg // TODO: "Zero count" if 0 specified as arg
@@ -431,10 +427,7 @@ liberator.Tabs = function () //{{{
liberator.commands.add(["tabr[ewind]", "tabfir[st]", "br[ewind]", "bf[irst]"], liberator.commands.add(["tabr[ewind]", "tabfir[st]", "br[ewind]", "bf[irst]"],
"Switch to the first tab", "Switch to the first tab",
function () function () liberator.tabs.select(0, false),
{
liberator.tabs.select(0, false);
},
{ argCount: "0" }); { argCount: "0" });
if (liberator.config.name == "Vimperator") if (liberator.config.name == "Vimperator")
@@ -463,32 +456,33 @@ liberator.Tabs = function () //{{{
} }
}, },
{ {
bangAllowed: true,
completer: function (filter) liberator.completion.buffer(filter) completer: function (filter) liberator.completion.buffer(filter)
}); });
liberator.commands.add(["buffers", "files", "ls", "tabs"], liberator.commands.add(["buffers", "files", "ls", "tabs"],
"Show a list of all buffers", "Show a list of all buffers",
function (args, special) function (args, special) liberator.tabs.list(special),
{ {
liberator.tabs.list(special); argCount: "0",
}, bangAllowed: true
{ argCount: "0" }); });
liberator.commands.add(["quita[ll]", "qa[ll]"], liberator.commands.add(["quita[ll]", "qa[ll]"],
"Quit " + liberator.config.name, "Quit " + liberator.config.name,
function (args, special) function (args, special) liberator.quit(false, special),
{ {
liberator.quit(false, special); argCount: "0",
}, bangAllowed: true
{ argCount: "0" }); });
liberator.commands.add(["reloada[ll]"], liberator.commands.add(["reloada[ll]"],
"Reload all tab pages", "Reload all tab pages",
function (args, special) function (args, special) liberator.tabs.reloadAll(special),
{ {
liberator.tabs.reloadAll(special); argCount: "0",
}, bangAllowed: true
{ argCount: "0" }); });
// TODO: add count support // TODO: add count support
liberator.commands.add(["tabm[ove]"], liberator.commands.add(["tabm[ove]"],
@@ -506,14 +500,12 @@ liberator.Tabs = function () //{{{
args = "$"; // if not specified, move to the last tab args = "$"; // if not specified, move to the last tab
liberator.tabs.move(getBrowser().mCurrentTab, args, special); liberator.tabs.move(getBrowser().mCurrentTab, args, special);
}); },
{ bangAllowed: true });
liberator.commands.add(["tabo[nly]"], liberator.commands.add(["tabo[nly]"],
"Close all other tabs", "Close all other tabs",
function () function () liberator.tabs.keepOnly(getBrowser().mCurrentTab),
{
liberator.tabs.keepOnly(getBrowser().mCurrentTab);
},
{ argCount: "0" }); { argCount: "0" });
liberator.commands.add(["tabopen", "t[open]", "tabnew", "tabe[dit]"], liberator.commands.add(["tabopen", "t[open]", "tabnew", "tabe[dit]"],
@@ -530,16 +522,17 @@ liberator.Tabs = function () //{{{
liberator.open("about:blank", where); liberator.open("about:blank", where);
}, },
{ {
bangAllowed: true,
completer: function (filter) liberator.completion.url(filter) completer: function (filter) liberator.completion.url(filter)
}); });
liberator.commands.add(["tabde[tach]"], liberator.commands.add(["tabde[tach]"],
"Detach current tab to its own window", "Detach current tab to its own window",
function (args, special, count) function (args, special, count) liberator.tabs.detachTab(null),
{ {
liberator.tabs.detachTab(null); argCount: "0",
}, bangAllowed: true
{ argCount: "0" }); });
liberator.commands.add(["tabd[uplicate]"], liberator.commands.add(["tabd[uplicate]"],
"Duplicate current tab", "Duplicate current tab",
@@ -557,7 +550,10 @@ liberator.Tabs = function () //{{{
for (let i = 0; i < count; i++) for (let i = 0; i < count; i++)
liberator.tabs.cloneTab(tab, activate); liberator.tabs.cloneTab(tab, activate);
}, },
{ argCount: "0" }); {
argCount: "0",
bangAllowed: true
});
} }
if (liberator.has("session")) if (liberator.has("session"))
@@ -626,7 +622,10 @@ liberator.Tabs = function () //{{{
for (let i = 0; i < undoItems.length; i++) for (let i = 0; i < undoItems.length; i++)
undoCloseTab(); // doesn't work with i as the index to undoCloseTab undoCloseTab(); // doesn't work with i as the index to undoCloseTab
}, },
{ argCount: "0" }); {
argCount: "0",
bangAllowed: true
});
liberator.commands.add(["wqa[ll]", "wq", "xa[ll]"], liberator.commands.add(["wqa[ll]", "wq", "xa[ll]"],
"Save the session and quit", "Save the session and quit",

View File

@@ -328,16 +328,12 @@ liberator.CommandLine = function () //{{{
liberator.options.add(["history", "hi"], liberator.options.add(["history", "hi"],
"Number of Ex commands and search patterns to store in the command-line history", "Number of Ex commands and search patterns to store in the command-line history",
"number", 500, "number", 500,
{ { validator: function (value) value >= 0 });
validator: function (value) value >= 0
});
liberator.options.add(["messages", "msgs"], liberator.options.add(["messages", "msgs"],
"Number of messages to store in the message history", "Number of messages to store in the message history",
"number", 100, "number", 100,
{ { validator: function (value) value >= 0 });
validator: function (value) value >= 0
});
liberator.options.add(["more"], liberator.options.add(["more"],
"Pause the message list window when more than one screen of listings is displayed", "Pause the message list window when more than one screen of listings is displayed",
@@ -499,9 +495,7 @@ liberator.CommandLine = function () //{{{
if (str != null) if (str != null)
command.action(str); command.action(str);
}, },
{ { completer: function (filter) liberator.completion.javascript(filter) });
completer: function (filter) liberator.completion.javascript(filter)
});
}); });
liberator.commands.add(["mes[sages]"], liberator.commands.add(["mes[sages]"],
@@ -514,7 +508,8 @@ liberator.CommandLine = function () //{{{
let list = messageHistory.messages.join("\n"); let list = messageHistory.messages.join("\n");
liberator.commandline.echo(list); liberator.commandline.echo(list);
}, { argCount: "0" }); },
{ argCount: "0" });
/////////////////////////////////////////////////////////////////////////////}}} /////////////////////////////////////////////////////////////////////////////}}}
////////////////////// PUBLIC SECTION ////////////////////////////////////////// ////////////////////// PUBLIC SECTION //////////////////////////////////////////

View File

@@ -287,6 +287,7 @@ liberator.config = { //{{{
} }
}, },
{ {
bangAllowed: true,
completer: function (filter) liberator.completion.url(filter) completer: function (filter) liberator.completion.url(filter)
}); });
@@ -363,9 +364,7 @@ liberator.config = { //{{{
else else
liberator.open("about:blank", liberator.NEW_WINDOW); liberator.open("about:blank", liberator.NEW_WINDOW);
}, },
{ { completer: function (filter) liberator.completion.url(filter) });
completer: function (filter) liberator.completion.url(filter)
});
/////////////////////////////////////////////////////////////////////////////}}} /////////////////////////////////////////////////////////////////////////////}}}
////////////////////// OPTIONS ///////////////////////////////////////////////// ////////////////////// OPTIONS /////////////////////////////////////////////////