1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2025-12-23 15:22:26 +01:00

expand environment variables when setting 'cdpath' and 'shell'

This commit is contained in:
Doug Kearns
2008-09-01 13:36:15 +00:00
parent 26adf51554
commit 339dd911cd
9 changed files with 76 additions and 8 deletions

View File

@@ -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 ()
{

View File

@@ -123,6 +123,8 @@ liberator.Search = function () //{{{
liberator.search.highlight();
else
liberator.search.clear();
return value;
}
});

View File

@@ -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",

View File

@@ -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"],

View File

@@ -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;
}
});*/

View File

@@ -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);

View File

@@ -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); }
});

View File

@@ -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)

View File

@@ -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;
}
});