Skip to content

Instantly share code, notes, and snippets.

@sprintr
Last active August 29, 2015 14:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sprintr/b48c318ced6af39bf123 to your computer and use it in GitHub Desktop.
Save sprintr/b48c318ced6af39bf123 to your computer and use it in GitHub Desktop.
A code snippet to demonstrate the new preferences code hints feature of Brackets.io
define(function (require, module, exports) {
var PreferencesManager = brackets.getModule("preferences/PreferencesManager"),
prefs = PreferencesManager.getExtensionPrefs("TestExt");
// Boolean
prefs.definePreference("one", "boolean", true, {
excludeFromHints: true // This won't show up in the code hints.
});
// Boolean Preference that will show up in code hints
prefs.definePreference("foo", "boolean", true, {
description: "This is a boolean preference"
});
PreferencesManager.definePreference("testPref", "boolean", true);
// Number
prefs.definePreference("two", "number", 4, {
description: "This is a number Preference",
values: [1, 2, 3, 5]
});
// String
prefs.definePreference("three", "string", "foo", {
description: "This is a string Preference",
values: ["foo", "bar", "baz"]
});
// Array
prefs.definePreference("four", "array", ["foo"], {
description: "This is an array of strings",
valueType: "string",
values: ["foo", "bar", "baz"]
});
// Object
prefs.definePreference("five", "object", {}, {
description: "This is an object",
keys: {
fiveA: {
type: "boolean",
description: "This is a nested boolean Preference"
},
fiveB: {
type: "boolean",
description: "This is also a nested boolean Preference"
},
fiveC: {
type: "number",
description: "This is a nested number Preference",
values: [2, 4, 6, 8, 10]
},
fiveD: {
type: "string",
description: "This is a string Preference",
values: ["foo", "bar", "baz"]
},
fiveE: {
type: "array",
description: "This is an array of numbers",
values: [1, 2, 3, 4, 5, 6],
valueType: "number"
},
fiveF: {
type: "array",
description: "This is an array of strings",
values: ["foo", "bar", "baz"],
valueType: "string"
}
}
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment