diff --git a/chrome/content/vimperator/commands.js b/chrome/content/vimperator/commands.js index 51fd41ef..c4783a55 100644 --- a/chrome/content/vimperator/commands.js +++ b/chrome/content/vimperator/commands.js @@ -915,6 +915,7 @@ function Commands() //{{{ } else { + // 1 2 3 4 5 6 var matches = args.match(/^\s*(no|inv)?([a-z]+)([?&!])?(([+-])?=(.*))?/); if (!matches) { @@ -923,26 +924,36 @@ function Commands() //{{{ } var no = false; - if (matches[1] == 'no') + if (matches[1] == "no") no = true; + var opt = matches[2]; + + var all = false; + if (opt == "all") + all = true; + var option = vimperator.options.get(opt); - if (!option) + if (!option && !all) { vimperator.echoerr("E518: Unknown option: " + opt); return; } var get = false; - if (matches[3] == "?" || (option.type != 'boolean' && matches[4] === undefined)) + if (all || matches[3] == "?" || (option.type != "boolean" && matches[4] === undefined)) get = true; + var reset = false; if (matches[3] == "&") reset = true; + var invert = false; - if (matches[1] == 'inv' || matches[3] == "!") + if (matches[1] == "inv" || matches[3] == "!") invert = true; + var oper = matches[5]; + var val = matches[6]; if (val === undefined) val = ""; @@ -951,15 +962,30 @@ function Commands() //{{{ // TODO: remove the value from about:config instead of setting it to the current default value if (reset) { - option.value = option.default_value; + if (all) + { + for (let opt in vimperator.options) + opt.value = opt.default_value; + } + else + { + option.value = option.default_value; + } } // read access else if (get) { - if (option.type == 'boolean') - vimperator.echo((option.value ? " " : "no") + option.name); + if (all) + { + vimperator.options.list(); + } else - vimperator.echo(" " + option.name + "=" + option.value); + { + if (option.type == "boolean") + vimperator.echo((option.value ? " " : "no") + option.name); + else + vimperator.echo(" " + option.name + "=" + option.value); + } } // write access else @@ -1023,7 +1049,8 @@ function Commands() //{{{ }, { usage: ["se[t][!]", "se[t] {option}?", "se[t] [no]{option}", "se[t] {option}[+-]={value}", "se[t] {option}! | inv{option}", "se[t] {option}&"], - short_help: "Set an option", help: "Permanently change an option. In contrast to Vim options are stored throughout sessions.
" + + short_help: "Set an option", + help: "Permanently change an option. In contrast to Vim options are stored throughout sessions.
" + ":set without an argument opens about:config in a new tab to change advanced Firefox options.
" + ":set! opens the GUI preference panel from Firefox in a new tab.
" + "There are three types of options: boolean, number and string. " + @@ -1032,7 +1059,8 @@ function Commands() //{{{ ":set option! and :set invoption invert the value of a boolean option.
" + ":set option? or :set option(for string and list options) shows the current value of an option.
" + ":set option& resets an option to its default value.
" + - ":set option+={value} and :set option-={value} will add/subtract {value} to a number option and append/remove {value} to a string option.
", + ":set option+={value} and :set option-={value} will add/subtract {value} to a number option and append/remove {value} to a string option.
" + + ":set all will show the current value of all options and :set all& will reset all options to their default values.
", completer: function(filter) { return vimperator.completion.get_options_completions(filter); } } )); diff --git a/chrome/content/vimperator/options.js b/chrome/content/vimperator/options.js index a82c19b3..d5cc7151 100644 --- a/chrome/content/vimperator/options.js +++ b/chrome/content/vimperator/options.js @@ -271,6 +271,34 @@ function Options() //{{{ storePreference('dom.popup_allowed_events', popup_allowed_events); } + this.list = function() + { + // TODO: columns like Vim? + var list = "" + + ""; + var name, value; + + for (var i = 0; i < options.length; i++) + { + name = options[i].name; + value = options[i].value; + + if (options[i].type == "boolean") + { + name = value ? "  " + name : "no" + name; + list += ""; + } + else + { + list += ""; + } + } + + list += "
--- Options ---
" + name + "
" + "  " + name + "=" + value + "
"; + + vimperator.commandline.echo(list, true); + } + // TODO: separate Preferences from Options? Would these utility functions // be better placed in the 'core' vimperator namespace somewhere? Options.setPref = function(name, value)