-
Notifications
You must be signed in to change notification settings - Fork 7.5k
Themes in Brackets core #7616
Themes in Brackets core #7616
Changes from 1 commit
d12d87b
657df85
5cb4085
abf3e49
5473380
a1dea7e
6f1df7a
361d715
7a8997f
2856006
b0df2fc
1c64c1a
a572d22
e68c3ec
43b5abb
92ac359
fb54d2f
bc7054f
767c9e5
5c6f83b
d83bf29
0854441
f9d29db
d55254f
f686926
02515b1
e037fc0
8ee527b
fe05d09
f8eac83
1ba4ac0
5bd2d89
e46a93d
b2d0702
768d2f0
2c74247
a1f6c6a
bce17ad
9832add
6cf0eae
803c26f
fc498a8
796322a
2f94472
ff3c065
ab93c01
1d81228
8d94e86
7834318
280c83e
72f6354
43ed137
1c05805
ea1aab0
1416cd9
8bfd51e
ef8b5cd
2c06fd2
c38e68d
79f7350
aebe379
8cef24a
710d4e0
9894c0e
72f5f34
57df196
7f5a33c
d71bbcb
cdfa4be
1491ad3
9188e5c
22fc569
67abe19
e14f151
d302434
31cb2a6
b6a7ef3
86f78eb
a102a51
0ce29ce
c2d26f2
8f2619f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| /** | ||
|
Contributor
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. Why are these CodeMirror addons added automatically with themes? Is there some connection between themes and these addons? If there is some reason why we must enable these addons, we should do so in the main place where we enable CM addons (which I don't know offhand, but I'm sure it's there somewhere 😁) |
||
| * Brackets Themes Copyright (c) 2014 Miguel Castillo. | ||
| * | ||
| * Licensed under MIT | ||
| */ | ||
|
|
||
|
|
||
| define(function () { | ||
| "use strict"; | ||
|
|
||
| var CodeMirror = require("thirdparty/CodeMirror2/lib/codemirror"); | ||
|
|
||
| function initAddons() { | ||
| // Set some default value for codemirror... | ||
| CodeMirror.defaults.highlightSelectionMatches = true; | ||
| CodeMirror.defaults.styleSelectedText = true; | ||
| } | ||
|
|
||
| function init() { | ||
| var deferred = $.Deferred(); | ||
|
|
||
| /** | ||
| * This is where is all starts to load up... | ||
| */ | ||
| require([ | ||
| "thirdparty/CodeMirror2/addon/selection/mark-selection", | ||
| "thirdparty/CodeMirror2/addon/search/match-highlighter" | ||
| ], deferred.resolve); | ||
|
|
||
| return deferred.done(initAddons).promise(); | ||
| } | ||
|
|
||
| return { | ||
| ready: init() | ||
| }; | ||
| }); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| /** | ||
|
Contributor
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. This can probably just go in Settings.js |
||
| * Brackets Themes Copyright (c) 2014 Miguel Castillo. | ||
| * | ||
| * Licensed under MIT | ||
| */ | ||
|
|
||
|
|
||
| define(function(require) { | ||
| var FileUtils = require("file/FileUtils"); | ||
| var cm_path = FileUtils.getNativeBracketsDirectoryPath() + "/thirdparty/CodeMirror2"; | ||
|
|
||
| return { | ||
| "fontSize": 12, | ||
| "lineHeight": '1.3em', | ||
| "fontType": "'SourceCodePro-Medium', MS ゴシック, 'MS Gothic', monospace", | ||
| "customScrollbars": true, | ||
| "theme": ["default"], | ||
| "paths": [ | ||
| {path:require.toUrl("./") + "../../themes"}, | ||
|
Contributor
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. missing space after colon (Coding Conventions) |
||
| {path:require.toUrl("./theme/")}, | ||
| {path:cm_path + "/theme"} | ||
| ] | ||
| }; | ||
| }); | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| /** | ||
|
Contributor
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. This should be merged into ViewCommandHandlers. In fact, it may make sense to put the code in |
||
| * Brackets Themes Copyright (c) 2014 Miguel Castillo. | ||
| * @author Brad Gearon | ||
| * | ||
| * Licensed under MIT | ||
| */ | ||
|
|
||
|
|
||
| define(function (require) { | ||
| "use strict"; | ||
|
|
||
| var Settings = require("themes/Settings"), | ||
| DefaultSettings = require("themes/DefaultSettings"), | ||
| ViewCommandHandlers = require("view/ViewCommandHandlers"), | ||
| PreferencesManager = require("preferences/PreferencesManager"); | ||
|
|
||
| function ViewCommandsManager () { | ||
| $(ViewCommandHandlers).on("fontSizeChange", updateThemeFontSize); | ||
| $(Settings).on("change:fontSize", updateBracketsFontSize); | ||
| updateBracketsFontSize(); | ||
| } | ||
|
|
||
| function updateThemeFontSize (evt, adjustment, fontSize /*, lineHeight*/) { | ||
| Settings.setValue("fontSize", fontSize); | ||
| } | ||
|
|
||
| function updateBracketsFontSize() { | ||
| var fontSize = Settings.getValue("fontSize"), | ||
| fontSizeNumeric = Number(fontSize.replace(/px|em/, "")), | ||
| fontSizeOffset = fontSizeNumeric - DefaultSettings.fontSize; | ||
|
|
||
| if(!isNaN(fontSizeOffset)) { | ||
| PreferencesManager.setViewState("fontSizeAdjustment", fontSizeOffset); | ||
| PreferencesManager.setViewState("fontSizeStyle", fontSize); | ||
| } | ||
| } | ||
|
|
||
| // Let's make sure we use Themes fonts by default | ||
| return { | ||
| init: ViewCommandsManager | ||
| }; | ||
| }); | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
| /** | ||
|
Contributor
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. The font settings should be merged with the Increase/Decrease Font Size commands. I am thinking that we should make the Since we don't have an UI for the preferences I am not sure if we should keep the UI used with the themes or just don't use any UI at the moment.
Contributor
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. Maybe all these can be part of a different PR.
Contributor
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. We need a UI to change themes at the very least, and I'd rather we have a dialog box with a few appearance-related settings than add a top-level menu.
Contributor
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 don't mind keeping the dialog. But when saving, it should only change the preferences values and the code in View Commands Manger can deal with the preference change.
Contributor
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. Yeah, that makes sense.
Contributor
Author
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. @TomMalbran Yeah, optimally font values will be read/set from a core api. I remember some conversation we had around this here #7185. The idea was to make possibly make _adjustFontSize public. Adding the settings as you explain as view states will definitely help in the long run. If some makes those changes, I will be happy to make use of them.
Contributor
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've opened #7800 to log that we should change the font size handling before landing themes.
Contributor
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. Great. Once #7800 is merged, we should remove all the preferences here, and just call the methods from the View Commands.
Contributor
Author
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. Yeap, that would be super awesome and will clean up the code real nicely. |
||
| * Brackets Themes Copyright (c) 2014 Miguel Castillo. | ||
| * | ||
| * Licensed under MIT | ||
| */ | ||
|
|
||
|
|
||
| define(function () { | ||
| "use strict"; | ||
|
|
||
| var $lineHeight = $("<style type='text/css' id='lineHeight'>").appendTo("head"), | ||
| $fontSize = $("<style type='text/css' id='fontSize'>").appendTo("head"), | ||
| $fontType = $("<style type='text/css' id='fontType'>").appendTo("head"); | ||
|
|
||
| var Settings = null; | ||
|
|
||
|
|
||
| function FontSettings(_settings) { | ||
| Settings = _settings; | ||
| $(Settings).on("change:lineHeight", FontSettings.updateLineHeight); | ||
| $(Settings).on("change:fontSize", FontSettings.updateFontSize); | ||
| $(Settings).on("change:fontType", FontSettings.updateFontType); | ||
| FontSettings.update(); | ||
| } | ||
|
|
||
|
|
||
| FontSettings.updateLineHeight = function () { | ||
| clearFonts(); | ||
| var value = Settings.getValue("lineHeight"); | ||
| $lineHeight.text(".CodeMirror{" + "line-height: " + value + "; }"); | ||
| }; | ||
|
|
||
|
|
||
| FontSettings.updateFontSize = function () { | ||
| clearFonts(); | ||
| var value = Settings.getValue("fontSize"); | ||
| $fontSize.text(".CodeMirror{" + "font-size: " + value + " !important; }"); | ||
| }; | ||
|
|
||
|
|
||
| FontSettings.updateFontType = function () { | ||
| clearFonts(); | ||
| var value = Settings.getValue("fontType"); | ||
| $fontType.text(".CodeMirror{" + "font-family: " + value + " !important; }"); | ||
| }; | ||
|
|
||
|
|
||
| FontSettings.update = function () { | ||
| clearFonts(); | ||
| FontSettings.updateLineHeight(); | ||
| FontSettings.updateFontSize(); | ||
| FontSettings.updateFontType(); | ||
| }; | ||
|
|
||
|
|
||
| function clearFonts() { | ||
| // Remove this tag that is intefering with font settings set in this module | ||
| $("#codemirror-dynamic-fonts").remove(); | ||
| } | ||
|
|
||
| return FontSettings; | ||
| }); | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| /** | ||
| * Brackets Themes Copyright (c) 2014 Miguel Castillo. | ||
| * | ||
| * Licensed under MIT | ||
| */ | ||
|
|
||
|
|
||
| define(function (require, exports, module) { | ||
| "use strict"; | ||
|
|
||
| require("themes/String"); | ||
| require("themes/MenuCommands"); | ||
|
|
||
| var ExtensionUtils = require("utils/ExtensionUtils"), | ||
| ThemeManager = require("themes/ThemeManager"), | ||
| CodeMirrorAddons = require("themes/CodeMirrorAddons"); | ||
|
|
||
| // Load up reset.css to override brackground settings from brackets because | ||
| // they make the themes look really bad. | ||
| ExtensionUtils.loadStyleSheet(module, "reset.css"); | ||
| ExtensionUtils.loadStyleSheet(module, "views/settings.css"); | ||
|
|
||
| function init() { | ||
| CodeMirrorAddons.ready(ThemeManager); | ||
| } | ||
|
|
||
| exports.init = init; | ||
| }); | ||
|
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| Copyright (c) 2014 Miguel Castillo. | ||
|
Contributor
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. This file just goes away as all of our code is MIT and newly contributed code comes in under the CLA. |
||
|
|
||
| Licensed under MIT | ||
|
|
||
| Permission is hereby granted, free of charge, to any person obtaining a | ||
| copy of this software and associated documentation files (the "Software"), | ||
| to deal in the Software without restriction, including without limitation | ||
| the rights to use, copy, modify, merge, publish, distribute, sublicense, | ||
| and/or sell copies of the Software, and to permit persons to whom the | ||
| Software is furnished to do so, subject to the following conditions: | ||
|
|
||
| The above copyright notice and this permission notice shall be included in | ||
| all copies or substantial portions of the Software. | ||
|
|
||
| THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
| IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
| FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
| AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
| LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | ||
| FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | ||
| DEALINGS IN THE SOFTWARE. | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| /** | ||
| * Brackets Themes Copyright (c) 2014 Miguel Castillo. | ||
| * | ||
| * Licensed under MIT | ||
| */ | ||
|
|
||
|
|
||
| define(function(require) { | ||
| "use strict"; | ||
| var Commands = require("command/Commands"), | ||
| CommandManager = require("command/CommandManager"), | ||
| Settings = require("themes/Settings"); | ||
|
|
||
| CommandManager.register("Themes", Commands.THEMES, Settings.open); | ||
| }); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,87 @@ | ||
| Brackets-Themes | ||
| =============== | ||
|
|
||
| Set CodeMirror and Custom themes in Brackets. | ||
|
|
||
|
|
||
| Features | ||
| =============== | ||
|
|
||
| * Automatic loading of CodeMirror's themes shipped with Brackets. | ||
| * Enjoy a variety of <i>custom</i> themes created by other users like yourself! For <i>custom</i> themes 101 primer, please read below. | ||
| * Configure font size and font type. | ||
| * Disable scrollbars defined in themes. Good if you just want to use the default scrollbars. | ||
| * Support for LESS files! | ||
| * Auto reload themes upon saving changes made to theme files. | ||
| * Configure custom folders to load themes from. This is good if you want to have a folder to hold your custom themes that you want to persist after Brackets/Themes updates. | ||
|
|
||
|
|
||
| Screenshot | ||
| =============== | ||
| <b>Visual Studio theme</b> | ||
|  | ||
|
|
||
| <b>Monokai Dark Soda custom theme by @simpleshadow.</b> | ||
|  | ||
|
|
||
| Custom themes 101 guide | ||
| =============== | ||
|
|
||
| Custom themes are codemirror's themes, so you will need to be familiar with codemirror's theme guidelines. I provide a set of steps to get you started below, but for more details please navigate to http://codemirror.net/doc/manual.html and search for "theme". | ||
| <br><br> | ||
| Codemirror's themes are css files. Important requirement is that the file name has to match your css class definition. E.g. If your theme file is called "default", then your primary css class name needs to be "default". Codemirror's guidelines require that the actual css class name starts with ".cm-s-", so your fully qualified css class name will be ".cm-s-default". | ||
| <br><br> | ||
| To get you started, you could use the already existing custom theme "default.css". Let's do the following. | ||
| <br> | ||
| - Open the custom theme directory. Navigate to your themes manager directory (extensions directory/themes) and you will find custom themes in the "theme" directory. Brackets provides a quick way of accessing your extensions directory... Help > Show Extensions Folder. | ||
| - Copy and paste the file "default.css" and rename it to "my-theme.css". | ||
| - Open "my-theme.css" and replace "default" with "my-theme", which should end up looking like ".cm-s-my-theme". You will also have a second class ".CodeMirror", just leave it there and the net result will look like ".cm-s-my-theme.CodeMirror". | ||
| - In "my-theme.css", change "background-color: #F8F8F8;" to "backgound-color: red;". | ||
| - Relaunch brackets, open a JavaScript file and you should see the document with a red background. | ||
| <br><br> | ||
| For details on what can be customized, please navigate to http://codemirror.net/doc/manual.html and search for "Customized Styling". As you will notice, the documentation isn't exhautive but they suggest you use "codemirror.css" as a reference. Give it a try, it is pretty straight forward. | ||
| <br><br> | ||
| If you have a cool theme you created and want to share, please send it my way and I will gladly add it to the custom themes. | ||
|
|
||
|
|
||
| FAQ | ||
| =============== | ||
|
|
||
| * Why disabling/enabling the scrollbars don't always take effect? | ||
| - This due to the fact that CodeMirror builds "fake" scrollbars that only get created when the document is loaded. So toggling the scrollbars with the document open might not take effect as expected. To get around this behavior, reopen the document or restart Brackets. | ||
|
|
||
|
|
||
| How to | ||
| =============== | ||
|
|
||
| * Install... Open Brackets then copy and paste https://github.com/MiguelCastillo/Brackets-Themes into File->Install Extension. You don't need to restart Brackets. | ||
| * Set a theme? Find the Themes menu and make a selection. | ||
|  | ||
|
|
||
| Credit | ||
| ============== | ||
| Corey Gwin: Monokai Dark Soda<br> | ||
| Kulcsár Kázmér: Zamiere<br> | ||
| Diego Alvarez: Aquaman<br> | ||
| Felipe K. de Mello: Dracula<br> | ||
| Fernando Hurtado: Nando<br> | ||
| Jordan Hess: Pixie<br> | ||
| John Hamm: Hammsidian<br> | ||
| Christopher Kelly (scriptmunkee) for additions to reset.cs<br> | ||
|
|
||
|
|
||
| Links | ||
| =============== | ||
| Brackets? Right here... http://brackets.io/ <br> | ||
| Brackets github? Right here... https://github.com/adobe/brackets | ||
|
|
||
|
|
||
| Contact me | ||
| =============== | ||
|
|
||
| If you have any issues or want to just drop in a line, you can use my personal email at manchagnu@gmail.com | ||
|
|
||
| License | ||
| =============== | ||
|
|
||
| Licensed under MIT |
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.
Stay in sync with the detailed comments of the other entries.
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.
We should probably also use
CMD_THEMESafter the change done with the Find commands