1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2025-12-23 18:02:27 +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", "Show the current window fullscreen",
"boolean", false, "boolean", false,
{ {
setter: function (value) { window.fullScreen = value; }, setter: function (value)
{
window.fullScreen = value;
return value;
},
getter: function () { return window.fullScreen; } getter: function () { return window.fullScreen; }
}); });
@@ -199,6 +203,8 @@ liberator.Buffer = function () //{{{
getMarkupDocumentViewer().authorStyleDisabled = value; getMarkupDocumentViewer().authorStyleDisabled = value;
} }
catch (e) {} catch (e) {}
return value;
}, },
getter: function () getter: function ()
{ {

View File

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

View File

@@ -47,10 +47,26 @@ liberator.IO = function () //{{{
var cdpath = "," + (environmentService.get("CDPATH").replace(/[:;]/g, ",") || ","); var cdpath = "," + (environmentService.get("CDPATH").replace(/[:;]/g, ",") || ",");
// TODO: setter should expand environment variables
liberator.options.add(["cdpath", "cd"], liberator.options.add(["cdpath", "cd"],
"List of directories searched when executing :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; var shell, shellcmdflag;
@@ -67,10 +83,15 @@ liberator.IO = function () //{{{
shellcmdflag = "-c"; shellcmdflag = "-c";
} }
// TODO: setter should expand environment variables
liberator.options.add(["shell", "sh"], liberator.options.add(["shell", "sh"],
"Shell to use for executing :! and :run commands", "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"], liberator.options.add(["shellcmdflag", "shcf"],
"Flag passed to shell when executing :! and :run commands", "Flag passed to shell when executing :! and :run commands",

View File

@@ -50,6 +50,7 @@ const liberator = (function () //{{{
setter: function (value) setter: function (value)
{ {
var guioptions = liberator.config.guioptions || {}; var guioptions = liberator.config.guioptions || {};
for (let option in guioptions) for (let option in guioptions)
{ {
guioptions[option].forEach(function (elem) guioptions[option].forEach(function (elem)
@@ -61,10 +62,13 @@ const liberator = (function () //{{{
catch (e) {} catch (e) {}
}); });
} }
return value;
}, },
validator: function (value) validator: function (value)
{ {
var regex = "[^"; var regex = "[^";
for (let option in liberator.config.guioptions) for (let option in liberator.config.guioptions)
regex += option.toString(); regex += option.toString();
@@ -87,7 +91,11 @@ const liberator = (function () //{{{
"Use visual bell instead of beeping on errors", "Use visual bell instead of beeping on errors",
"boolean", false, "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"], liberator.options.add(["visualbellstyle", "t_vb"],

View File

@@ -216,6 +216,8 @@ liberator.Mail = function () //{{{
case "vertical": ChangeMailLayout(2); break; case "vertical": ChangeMailLayout(2); break;
// case "inherit" just does nothing // case "inherit" just does nothing
} }
return value;
} }
}); });
@@ -229,6 +231,8 @@ liberator.Mail = function () //{{{
MsgSortThreaded(); MsgSortThreaded();
else else
MsgSortUnthreaded(); 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 // Do NOT create instances of this class yourself, use the helper method
// liberator.options.add() instead // 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) //{{{ liberator.Option = function (names, description, type, defaultValue, scope, getter, setter, validator, completer) //{{{
{ {
if (!names || !type) if (!names || !type)
@@ -73,7 +74,9 @@ liberator.Option = function (names, description, type, defaultValue, scope, gett
return null; return null;
} }
else else
{
scope = this.scope; scope = this.scope;
}
var aValue; var aValue;
@@ -96,7 +99,21 @@ liberator.Option = function (names, description, type, defaultValue, scope, gett
return null; return null;
} }
else else
{
scope = this.scope; 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)) if (liberator.has("tabs") && (scope & liberator.options.OPTION_SCOPE_LOCAL))
liberator.tabs.options[this.name] = newValue; liberator.tabs.options[this.name] = newValue;
@@ -104,8 +121,6 @@ liberator.Option = function (names, description, type, defaultValue, scope, gett
value = newValue; value = newValue;
this.hasChanged = true; this.hasChanged = true;
if (this.setter)
this.setter.call(this, newValue);
}; };
this.__defineGetter__("value", this.get); this.__defineGetter__("value", this.get);

View File

@@ -121,6 +121,7 @@ liberator.Tabs = function () //{{{
setter: function (value) setter: function (value)
{ {
var tabs = liberator.tabs.tabStrip; var tabs = liberator.tabs.tabStrip;
if (!tabs) if (!tabs)
return; return;
@@ -138,6 +139,8 @@ liberator.Tabs = function () //{{{
liberator.options.setPref("browser.tabs.autoHide", false); liberator.options.setPref("browser.tabs.autoHide", false);
tabs.collapsed = false; tabs.collapsed = false;
} }
return value;
}, },
validator: function (value) { return (value >= 0 && value <= 2); }, validator: function (value) { return (value >= 0 && value <= 2); },
completer: function (filter) completer: function (filter)
@@ -184,8 +187,11 @@ liberator.Tabs = function () //{{{
[2, 3], // in a new window if it has specified sizes [2, 3], // in a new window if it has specified sizes
[1, 2], // always in new window [1, 2], // always in new window
[2, 1]];// current tab unless it has specified sizes [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.restriction", values[value][0]);
liberator.options.setPref("browser.link.open_newwindow", values[value][1]); liberator.options.setPref("browser.link.open_newwindow", values[value][1]);
return value;
}, },
validator: function (value) { return (value >= 0 && value <= 4); } 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"); liberator.echo("show status line only with > 1 window not implemented yet");
else else
document.getElementById("status-bar").collapsed = false; document.getElementById("status-bar").collapsed = false;
return value;
}, },
validator: function (value) { return (value >= 0 && value <= 2); }, validator: function (value) { return (value >= 0 && value <= 2); },
completer: function (filter) completer: function (filter)

View File

@@ -376,6 +376,8 @@ liberator.config = { //{{{
ioService.offline = !value; ioService.offline = !value;
gPrefService.setBoolPref("browser.offline", ioService.offline); gPrefService.setBoolPref("browser.offline", ioService.offline);
return value;
}, },
getter: function () getter: function ()
@@ -404,6 +406,8 @@ liberator.config = { //{{{
{ {
liberator.log("Couldn't set titlestring", 3); liberator.log("Couldn't set titlestring", 3);
} }
return value;
} }
}); });