mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2025-12-21 00:28:00 +01:00
Remove the command Args dependency from a few straggling completers.
--HG-- extra : rebase_source : 12e642050a248dc0a33164d6757e925c9339a760
This commit is contained in:
@@ -215,12 +215,9 @@ const Abbreviations = Module("abbreviations", {
|
||||
}, {
|
||||
}, {
|
||||
completion: function () {
|
||||
// TODO: shouldn't all of these have a standard signature (context, args, ...)? --djk
|
||||
completion.abbreviation = function abbreviation(context, args, modes) {
|
||||
if (args.completeArg == 0) {
|
||||
completion.abbreviation = function abbreviation(context, modes) {
|
||||
let abbrevs = abbreviations.merged.filter(function (abbr) abbr.inModes(modes));
|
||||
context.completions = [[abbr.lhs, abbr.rhs] for ([, abbr] in Iterator(abbrevs))];
|
||||
}
|
||||
};
|
||||
},
|
||||
|
||||
@@ -252,7 +249,7 @@ const Abbreviations = Module("abbreviations", {
|
||||
],
|
||||
completer: function (context, args) {
|
||||
if (args.length == 1)
|
||||
return completion.abbreviation(context, args, modes);
|
||||
return completion.abbreviation(context, modes);
|
||||
else if (args["-javascript"])
|
||||
return completion.javascript(context);
|
||||
},
|
||||
@@ -279,7 +276,7 @@ const Abbreviations = Module("abbreviations", {
|
||||
return dactyl.echoerr("E24: No such abbreviation");
|
||||
}, {
|
||||
argCount: "1",
|
||||
completer: function (context, args) completion.abbreviation(context, args, modes),
|
||||
completer: function (context) completion.abbreviation(context, modes),
|
||||
literal: 0
|
||||
});
|
||||
|
||||
|
||||
@@ -1205,7 +1205,7 @@ const Buffer = Module("buffer", {
|
||||
|
||||
elem.value = file.path;
|
||||
}, {
|
||||
completer: completion.file,
|
||||
completer: function (context) completion.file(context),
|
||||
default: elem.value
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1252,7 +1252,7 @@ const Commands = Module("commands", {
|
||||
argCount: args["-nargs"],
|
||||
bang: args["-bang"],
|
||||
count: args["-count"],
|
||||
completer: completeFunc,
|
||||
completer: function (context) completeFunc(context),
|
||||
persist: !args["-nopersist"],
|
||||
replacementText: args.literalArg,
|
||||
sourcing: io.sourcing && update({}, io.sourcing)
|
||||
|
||||
@@ -851,7 +851,7 @@ const Completion = Module("completion", {
|
||||
},
|
||||
{
|
||||
argCount: "*",
|
||||
completer: function (context, args) {
|
||||
completer: function (context) {
|
||||
let PREFIX = "/ex/contexts";
|
||||
context.fork("ex", 0, completion, "ex");
|
||||
completion.contextList = [[k.substr(PREFIX.length), v.title[0]] for ([k, v] in iter(context.contexts)) if (k.substr(0, PREFIX.length) == PREFIX)];
|
||||
|
||||
@@ -406,7 +406,7 @@ const Mappings = Module("mappings", {
|
||||
const opts = {
|
||||
completer: function (context, args) {
|
||||
if (args.length == 1)
|
||||
return completion.userMapping(context, args, mapmodes);
|
||||
return completion.userMapping(context, mapmodes);
|
||||
if (args.length == 2) {
|
||||
if (args["-javascript"])
|
||||
return completion.javascript(context);
|
||||
@@ -515,7 +515,7 @@ const Mappings = Module("mappings", {
|
||||
},
|
||||
{
|
||||
argCount: "1",
|
||||
completer: function (context, args) completion.userMapping(context, args, mapmodes)
|
||||
completer: function (context) completion.userMapping(context, mapmodes)
|
||||
});
|
||||
}
|
||||
|
||||
@@ -528,14 +528,11 @@ const Mappings = Module("mappings", {
|
||||
[mode.disp.toLowerCase()]);
|
||||
},
|
||||
completion: function () {
|
||||
completion.userMapping = function userMapping(context, args, modes) {
|
||||
completion.userMapping = function userMapping(context, modes) {
|
||||
// FIXME: have we decided on a 'standard' way to handle this clash? --djk
|
||||
modes = modes || [modules.modes.NORMAL];
|
||||
|
||||
if (args.completeArg == 0) {
|
||||
let maps = [[m.names[0], ""] for (m in mappings.getUserIterator(modes))];
|
||||
context.completions = maps;
|
||||
}
|
||||
};
|
||||
},
|
||||
javascript: function () {
|
||||
|
||||
@@ -408,7 +408,7 @@ const Sanitizer = Module("sanitizer", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakR
|
||||
{
|
||||
names: ["-host", "-h"],
|
||||
description: "Only sanitize items referring to listed host or hosts",
|
||||
completer: function (context, args) {
|
||||
completer: function (context) {
|
||||
let hosts = context.filter.split(",");
|
||||
context.advance(context.filter.length - hosts.pop().length);
|
||||
context.filters.push(function (item)
|
||||
|
||||
@@ -487,7 +487,7 @@ const Player = Module("player", {
|
||||
},
|
||||
{
|
||||
argCount: "?",
|
||||
completer: function (context, args) completion.playlist(context, args),
|
||||
completer: function (context, args) completion.playlist(context),
|
||||
literal: 0
|
||||
});
|
||||
|
||||
@@ -617,7 +617,14 @@ const Player = Module("player", {
|
||||
},
|
||||
{
|
||||
argCount: "+",
|
||||
completer: function (context, args) completion.song(context, args)
|
||||
completer: function (context, args) {
|
||||
if (args.completeArg == 0)
|
||||
completion.artist(context);
|
||||
else if (args.completeArg == 1)
|
||||
completion.album(context, args[0]);
|
||||
else if (args.completeArg == 2)
|
||||
completion.song(context, args[0], args[1]);
|
||||
}
|
||||
});
|
||||
|
||||
// TODO: maybe :vol! could toggle mute on/off? --djk
|
||||
@@ -639,26 +646,17 @@ const Player = Module("player", {
|
||||
{ argCount: "1" });
|
||||
},
|
||||
completion: function () {
|
||||
completion.song = function song(context, args) {
|
||||
// TODO: useful descriptions?
|
||||
function map(list) list.map(function (i) [i, ""]);
|
||||
let [artist, album] = [args[0], args[1]];
|
||||
|
||||
if (args.completeArg == 0) {
|
||||
context.title = ["Artists"];
|
||||
context.completions = map(library.getArtists());
|
||||
}
|
||||
else if (args.completeArg == 1) {
|
||||
context.title = ["Albums by " + artist];
|
||||
context.completions = map(library.getAlbums(artist));
|
||||
}
|
||||
else if (args.completeArg == 2) {
|
||||
context.title = ["Tracks from " + album + " by " + artist];
|
||||
context.completions = map(library.getTracks(artist, album));
|
||||
}
|
||||
completion.album = function album(context, artist) {
|
||||
context.title = ["Album"];
|
||||
context.completions = [[v, ""] for ([, v] in Iterator(library.getAlbums(artist)))];
|
||||
};
|
||||
|
||||
completion.playlist = function playlist(context, args) {
|
||||
completion.artist = function artist(context) {
|
||||
context.title = ["Artist"];
|
||||
context.completions = [[v, ""] for ([, v] in Iterator(library.getArtists()))];
|
||||
};
|
||||
|
||||
completion.playlist = function playlist(context) {
|
||||
context.title = ["Playlist", "Type"];
|
||||
context.keys = { text: "name", description: "type" };
|
||||
context.completions = player.getPlaylists();
|
||||
@@ -677,6 +675,11 @@ const Player = Module("player", {
|
||||
context.completions = [["title", "Track name"], ["time", "Duration"], ["artist", "Artist name"],
|
||||
["album", "Album name"], ["genre", "Genre"], ["rating", "Rating"]]; // FIXME: generate this list dynamically - see #sortBy
|
||||
};
|
||||
|
||||
completion.song = function album(context, artist, album) {
|
||||
context.title = ["Song"];
|
||||
context.completions = [[v, ""] for ([, v] in Iterator(library.getTracks(artist, album)))];
|
||||
};
|
||||
},
|
||||
mappings: function () {
|
||||
mappings.add([modes.PLAYER],
|
||||
|
||||
Reference in New Issue
Block a user