diff --git a/src/config-schema.js b/src/config-schema.js index 97a6d16f3..343726d2c 100644 --- a/src/config-schema.js +++ b/src/config-schema.js @@ -355,6 +355,21 @@ const configSchema = { type: 'boolean', default: false, description: 'Experimental: Use the new Tree-sitter parsing system for supported languages.' + }, + colorProfile: { + description: "Specify whether Atom should use the operating system's color profile (recommended) or an alternative color profile.
Changing this setting will require a relaunch of Atom to take effect.", + type: 'string', + default: 'default', + enum: [ + { + value: 'default', + description: 'Use color profile configured in the operating system' + }, + { + value: 'srgb', + description: 'Use sRGB color profile' + } + ] } } }, diff --git a/src/main-process/start.js b/src/main-process/start.js index 23b4df594..25bc9c00d 100644 --- a/src/main-process/start.js +++ b/src/main-process/start.js @@ -5,6 +5,9 @@ const temp = require('temp').track() const parseCommandLine = require('./parse-command-line') const startCrashReporter = require('../crash-reporter-start') const atomPaths = require('../atom-paths') +const fs = require('fs') +const CSON = require('season') +const Config = require('../config') module.exports = function start (resourcePath, startTime) { global.shellStartTime = startTime @@ -39,6 +42,12 @@ module.exports = function start (resourcePath, startTime) { atomPaths.setUserData(app) setupCompileCache() + const config = getConfig() + const colorProfile = config.get('core.colorProfile') + if (colorProfile && colorProfile !== 'default') { + app.commandLine.appendSwitch('force-color-profile', colorProfile) + } + if (handleStartupEventWithSquirrel()) { return } else if (args.test && args.mainProcess) { @@ -97,3 +106,21 @@ function setupCompileCache () { CompileCache.setAtomHomeDirectory(process.env.ATOM_HOME) CompileCache.install(process.resourcesPath, require) } + +function getConfig () { + const config = new Config() + + let configFilePath + if (fs.existsSync(path.join(process.env.ATOM_HOME, 'config.json'))) { + configFilePath = path.join(process.env.ATOM_HOME, 'config.json') + } else if (fs.existsSync(path.join(process.env.ATOM_HOME, 'config.cson'))) { + configFilePath = path.join(process.env.ATOM_HOME, 'config.cson') + } + + if (configFilePath) { + const configFileData = CSON.readFileSync(configFilePath) + config.resetUserSettings(configFileData) + } + + return config +} diff --git a/src/scope-descriptor.coffee b/src/scope-descriptor.coffee deleted file mode 100644 index f1070f277..000000000 --- a/src/scope-descriptor.coffee +++ /dev/null @@ -1,63 +0,0 @@ -# Extended: Wraps an {Array} of `String`s. The Array describes a path from the -# root of the syntax tree to a token including _all_ scope names for the entire -# path. -# -# Methods that take a `ScopeDescriptor` will also accept an {Array} of {String} -# scope names e.g. `['.source.js']`. -# -# You can use `ScopeDescriptor`s to get language-specific config settings via -# {Config::get}. -# -# You should not need to create a `ScopeDescriptor` directly. -# -# * {TextEditor::getRootScopeDescriptor} to get the language's descriptor. -# * {TextEditor::scopeDescriptorForBufferPosition} to get the descriptor at a -# specific position in the buffer. -# * {Cursor::getScopeDescriptor} to get a cursor's descriptor based on position. -# -# See the [scopes and scope descriptor guide](http://flight-manual.atom.io/behind-atom/sections/scoped-settings-scopes-and-scope-descriptors/) -# for more information. -module.exports = -class ScopeDescriptor - @fromObject: (scopes) -> - if scopes instanceof ScopeDescriptor - scopes - else - new ScopeDescriptor({scopes}) - - ### - Section: Construction and Destruction - ### - - # Public: Create a {ScopeDescriptor} object. - # - # * `object` {Object} - # * `scopes` {Array} of {String}s - constructor: ({@scopes}) -> - - # Public: Returns an {Array} of {String}s - getScopesArray: -> @scopes - - getScopeChain: -> - # For backward compatibility, prefix TextMate-style scope names with - # leading dots (e.g. 'source.js' -> '.source.js'). - if @scopes[0]?.includes('.') - result = '' - for scope, i in @scopes - result += ' ' if i > 0 - result += '.' if scope[0] isnt '.' - result += scope - result - else - @scopes.join(' ') - - toString: -> - @getScopeChain() - - isEqual: (other) -> - if @scopes.length isnt other.scopes.length - return false - for scope, i in @scopes - if scope isnt other.scopes[i] - return false - true diff --git a/src/scope-descriptor.js b/src/scope-descriptor.js new file mode 100644 index 000000000..63075e8a1 --- /dev/null +++ b/src/scope-descriptor.js @@ -0,0 +1,80 @@ +// Extended: Wraps an {Array} of `String`s. The Array describes a path from the +// root of the syntax tree to a token including _all_ scope names for the entire +// path. +// +// Methods that take a `ScopeDescriptor` will also accept an {Array} of {String} +// scope names e.g. `['.source.js']`. +// +// You can use `ScopeDescriptor`s to get language-specific config settings via +// {Config::get}. +// +// You should not need to create a `ScopeDescriptor` directly. +// +// * {TextEditor::getRootScopeDescriptor} to get the language's descriptor. +// * {TextEditor::scopeDescriptorForBufferPosition} to get the descriptor at a +// specific position in the buffer. +// * {Cursor::getScopeDescriptor} to get a cursor's descriptor based on position. +// +// See the [scopes and scope descriptor guide](http://flight-manual.atom.io/behind-atom/sections/scoped-settings-scopes-and-scope-descriptors/) +// for more information. +module.exports = +class ScopeDescriptor { + static fromObject (scopes) { + if (scopes instanceof ScopeDescriptor) { + return scopes + } else { + return new ScopeDescriptor({scopes}) + } + } + + /* + Section: Construction and Destruction + */ + + // Public: Create a {ScopeDescriptor} object. + // + // * `object` {Object} + // * `scopes` {Array} of {String}s + constructor ({scopes}) { + this.scopes = scopes + } + + // Public: Returns an {Array} of {String}s + getScopesArray () { + return this.scopes + } + + getScopeChain () { + // For backward compatibility, prefix TextMate-style scope names with + // leading dots (e.g. 'source.js' -> '.source.js'). + if (this.scopes[0] != null && this.scopes[0].includes('.')) { + let result = '' + for (let i = 0; i < this.scopes.length; i++) { + const scope = this.scopes[i] + if (i > 0) { result += ' ' } + if (scope[0] !== '.') { result += '.' } + result += scope + } + return result + } else { + return this.scopes.join(' ') + } + } + + toString () { + return this.getScopeChain() + } + + isEqual (other) { + if (this.scopes.length !== other.scopes.length) { + return false + } + for (let i = 0; i < this.scopes.length; i++) { + const scope = this.scopes[i] + if (scope !== other.scopes[i]) { + return false + } + } + return true + } +}