diff --git a/content/commands.js b/content/commands.js
index a0240cd7..0d15f1c8 100644
--- a/content/commands.js
+++ b/content/commands.js
@@ -914,6 +914,7 @@ vimperator.Commands = function() //{{{
for (var option in vimperator.options)
{
// TODO: options should be queried for this info
+ // TODO: string/list options might need escaping in future
if (!/fullscreen|usermode/.test(option.name) && option.value != option.default_value)
{
if (option.type == "boolean")
@@ -932,7 +933,7 @@ vimperator.Commands = function() //{{{
short_help: "Write current keymappings and changed options to [file]",
help: "If no [file] is specified then ~/.vimperatorrc is written unless this file already exists. " +
"The special version will overwrite [file] if it exists.
" +
- "WARNING: this differs from Vim's behaviour which defaults to writing the file in the current directory."
+ "WARNING: this differs from Vim's behavior which defaults to writing the file in the current directory."
}
));
addDefaultCommand(new vimperator.Command(["noh[lsearch]"],
@@ -1249,17 +1250,16 @@ vimperator.Commands = function() //{{{
val = "";
// reset a variable to its default value
- // TODO: remove the value from about:config instead of setting it to the current default value
if (reset)
{
if (all)
{
for (let opt in vimperator.options)
- opt.value = opt.default_value;
+ opt.reset();
}
else
{
- option.value = option.default_value;
+ option.reset();
}
}
// read access
diff --git a/content/options.js b/content/options.js
index 042a62b8..eaa94a50 100644
--- a/content/options.js
+++ b/content/options.js
@@ -105,6 +105,11 @@ vimperator.Option = function(names, type, extra_info) //{{{
}
return false;
}
+
+ this.reset = function()
+ {
+ this.value = this.default_value;
+ }
} //}}}
vimperator.Options = function() //{{{
@@ -112,12 +117,14 @@ vimperator.Options = function() //{{{
////////////////////////////////////////////////////////////////////////////////
////////////////////// PRIVATE SECTION /////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////{{{
-
var firefox_prefs = Components.classes["@mozilla.org/preferences-service;1"]
.getService(Components.interfaces.nsIPrefBranch);
var vimperator_prefs = firefox_prefs.getBranch("extensions.vimperator.");
var options = [];
+ // save if we already changed a GUI related option, used for setInitialGUI
+ var guioptions_done = false, showtabline_done = false, laststatus_done = false;
+
function optionsIterator()
{
for (var i = 0; i < options.length; i++)
@@ -199,17 +206,19 @@ vimperator.Options = function() //{{{
function setGuiOptions(value)
{
// hide menubar
- //document.getElementById("toolbar-menubar").collapsed = value.indexOf("m") > -1 ? false : true;
- //document.getElementById("toolbar-menubar").hidden = value.indexOf("m") > -1 ? false : true;
+ document.getElementById("toolbar-menubar").collapsed = value.indexOf("m") > -1 ? false : true;
+ document.getElementById("toolbar-menubar").hidden = value.indexOf("m") > -1 ? false : true;
// and main toolbar
document.getElementById("nav-bar").collapsed = value.indexOf("T") > -1 ? false : true;
document.getElementById("nav-bar").hidden = value.indexOf("T") > -1 ? false : true;
// and bookmarks toolbar
document.getElementById("PersonalToolbar").collapsed = value.indexOf("b") > -1 ? false : true;
document.getElementById("PersonalToolbar").hidden = value.indexOf("b") > -1 ? false : true;
+
+ guioptions_done = true;
}
- function setStatusLine(value)
+ function setLastStatus(value)
{
if (value == 0)
{
@@ -225,6 +234,8 @@ vimperator.Options = function() //{{{
document.getElementById("status-bar").collapsed = false;
document.getElementById("status-bar").hidden = false;
}
+
+ laststatus_done = true;
}
function setShowTabline(value)
@@ -247,6 +258,8 @@ vimperator.Options = function() //{{{
storePreference("browser.tabs.autoHide", false);
tabs.collapsed = false;
}
+
+ showtabline_done = true;
}
function setTitleString(value)
@@ -358,7 +371,18 @@ vimperator.Options = function() //{{{
list += "";
- vimperator.commandline.echo(list, vimperator.commandline.HL_NORMAL, true);
+ vimperator.commandline.echo(list, vimperator.commandline.HL_NORMAL, vimperator.commandline.FORCE_MULTILINE);
+ }
+
+ // this hack is only needed, because we need to do asynchronous loading of the .vimperatorrc
+ this.setInitialGUI = function()
+ {
+ if (!guioptions_done)
+ this.get("guioptions").reset();
+ if (!laststatus_done)
+ this.get("laststatus").reset();
+ if (!showtabline_done)
+ this.get("showtabline").reset();
}
// TODO: separate Preferences from Options? Would these utility functions
@@ -522,7 +546,7 @@ vimperator.Options = function() //{{{
"" +
"NOTE: laststatus=1 not implemented yet.",
default_value: 2,
- setter: function(value) { setStatusLine(value); },
+ setter: function(value) { setLastStatus(value); },
validator: function (value) { if (value >= 0 && value <= 2) return true; else return false; }
}
));
@@ -717,9 +741,13 @@ vimperator.Options = function() //{{{
));
//}}}
- setShowTabline(this.showtabline);
- setGuiOptions(this.guioptions);
- setStatusLine(this.laststatus);
+ // 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
+ setShowTabline(0);
+ setGuiOptions("");
+ setLastStatus(0);
+ guioptions_done = showtabline_done = laststatus_done = false;
+
setTitleString(this.titlestring);
setPopups(this.popups);
} //}}}
diff --git a/content/vimperator.js b/content/vimperator.js
index 564f6006..0a3c85f2 100644
--- a/content/vimperator.js
+++ b/content/vimperator.js
@@ -753,11 +753,9 @@ const vimperator = (function() //{{{
vimperator.log("No user RC file found", 3);
// also source plugins in ~/.vimperator/plugin/
- var entries = [];
try
{
var plugin_dir = vimperator.io.getPluginDir();
-
if (plugin_dir)
{
var files = vimperator.io.readDirectory(plugin_dir.path);
@@ -777,6 +775,11 @@ const vimperator = (function() //{{{
// thrown if directory does not exist
//vimperator.log("Error sourcing plugin directory: " + e);
}
+
+ // after sourcing the initialization files, this function will set
+ // all gui options to their default values, if they have not been
+ // set before by any rc file
+ vimperator.options.setInitialGUI();
}, 0);
vimperator.statusline.update();