Komodo uses a number of preferences to control how the program is run. Most preferences are modified through the Komodo preferences dialog, though there are some that are not exposed through the UI.
The preferences are based on a default “prefs.xml” which can be found inside your Komodo installation directory, and then any preference changes to the base preferences are stored into your Komodo profile directory. Here is the default preferences file that Komodo starts out with:
The preferences can either be manually edited (whilst Komodo is shutdown), or can be changed (at runtime) using the Komodo API, such as through a JavaScript macro.
Some example JavaScript macros (which can be added to your Komodo toolbox) for changing preferences are listed below:
Getting a boolean preference
var pref_name = ko.interpolate.interpolateStrings(["%(ask: Boolean pref name)"]);
if (pref_name) {
if (ko.prefs.hasBoolean(pref_name)) {
alert("'" + pref_name + "': " + ko.prefs.getBoolean(pref_name));
} else {
alert("No boolean pref exists for '" + pref_name + "'");
}
}
Setting a boolean preference
var pref_name = ko.interpolate.interpolateStrings(["%(ask: Pref name)"]);
if (pref_name) {
var pref_value = ko.interpolate.interpolateStrings(["%(ask: Value: 1)"]);
if (pref_value !== null) {
if (pref_value == "1" || pref_value.toLowerCase() == "true") {
ko.prefs.setBoolean(pref_name, true);
} else {
ko.prefs.setBoolean(pref_name, false);
}
}
}
Setting a string preference
var pref_name = ko.interpolate.interpolateStrings(["%(ask: Pref name)"]);
if (pref_name) {
var pref_value = ko.interpolate.interpolateStrings(["%(ask: Value)"]);
if (pref_value !== null) {
ko.prefs.setString(pref_name, pref_value);
}
}
Setting a number preference
var pref_name = ko.interpolate.interpolateStrings(["%(ask: Pref name)"]);
if (pref_name) {
var pref_value = ko.interpolate.interpolateStrings(["%(ask: Value)"]);
if (pref_value !== null) {
ko.prefs.setLong(pref_name, parseInt(pref_value));
}
}