1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2025-12-23 16:32:27 +01:00

add some more completion args for :command -complete

This commit is contained in:
Doug Kearns
2008-11-14 14:50:39 +00:00
parent 05a699dc53
commit 0b4232d401
4 changed files with 39 additions and 9 deletions

View File

@@ -512,7 +512,7 @@ function Buffer() //{{{
stylesheetSwitchAll(window.content, args); stylesheetSwitchAll(window.content, args);
}, },
{ completer: function (filter) completion.stylesheet(filter) }); { completer: function (filter) completion.alternateStylesheet(filter) });
commands.add(["re[load]"], commands.add(["re[load]"],
"Reload current page", "Reload current page",

View File

@@ -668,10 +668,18 @@ function Commands() //{{{
liberator.execute(commands.replaceTokens(this.replacementText, tokens)); liberator.execute(commands.replaceTokens(this.replacementText, tokens));
} }
// TODO: add dir, highlight, menu, option completers // TODO: offer completion.ex?
var completeOptionMap = { url: "url", buffer: "buffer", bookmark: "bookmark", command: "ex", var completeOptionMap = {
environment: "environment", event: "autocmdEvent", file: "file", shellcmd: "shellCommand", altstyle: "alternateStylesheet", bookmark: "bookmark",
javascript: "javascript", help: "help", mapping: "userMapping" }; buffer: "buffer", color: "colorScheme", command: "command",
dialog: "dialog", dir: "directory", environment: "environment",
event: "autocmdEvent", file: "file", help: "help",
highlight: "highlightGroup", javascript: "javascript", macro: "macro",
mapping: "userMapping", menu: "menuItem", option: "option",
preference: "preference", search: "search",
shellcmd: "shellCommand", sidebar: "sidebar", url: "url",
usercommand: "userCommand"
};
// TODO: Vim allows commands to be defined without {rep} if there are {attr}s // TODO: Vim allows commands to be defined without {rep} if there are {attr}s
// specified - useful? // specified - useful?

View File

@@ -795,6 +795,8 @@ function Completion() //{{{
////////////////////// COMPLETION TYPES //////////////////////////////////////// ////////////////////// COMPLETION TYPES ////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////{{{ /////////////////////////////////////////////////////////////////////////////{{{
autocmdEvent: function autocmdEvent(filter) [0, this.filter(config.autocommands, filter)],
bookmark: function (filter) bookmark: function (filter)
{ {
return { return {
@@ -908,6 +910,8 @@ function Completion() //{{{
dialog: function dialog(filter) [0, this.filter(config.dialogs, filter)], dialog: function dialog(filter) [0, this.filter(config.dialogs, filter)],
directory: function (filter, tail) [0, this.file(filter, tail)[1].filter(function (f) f[1] == "Directory")],
environment: function environment(filter) environment: function environment(filter)
{ {
let command = liberator.has("Win32") ? "set" : "export"; let command = liberator.has("Win32") ? "set" : "export";
@@ -923,8 +927,6 @@ function Completion() //{{{
return [0, this.filter(vars, filter)]; return [0, this.filter(vars, filter)];
}, },
autocmdEvent: function autocmdEvent(filter) [0, this.filter(config.autocommands, filter)],
// provides completions for ex commands, including their arguments // provides completions for ex commands, including their arguments
ex: function ex(str) ex: function ex(str)
{ {
@@ -1028,6 +1030,8 @@ function Completion() //{{{
return [0, this.filter(res, filter)]; return [0, this.filter(res, filter)];
}, },
highlightGroup: function highlightGroup(filter) commands.get("highlight").completer(filter), // XXX
history: function _history(filter) [0, history.get(filter)], history: function _history(filter) [0, history.get(filter)],
get javascriptCompleter() javascript, get javascriptCompleter() javascript,
@@ -1044,6 +1048,12 @@ function Completion() //{{{
return [0, this.filter(macros, filter)]; return [0, this.filter(macros, filter)];
}, },
menuItem: function menuItem(filter) commands.get("emenu").completer(filter), // XXX
option: function option(filter) commands.get("set").completer(filter), // XXX
preference: function preference(filter) commands.get("set").completer(filter, true), // XXX
search: function search(filter) search: function search(filter)
{ {
let [, keyword, args] = filter.match(/^\s*(\S*)\s*(.*)/); let [, keyword, args] = filter.match(/^\s*(\S*)\s*(.*)/);
@@ -1163,9 +1173,9 @@ function Completion() //{{{
return [0, this.filter(panels, filter)]; return [0, this.filter(panels, filter)];
}, },
stylesheet: function stylesheet(filter) alternateStylesheet: function alternateStylesheet(filter)
{ {
var completions = buffer.alternateStyleSheets.map( let completions = buffer.alternateStyleSheets.map(
function (stylesheet) [stylesheet.title, stylesheet.href || "inline"] function (stylesheet) [stylesheet.title, stylesheet.href || "inline"]
); );

View File

@@ -293,17 +293,29 @@ Completion for arguments to user defined commands is not available by default.
Completion can be enabled by specifying one of the following arguments to the Completion can be enabled by specifying one of the following arguments to the
-complete option when defining the command. -complete option when defining the command.
`----------------`-------------------------------------------------------------- `----------------`--------------------------------------------------------------
*altstyle* alternate author style sheets
*bookmark* bookmarks *bookmark* bookmarks
*buffer* buffers *buffer* buffers
*color* color schemes
*command* Ex commands *command* Ex commands
*dialog* Firefox dialogs
*dir* directories
*environment* environment variables *environment* environment variables
*event* autocommand events *event* autocommand events
*file* files *file* files
*help* help tags *help* help tags
*highlight* highlight groups
*javascript* JavaScript expressions *javascript* JavaScript expressions
*macro* named macros
*mapping* user mappings *mapping* user mappings
*menu* menu items
*option* Vimperator options
*preference* Firefox preferences
*search* search engines and keywords
*shellcmd* shell commands *shellcmd* shell commands
*sidebar* sidebar panels
*url* URLs *url* URLs
*usercommand* user commands
*custom,{func}* custom completion, provided by {func} *custom,{func}* custom completion, provided by {func}
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------