├── examples ├── c.c ├── .jscsrc ├── .jshintrc ├── .project ├── .todo ├── cfm.cfm ├── cfml.cfml ├── clj.clj ├── css.css ├── html.html ├── hx.hx ├── ico.ico ├── jade.jade ├── java.java ├── jpg.jpg ├── json.json ├── less.less ├── log.log ├── lua.lua ├── mp3.mp3 ├── mp4.mp4 ├── pdf.pdf ├── php.php ├── pl.pl ├── png.png ├── puppet.pp ├── py.py ├── ruby.rb ├── sass.sass ├── shell.sh ├── sqf.sqf ├── sql.sql ├── svg.svg ├── text.txt ├── tiff.tiff ├── ttf.ttf ├── vb.vb ├── xml.xml ├── yaml.yaml ├── zip.zip ├── .classpath ├── .editorconfig ├── .gitignore ├── .gitmodules ├── .jshintignore ├── apache.conf ├── git.gitignore ├── git.gitmodules ├── groovy.groovy ├── javascript.js ├── livescript.ls ├── markdown.md ├── npm.npmignore ├── scala.scala ├── stylus.styl ├── typescript.ts ├── apache.htaccess ├── apache.htpasswd ├── coffeescript.coffee └── gif.gif ├── styles └── style.css ├── package.json ├── LICENSE ├── README.md └── main.js /examples/c.c: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /examples/.jscsrc: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /examples/.jshintrc: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /examples/.project: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /examples/.todo: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /examples/cfm.cfm: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /examples/cfml.cfml: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /examples/clj.clj: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /examples/css.css: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /examples/html.html: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /examples/hx.hx: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /examples/ico.ico: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /examples/jade.jade: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /examples/java.java: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /examples/jpg.jpg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /examples/json.json: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /examples/less.less: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /examples/log.log: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /examples/lua.lua: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /examples/mp3.mp3: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /examples/mp4.mp4: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /examples/pdf.pdf: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /examples/php.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /examples/pl.pl: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /examples/png.png: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /examples/puppet.pp: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /examples/py.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /examples/ruby.rb: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /examples/sass.sass: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /examples/shell.sh: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /examples/sqf.sqf: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /examples/sql.sql: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /examples/svg.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /examples/text.txt: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /examples/tiff.tiff: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /examples/ttf.ttf: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /examples/vb.vb: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /examples/xml.xml: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /examples/yaml.yaml: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /examples/zip.zip: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /examples/.classpath: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /examples/.editorconfig: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /examples/.gitignore: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /examples/.gitmodules: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /examples/.jshintignore: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /examples/apache.conf: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /examples/git.gitignore: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /examples/git.gitmodules: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /examples/groovy.groovy: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /examples/javascript.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /examples/livescript.ls: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /examples/markdown.md: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /examples/npm.npmignore: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /examples/scala.scala: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /examples/stylus.styl: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /examples/typescript.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /examples/apache.htaccess: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /examples/apache.htpasswd: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /examples/coffeescript.coffee: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /examples/gif.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tjeffree/Brackets-ExtensionHighlight/HEAD/examples/gif.gif -------------------------------------------------------------------------------- /styles/style.css: -------------------------------------------------------------------------------- 1 | .ext-col.bg-on { 2 | border-radius: 8px; 3 | padding: 0 5px 0 0; 4 | color: #fff !important; 5 | } 6 | .ext-col::before { 7 | content: "."; 8 | } -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "tjeffree.extensionhighlighter", 3 | "title": "Extension Highlighter", 4 | "description": "File extension colours in Brackets' file tree.", 5 | "homepage": "https://github.com/tjeffree/Brackets-ExtensionHighlight", 6 | "version": "1.2.6", 7 | "author": "Tony Jeffree (https://github.com/tjeffree)", 8 | "license": "MIT", 9 | 10 | "keywords": [ 11 | "file", 12 | "tree", 13 | "colour", 14 | "color", 15 | "highlight" 16 | ], 17 | "engines": { 18 | "brackets": ">=0.38.0" 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 Tony Jeffree 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Brackets Extension Highlighter 2 | ============================== 3 | This extension adds colours and highlights to file extensions on the brackets file tree. The following files are supported at the moment: 4 | 5 | - JavaScript 6 | - JSON 7 | - TypeScript 8 | - CoffeeScript 9 | - LiveScript 10 | - HTML, HTM 11 | - SVG 12 | - XML 13 | - PHP 14 | - Java, Java Server Pages 15 | - CSS, SASS, Less, Stylus 16 | - Shell script (sh, bat) 17 | - TXT 18 | - Markdown 19 | - PNG, JPG, JPEG, TIFF, ICO 20 | - GIF 21 | - MP4, WebM, OGG 22 | - MP3, WAV 23 | - Jade 24 | - EOT, TTF, WOFF 25 | - GitIgnore, GitModules 26 | - NPMIgnore 27 | - HTAccess, HTPasswd, Conf 28 | - YAML 29 | - Puppet (pp) 30 | - SQL 31 | - Archives (rar, zip, 7z, tgz, tar, gz, bzip) 32 | - PDF 33 | - Other dot Files (classpath, editorconfig, jscsrc, jshintignore, jshintrc, project, todo) 34 | - Ruby (rb) 35 | - Coldfusion (cfm, cfml) 36 | 37 | You can request more file formats by creating an issue. Choose a color (in hex format) and add it to the issue. 38 | 39 | How to install 40 | -------------- 41 | Open Brackets, and click the extensions button on the right. Search for 'Brackets Extension Highlighter' and click install. 42 | 43 | What it looks like 44 | ------------------ 45 | 46 | ![Screenshot](https://raw.githubusercontent.com/tjeffree/Brackets-ExtensionHighlight/master/examples/gif.gif) 47 | 48 | Contributors 49 | ------------ 50 | 51 | * [Akash Vartak](https://github.com/akash-vartak) 52 | * [Michael McIver](https://github.com/mike1104) 53 | 54 | License 55 | ------- 56 | Brackets Extension Highlighter is licensed under the [MIT license](http://opensource.org/licenses/MIT). 57 | 58 | --- 59 | 60 | The base for this repo is a fork from [ivogabe/Brackets-Icons](https://github.com/ivogabe/Brackets-Icons) 61 | -------------------------------------------------------------------------------- /main.js: -------------------------------------------------------------------------------- 1 | define(function(require, exports, module) { 2 | "use strict"; 3 | 4 | var CLASS_PREFIX = 'b-exthl-', 5 | fileInfo = {}, 6 | sideBarColour = null, 7 | bgLuminance, 8 | constrastCache = {}, 9 | menuCmd, 10 | _preferences, 11 | preferencesId = "tjeffree.extensionhighlighter", 12 | CONTRAST_MENU_ID = preferencesId + ".toggle", 13 | 14 | PreferencesManager = brackets.getModule("preferences/PreferencesManager"), 15 | ProjectManager = brackets.getModule('project/ProjectManager'), 16 | DocumentManager = brackets.getModule('document/DocumentManager'), 17 | ExtensionUtils = brackets.getModule("utils/ExtensionUtils"); 18 | 19 | // Manage some startup tasks 20 | (function() { 21 | 22 | // Get initial sidebar colour and luminance 23 | sideBarColour = $('#sidebar').css('backgroundColor').match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/); 24 | 25 | if (sideBarColour === null) { 26 | // Set to default value 27 | sideBarColour = [0,68,71,73]; 28 | } 29 | 30 | bgLuminance = luminanace(sideBarColour[1],sideBarColour[2],sideBarColour[3]); 31 | 32 | 33 | // Add menu item to disable background contrast (might make some extensions hard to read) as per #16 34 | var CommandManager = brackets.getModule("command/CommandManager"), 35 | Menus = brackets.getModule("command/Menus"); 36 | 37 | menuCmd = CommandManager.get(CONTRAST_MENU_ID); 38 | 39 | if (!menuCmd) { 40 | menuCmd = CommandManager.register("Disable Contrast In File Tree", CONTRAST_MENU_ID, handleConstrastSwitch); 41 | } else { 42 | menuCmd._commandFn = handleConstrastSwitch; 43 | } 44 | 45 | var menu = Menus.getMenu(Menus.AppMenuBar.VIEW_MENU); 46 | menu.addMenuItem(CONTRAST_MENU_ID); 47 | 48 | menuCmd.on("checkedStateChange", onCheckedStateChange); 49 | 50 | loadPreferences(); 51 | 52 | menuCmd.setChecked(_preferences.get("checked")); 53 | 54 | 55 | })(); 56 | 57 | function addDef(extension, color) { 58 | fileInfo[extension] = { 59 | color: color 60 | }; 61 | } 62 | function addAlias(extension, other) { 63 | fileInfo[extension] = fileInfo[other]; 64 | } 65 | 66 | // XML 67 | addDef('xml', '#ff6600'); 68 | addDef('html', '#E34C26'); 69 | addAlias('htm', 'html'); 70 | 71 | // Stylesheets 72 | addDef('css', '#0270b9'); 73 | addDef('scss', '#c6538c'); 74 | addAlias('sass', 'scss'); 75 | addDef('less', '#2b5086'); 76 | addDef('styl', '#b3d107'); 77 | 78 | // JavaScript 79 | addDef('js', '#e5a228'); 80 | addDef('ts', '#0074c1'); 81 | addDef('coffee', '#425d99'); 82 | addAlias('eco', 'coffee'); 83 | addDef('json', '#e5a228'); 84 | addDef('ls', '#369bd7'); 85 | 86 | // Server side 87 | addDef('php', '#6976c3'); 88 | 89 | // Java 90 | addDef('java', '#5382A1'); 91 | addAlias('class', 'java'); 92 | 93 | // Java server pages 94 | addAlias('jsp', 'html'); 95 | 96 | // Shell 97 | addDef('sh', '#008d00'); 98 | addDef('bat', '#60c910'); 99 | 100 | // Images 101 | addDef('png', '#dbb1a9'); 102 | addDef('jpg', '#dedfa3'); 103 | addAlias('jpeg', 'jpg'); 104 | addDef('tiff', '#ff4000'); 105 | addDef('ico', '#b6d2d1'); 106 | addDef('gif', '#aaecc0'); 107 | addDef('svg', '#c0c5eb'); 108 | 109 | // Videos 110 | addDef('mp4', '#008d00'); 111 | addAlias('webm', 'mp4'); 112 | addAlias('ogg', 'mp4'); 113 | 114 | // Audio 115 | addDef('mp3', '#921100'); 116 | addAlias('wav', 'mp3'); 117 | 118 | // Documents 119 | addDef('md', '#b94700'); 120 | addAlias('markdown','md'); 121 | addDef('pdf', '#FF0000'); 122 | 123 | // Templating 124 | addDef('jade', '#00a86b'); 125 | 126 | // Git 127 | addDef('gitignore', '#f64d27'); 128 | addDef('gitmodules','#f64d27'); 129 | 130 | // Fonts 131 | addDef('ttf', '#b42950'); 132 | addAlias('eot', 'ttf'); 133 | addAlias('woff', 'ttf'); 134 | 135 | // Webservers 136 | addDef('htaccess', '#e41a54'); 137 | addDef('htpasswd', '#6c369c'); 138 | addDef('conf', '#009900'); 139 | 140 | // Puppet 141 | addDef('pp', '#7761A7'); 142 | 143 | // SQL 144 | addDef('sql', '#008DBB'); 145 | addDef('sqf', '#b9e11f'); 146 | 147 | // Archives 148 | addDef('zip', '#008858'); 149 | addDef('rar', '#005888'); 150 | addDef('7z', '#880058'); 151 | addDef('tgz', '#7900BC'); 152 | addDef('tar', '#885800'); 153 | addDef('gz', '#588800'); 154 | addDef('bzip', '#884300'); 155 | 156 | // Other text files 157 | addDef('txt', '#4192c1'); 158 | addDef('log', '#225dc9'); 159 | addDef('npmignore', '#cb3837'); 160 | addDef('yml', '#008000'); 161 | addAlias('yaml', 'yml'); 162 | 163 | // Other dot files 164 | addDef('classpath', '#bbbbbb'); 165 | addDef('properties', '#00ff00'); 166 | addAlias('editorconfig', 'classpath'); 167 | addAlias('jscsrc', 'classpath'); 168 | addAlias('jshintignore', 'classpath'); 169 | addAlias('jshintrc', 'classpath'); 170 | addAlias('project', 'classpath'); 171 | addAlias('todo', 'classpath'); 172 | 173 | // Ruby 174 | addDef('rb', '#CC342D'); 175 | 176 | // Coldfusion 177 | addDef('cfm', '#74B1D4'); 178 | addAlias('cfml', 'cfm'); 179 | 180 | // Haxe 181 | addDef('hx', '#be9c17'); 182 | 183 | // Lua 184 | addDef('lua', '#11d2bf'); 185 | 186 | // Lua 187 | addDef('pl', '#0000ff'); 188 | 189 | // C/C++/C# 190 | addDef('c', '#008985'); 191 | addAlias('cs', 'c'); 192 | addAlias('cpp', 'c'); 193 | 194 | // VB 195 | addDef('vb', '#0000ff'); 196 | addDef('vbs', '#00ff00'); 197 | 198 | // Groovy 199 | addDef('groovy', '#0000ff'); 200 | 201 | // Scala 202 | addDef('scala', '#b19714'); 203 | 204 | // Clojure 205 | addDef('clj', '#e1ce29'); 206 | 207 | // Python 208 | addDef('py', '#fdca3c'); 209 | 210 | //Lex and Yacc files 211 | addDef('l', '#cc00ff'); 212 | addAlias('lex', 'l'); 213 | addDef('y', '#ff0066'); 214 | addAlias('yacc', 'y'); 215 | 216 | //Header files 217 | addDef('h', '#00ffff'); 218 | 219 | var def = { 220 | color: 'rgb(187, 187, 187)' 221 | } 222 | 223 | // Add new modules for V0.44+ 224 | try { 225 | var 226 | MainViewManager = brackets.getModule('view/MainViewManager'), 227 | FileTreeView = brackets.getModule("project/FileTreeView"); 228 | } catch (e) { /* do nothing */ } 229 | 230 | ExtensionUtils.loadStyleSheet(module, "styles/style.css"); 231 | 232 | // Create the CSS for all the classes 233 | (function(){ 234 | 235 | // V0.44+ only 236 | if (!FileTreeView) { 237 | return; 238 | } 239 | 240 | createStyles(); 241 | 242 | })(); 243 | 244 | function createStyles() { 245 | 246 | $('#ext-highlight').remove(); 247 | 248 | // Create a new stylesheet and populate with file settings 249 | var contrast, 250 | newStyle, 251 | style = document.createElement('style'); 252 | 253 | style.setAttribute('media','screen'); 254 | style.appendChild(document.createTextNode('')); 255 | style.id = 'ext-highlight'; 256 | 257 | document.head.appendChild(style); 258 | 259 | for (var ext in fileInfo) { 260 | 261 | contrast = getContrast(fileInfo[ext].color); 262 | 263 | if (contrast === false) { 264 | newStyle = "color: #f1f1f1; " 265 | + "background: linear-gradient(to right, rgba(0,0,0,0) 0%, " + fileInfo[ext].color + " 33%); " 266 | + "border-radius: 8px; " 267 | + "padding-right: 5px;"; 268 | } else { 269 | newStyle = 'color: ' + fileInfo[ext].color + ';'; 270 | } 271 | 272 | style.sheet.insertRule('.jstree-brackets li.' + CLASS_PREFIX + ext + ' span.extension {' + newStyle + '}', 0); 273 | 274 | } 275 | } 276 | 277 | function renderFiles(container, requireLeaf) { 278 | 279 | var aList = document.querySelectorAll(container + ' li>a'); 280 | 281 | if (aList.length > 0) { 282 | 283 | $(container + ' li>a>.ext-col').remove(); 284 | $(container + ' li>a>.extension').show(); 285 | 286 | [].forEach.call( aList , function(el) { 287 | 288 | if (requireLeaf === true && !el.parentNode.classList.contains('jstree-leaf')) { 289 | return false; 290 | } 291 | 292 | parseExtension( el.querySelector('.extension') ); 293 | }); 294 | 295 | } 296 | 297 | } 298 | 299 | function parseExtension(ext) { 300 | 301 | if (ext === null) { 302 | return; 303 | } 304 | 305 | var allExt = ext.innerText.substr(1).split('.'), 306 | x = 0, 307 | extLen = allExt.length, 308 | data; 309 | 310 | if (extLen === 0) { 311 | return; 312 | } 313 | 314 | for (;x= 0) { 426 | ext = ext.substr(lastIndex + 1); 427 | 428 | if (fileInfo.hasOwnProperty(ext)) { 429 | return CLASS_PREFIX + ext; 430 | } 431 | } 432 | 433 | return; 434 | 435 | }); 436 | } 437 | 438 | if (MainViewManager) { 439 | MainViewManager.on("workingSetAdd workingSetAddList workingSetRemove workingSetRemoveList fileNameChange pathDeleted workingSetSort workingSetUpdate currentFileChange", function(e) { 440 | // renderFiles('.open-files-container'); 441 | setTimeout(function() { renderFiles('.open-files-container'); }, 1); 442 | }); 443 | } else { 444 | DocumentManager.on("workingSetAdd workingSetAddList workingSetRemove workingSetRemoveList fileNameChange pathDeleted workingSetSort", function(e) { 445 | renderFiles('.open-files-container'); 446 | }); 447 | } 448 | 449 | renderFiles('.open-files-container'); 450 | 451 | }); 452 | --------------------------------------------------------------------------------