diff --git a/content/bookmarks.js b/content/bookmarks.js
index e78c95e5..6400625c 100644
--- a/content/bookmarks.js
+++ b/content/bookmarks.js
@@ -811,7 +811,8 @@ vimperator.QuickMarks = function () //{{{
/////////////////////////////////////////////////////////////////////////////{{{
var qmarks = {};
- var savedMarks = vimperator.options.getPref("quickmarks", "").split("\n");
+ // TODO: move to a storage module
+ var savedMarks = vimperator.options.getPref("vimperator.extensions.quickmarks", "").split("\n");
// load the saved quickmarks -- TODO: change to sqlite
for (var i = 0; i < savedMarks.length - 1; i += 2)
@@ -907,7 +908,7 @@ vimperator.QuickMarks = function () //{{{
savedQuickMarks += qmarks[i] + "\n";
}
- vimperator.options.setPref("quickmarks", savedQuickMarks);
+ vimperator.options.setPref("vimperator.extensions.quickmarks", savedQuickMarks);
}
};
diff --git a/content/buffers.js b/content/buffers.js
index 48793d5f..f18ca40c 100644
--- a/content/buffers.js
+++ b/content/buffers.js
@@ -348,7 +348,7 @@ vimperator.Buffer = function () //{{{
{
urlSecurityCheck(url, doc.nodePrincipal);
// we always want to save that link relative to the current working directory
- vimperator.options.setFirefoxPref("browser.download.lastDir", vimperator.io.getCurrentDirectory());
+ vimperator.options.setPref("browser.download.lastDir", vimperator.io.getCurrentDirectory());
saveURL(url, text, null, true, skipPrompt, makeURI(url, doc.characterSet));
}
catch (e)
diff --git a/content/commands.js b/content/commands.js
index c0ac34eb..27c13f3f 100644
--- a/content/commands.js
+++ b/content/commands.js
@@ -1757,7 +1757,7 @@ vimperator.Commands = function () //{{{
{
var file = vimperator.io.getFile(args || "");
// we always want to save that link relative to the current working directory
- vimperator.options.setFirefoxPref("browser.download.lastDir", vimperator.io.getCurrentDirectory());
+ vimperator.options.setPref("browser.download.lastDir", vimperator.io.getCurrentDirectory());
//if (args)
//{
// saveURL(vimperator.buffer.URL, args, null, true, special, // special == skipPrompt
@@ -1776,11 +1776,11 @@ vimperator.Commands = function () //{{{
{
if (special)
{
- var onlyNondefault = false;
+ var onlyNonDefault = false;
if (!args)
{
args = "all";
- onlyNondefault = true;
+ onlyNonDefault = true;
}
// 1 2 3 4 5
var matches = args.match(/^\s*?([a-zA-Z0-9\.\-_{}]+)([?&!])?\s*(([+-^]?)=(.*))?\s*$/);
@@ -1796,11 +1796,11 @@ vimperator.Commands = function () //{{{
if (name == "all" && reset)
vimperator.echoerr("You can't reset all the firefox options, it could make your browser unusable.");
else if (name == "all")
- vimperator.options.listFirefoxPrefs(onlyNondefault, "");
+ vimperator.options.listPrefs(onlyNonDefault, "");
else if (reset)
- vimperator.options.resetFirefoxPref(name);
+ vimperator.options.resetPref(name);
else if (invertBoolean)
- vimperator.options.invertFirefoxPref(name);
+ vimperator.options.invertPref(name);
else if (matches[3])
{
var value = matches[5];
@@ -1820,20 +1820,20 @@ vimperator.Commands = function () //{{{
if (!isNaN(valueInt))
value = valueInt;
}
- vimperator.options.setFirefoxPref(name, value);
+ vimperator.options.setPref(name, value);
}
else
{
- vimperator.options.listFirefoxPrefs(onlyNondefault, name);
+ vimperator.options.listPrefs(onlyNonDefault, name);
}
return;
}
- var onlyNondefault = false; // used for :set to print non-default options
+ var onlyNonDefault = false; // used for :set to print non-default options
if (!args)
{
args = "all";
- onlyNondefault = true;
+ onlyNonDefault = true;
}
// 1 2 3 4 5 6
@@ -1898,7 +1898,7 @@ vimperator.Commands = function () //{{{
{
if (all)
{
- vimperator.options.list(onlyNondefault);
+ vimperator.options.list(onlyNonDefault);
}
else
{
diff --git a/content/completion.js b/content/completion.js
index bdd5c130..1bb8e8cb 100644
--- a/content/completion.js
+++ b/content/completion.js
@@ -364,9 +364,9 @@ vimperator.Completion = function () //{{{
if (special)
{
- var firefoxBranch = Components.classes["@mozilla.org/preferences-service;1"]
+ var prefs = Components.classes["@mozilla.org/preferences-service;1"]
.getService(Components.interfaces.nsIPrefBranch);
- var prefArray = firefoxBranch.getChildList("", {value: 0});
+ var prefArray = prefs.getChildList("", {value: 0});
prefArray.sort();
if (filter.length > 0 && filter.lastIndexOf("=") == filter.length - 1)
@@ -376,7 +376,7 @@ vimperator.Completion = function () //{{{
var name = prefArray[i];
if (name.match("^" + filter.substr(0, filter.length - 1) + "$" ))
{
- var value = vimperator.options.getFirefoxPref(name) + "";
+ var value = vimperator.options.getPref(name) + "";
return [filter.length + 1, [[value, ""]]];
}
}
@@ -386,9 +386,9 @@ vimperator.Completion = function () //{{{
for (var i = 0; i < prefArray.length; i++)
{
if (!filter)
- optionCompletions.push([prefArray[i], vimperator.options.getFirefoxPref(prefArray[i])]);
+ optionCompletions.push([prefArray[i], vimperator.options.getPref(prefArray[i])]);
else
- optionCompletions.push([[prefArray[i]], vimperator.options.getFirefoxPref(prefArray[i])]);
+ optionCompletions.push([[prefArray[i]], vimperator.options.getPref(prefArray[i])]);
}
diff --git a/content/events.js b/content/events.js
index 1e5d1167..e0278ad0 100644
--- a/content/events.js
+++ b/content/events.js
@@ -853,7 +853,7 @@ vimperator.Events = function () //{{{
case vimperator.modes.CARET:
// setting this option will trigger an observer which will
// care about all other details like setting the NORMAL mode
- vimperator.options.setFirefoxPref("accessibility.browsewithcaret", false);
+ vimperator.options.setPref("accessibility.browsewithcaret", false);
break;
case vimperator.modes.INSERT:
@@ -1245,6 +1245,7 @@ vimperator.Events = function () //{{{
onLinkIconAvailable: function () { ; }
},
+ // TODO: move to options.js?
prefObserver: {
register: function ()
{
diff --git a/content/io.js b/content/io.js
index 5318fc8e..33b0ea2d 100644
--- a/content/io.js
+++ b/content/io.js
@@ -155,9 +155,9 @@ vimperator.IO = function () //{{{
var pluginDir;
if (WINDOWS)
- pluginDir = "~/vimperator/" + directory;
+ pluginDir = "~/" + vimperator.config.name.toLowerCase() + "/" + directory;
else
- pluginDir = "~/.vimperator/" + directory;
+ pluginDir = "~/." + vimperator.config.name.toLowerCase() + "/" + directory;
pluginDir = this.getFile(this.expandPath(pluginDir));
@@ -166,8 +166,8 @@ vimperator.IO = function () //{{{
getRCFile: function ()
{
- var rcFile1 = this.getFile("~/.vimperatorrc");
- var rcFile2 = this.getFile("~/_vimperatorrc");
+ var rcFile1 = this.getFile("~/." + vimperator.config.name.toLowerCase() + "rc");
+ var rcFile2 = this.getFile("~/_" + vimperator.config.name.toLowerCase() + "rc");
if (WINDOWS)
[rcFile1, rcFile2] = [rcFile2, rcFile1]
diff --git a/content/mappings.js b/content/mappings.js
index 39cde99e..7550338e 100644
--- a/content/mappings.js
+++ b/content/mappings.js
@@ -396,7 +396,7 @@ vimperator.Mappings = function () //{{{
{
// setting this option triggers an observer
// which takes care of the mode setting
- vimperator.options.setFirefoxPref("accessibility.browsewithcaret", true);
+ vimperator.options.setPref("accessibility.browsewithcaret", true);
},
{ shortHelp: "Start caret mode" }
));
diff --git a/content/modes.js b/content/modes.js
index cb76afaf..c7910e0b 100644
--- a/content/modes.js
+++ b/content/modes.js
@@ -135,9 +135,9 @@ vimperator.modes = (function () //{{{
if (newMode == vimperator.modes.NORMAL)
{
// disable caret mode when we want to switch to normal mode
- var value = vimperator.options.getFirefoxPref("accessibility.browsewithcaret", false);
+ var value = vimperator.options.getPref("accessibility.browsewithcaret", false);
if (value)
- vimperator.options.setFirefoxPref("accessibility.browsewithcaret", false);
+ vimperator.options.setPref("accessibility.browsewithcaret", false);
vimperator.statusline.updateUrl();
vimperator.focusContent(false);
diff --git a/content/options.js b/content/options.js
index 32af4e66..a8efde72 100644
--- a/content/options.js
+++ b/content/options.js
@@ -116,10 +116,10 @@ vimperator.Options = function () //{{{
////////////////////// PRIVATE SECTION /////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////{{{
- var firefoxBranch = Components.classes["@mozilla.org/preferences-service;1"]
- .getService(Components.interfaces.nsIPrefBranch);
- var defaultBranch = firefoxBranch.getDefaultBranch("");
- var vimperatorBranch = firefoxBranch.getBranch("extensions.vimperator.");
+ var prefService = Components.classes["@mozilla.org/preferences-service;1"]
+ .getService(Components.interfaces.nsIPrefBranch);
+ var preferences = prefService.getDefaultBranch("");
+
var options = [];
// save if we already changed a GUI related option, used for setInitialGUI
@@ -133,33 +133,29 @@ vimperator.Options = function () //{{{
throw StopIteration;
}
- function storePreference(name, value, branch)
+ function storePreference(name, value)
{
- if (!branch)
- branch = firefoxBranch;
-
- var type = branch.getPrefType(name);
-
+ var type = prefService.getPrefType(name);
switch (typeof value)
{
case "string":
- if (type == branch.PREF_INVALID || type == branch.PREF_STRING)
- branch.setCharPref(name, value);
- else if (type == branch.PREF_INT)
+ if (type == prefService.PREF_INVALID || type == prefService.PREF_STRING)
+ prefService.setCharPref(name, value);
+ else if (type == prefService.PREF_INT)
vimperator.echoerr("E521: Number required after =: " + name + "=" + value);
else
vimperator.echoerr("E474: Invalid argument: " + name + "=" + value);
break;
case "number":
- if (type == branch.PREF_INVALID || type == branch.PREF_INT)
- branch.setIntPref(name, value);
+ if (type == prefService.PREF_INVALID || type == prefService.PREF_INT)
+ prefService.setIntPref(name, value);
else
vimperator.echoerr("E474: Invalid argument: " + name + "=" + value);
break;
case "boolean":
- if (type == branch.PREF_INVALID || type == branch.PREF_BOOL)
- branch.setBoolPref(name, value);
- else if (type == branch.PREF_INT)
+ if (type == prefService.PREF_INVALID || type == prefService.PREF_BOOL)
+ prefService.setBoolPref(name, value);
+ else if (type == prefService.PREF_INT)
vimperator.echoerr("E521: Number required after =: " + name + "=" + value);
else
vimperator.echoerr("E474: Invalid argument: " + name + "=" + value);
@@ -169,32 +165,28 @@ vimperator.Options = function () //{{{
}
}
- function loadPreference(name, forcedDefault, branch)
+ function loadPreference(name, forcedDefault)
{
var defaultValue = null;
- if (forcedDefault != null) // this argument sets defaults for non-user settable options (like comp_history)
+ if (forcedDefault != null) // this argument sets defaults for non-user settable options (like extensions.history.comp_history)
defaultValue = forcedDefault;
- if (!branch)
- branch = firefoxBranch;
-
- var type = branch.getPrefType(name);
-
+ var type = prefService.getPrefType(name);
try
{
switch (type)
{
- case branch.PREF_STRING:
- var value = branch.getComplexValue(name, Components.interfaces.nsISupportsString).data;
+ case prefService.PREF_STRING:
+ var value = prefService.getComplexValue(name, Components.interfaces.nsISupportsString).data;
// Try in case it's a localized string (will throw an exception if not)
- if (!branch.prefIsLocked(name) && !branch.prefHasUserValue(name) &&
+ if (!prefService.prefIsLocked(name) && !prefService.prefHasUserValue(name) &&
/^chrome:\/\/.+\/locale\/.+\.properties/.test(value))
- value = branch.getComplexValue(name, Components.interfaces.nsIPrefLocalizedString).data;
+ value = prefService.getComplexValue(name, Components.interfaces.nsIPrefLocalizedString).data;
return value;
- case branch.PREF_INT:
- return branch.getIntPref(name);
- case branch.PREF_BOOL:
- return branch.getBoolPref(name);
+ case prefService.PREF_INT:
+ return prefService.getIntPref(name);
+ case prefService.PREF_BOOL:
+ return prefService.getBoolPref(name);
default:
return defaultValue;
}
@@ -336,7 +328,7 @@ vimperator.Options = function () //{{{
storePreference("dom.popup_allowed_events", popupAllowedEvents);
},
- list: function (onlyNondefault)
+ list: function (onlyNonDefault)
{
var list = ":" + vimperator.util.escapeHTML(vimperator.commandline.getCommand()) + "
" +
"
| --- Options --- |
";
@@ -348,7 +340,7 @@ vimperator.Options = function () //{{{
value = options[i].value;
def = options[i].defaultValue;
- if (onlyNondefault && value == def)
+ if (onlyNonDefault && value == def)
continue;
if (options[i].type == "boolean")
@@ -377,28 +369,30 @@ vimperator.Options = function () //{{{
vimperator.commandline.echo(list, vimperator.commandline.HL_NORMAL, vimperator.commandline.FORCE_MULTILINE);
},
- listFirefoxPrefs: function (onlyNondefault, filter)
+ listPrefs: function (onlyNonDefault, filter)
{
if (!filter)
filter = "";
- var prefArray = firefoxBranch.getChildList("", {value: 0});
+
+ var prefArray = prefService.getChildList("", {value: 0});
prefArray.sort();
var list = ":" + vimperator.util.escapeHTML(vimperator.commandline.getCommand()) + "
" +
- "| --- Firefox Options --- |
";
+ "| --- " + vimperator.config.hostApplication +
+ " Options --- |
";
var name, value;
for (var i = 0; i < prefArray.length; i++)
{
- var userValue = firefoxBranch.prefHasUserValue(prefArray[i]);
- if ((!onlyNondefault || userValue) && prefArray[i].indexOf(filter) >= 0)
+ var userValue = prefService.prefHasUserValue(prefArray[i]);
+ if ((!onlyNonDefault || userValue) && prefArray[i].indexOf(filter) >= 0)
{
name = prefArray[i];
- value = this.getFirefoxPref(name);
+ value = this.getPref(name);
if (typeof value == "string")
value = value.substr(0,100).replace(/\n/g, " ");
value = vimperator.util.colorize(value, false);
- defaultValue = loadPreference(name, null, defaultBranch);
+ defaultValue = loadPreference(name, null);
if (defaultValue == null)
defaultValue = "no default";
@@ -431,38 +425,27 @@ vimperator.Options = function () //{{{
this.get("showtabline").reset();
},
- // TODO: separate Preferences from Options? Would these utility functions
// be better placed in the 'core' vimperator namespace somewhere?
setPref: function (name, value)
- {
- return storePreference(name, value, vimperatorBranch);
- },
-
- getPref: function (name, forcedDefault)
- {
- return loadPreference(name, forcedDefault, vimperatorBranch);
- },
-
- setFirefoxPref: function (name, value)
{
return storePreference(name, value);
},
- getFirefoxPref: function (name, forcedDefault)
+ getPref: function (name, forcedDefault)
{
return loadPreference(name, forcedDefault);
},
- resetFirefoxPref: function (name)
+ resetPref: function (name)
{
- return firefoxBranch.clearUserPref(name);
+ return preferences.clearUserPref(name);
},
// this works only for booleans
- invertFirefoxPref: function (name)
+ invertPref: function (name)
{
- if (firefoxBranch.getPrefType(name) == firefoxBranch.PREF_BOOL)
- this.setFirefoxPref(name, !this.getFirefoxPref(name));
+ if (prefService.getPrefType(name) == prefService.PREF_BOOL)
+ this.setPref(name, !this.getPref(name));
else
vimperator.echoerr("E488: Trailing characters: " + name + "!");
}
@@ -712,7 +695,7 @@ vimperator.Options = function () //{{{
optionManager.add(new vimperator.Option(["visualbell", "vb"], "boolean",
{
shortHelp: "Use visual bell instead of beeping on errors",
- setter: function (value) { vimperator.options.setFirefoxPref("accessibility.typeaheadfind.enablesound", !value); },
+ setter: function (value) { vimperator.options.setPref("accessibility.typeaheadfind.enablesound", !value); },
defaultValue: false
}
));
@@ -737,9 +720,6 @@ vimperator.Options = function () //{{{
// we start with an "empty" GUI so that no toolbars or tabbar is shown if the user
// sets them to empty in the .vimperatorrc, which is sourced asynchronously
- if (vimperator.config.name != "Vimperator")
- alert("mooh");
- else alert("maeh");
if (vimperator.config.name != "Vimperator")
return optionManager;
diff --git a/content/ui.js b/content/ui.js
index 90ee8aa5..41891783 100644
--- a/content/ui.js
+++ b/content/ui.js
@@ -59,14 +59,15 @@ vimperator.CommandLine = function () //{{{
load: function ()
{
- this.cmd = vimperator.options.getPref("commandline_cmd_history", "").split("\n");
- this.search = vimperator.options.getPref("commandline_search_history", "").split("\n");
+ // TODO: move to storage module
+ this.cmd = vimperator.options.getPref("extensions.vimperator.commandline_cmd_history", "").split("\n");
+ this.search = vimperator.options.getPref("extensions.vimperator.commandline_search_history", "").split("\n");
},
save: function ()
{
- vimperator.options.setPref("commandline_cmd_history", this.cmd.join("\n"));
- vimperator.options.setPref("commandline_search_history", this.search.join("\n"));
+ vimperator.options.setPref("extensions.vimperator.commandline_cmd_history", this.cmd.join("\n"));
+ vimperator.options.setPref("extensions.vimperator.commandline_search_history", this.search.join("\n"));
},
add: function (str)