diff --git a/content/buffer.js b/content/buffer.js index 3269a6a4..ec51819c 100644 --- a/content/buffer.js +++ b/content/buffer.js @@ -149,7 +149,11 @@ liberator.Buffer = function () //{{{ "Show the current window fullscreen", "boolean", false, { - setter: function (value) { window.fullScreen = value; }, + setter: function (value) + { + window.fullScreen = value; + return value; + }, getter: function () { return window.fullScreen; } }); @@ -199,6 +203,8 @@ liberator.Buffer = function () //{{{ getMarkupDocumentViewer().authorStyleDisabled = value; } catch (e) {} + + return value; }, getter: function () { diff --git a/content/find.js b/content/find.js index 812c06d8..5dde9456 100644 --- a/content/find.js +++ b/content/find.js @@ -123,6 +123,8 @@ liberator.Search = function () //{{{ liberator.search.highlight(); else liberator.search.clear(); + + return value; } }); diff --git a/content/io.js b/content/io.js index 5c4746a1..fd571f81 100644 --- a/content/io.js +++ b/content/io.js @@ -47,10 +47,26 @@ liberator.IO = function () //{{{ var cdpath = "," + (environmentService.get("CDPATH").replace(/[:;]/g, ",") || ","); - // TODO: setter should expand environment variables liberator.options.add(["cdpath", "cd"], "List of directories searched when executing :cd", - "stringlist", cdpath); + "stringlist", cdpath, + { + setter: function (value) + { + var values = value.split(","); + var expanded = ""; + + for (let i = 0; i < values.length; i++) + { + expanded += liberator.io.expandPath(values[i]); + if (i < values.length - 1) + expanded += ","; + } + + return expanded; + } + }); + var shell, shellcmdflag; @@ -67,10 +83,15 @@ liberator.IO = function () //{{{ shellcmdflag = "-c"; } - // TODO: setter should expand environment variables liberator.options.add(["shell", "sh"], "Shell to use for executing :! and :run commands", - "string", shell); + "string", shell, + { + setter: function (value) + { + return liberator.io.expandPath(value); + } + }); liberator.options.add(["shellcmdflag", "shcf"], "Flag passed to shell when executing :! and :run commands", diff --git a/content/liberator.js b/content/liberator.js index 3830deaa..5c76f42a 100644 --- a/content/liberator.js +++ b/content/liberator.js @@ -50,6 +50,7 @@ const liberator = (function () //{{{ setter: function (value) { var guioptions = liberator.config.guioptions || {}; + for (let option in guioptions) { guioptions[option].forEach(function (elem) @@ -61,10 +62,13 @@ const liberator = (function () //{{{ catch (e) {} }); } + + return value; }, validator: function (value) { var regex = "[^"; + for (let option in liberator.config.guioptions) regex += option.toString(); @@ -87,7 +91,11 @@ const liberator = (function () //{{{ "Use visual bell instead of beeping on errors", "boolean", false, { - setter: function (value) { liberator.options.setPref("accessibility.typeaheadfind.enablesound", !value); } + setter: function (value) + { + liberator.options.setPref("accessibility.typeaheadfind.enablesound", !value); + return value; + } }); liberator.options.add(["visualbellstyle", "t_vb"], diff --git a/content/mail.js b/content/mail.js index d2076beb..ef263c8a 100644 --- a/content/mail.js +++ b/content/mail.js @@ -216,6 +216,8 @@ liberator.Mail = function () //{{{ case "vertical": ChangeMailLayout(2); break; // case "inherit" just does nothing } + + return value; } }); @@ -229,6 +231,8 @@ liberator.Mail = function () //{{{ MsgSortThreaded(); else MsgSortUnthreaded(); + + return value; } });*/ diff --git a/content/options.js b/content/options.js index 8bd1e17d..f56edf98 100644 --- a/content/options.js +++ b/content/options.js @@ -28,6 +28,7 @@ the terms of any one of the MPL, the GPL or the LGPL. // Do NOT create instances of this class yourself, use the helper method // liberator.options.add() instead +// FIXME: why is this arg list not reflecting that of Command, or vice versa? liberator.Option = function (names, description, type, defaultValue, scope, getter, setter, validator, completer) //{{{ { if (!names || !type) @@ -73,7 +74,9 @@ liberator.Option = function (names, description, type, defaultValue, scope, gett return null; } else + { scope = this.scope; + } var aValue; @@ -96,7 +99,21 @@ liberator.Option = function (names, description, type, defaultValue, scope, gett return null; } else + { scope = this.scope; + } + + if (this.setter) + { + var tmpValue = newValue; + var newValue = this.setter.call(this, newValue); + + if (!newValue === "undefined") + { + newValue = tmpValue; + liberator.log("DEPRECATED: option setters should return a value"); + } + } if (liberator.has("tabs") && (scope & liberator.options.OPTION_SCOPE_LOCAL)) liberator.tabs.options[this.name] = newValue; @@ -104,8 +121,6 @@ liberator.Option = function (names, description, type, defaultValue, scope, gett value = newValue; this.hasChanged = true; - if (this.setter) - this.setter.call(this, newValue); }; this.__defineGetter__("value", this.get); diff --git a/content/tabs.js b/content/tabs.js index d6ba9182..afa72f2a 100644 --- a/content/tabs.js +++ b/content/tabs.js @@ -121,6 +121,7 @@ liberator.Tabs = function () //{{{ setter: function (value) { var tabs = liberator.tabs.tabStrip; + if (!tabs) return; @@ -138,6 +139,8 @@ liberator.Tabs = function () //{{{ liberator.options.setPref("browser.tabs.autoHide", false); tabs.collapsed = false; } + + return value; }, validator: function (value) { return (value >= 0 && value <= 2); }, completer: function (filter) @@ -184,8 +187,11 @@ liberator.Tabs = function () //{{{ [2, 3], // in a new window if it has specified sizes [1, 2], // always in new window [2, 1]];// current tab unless it has specified sizes + liberator.options.setPref("browser.link.open_newwindow.restriction", values[value][0]); liberator.options.setPref("browser.link.open_newwindow", values[value][1]); + + return value; }, validator: function (value) { return (value >= 0 && value <= 4); } }); diff --git a/content/ui.js b/content/ui.js index 6134c5a5..41ca4e27 100644 --- a/content/ui.js +++ b/content/ui.js @@ -1303,6 +1303,8 @@ liberator.StatusLine = function () //{{{ liberator.echo("show status line only with > 1 window not implemented yet"); else document.getElementById("status-bar").collapsed = false; + + return value; }, validator: function (value) { return (value >= 0 && value <= 2); }, completer: function (filter) diff --git a/content/vimperator.js b/content/vimperator.js index ebd2b856..2e43a9cd 100644 --- a/content/vimperator.js +++ b/content/vimperator.js @@ -376,6 +376,8 @@ liberator.config = { //{{{ ioService.offline = !value; gPrefService.setBoolPref("browser.offline", ioService.offline); + + return value; }, getter: function () @@ -404,6 +406,8 @@ liberator.config = { //{{{ { liberator.log("Couldn't set titlestring", 3); } + + return value; } });