From 5c6e60676fca4a078e325618ed7b059554cf8149 Mon Sep 17 00:00:00 2001 From: Doug Kearns Date: Sat, 20 Oct 2007 12:47:15 +0000 Subject: [PATCH] don't store options as preferences anymore --- NEWS | 5 +++-- content/options.js | 39 +++++++++++++++++++++++++++------------ 2 files changed, 30 insertions(+), 14 deletions(-) diff --git a/NEWS b/NEWS index f5e7952c..7110a949 100644 --- a/NEWS +++ b/NEWS @@ -2,7 +2,8 @@ 2007-xx-xx: * version 0.6 * THIS VERSION ONLY WORKS WITH FIREFOX 3.0 - * added new :mkvimperatorc command + * options are no longer stored in preferences - use the RC file instead + * added new :mkvimperatorc command * you can edit textfields with Ctrl-i now using an external editor (thanks to Joseph Xu) * :open, :bmarks, etc. filter on space separated tokens now, so you can search with :open linux windows <tab> all your bookmarks/history @@ -43,7 +44,7 @@ * added 'visualbellstyle' for styling/hiding the visual bell * merge the existing status bar with the standard FF status bar so that security information and extension buttons are included - * :buffer partial_string works now as in vim, and with ! even better + * :buffer partial_string works now as in vim, and with ! even better * new :time command for profiling * added new :sidebar and :sbclose commands * added 'more' and standard more-prompt key mappings to control diff --git a/content/options.js b/content/options.js index 67645d0c..152baaec 100644 --- a/content/options.js +++ b/content/options.js @@ -31,14 +31,13 @@ function Option(names, type, extra_info) //{{{ if (!names || !type) return null; + var value = null; + this.name = names[0]; this.names = names; this.usage = this.names; this.type = type; - this.setter = function(value) { Options.setPref(this.name, value); }; - this.getter = function() { return Options.getPref(this.name); }; - if (extra_info) { if (extra_info.usage) @@ -53,6 +52,8 @@ function Option(names, type, extra_info) //{{{ else this.default_value = null; + value = this.default_value; + if (extra_info.setter) this.setter = extra_info.setter; if (extra_info.getter) @@ -75,8 +76,22 @@ function Option(names, type, extra_info) //{{{ } // NOTE: forced defaults need to use Options.getPref - Option.prototype.__defineGetter__("value", function() { return this.getter.call(this); }); - Option.prototype.__defineSetter__("value", function(value) { this.setter.call(this, value); }); + this.__defineGetter__("value", + function() + { + if (this.getter) + this.getter.call(this); + return value; + } + ); + this.__defineSetter__("value", + function(new_value) + { + value = new_value; + if (this.setter) + this.setter.call(this, value); + } + ); // TODO: add is[Type]() queries for use in set()? // : add isValid() or just throw an exception? @@ -461,7 +476,7 @@ function Options() //{{{ "
  • T: toolbar
  • " + "
  • b: bookmark bar
  • " + "", - setter: function(value) { Options.setPref("guioptions", value); setGuiOptions(value); }, + setter: function(value) { setGuiOptions(value); }, default_value: "", validator: function (value) { if (/[^mTb]/.test(value)) return false; else return true; } } @@ -488,7 +503,7 @@ function Options() //{{{ addOption(new Option(["hlsearch", "hls"], "boolean", { short_help: "Highlight previous search pattern matches", - setter: function(value) { Options.setPref("hlsearch", value); if (value) vimperator.search.highlight(); else vimperator.search.clear(); }, + setter: function(value) { if (value) vimperator.search.highlight(); else vimperator.search.clear(); }, default_value: false } )); @@ -531,7 +546,7 @@ function Options() //{{{ "" + "NOTE: laststatus=1 not implemented yet.", default_value: 2, - setter: function(value) { Options.setPref("laststatus", value); setStatusLine(value); }, + setter: function(value) { setStatusLine(value); }, validator: function (value) { if (value >= 0 && value <= 2) return true; else return false; } } )); @@ -569,7 +584,7 @@ function Options() //{{{ "" + "NOTE: This option does not change the popup blocker of Firefox in any way.", default_value: 1, - setter: function(value) { Options.setPref("popups", value); setPopups(value); }, + setter: function(value) { setPopups(value); }, validator: function (value) { if (value >= 0 && value <= 3) return true; else return false; } } )); @@ -630,7 +645,7 @@ function Options() //{{{ "
  • 1: Show tab bar only if more than one tab is open
  • " + "
  • 2: Always show tab bar
  • " + "", - setter: function(value) { Options.setPref("showtabline", value); setShowTabline(value); }, + setter: function(value) { setShowTabline(value); }, default_value: 2, validator: function (value) { if (value >= 0 && value <= 2) return true; else return false; } } @@ -648,7 +663,7 @@ function Options() //{{{ help: "Vimperator changes the browser title from \"Title of web page - Mozilla Firefox\" to " + "\"Title of web page - Vimperator\".
    If you don't like that, you can restore it with: " + ":set titlestring=Mozilla Firefox.", - setter: function(value) { Options.setPref("titlestring", value); setTitleString(value); }, + setter: function(value) { setTitleString(value); }, default_value: "Vimperator" } )); @@ -673,7 +688,7 @@ function Options() //{{{ addOption(new Option(["visualbell", "vb"], "boolean", { short_help: "Use visual bell instead of beeping on errors", - setter: function(value) { Options.setPref("visualbell", value); Options.setFirefoxPref("accessibility.typeaheadfind.enablesound", !value); }, + setter: function(value) { Options.setFirefoxPref("accessibility.typeaheadfind.enablesound", !value); }, default_value: false } ));