From c55d7b51d002c186f16de4e11bd818d5f72174b9 Mon Sep 17 00:00:00 2001 From: Tim Hammerquist Date: Thu, 19 Jun 2008 22:34:45 +0000 Subject: [PATCH] added option value completion; small typos. --- content/buffer.js | 10 +++++++++- content/hints.js | 7 ++++++- content/options.js | 8 ++++++-- content/tabs.js | 10 +++++++++- content/ui.js | 23 +++++++++++++++++++++-- 5 files changed, 51 insertions(+), 7 deletions(-) diff --git a/content/buffer.js b/content/buffer.js index aa6f3142..1fc01f9a 100644 --- a/content/buffer.js +++ b/content/buffer.js @@ -178,7 +178,15 @@ liberator.Buffer = function () //{{{ "Show the destination of the link under the cursor in the status bar", "number", 1, { - validator: function (value) { return (value >= 0 && value <= 2); } + validator: function (value) { return (value >= 0 && value <= 2); }, + completer: function (filter) + { + return [ + ["0", "Don't show link destination"], + ["1", "Show the link in the status line"], + ["2", "Show the link in the command line"], + ]; + }, }); liberator.options.add(["usermode", "um"], diff --git a/content/hints.js b/content/hints.js index 0f992177..298600de 100644 --- a/content/hints.js +++ b/content/hints.js @@ -589,7 +589,12 @@ liberator.Hints = function () //{{{ "How links are matched", "string", "contains", { - validator: function (value) { return /^(?:contains|wordstartswith|firstletters|custom)$/.test(value); } + validator: function (value) { return /^(?:contains|wordstartswith|firstletters|custom)$/.test(value); }, + completer: function (filter) + { + return ["contains","wordstartswith","firstletters","custom"] + .map(function(m){ return [m,""] }); + }, }); liberator.options.add(["wordseparators", "wsp"], diff --git a/content/options.js b/content/options.js index 74109719..8e758163 100644 --- a/content/options.js +++ b/content/options.js @@ -360,7 +360,7 @@ liberator.Options = function () //{{{ value = false; break; default: - if (/^(\d+)$/.test(value)) + if (/^\d+$/.test(value)) value = parseInt(value, 10); } liberator.options.setPref(name, value); @@ -612,7 +612,11 @@ liberator.Options = function () //{{{ for (var option in liberator.options) { if (option.hasName(filter)) + { + if (option.completer) + return [filter.length + 1, option.completer(filter)]; return [filter.length + 1, [[option.value + "", ""]]]; + } } return [0, optionCompletions]; } @@ -684,7 +688,7 @@ liberator.Options = function () //{{{ extraInfo = {}; var option = new liberator.Option(names, description, type, defaultValue, - extraInfo.getter, extraInfo.setter, extraInfo.validator); + extraInfo.getter, extraInfo.setter, extraInfo.validator, extraInfo.completer); // quickly access options with liberator.options["wildmode"]: this.__defineGetter__(option.name, function () { return option.value; }); diff --git a/content/tabs.js b/content/tabs.js index 5ff9525a..9a8b80a6 100644 --- a/content/tabs.js +++ b/content/tabs.js @@ -126,7 +126,15 @@ liberator.Tabs = function () //{{{ tabs.collapsed = false; } }, - validator: function (value) { return (value >= 0 && value <= 2); } + validator: function (value) { return (value >= 0 && value <= 2); }, + completer: function (filter) + { + return [ + ["0", "Never show tab bar"], + ["1", "Show tab bar only if more than one tab is open"], + ["2", "Always show tab bar"], + ]; + }, }); diff --git a/content/ui.js b/content/ui.js index af007b10..6eddb8eb 100644 --- a/content/ui.js +++ b/content/ui.js @@ -328,7 +328,18 @@ liberator.CommandLine = function () //{{{ validator: function (value) { return value.split(",").every(function (item) { return /^(full|longest|list|list:full|list:longest|)$/.test(item); }); - } + }, + completer: function (filter) + { + return [ + ["", "Complete only the first match"], + ["full", "Complete the next full match"], + ["longest", "Complete to longest common string"], + ["list", "If more than one match, list all matches"], + ["list:full", "List all and complete first match"], + ["list:longest", "List all and complete common string"], + ]; + }, }); liberator.options.add(["wildoptions", "wop"], @@ -1280,7 +1291,15 @@ liberator.StatusLine = function () //{{{ else document.getElementById("status-bar").collapsed = false; }, - validator: function (value) { return (value >= 0 && value <= 2); } + validator: function (value) { return (value in [0,1,2]); }, + completer: function (filter) + { + return [ + ["0", "Never display status line"], + ["1", "Display status line only if there are multiple windows"], + ["2", "Always display status line"], + ]; + }, }); /////////////////////////////////////////////////////////////////////////////}}}