This repository has been archived by the owner on Sep 6, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7.6k
Fonts api with Themes integrated #8492
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
f4d1e71
Fix #8481 by adding a newline to the light theme.
dangoor 3681d92
Fonts api with themes integrated
MiguelCastillo da45d27
Fixed jslint complaints
MiguelCastillo 8ce9221
Merge pull request #8282 from le717/issue-8216
TomMalbran 86fa10f
Fonts api with themes integrated
MiguelCastillo 8df039b
Fixed jslint complaints
MiguelCastillo 2822783
Merge branch 'fonts' of https://github.com/MiguelCastillo/brackets in…
MiguelCastillo 9c339f0
Corrected check if default settings have changed
MiguelCastillo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,12 +27,13 @@ | |
define(function (require, exports, module) { | ||
"use strict"; | ||
|
||
var _ = require("thirdparty/lodash"), | ||
Dialogs = require("widgets/Dialogs"), | ||
Strings = require("strings"), | ||
PreferencesManager = require("preferences/PreferencesManager"), | ||
settingsTemplate = require("text!htmlContent/themes-settings.html"), | ||
prefs = PreferencesManager.getExtensionPrefs("themes"); | ||
var _ = require("thirdparty/lodash"), | ||
Dialogs = require("widgets/Dialogs"), | ||
Strings = require("strings"), | ||
ViewCommandHandlers = require("view/ViewCommandHandlers"), | ||
settingsTemplate = require("text!htmlContent/themes-settings.html"), | ||
PreferencesManager = require("preferences/PreferencesManager"), | ||
prefs = PreferencesManager.getExtensionPrefs("themes"); | ||
|
||
/** | ||
* @type {Object} | ||
|
@@ -44,9 +45,6 @@ define(function (require, exports, module) { | |
* Object with all default values that can be configure via the settings UI | ||
*/ | ||
var defaults = { | ||
"fontSize": 12, | ||
"lineHeight": 1.25, | ||
"fontFamily": "'SourceCodePro-Medium', MS ゴシック, 'MS Gothic', monospace", | ||
"customScrollbars": true, | ||
"theme": "thor-light-theme" | ||
}; | ||
|
@@ -64,9 +62,16 @@ define(function (require, exports, module) { | |
* @return {Object} a collection with all the settings | ||
*/ | ||
function getValues() { | ||
return _.transform(defaults, function (result, value, key) { | ||
var result = {}; | ||
|
||
Object.keys(defaults).forEach(function (key) { | ||
result[key] = prefs.get(key); | ||
}); | ||
|
||
result.fontFamily = ViewCommandHandlers.getFontFamily(); | ||
result.fontSize = ViewCommandHandlers.getFontSize(); | ||
result.lineHeight = ViewCommandHandlers.getLineHeight(); | ||
return result; | ||
} | ||
|
||
/** | ||
|
@@ -109,9 +114,21 @@ define(function (require, exports, module) { | |
}); | ||
|
||
Dialogs.showModalDialogUsingTemplate($template).done(function (id) { | ||
var setterFn; | ||
|
||
if (id === "save") { | ||
// Go through each new setting and apply it | ||
Object.keys(newSettings).forEach(function (setting) { | ||
prefs.set(setting, newSettings[setting]); | ||
if (defaults.hasOwnProperty(setting)) { | ||
prefs.set(setting, newSettings[setting]); | ||
} else { | ||
// Figure out if the setting is in the ViewCommandHandlers, which means it is | ||
// a font setting | ||
setterFn = "set" + setting[0].toLocaleUpperCase() + setting.substr(1); | ||
if (typeof ViewCommandHandlers[setterFn] === 'function') { | ||
ViewCommandHandlers[setterFn](newSettings[setting]); | ||
} | ||
} | ||
}); | ||
} else if (id === "cancel") { | ||
// Make sure we revert any changes to theme selection | ||
|
@@ -133,21 +150,13 @@ define(function (require, exports, module) { | |
*/ | ||
function restore() { | ||
prefs.set("theme", defaults.theme); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I forgot to mention this previously: the better way to restore the default is There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh ok, cool. I will change that then |
||
prefs.set("fontSize", defaults.fontSize + "px"); | ||
prefs.set("lineHeight", defaults.lineHeight); | ||
prefs.set("fontFamily", defaults.fontFamily); | ||
prefs.set("customScrollbars", defaults.customScrollbars); | ||
} | ||
|
||
|
||
prefs.definePreference("theme", "string", defaults.theme); | ||
prefs.definePreference("fontSize", "string", defaults.fontSize + "px"); | ||
prefs.definePreference("lineHeight", "number", defaults.lineHeight); | ||
prefs.definePreference("fontFamily", "string", defaults.fontFamily); | ||
prefs.definePreference("customScrollbars", "boolean", defaults.customScrollbars); | ||
|
||
exports._setThemes = setThemes; | ||
exports._defaults = defaults; | ||
exports.restore = restore; | ||
exports.showDialog = showDialog; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I realize that
restore
is not new, but I wonder if it's actually useful? Maybe we should just delete it?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah man, we can delete that for sure if nothing breaks
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I remember now. I use that function in the extension because I have a reset button in the settings dialog. I am thinking that something like might actually be useful here too. What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ahh, that makes sense. This does seem like a context in which a reset button could be useful.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would you prefer we remove the function? It seems like we can add it back if/when a restore setttings button is added. I am happy either way.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nope, let's leave it in.