From e5e5c497e1b7720c8226345f303d4c7f12608d2b Mon Sep 17 00:00:00 2001 From: Corey Johnson Date: Wed, 26 Dec 2012 14:38:25 -0800 Subject: [PATCH] Load themes from ~/.atom/themes --- .atom/themes/IR_Black.tmTheme | 810 +++++++++++++++++++++++++++++++++ Rakefile | 20 +- script/copy-files-to-bundle | 2 +- src/app/atom.coffee | 4 +- src/app/config.coffee | 2 + src/app/text-mate-theme.coffee | 23 +- src/app/window.coffee | 1 - 7 files changed, 841 insertions(+), 21 deletions(-) create mode 100644 .atom/themes/IR_Black.tmTheme diff --git a/.atom/themes/IR_Black.tmTheme b/.atom/themes/IR_Black.tmTheme new file mode 100644 index 000000000..cbc18d0b9 --- /dev/null +++ b/.atom/themes/IR_Black.tmTheme @@ -0,0 +1,810 @@ + + + + + name + IR_Black + settings + + + settings + + background + #000000 + caret + #FFFFFF + foreground + #EDEDED + invisibles + #CAE2FB3D + lineHighlight + #FFFFFF24 + selection + #333333 + + + + name + Comment + scope + comment + settings + + fontStyle + + foreground + #7C7C7C + + + + name + Entity + scope + entity + settings + + fontStyle + + foreground + #FFD2A7 + + + + name + Keyword + scope + keyword + settings + + fontStyle + + foreground + #96CBFE + + + + name + Keyword.control + scope + keyword.control + settings + + fontStyle + + foreground + #96CBFE + + + + name + Keyword.Operator + scope + keyword.operator + settings + + foreground + #EDEDED + + + + name + Class + scope + entity.name.type + settings + + fontStyle + underline + foreground + #FFFFB6 + + + + name + Support + scope + support + settings + + fontStyle + + foreground + #FFFFB6 + + + + name + Storage + scope + storage + settings + + fontStyle + + foreground + #CFCB90 + + + + name + Storage.modifier + scope + storage.modifier + settings + + fontStyle + + foreground + #96CBFE + + + + name + Constant + scope + constant + settings + + fontStyle + + foreground + #99CC99 + + + + name + String + scope + string + settings + + fontStyle + bold + foreground + #A8FF60 + + + + name + Number + scope + constant.numeric + settings + + fontStyle + bold + foreground + #FF73FD + + + + name + Punctuation + scope + punctuation + settings + + fontStyle + + + + + name + Variable + scope + variable + settings + + fontStyle + + foreground + #C6C5FE + + + + name + Invalid – Deprecated + scope + invalid.deprecated + settings + + fontStyle + italic underline + foreground + #FD5FF1 + + + + name + Invalid – Illegal + scope + invalid.illegal + settings + + background + #562D56BF + foreground + #FD5FF1 + + + + name + ----------------------------------- + settings + + + + name + ♦ Embedded Source (Bright) + scope + text source + settings + + background + #B1B3BA08 + fontStyle + + + + + name + ♦ Entity inherited-class + scope + entity.other.inherited-class + settings + + fontStyle + italic + foreground + #9B5C2E + + + + name + ♦ String embedded-variable + scope + source string source + settings + + fontStyle + + foreground + #EDEDED + + + + name + ♦ String punctuation + scope + source string source punctuation.section.embedded + settings + + fontStyle + + foreground + #00A0A0 + + + + name + ♦ String constant + scope + string constant + settings + + fontStyle + + foreground + #00A0A0 + + + + name + ♦ String.regexp + scope + string.regexp + settings + + foreground + #E9C062 + + + + name + ♦ String.regexp.«special» + scope + string.regexp constant.character.escape, string.regexp source.ruby.embedded, string.regexp string.regexp.arbitrary-repitition + settings + + fontStyle + + foreground + #FF8000 + + + + name + ♦ String.regexp.group + scope + string.regexp.group + settings + + background + #FFFFFF0F + fontStyle + + foreground + #C6A24F + + + + name + ♦ String.regexp.character-class + scope + string.regexp.character-class + settings + + fontStyle + + foreground + #B18A3D + + + + name + ♦ String variable + scope + string variable + settings + + fontStyle + + foreground + #8A9A95 + + + + name + ♦ Support.function + scope + support.function + settings + + fontStyle + + foreground + #DAD085 + + + + name + ♦ Support.constant + scope + support.constant + settings + + fontStyle + + foreground + #FFD2A7 + + + + name + c C/C++ Preprocessor Line + scope + meta.preprocessor.c + settings + + foreground + #8996A8 + + + + name + c C/C++ Preprocessor Directive + scope + meta.preprocessor.c keyword + settings + + fontStyle + + foreground + #AFC4DB + + + + name + j Cast + scope + meta.cast + settings + + fontStyle + italic + foreground + #676767 + + + + name + ✘ Doctype/XML Processing + scope + meta.sgml.html meta.doctype, meta.sgml.html meta.doctype entity, meta.sgml.html meta.doctype string, meta.xml-processing, meta.xml-processing entity, meta.xml-processing string + settings + + foreground + #494949 + + + + name + ✘ Meta.tag.«all» + scope + meta.tag, meta.tag entity + settings + + fontStyle + bold + foreground + #96CBFE + + + + name + ✘ Meta.tag.inline + scope + source entity.name.tag, source entity.other.attribute-name, meta.tag.inline, meta.tag.inline entity + settings + + fontStyle + + foreground + #96CBFE + + + + name + ✘ Meta.tag.attribute-name + scope + entity.other.attribute-name + settings + + fontStyle + + foreground + #FFD7B1 + + + + name + ✘ Namespaces + scope + entity.name.tag.namespace, entity.other.attribute-name.namespace + settings + + fontStyle + + foreground + #E18964 + + + + name + § css tag-name + scope + meta.selector.css entity.name.tag + settings + + fontStyle + underline + foreground + #96CBFE + + + + name + § css:pseudo-class + scope + meta.selector.css entity.other.attribute-name.tag.pseudo-class + settings + + fontStyle + + foreground + #8F9D6A + + + + name + § css#id + scope + meta.selector.css entity.other.attribute-name.id + settings + + fontStyle + + foreground + #8B98AB + + + + name + § css.class + scope + meta.selector.css entity.other.attribute-name.class + settings + + fontStyle + + foreground + #62B1FE + + + + name + § css property-name: + scope + support.type.property-name.css + settings + + foreground + #EDEDED + + + + name + § css property-value; + scope + meta.property-group support.constant.property-value.css, meta.property-value support.constant.property-value.css + settings + + fontStyle + + foreground + #F9EE98 + + + + name + § css @at-rule + scope + meta.preprocessor.at-rule keyword.control.at-rule + settings + + foreground + #8693A5 + + + + name + § css additional-constants + scope + meta.property-value support.constant.named-color.css, meta.property-value constant + settings + + fontStyle + + foreground + #87C38A + + + + name + § css constructor.argument + scope + meta.constructor.argument.css + settings + + foreground + #8F9D6A + + + + name + ⎇ diff.header + scope + meta.diff, meta.diff.header + settings + + background + #0E2231 + fontStyle + italic + foreground + #F8F8F8 + + + + name + ⎇ diff.deleted + scope + markup.deleted + settings + + background + #420E09 + foreground + #F8F8F8 + + + + name + ⎇ diff.changed + scope + markup.changed + settings + + background + #4A410D + foreground + #F8F8F8 + + + + name + ⎇ diff.inserted + scope + markup.inserted + settings + + background + #253B22 + foreground + #F8F8F8 + + + + name + -------------------------------- + settings + + + + name + Markup: Italic + scope + markup.italic + settings + + fontStyle + italic + foreground + #E9C062 + + + + name + Markup: Bold + scope + markup.bold + settings + + fontStyle + bold + foreground + #E9C062 + + + + name + Markup: Underline + scope + markup.underline + settings + + fontStyle + underline + foreground + #E18964 + + + + name + Markup: Quote + scope + markup.quote + settings + + background + #FEE09C12 + fontStyle + italic + foreground + #E1D4B9 + + + + name + Markup: Heading + scope + markup.heading, markup.heading entity + settings + + background + #632D04 + fontStyle + + foreground + #FEDCC5 + + + + name + Markup: List + scope + markup.list + settings + + foreground + #E1D4B9 + + + + name + Markup: Raw + scope + markup.raw + settings + + background + #B1B3BA08 + fontStyle + + foreground + #578BB3 + + + + name + Markup: Comment + scope + markup comment + settings + + fontStyle + italic + foreground + #F67B37 + + + + name + Markup: Separator + scope + meta.separator + settings + + background + #242424 + foreground + #60A633 + + + + name + Log Entry + scope + meta.line.entry.logfile, meta.line.exit.logfile + settings + + background + #EEEEEE29 + + + + name + Log Entry Error + scope + meta.line.error.logfile + settings + + background + #751012 + + + + uuid + D039AEA9-9DD2-4237-A963-E84494B0B3FB + + diff --git a/Rakefile b/Rakefile index 4c78ff14d..2dd0680d3 100644 --- a/Rakefile +++ b/Rakefile @@ -60,11 +60,26 @@ end desc "Creates .atom file if non exists" task "create-dot-atom" do + # Migration: If there is still a bundle path, rename it to packages + if File.exists?(DOT_ATOM_PATH) and File.exists?(File.join(DOT_ATOM_PATH, "bundles")) + if File.join(DOT_ATOM_PATH, "packages") + `rm #{File.join(DOT_ATOM_PATH, "bundles")}` + $stderr.puts "WARNING: removed ~/.atom/bundles" + else + `mv #{File.join(DOT_ATOM_PATH, "bundles")} #{File.join(DOT_ATOM_PATH, "packages")}` + $stderr.puts "WARNING: ~/.atom/bundles was moved to ~/.atom/packages" + end + end + + # Migration: If there is no theme directory, create if File.exists?(DOT_ATOM_PATH) and File.exists?(File.join(DOT_ATOM_PATH, "bundles")) `mv #{File.join(DOT_ATOM_PATH, "bundles")} #{File.join(DOT_ATOM_PATH, "packages")}` $stderr.puts "WARNING: ~/.atom/bundles was moved to ~/.atom/packages" end + # Migration: remove files that are no longer needed + `rm -rf #{File.join(DOT_ATOM_PATH, 'default-config.coffee')}` + dot_atom_template_path = ATOM_SRC_PATH + "/.atom" replace_dot_atom = false next if File.exists?(DOT_ATOM_PATH) @@ -73,6 +88,7 @@ task "create-dot-atom" do `mkdir "#{DOT_ATOM_PATH}"` `cp "#{dot_atom_template_path}/atom.coffee" "#{DOT_ATOM_PATH}"` `cp "#{dot_atom_template_path}/packages" "#{DOT_ATOM_PATH}"` + `cp -r "#{dot_atom_template_path}/themes" "#{DOT_ATOM_PATH}"` end desc "Clone default bundles into .atom directory" @@ -107,6 +123,8 @@ end desc "Clean build Atom via `xcodebuild`" task :clean do output = `xcodebuild clean` + `rm -rf #{application_path()}` + `rm -rf #{BUILD_DIR}` end desc "Run Atom" @@ -132,7 +150,7 @@ task :benchmark do end task :nof do - system %{find . -name *spec.coffee | grep -v atom-build | xargs sed -E -i "" "s/f+(it|describe) +(['\\"])/\\1 \\2/g"} + system %{find . -name *spec.coffee | grep -v #{BUILD_DIR} | xargs sed -E -i "" "s/f+(it|describe) +(['\\"])/\\1 \\2/g"} end task :tags do diff --git a/script/copy-files-to-bundle b/script/copy-files-to-bundle index f850405a7..659c87e04 100755 --- a/script/copy-files-to-bundle +++ b/script/copy-files-to-bundle @@ -29,4 +29,4 @@ for COFFEE_FILE in $COFFEE_FILES; do done; # Copy non-coffee files into bundle -rsync --archive --recursive --exclude="src/**/*.coffee" src static vendor spec benchmark themes "$RESOUCES_PATH" +rsync --archive --recursive --exclude="src/**/*.coffee" src static vendor spec benchmark "$RESOUCES_PATH" diff --git a/src/app/atom.coffee b/src/app/atom.coffee index 4e1ae3904..82a406bd7 100644 --- a/src/app/atom.coffee +++ b/src/app/atom.coffee @@ -15,7 +15,9 @@ _.extend atom, getAvailablePackages: -> allPackageNames = [] for packageDirPath in config.packageDirPaths - packageNames = fs.list(packageDirPath).map (packagePath) -> fs.base(packagePath) + packageNames = fs.list(packageDirPath) + .filter((packagePath) -> fs.isDirectory(packagePath)) + .map((packagePath) -> fs.base(packagePath)) allPackageNames.push(packageNames...) _.unique(allPackageNames) diff --git a/src/app/config.coffee b/src/app/config.coffee index 2a1f8dc27..854cc40a5 100644 --- a/src/app/config.coffee +++ b/src/app/config.coffee @@ -9,6 +9,7 @@ configDirPath = fs.absolute("~/.atom") configJsonPath = fs.join(configDirPath, "config.json") userInitScriptPath = fs.join(configDirPath, "atom.coffee") bundledPackagesDirPath = fs.join(resourcePath, "src/packages") +userThemesDirPath = fs.join(configDirPath, "themes") userPackagesDirPath = fs.join(configDirPath, "packages") require.paths.unshift userPackagesDirPath @@ -16,6 +17,7 @@ require.paths.unshift userPackagesDirPath module.exports = class Config configDirPath: configDirPath + themeDirPath: userThemesDirPath packageDirPaths: [userPackagesDirPath, bundledPackagesDirPath] settings: null diff --git a/src/app/text-mate-theme.coffee b/src/app/text-mate-theme.coffee index 70f0602e2..77ff38f96 100644 --- a/src/app/text-mate-theme.coffee +++ b/src/app/text-mate-theme.coffee @@ -4,31 +4,20 @@ plist = require 'plist' module.exports = class TextMateTheme - @themesByName: {} + @load: (name) -> + regex = new RegExp("#{_.escapeRegExp(name)}\.(tmTheme|plist)$", "i") + path = _.find fs.list(config.themeDirPath), (path) -> regex.test(path) + return null unless path - @loadAll: -> - for themePath in fs.list(require.resolve("themes")) - @registerTheme(TextMateTheme.load(themePath)) - - @load: (path) -> - plistString = fs.read(require.resolve(path)) + plistString = fs.read(path) theme = null plist.parseString plistString, (err, data) -> throw new Error("Error loading theme at '#{path}': #{err}") if err theme = new TextMateTheme(data[0]) theme - @registerTheme: (theme) -> - @themesByName[theme.name] = theme - - @getNames: -> - _.keys(@themesByName) - - @getTheme: (name) -> - @themesByName[name] - @activate: (name) -> - if theme = @getTheme(name) + if theme = @load(name) theme.activate() else throw new Error("No theme with name '#{name}'") diff --git a/src/app/window.coffee b/src/app/window.coffee index ed0490d29..4b6d7047d 100644 --- a/src/app/window.coffee +++ b/src/app/window.coffee @@ -27,7 +27,6 @@ windowAdditions = startup: -> @config = new Config @syntax = new Syntax - TextMateTheme.loadAll() @setUpKeymap() @pasteboard = new Pasteboard