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

Dont use argCount with literal. Use the default favicon in :ls

This commit is contained in:
Kris Maglione
2008-11-28 12:52:09 +00:00
parent 8a69d2f3a1
commit d25867e7b5
14 changed files with 45 additions and 73 deletions

View File

@@ -27,6 +27,7 @@ the terms of any one of the MPL, the GPL or the LGPL.
}}} ***** END LICENSE BLOCK *****/ }}} ***** END LICENSE BLOCK *****/
// TODO: with the new subscript loader, is there really no way to keep variable in per-file scope? // TODO: with the new subscript loader, is there really no way to keep variable in per-file scope?
// Not really. --Kris
const DEFAULT_FAVICON = "chrome://mozapps/skin/places/defaultFavicon.png"; const DEFAULT_FAVICON = "chrome://mozapps/skin/places/defaultFavicon.png";
// also includes methods for dealing with keywords and search engines // also includes methods for dealing with keywords and search engines
@@ -339,7 +340,7 @@ function Bookmarks() //{{{
}, },
{ {
completer: function completer(context) completion.bookmark(context), completer: function completer(context) completion.bookmark(context),
literal: true literal: 0
}); });
/////////////////////////////////////////////////////////////////////////////}}} /////////////////////////////////////////////////////////////////////////////}}}
@@ -667,7 +668,7 @@ function History() //{{{
return [0, completions]; return [0, completions];
}, },
count: true, count: true,
literal: true literal: 0
}); });
commands.add(["fo[rward]", "fw"], commands.add(["fo[rward]", "fw"],
@@ -719,7 +720,7 @@ function History() //{{{
return [0, completions]; return [0, completions];
}, },
count: true, count: true,
literal: true literal: 0
}); });
commands.add(["hist[ory]", "hs"], commands.add(["hist[ory]", "hs"],
@@ -727,7 +728,7 @@ function History() //{{{
function (args) { history.list(args.string, args.bang); }, function (args) { history.list(args.string, args.bang); },
{ {
bang: true, bang: true,
literal: true, literal: 0,
completer: function (context) completion.history(context) completer: function (context) completion.history(context)
// completer: function (filter) completion.history(filter) // completer: function (filter) completion.history(filter)
}); });

View File

@@ -521,7 +521,7 @@ function Buffer() //{{{
}, },
{ {
completer: function (context) completion.alternateStylesheet(context), completer: function (context) completion.alternateStylesheet(context),
literal: true literal: 0
}); });
commands.add(["re[load]"], commands.add(["re[load]"],

View File

@@ -86,7 +86,7 @@ function Command(specs, description, action, extraInfo) //{{{
this.options = extraInfo.options || []; this.options = extraInfo.options || [];
this.bang = extraInfo.bang || false; this.bang = extraInfo.bang || false;
this.count = extraInfo.count || false; this.count = extraInfo.count || false;
this.literal = extraInfo.literal || false; this.literal = extraInfo.literal == null ? null : extraInfo.literal;
this.serial = extraInfo.serial; this.serial = extraInfo.serial;
this.isUserCommand = extraInfo.isUserCommand || false; this.isUserCommand = extraInfo.isUserCommand || false;
@@ -413,29 +413,6 @@ function Commands() //{{{
if (!options) if (!options)
options = []; options = [];
if (literal)
/*
TODO: This change doesn't seem right to me. It no longer
supports "?" which is really the only non-integer argCount
that makes much sense with a literal arg. Likewise, it no
longer supports "*" which we can allow and treat as "?" - "+"
as "1". I also don't like having argCounts > 1 specified as
integers and those below as strings, even if the former are
currently only used with 'literal'. I might be missing
something? -- djk
The reason I chose "+" was that some functions were already
using it when they expected a literal arg. "?" probably makes
more sense. I changed it to integers only in the cases where
literal is used, because then it has a different meaning, i.e.,
if we have this many args, push the rest of the string into the
last arg, bug don't worry whether we actually have that many
args. Using strings gave the wrong results, because "1" died
if you didn't have 1 arg, but "2" didn't die if you didn't have
2. Perhaps it should have a separate option. --Kris
*/
var literalIndex = argCount == "+" ? 0 : Math.max(argCount - 1, 0);
if (!argCount) if (!argCount)
argCount = "*"; argCount = "*";
@@ -599,7 +576,7 @@ function Commands() //{{{
complete.highlight(i, sub.length, "SPELLCHECK") complete.highlight(i, sub.length, "SPELLCHECK")
} }
if (literal && args.length == literalIndex) if (args.length == literal)
{ {
if (complete) if (complete)
args.completeArg = args.length; args.completeArg = args.length;
@@ -660,7 +637,7 @@ function Commands() //{{{
// check for correct number of arguments // check for correct number of arguments
if (args.length == 0 && /^[1+]$/.test(argCount) || if (args.length == 0 && /^[1+]$/.test(argCount) ||
literal && argCount == "+" && /^\s*$/.test(args.literalArg)) literal != null && /[+?]/.test(argCount) && !/\S/.test(args.literalArg || ""))
{ {
if (!complete) if (!complete)
{ {
@@ -855,7 +832,6 @@ function Commands() //{{{
} }
}, },
{ {
argCount: 2,
bang: true, bang: true,
completer: function (context) completion.userCommand(context), completer: function (context) completion.userCommand(context),
options: [ options: [
@@ -866,7 +842,7 @@ function Commands() //{{{
[["-complete"], commandManager.OPTION_STRING, [["-complete"], commandManager.OPTION_STRING,
function (arg) arg in completeOptionMap || /custom,\w+/.test(arg)] function (arg) arg in completeOptionMap || /custom,\w+/.test(arg)]
], ],
literal: true, literal: 1,
serial: function () [ serial: function () [
{ {
command: this.name, command: this.name,

View File

@@ -1150,9 +1150,10 @@ function Completion() //{{{
context.title = ["Buffer", "URL"]; context.title = ["Buffer", "URL"];
context.keys = { text: "text", description: "url", icon: "icon" }; context.keys = { text: "text", description: "url", icon: "icon" };
let process = context.process[0]; let process = context.process[0];
context.process = [function ({ text: text, item: item }) <> context.process = [function (item)
<span highlight="Indicator" style="display: inline-block; width: 1.5em; text-align: center">{item.indicator}</span> <>
{ process.call(this, { item: item, text: text }) } <span highlight="Indicator" style="display: inline-block; width: 1.5em; text-align: center">{item.item.indicator}</span>
{ process.call(this, item) }
</>]; </>];
context.completions = util.map(tabs.browsers, function ([i, browser]) { context.completions = util.map(tabs.browsers, function ([i, browser]) {
@@ -1171,7 +1172,7 @@ function Completion() //{{{
text: [i + ": " + (tab.label || "(Untitled)"), i + ": " + url], text: [i + ": " + (tab.label || "(Untitled)"), i + ": " + url],
url: url, url: url,
indicator: indicator, indicator: indicator,
icon: tab.image icon: tab.image || DEFAULT_FAVICON
}; };
}); });
}, },

View File

@@ -173,8 +173,7 @@ function Editor() //{{{
editor.listAbbreviations(mode, lhs || ""); editor.listAbbreviations(mode, lhs || "");
}, },
{ {
argCount: 2, literal: 1,
literal: true,
serial: function () [ serial: function () [
{ {
command: this.name, command: this.name,

View File

@@ -103,10 +103,9 @@ function AutoCommands() //{{{
} }
}, },
{ {
argCount: 3,
bang: true, bang: true,
completer: function (context) completion.autocmdEvent(context), completer: function (context) completion.autocmdEvent(context),
literal: true literal: 2
}); });
// TODO: expand target to all buffers // TODO: expand target to all buffers
@@ -118,7 +117,7 @@ function AutoCommands() //{{{
}, },
{ {
completer: function (context) completion.autocmdEvent(context), completer: function (context) completion.autocmdEvent(context),
literal: true literal: 0
} }
); );
@@ -156,7 +155,7 @@ function AutoCommands() //{{{
}, },
{ {
completer: function (context) completion.autocmdEvent(context), completer: function (context) completion.autocmdEvent(context),
literal: true literal: 0
} }
); );
@@ -710,7 +709,7 @@ function Events() //{{{
{ {
bang: true, bang: true,
completer: function (context) completion.macro(context), completer: function (context) completion.macro(context),
literal: true literal: 0
}); });
commands.add(["macros"], commands.add(["macros"],

View File

@@ -234,7 +234,7 @@ function IO() //{{{
{ {
argCount: "+", // FIXME: "?" argCount: "+", // FIXME: "?"
completer: function (context) completion.file(context, true), completer: function (context) completion.file(context, true),
literal: true literal: 0
}); });
// NOTE: this command is only used in :source // NOTE: this command is only used in :source
@@ -366,7 +366,7 @@ function IO() //{{{
{ {
bang: true, bang: true,
completer: function (context) completion.shellCommand(context), completer: function (context) completion.shellCommand(context),
literal: true literal: 0
}); });
/////////////////////////////////////////////////////////////////////////////}}} /////////////////////////////////////////////////////////////////////////////}}}

View File

@@ -274,7 +274,7 @@ const liberator = (function () //{{{
context.keys = { text: "fullMenuPath", description: "label" }; context.keys = { text: "fullMenuPath", description: "label" };
context.completions = getMenuItems(); context.completions = getMenuItems();
}, },
literal: true literal: 0
}); });
commands.add(["exe[cute]"], commands.add(["exe[cute]"],
@@ -321,7 +321,7 @@ const liberator = (function () //{{{
{ {
bang: true, bang: true,
completer: function (context) completion.help(context), completer: function (context) completion.help(context),
literal: true literal: 0
}); });
commands.add(["javas[cript]", "js"], commands.add(["javas[cript]", "js"],
@@ -350,7 +350,7 @@ const liberator = (function () //{{{
bang: true, bang: true,
completer: function (context) completion.javascript(context), completer: function (context) completion.javascript(context),
hereDoc: true, hereDoc: true,
literal: true literal: 0
}); });
commands.add(["loadplugins", "lpl"], commands.add(["loadplugins", "lpl"],
@@ -487,7 +487,7 @@ const liberator = (function () //{{{
return completion.javascript(context); return completion.javascript(context);
}, },
count: true, count: true,
literal: true literal: 0
}); });
commands.add(["ve[rsion]"], commands.add(["ve[rsion]"],

View File

@@ -185,12 +185,11 @@ function Mappings() //{{{
modeDescription = modeDescription ? " in " + modeDescription + " mode" : ""; modeDescription = modeDescription ? " in " + modeDescription + " mode" : "";
const opts = { const opts = {
argCount: 2,
completer: function (context, args) completion.userMapping(context, args, modes), completer: function (context, args) completion.userMapping(context, args, modes),
options: [ options: [
[["<silent>", "<Silent>"], commands.OPTION_NOARG] [["<silent>", "<Silent>"], commands.OPTION_NOARG]
], ],
literal: true, literal: 1,
serial: function () { serial: function () {
let noremap = this.name.indexOf("noremap") > -1; let noremap = this.name.indexOf("noremap") > -1;
return [ return [

View File

@@ -525,7 +525,7 @@ function Options() //{{{
{ {
return commands.get("set").completer(context.filter, args.bang, args.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: 0
} }
); );
@@ -542,7 +542,7 @@ function Options() //{{{
{ {
return commands.get("set").completer(context.filter, args.bang, args.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: 0
} }
); );
@@ -717,7 +717,7 @@ function Options() //{{{
completion.optionValue(context, opt.name, opt.operator); completion.optionValue(context, opt.name, opt.operator);
}, },
literal: true, literal: 0,
serial: function () [ serial: function () [
{ {
command: this.name, command: this.name,

View File

@@ -414,7 +414,7 @@ liberator.registerObserver("load_commands", function ()
liberator.echoerr("E185: Cannot find color scheme " + scheme); liberator.echoerr("E185: Cannot find color scheme " + scheme);
}, },
{ {
argCount: 1, argCount: "1",
completer: function (context) completion.colorScheme(context) completer: function (context) completion.colorScheme(context)
}); });
@@ -453,7 +453,6 @@ liberator.registerObserver("load_commands", function ()
} }
}, },
{ {
argCount: 2,
bang: true, bang: true,
completer: function (context, args) { completer: function (context, args) {
let compl = []; let compl = [];
@@ -475,7 +474,7 @@ liberator.registerObserver("load_commands", function ()
} }
}, },
hereDoc: true, hereDoc: true,
literal: true, literal: 1,
options: [[["-name", "-n"], commands.OPTION_STRING, null, function () [[k, v.css] for ([k, v] in Iterator(styles.userNames))]], options: [[["-name", "-n"], commands.OPTION_STRING, null, function () [[k, v.css] for ([k, v] in Iterator(styles.userNames))]],
[["-append", "-a"], commands.OPTION_NOARG]], [["-append", "-a"], commands.OPTION_NOARG]],
serial: function () [ serial: function () [
@@ -495,9 +494,8 @@ liberator.registerObserver("load_commands", function ()
styles.removeSheet(args["-name"], args[0], args.literalArg, args["-index"], false); styles.removeSheet(args["-name"], args[0], args.literalArg, args["-index"], false);
}, },
{ {
argCount: 2,
completer: function (context) { context.completions = styles.sites.map(function (site) [site, ""]); }, completer: function (context) { context.completions = styles.sites.map(function (site) [site, ""]); },
literal: true, literal: 1,
options: [[["-index", "-i"], commands.OPTION_INT, null, function () [[i, <>{s.sites.join(",")}: {s.css.replace("\n", "\\n")}</>] for ([i, s] in styles.userSheets)]], options: [[["-index", "-i"], commands.OPTION_INT, null, function () [[i, <>{s.sites.join(",")}: {s.css.replace("\n", "\\n")}</>] for ([i, s] in styles.userSheets)]],
[["-name", "-n"], commands.OPTION_STRING, null, function () [[k, v.css] for ([k, v] in Iterator(styles.userNames))]]] [["-name", "-n"], commands.OPTION_STRING, null, function () [[k, v.css] for ([k, v] in Iterator(styles.userNames))]]]
}); });
@@ -533,7 +531,6 @@ liberator.registerObserver("load_commands", function ()
liberator.echoerr(error); liberator.echoerr(error);
}, },
{ {
argCount: 2,
bang: true, bang: true,
// TODO: add this as a standard highlight completion function? // TODO: add this as a standard highlight completion function?
completer: function (context, args) completer: function (context, args)
@@ -548,7 +545,7 @@ liberator.registerObserver("load_commands", function ()
} }
}, },
hereDoc: true, hereDoc: true,
literal: true, literal: 1,
options: [[["-append", "-a"], commands.OPTION_NOARG]], options: [[["-append", "-a"], commands.OPTION_NOARG]],
serial: function () [ serial: function () [
{ {

View File

@@ -347,7 +347,7 @@ function Tabs() //{{{
bang: true, bang: true,
count: true, count: true,
completer: function (context) completion.buffer(context), completer: function (context) completion.buffer(context),
literal: true literal: 0
}); });
// TODO: this should open in a new tab positioned directly after the current one, not at the end // TODO: this should open in a new tab positioned directly after the current one, not at the end
@@ -362,7 +362,7 @@ function Tabs() //{{{
{ {
argCount: "+", argCount: "+",
completer: function (context) completion.ex(context.filter), completer: function (context) completion.ex(context.filter),
literal: true literal: 0
}); });
commands.add(["tabl[ast]", "bl[ast]"], commands.add(["tabl[ast]", "bl[ast]"],
@@ -477,7 +477,7 @@ function Tabs() //{{{
bang: true, bang: true,
count: true, count: true,
completer: function (context) completion.buffer(context), completer: function (context) completion.buffer(context),
literal: true literal: 0
}); });
commands.add(["buffers", "files", "ls", "tabs"], commands.add(["buffers", "files", "ls", "tabs"],
@@ -485,7 +485,7 @@ function Tabs() //{{{
function (args) { tabs.list(args.literalArg); }, function (args) { tabs.list(args.literalArg); },
{ {
argCount: "?", argCount: "?",
literal: true literal: 0
}); });
commands.add(["quita[ll]", "qa[ll]"], commands.add(["quita[ll]", "qa[ll]"],
@@ -550,7 +550,7 @@ function Tabs() //{{{
{ {
bang: true, bang: true,
completer: function (context) completion.url(context), completer: function (context) completion.url(context),
literal: true literal: 0
}); });
commands.add(["tabde[tach]"], commands.add(["tabde[tach]"],
@@ -635,7 +635,7 @@ function Tabs() //{{{
return [0, completions]; return [0, completions];
}, },
count: true, count: true,
literal: true literal: 0
}); });
commands.add(["undoa[ll]"], commands.add(["undoa[ll]"],

View File

@@ -616,7 +616,7 @@ function CommandLine() //{{{
}, },
{ {
completer: function (context) completion.javascript(context), completer: function (context) completion.javascript(context),
literal: true literal: 0
}); });
}); });
@@ -1439,7 +1439,7 @@ function ItemList(id) //{{{
{ {
do do
var next = nodes[++i]; var next = nodes[++i];
while ((!next || next.parentNode != items) && i < nodes.length); while ((!next || next.parentNode != items) && i < end)
items.insertBefore(row, next); items.insertBefore(row, next);
} }
else if (!display && row.parentNode == items) else if (!display && row.parentNode == items)

View File

@@ -289,7 +289,7 @@ const config = { //{{{
{ {
bang: true, bang: true,
completer: function (context) completion.url(context), completer: function (context) completion.url(context),
literal: true literal: 0
}); });
commands.add(["redr[aw]"], commands.add(["redr[aw]"],
@@ -342,7 +342,7 @@ const config = { //{{{
{ {
argCount: "+", argCount: "+",
completer: function (context) completion.sidebar(context), completer: function (context) completion.sidebar(context),
literal: true literal: 0
}); });
commands.add(["winc[lose]", "wc[lose]"], commands.add(["winc[lose]", "wc[lose]"],
@@ -363,7 +363,7 @@ const config = { //{{{
}, },
{ {
completer: function (context) completion.url(context), completer: function (context) completion.url(context),
literal: true literal: 0
}); });
/////////////////////////////////////////////////////////////////////////////}}} /////////////////////////////////////////////////////////////////////////////}}}