Created
December 23, 2014 10:52
-
-
Save miva2/ab2981fd8f3e5f06a2ce to your computer and use it in GitHub Desktop.
Atom files for fixing startup issue - https://github.com/atom/atom-keymap/issues/62
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
(function() { | |
var CoffeeScript, crypto, csonCache, fs, getCachePath, multiplyString, parseContents, parseContentsSync, parseObject, path, stringifyArray, stringifyBoolean, stringifyIndent, stringifyNull, stringifyNumber, stringifyObject, stringifyString, writeCacheFile, writeCacheFileSync, _; | |
crypto = require('crypto'); | |
path = require('path'); | |
_ = require('underscore-plus'); | |
fs = require('fs-plus'); | |
CoffeeScript = null; | |
multiplyString = function(string, n) { | |
return new Array(1 + n).join(string); | |
}; | |
stringifyIndent = function(level) { | |
if (level == null) { | |
level = 0; | |
} | |
return multiplyString(' ', Math.max(level, 0)); | |
}; | |
stringifyString = function(string) { | |
string = JSON.stringify(string); | |
string = string.slice(1, -1); | |
string = string.replace(/\\"/g, '"'); | |
string = string.replace(/'/g, '\\\''); | |
return "'" + string + "'"; | |
}; | |
stringifyBoolean = function(boolean) { | |
return "" + boolean; | |
}; | |
stringifyNumber = function(number) { | |
return "" + number; | |
}; | |
stringifyNull = function() { | |
return 'null'; | |
}; | |
stringifyArray = function(array, indentLevel) { | |
var cson, indent, value, _i, _len; | |
if (indentLevel == null) { | |
indentLevel = 0; | |
} | |
if (array.length === 0) { | |
return '[]'; | |
} | |
cson = '[\n'; | |
for (_i = 0, _len = array.length; _i < _len; _i++) { | |
value = array[_i]; | |
indent = stringifyIndent(indentLevel + 2); | |
cson += indent; | |
if (_.isString(value)) { | |
cson += stringifyString(value); | |
} else if (_.isBoolean(value)) { | |
cson += stringifyBoolean(value); | |
} else if (_.isNumber(value)) { | |
cson += stringifyNumber(value); | |
} else if (_.isNull(value) || value === void 0) { | |
cson += stringifyNull(value); | |
} else if (_.isArray(value)) { | |
cson += stringifyArray(value, indentLevel + 2); | |
} else if (_.isObject(value)) { | |
cson += "{\n" + (stringifyObject(value, indentLevel + 4)) + "\n" + indent + "}"; | |
} else { | |
throw new Error("Unrecognized type for array value: " + value); | |
} | |
cson += '\n'; | |
} | |
return "" + cson + (stringifyIndent(indentLevel)) + "]"; | |
}; | |
stringifyObject = function(object, indentLevel) { | |
var cson, key, prefix, value; | |
if (indentLevel == null) { | |
indentLevel = 0; | |
} | |
if (_.isEmpty(object)) { | |
return '{}'; | |
} | |
cson = ''; | |
prefix = ''; | |
for (key in object) { | |
value = object[key]; | |
if (value === void 0) { | |
continue; | |
} | |
if (_.isFunction(value)) { | |
throw new Error("Function specified as value to key: " + key); | |
} | |
cson += "" + prefix + (stringifyIndent(indentLevel)) + (stringifyString(key)) + ":"; | |
if (_.isString(value)) { | |
cson += " " + (stringifyString(value)); | |
} else if (_.isBoolean(value)) { | |
cson += " " + (stringifyBoolean(value)); | |
} else if (_.isNumber(value)) { | |
cson += " " + (stringifyNumber(value)); | |
} else if (_.isNull(value)) { | |
cson += " " + (stringifyNull(value)); | |
} else if (_.isArray(value)) { | |
cson += " " + (stringifyArray(value, indentLevel)); | |
} else if (_.isObject(value)) { | |
if (_.isEmpty(value)) { | |
cson += ' {}'; | |
} else { | |
cson += "\n" + (stringifyObject(value, indentLevel + 2)); | |
} | |
} else { | |
throw new Error("Unrecognized value type for key: " + key + " with value: " + value); | |
} | |
prefix = '\n'; | |
} | |
return cson; | |
}; | |
csonCache = null; | |
getCachePath = function(cson) { | |
var digest; | |
digest = crypto.createHash('sha1').update(cson, 'utf8').digest('hex'); | |
return path.join(csonCache, "" + digest + ".json"); | |
}; | |
writeCacheFileSync = function(cachePath, object) { | |
try { | |
return fs.writeFileSync(cachePath, JSON.stringify(object)); | |
} catch (_error) {} | |
}; | |
writeCacheFile = function(cachePath, object) { | |
return fs.writeFile(cachePath, JSON.stringify(object)); | |
}; | |
parseObject = function(objectPath, contents) { | |
if (path.extname(objectPath) === '.cson') { | |
if (CoffeeScript == null) { | |
CoffeeScript = require('coffee-script'); | |
} | |
return CoffeeScript["eval"](contents, { | |
bare: true, | |
sandbox: true | |
}); | |
} else { | |
return JSON.parse(contents); | |
} | |
}; | |
parseContentsSync = function(objectPath, cachePath, contents) { | |
var object; | |
object = parseObject(objectPath, contents); | |
if (cachePath) { | |
writeCacheFileSync(cachePath, object); | |
} | |
return object; | |
}; | |
parseContents = function(objectPath, cachePath, contents, callback) { | |
var object, parseError; | |
try { | |
object = parseObject(objectPath, contents); | |
if (cachePath) { | |
writeCacheFile(cachePath, object); | |
} | |
return typeof callback === "function" ? callback(null, object) : void 0; | |
} catch (_error) { | |
parseError = _error; | |
return typeof callback === "function" ? callback(parseError) : void 0; | |
} | |
}; | |
module.exports = { | |
setCacheDir: function(cacheDirectory) { | |
return csonCache = cacheDirectory; | |
}, | |
isObjectPath: function(objectPath) { | |
var extension; | |
if (!objectPath) { | |
return false; | |
} | |
extension = path.extname(objectPath); | |
return extension === '.cson' || extension === '.json'; | |
}, | |
resolve: function(objectPath) { | |
var csonPath, jsonPath; | |
if (objectPath == null) { | |
objectPath = ''; | |
} | |
if (!objectPath) { | |
return null; | |
} | |
if (this.isObjectPath(objectPath) && fs.isFileSync(objectPath)) { | |
return objectPath; | |
} | |
jsonPath = "" + objectPath + ".json"; | |
if (fs.isFileSync(jsonPath)) { | |
return jsonPath; | |
} | |
csonPath = "" + objectPath + ".cson"; | |
if (fs.isFileSync(csonPath)) { | |
return csonPath; | |
} | |
return null; | |
}, | |
readFileSync: function(objectPath) { | |
var cachePath, contents; | |
contents = fs.readFileSync(objectPath, 'utf8'); | |
if (csonCache && path.extname(objectPath) === '.cson') { | |
cachePath = getCachePath(contents); | |
if (fs.isFileSync(cachePath)) { | |
try { | |
return JSON.parse(fs.readFileSync(cachePath, 'utf8')); | |
} catch (_error) {} | |
} | |
} | |
return parseContentsSync(objectPath, cachePath, contents); | |
}, | |
readFile: function(objectPath, callback) { | |
return fs.readFile(objectPath, 'utf8', (function(_this) { | |
return function(error, contents) { | |
var cachePath; | |
if (error != null) { | |
return typeof callback === "function" ? callback(error) : void 0; | |
} else { | |
if (csonCache && path.extname(objectPath) === '.cson') { | |
cachePath = getCachePath(contents); | |
return fs.stat(cachePath, function(error, stat) { | |
if (stat != null ? stat.isFile() : void 0) { | |
return fs.readFile(cachePath, 'utf8', function(error, cached) { | |
var parsed; | |
try { | |
parsed = JSON.parse(cached); | |
} catch (_error) { | |
error = _error; | |
try { | |
parseContents(objectPath, cachePath, contents, callback); | |
} catch (_error) {} | |
return; | |
} | |
return typeof callback === "function" ? callback(null, parsed) : void 0; | |
}); | |
} else { | |
return parseContents(objectPath, cachePath, contents, callback); | |
} | |
}); | |
} else { | |
return parseContents(objectPath, null, contents, callback); | |
} | |
} | |
}; | |
})(this)); | |
}, | |
writeFile: function(objectPath, object, callback) { | |
var contents, error; | |
try { | |
contents = this.stringifyPath(objectPath, object); | |
} catch (_error) { | |
error = _error; | |
callback(error); | |
return; | |
} | |
return fs.writeFile(objectPath, "" + contents + "\n", callback); | |
}, | |
writeFileSync: function(objectPath, object) { | |
return fs.writeFileSync(objectPath, "" + (this.stringifyPath(objectPath, object)) + "\n"); | |
}, | |
stringifyPath: function(objectPath, object) { | |
if (path.extname(objectPath) === '.cson') { | |
return this.stringify(object); | |
} else { | |
return JSON.stringify(object, void 0, 2); | |
} | |
}, | |
stringify: function(object) { | |
if (object === void 0) { | |
throw new Error("Cannot stringify undefined object"); | |
} | |
if (_.isFunction(object)) { | |
throw new Error("Cannot stringify function: " + object); | |
} | |
if (_.isString(object)) { | |
return stringifyString(object); | |
} | |
if (_.isBoolean(object)) { | |
return stringifyBoolean(object); | |
} | |
if (_.isNumber(object)) { | |
return stringifyNumber(object); | |
} | |
if (_.isNull(object)) { | |
return stringifyNull(object); | |
} | |
if (_.isArray(object)) { | |
return stringifyArray(object); | |
} | |
if (_.isObject(object)) { | |
return stringifyObject(object); | |
} | |
throw new Error("Unrecognized type to stringify: " + object); | |
} | |
}; | |
}).call(this); |
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
window.onload = function() { | |
try { | |
var startTime = Date.now(); | |
var fs = require('fs'); | |
var path = require('path'); | |
// Patch fs.statSyncNoException/fs.lstatSyncNoException to fail for non-strings | |
// https://github.com/atom/atom-shell/issues/843 | |
var statSyncNoException = fs.statSyncNoException; | |
var lstatSyncNoException = fs.lstatSyncNoException; | |
fs.statSyncNoException = function(pathToStat) { | |
if (pathToStat && typeof pathToStat === 'string') | |
return statSyncNoException(pathToStat); | |
else | |
return false; | |
}; | |
fs.lstatSyncNoException = function(pathToStat) { | |
if (pathToStat && typeof pathToStat === 'string') | |
return lstatSyncNoException(pathToStat); | |
else | |
return false; | |
}; | |
// Skip "?loadSettings=". | |
var loadSettings = JSON.parse(decodeURIComponent(location.search.substr(14))); | |
// Normalize to make sure drive letter case is consistent on Windows | |
process.resourcesPath = path.normalize(process.resourcesPath); | |
var devMode = loadSettings.devMode || !loadSettings.resourcePath.startsWith(process.resourcesPath + path.sep); | |
// Require before the module cache in dev mode | |
if (devMode) { | |
require('coffee-script').register(); | |
} | |
ModuleCache = require('../src/module-cache'); | |
ModuleCache.register(loadSettings); | |
ModuleCache.add(loadSettings.resourcePath); | |
// Start the crash reporter before anything else. | |
require('crash-reporter').start({ | |
productName: 'Atom', | |
companyName: 'GitHub', | |
// By explicitly passing the app version here, we could save the call | |
// of "require('remote').require('app').getVersion()". | |
extra: {_version: loadSettings.appVersion} | |
}); | |
require('vm-compatibility-layer'); | |
if (!devMode) { | |
require('coffee-script').register(); | |
} | |
require('../src/coffee-cache').register(); | |
require(loadSettings.bootstrapScript); | |
require('ipc').sendChannel('window-command', 'window:loaded'); | |
if (global.atom) { | |
global.atom.loadTime = Date.now() - startTime; | |
console.log('Window load time: ' + global.atom.getWindowLoadTime() + 'ms'); | |
} | |
} | |
catch (error) { | |
var currentWindow = require('remote').getCurrentWindow(); | |
currentWindow.setSize(800, 600); | |
currentWindow.center(); | |
currentWindow.show(); | |
currentWindow.openDevTools(); | |
console.error(error.stack || error); | |
} | |
} |
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
{ | |
"body": { | |
"ctrl-pageup": "pane:show-previous-item", | |
"ctrl-pagedown": "pane:show-next-item", | |
"enter": "core:confirm", | |
"escape": "core:cancel", | |
"up": "core:move-up", | |
"down": "core:move-down", | |
"left": "core:move-left", | |
"right": "core:move-right", | |
"ctrl-alt-r": "window:reload", | |
"ctrl-alt-i": "window:toggle-dev-tools", | |
"ctrl-alt-p": "window:run-package-specs", | |
"ctrl-alt-s": "application:run-all-specs", | |
"ctrl-alt-o": "application:open-dev", | |
"ctrl-shift-o": "application:open-folder", | |
"ctrl-shift-left": "pane:move-item-left", | |
"ctrl-shift-right": "pane:move-item-right", | |
"F11": "window:toggle-full-screen", | |
"ctrl-,": "application:show-settings", | |
"ctrl-N": "application:new-window", | |
"ctrl-W": "window:close", | |
"ctrl-o": "application:open-file", | |
"ctrl-T": "pane:reopen-closed-item", | |
"ctrl-n": "application:new-file", | |
"ctrl-s": "core:save", | |
"ctrl-S": "core:save-as", | |
"ctrl-f4": "core:close", | |
"ctrl-w": "core:close", | |
"ctrl-z": "core:undo", | |
"ctrl-shift-z": "core:redo", | |
"ctrl-y": "core:redo", | |
"ctrl-x": "core:cut", | |
"ctrl-c": "core:copy", | |
"ctrl-v": "core:paste", | |
"ctrl-insert": "core:copy", | |
"shift-insert": "core:paste", | |
"shift-up": "core:select-up", | |
"shift-down": "core:select-down", | |
"shift-left": "core:select-left", | |
"shift-right": "core:select-right", | |
"shift-pageup": "core:select-page-up", | |
"shift-pagedown": "core:select-page-down", | |
"delete": "core:delete", | |
"shift-delete": "core:cut", | |
"pageup": "core:page-up", | |
"pagedown": "core:page-down", | |
"backspace": "core:backspace", | |
"shift-backspace": "core:backspace", | |
"ctrl-tab": "pane:show-next-item", | |
"ctrl-shift-tab": "pane:show-previous-item", | |
"ctrl-shift-up": "core:move-up", | |
"ctrl-shift-down": "core:move-down", | |
"ctrl-alt-up": "editor:add-selection-above", | |
"ctrl-alt-down": "editor:add-selection-below", | |
"ctrl-=": "window:increase-font-size", | |
"ctrl-+": "window:increase-font-size", | |
"ctrl--": "window:decrease-font-size", | |
"ctrl-_": "window:decrease-font-size", | |
"ctrl-0": "window:reset-font-size", | |
"ctrl-k up": "pane:split-up", | |
"ctrl-k down": "pane:split-down", | |
"ctrl-k left": "pane:split-left", | |
"ctrl-k right": "pane:split-right", | |
"ctrl-k ctrl-w": "pane:close", | |
"ctrl-k alt-ctrl-w": "pane:close-other-items", | |
"ctrl-k ctrl-p": "window:focus-previous-pane", | |
"ctrl-k ctrl-n": "window:focus-next-pane", | |
"ctrl-k ctrl-up": "window:focus-pane-above", | |
"ctrl-k ctrl-down": "window:focus-pane-below", | |
"ctrl-k ctrl-left": "window:focus-pane-on-left", | |
"ctrl-k ctrl-right": "window:focus-pane-on-right" | |
}, | |
"atom-workspace atom-text-editor": { | |
"ctrl-left": "editor:move-to-beginning-of-word", | |
"ctrl-right": "editor:move-to-end-of-word", | |
"ctrl-shift-left": "editor:select-to-beginning-of-word", | |
"ctrl-shift-right": "editor:select-to-end-of-word", | |
"ctrl-backspace": "editor:delete-to-beginning-of-word", | |
"ctrl-delete": "editor:delete-to-end-of-word", | |
"ctrl-home": "core:move-to-top", | |
"ctrl-end": "core:move-to-bottom", | |
"ctrl-shift-home": "core:select-to-top", | |
"ctrl-shift-end": "core:select-to-bottom", | |
"ctrl-a": "core:select-all", | |
"ctrl-alt-shift-p": "editor:log-cursor-scope", | |
"ctrl-k ctrl-u": "editor:upper-case", | |
"ctrl-k ctrl-l": "editor:lower-case", | |
"ctrl-l": "editor:select-line" | |
}, | |
"atom-workspace atom-text-editor:not([mini])": { | |
"alt-ctrl-z": "editor:checkout-head-revision", | |
"ctrl-<": "editor:scroll-to-cursor", | |
"alt-ctrl-f": "editor:fold-selection", | |
"ctrl-enter": "editor:newline-below", | |
"ctrl-shift-enter": "editor:newline-above", | |
"ctrl-]": "editor:indent-selected-rows", | |
"ctrl-[": "editor:outdent-selected-rows", | |
"ctrl-up": "editor:move-line-up", | |
"ctrl-down": "editor:move-line-down", | |
"ctrl-/": "editor:toggle-line-comments", | |
"ctrl-j": "editor:join-lines", | |
"ctrl-D": "editor:duplicate-lines", | |
"ctrl-alt-]": "editor:unfold-current-row", | |
"ctrl-alt-[": "editor:fold-current-row", | |
"ctrl-alt-{": "editor:fold-all", | |
"ctrl-alt-}": "editor:unfold-all", | |
"ctrl-k ctrl-0": "editor:unfold-all", | |
"ctrl-k ctrl-1": "editor:fold-at-indent-level-1", | |
"ctrl-k ctrl-2": "editor:fold-at-indent-level-2", | |
"ctrl-k ctrl-3": "editor:fold-at-indent-level-3", | |
"ctrl-k ctrl-4": "editor:fold-at-indent-level-4", | |
"ctrl-k ctrl-5": "editor:fold-at-indent-level-5", | |
"ctrl-k ctrl-6": "editor:fold-at-indent-level-6", | |
"ctrl-k ctrl-7": "editor:fold-at-indent-level-7", | |
"ctrl-k ctrl-8": "editor:fold-at-indent-level-8", | |
"ctrl-k ctrl-9": "editor:fold-at-indent-level-9" | |
}, | |
"body .native-key-bindings": { | |
"ctrl-z": "native!", | |
"ctrl-Z": "native!", | |
"ctrl-x": "native!", | |
"ctrl-c": "native!", | |
"ctrl-v": "native!" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment