mirror of
https://github.com/atom/atom.git
synced 2026-02-15 17:15:24 -05:00
Merge remote-tracking branch 'origin/dev' into better-anchors
This commit is contained in:
@@ -26,15 +26,12 @@ class AtomPackage extends Package
|
||||
@metadata = fs.readObject(metadataPath)
|
||||
|
||||
loadKeymaps: ->
|
||||
for keymapPath in @getKeymapPaths()
|
||||
keymap.load(keymapPath)
|
||||
|
||||
getKeymapPaths: ->
|
||||
if keymaps = @metadata?.keymaps
|
||||
keymaps.map (relativePath) =>
|
||||
keymaps = keymaps.map (relativePath) =>
|
||||
fs.resolve(@keymapsDirPath, relativePath, ['cson', 'json', ''])
|
||||
keymap.load(keymapPath) for keymapPath in keymaps
|
||||
else
|
||||
fs.list(@keymapsDirPath)
|
||||
keymap.loadDirectory(@keymapsDirPath)
|
||||
|
||||
loadStylesheets: ->
|
||||
for stylesheetPath in @getStylesheetPaths()
|
||||
|
||||
@@ -3,9 +3,16 @@ Theme = require 'theme'
|
||||
|
||||
module.exports =
|
||||
class AtomTheme extends Theme
|
||||
|
||||
loadStylesheet: (stylesheetPath)->
|
||||
@stylesheets[stylesheetPath] = fs.read(stylesheetPath)
|
||||
|
||||
load: ->
|
||||
json = fs.read(fs.join(@path, "package.json"))
|
||||
for stylesheetName in JSON.parse(json).stylesheets
|
||||
stylesheetPath = fs.join(@path, stylesheetName)
|
||||
@stylesheets[stylesheetPath] = fs.read(stylesheetPath)
|
||||
if /\.css$/.test(@path)
|
||||
@loadStylesheet @path
|
||||
else
|
||||
json = fs.read(fs.join(@path, "package.json"))
|
||||
for stylesheetName in JSON.parse(json).stylesheets
|
||||
stylesheetPath = fs.join(@path, stylesheetName)
|
||||
@loadStylesheet stylesheetPath
|
||||
super
|
||||
|
||||
@@ -50,15 +50,21 @@ _.extend atom,
|
||||
.filter (name) -> not _.contains(disabledPackages, name)
|
||||
|
||||
loadThemes: ->
|
||||
themeNames = config.get("core.themes") ? ['Atom - Dark', 'IR_Black']
|
||||
themeNames = config.get("core.themes") ? ['atom-dark-ui', 'atom-dark-syntax']
|
||||
themeNames = [themeNames] unless _.isArray(themeNames)
|
||||
@loadTheme(themeName) for themeName in themeNames
|
||||
@loadUserStylesheet()
|
||||
|
||||
loadTheme: (name) ->
|
||||
@loadedThemes.push Theme.load(name)
|
||||
|
||||
loadUserStylesheet: ->
|
||||
userStylesheetPath = fs.join(config.configDirPath, 'user.css')
|
||||
if fs.isFile(userStylesheetPath)
|
||||
applyStylesheet(userStylesheetPath, fs.read(userStylesheetPath), 'userTheme')
|
||||
|
||||
getAtomThemeStylesheets: ->
|
||||
themeNames = config.get("core.themes") ? ['Atom - Dark', 'IR_Black']
|
||||
themeNames = config.get("core.themes") ? ['atom-dark-ui', 'atom-dark-syntax']
|
||||
themeNames = [themeNames] unless _.isArray(themeNames)
|
||||
|
||||
open: (args...) ->
|
||||
|
||||
@@ -4,7 +4,7 @@ EventEmitter = require 'event-emitter'
|
||||
|
||||
configDirPath = fs.absolute("~/.atom")
|
||||
configJsonPath = fs.join(configDirPath, "config.json")
|
||||
userInitScriptPath = fs.join(configDirPath, "atom.coffee")
|
||||
userInitScriptPath = fs.join(configDirPath, "user.coffee")
|
||||
bundledPackagesDirPath = fs.join(resourcePath, "src/packages")
|
||||
bundledThemesDirPath = fs.join(resourcePath, "themes")
|
||||
vendoredPackagesDirPath = fs.join(resourcePath, "vendor/packages")
|
||||
|
||||
@@ -18,7 +18,7 @@ class EditSession
|
||||
if fs.exists(state.buffer)
|
||||
session = project.buildEditSessionForPath(state.buffer)
|
||||
else
|
||||
console.warn "Could not build edit session for path '#{state.buffer}' because that file no longer exists"
|
||||
console.warn "Could not build edit session for path '#{state.buffer}' because that file no longer exists" if state.buffer
|
||||
session = project.buildEditSessionForPath(null)
|
||||
session.setScrollTop(state.scrollTop)
|
||||
session.setScrollLeft(state.scrollLeft)
|
||||
|
||||
@@ -14,7 +14,6 @@ _ = require 'underscore'
|
||||
module.exports =
|
||||
class Editor extends View
|
||||
@configDefaults:
|
||||
fontFamily: "Inconsolata, Monaco, Courier"
|
||||
fontSize: 20
|
||||
showInvisibles: false
|
||||
autosave: false
|
||||
@@ -352,11 +351,11 @@ class Editor extends View
|
||||
@hiddenInput.on 'focus', =>
|
||||
@rootView()?.editorFocused(this)
|
||||
@isFocused = true
|
||||
@addClass 'focused'
|
||||
@addClass 'is-focused'
|
||||
|
||||
@hiddenInput.on 'focusout', =>
|
||||
@isFocused = false
|
||||
@removeClass 'focused'
|
||||
@removeClass 'is-focused'
|
||||
@autosave() if config.get "editor.autosave"
|
||||
|
||||
@underlayer.on 'click', (e) =>
|
||||
@@ -697,6 +696,7 @@ class Editor extends View
|
||||
parseInt(@css("font-size"))
|
||||
|
||||
setFontFamily: (fontFamily) ->
|
||||
return if fontFamily == undefined
|
||||
headTag = $("head")
|
||||
styleTag = headTag.find("style.font-family")
|
||||
if styleTag.length == 0
|
||||
@@ -804,6 +804,10 @@ class Editor extends View
|
||||
@overlayer.append(view)
|
||||
|
||||
calculateDimensions: ->
|
||||
if not @isOnDom()
|
||||
detachedEditorParent = _.last(@parents()) ? this
|
||||
$(document.body).append(detachedEditorParent)
|
||||
|
||||
fragment = $('<pre class="line" style="position: absolute; visibility: hidden;"><span>x</span></div>')
|
||||
@renderedLines.append(fragment)
|
||||
|
||||
@@ -815,6 +819,8 @@ class Editor extends View
|
||||
@height(@lineHeight) if @mini
|
||||
fragment.remove()
|
||||
|
||||
$(detachedEditorParent).detach()
|
||||
|
||||
updateLayerDimensions: ->
|
||||
@gutter.calculateWidth()
|
||||
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
$ = require 'jquery'
|
||||
_ = require 'underscore'
|
||||
Subscriber = require 'subscriber'
|
||||
GitRepository = require 'git-repository'
|
||||
@@ -6,9 +5,9 @@ GitRepository = require 'git-repository'
|
||||
module.exports =
|
||||
class Git
|
||||
|
||||
@open: (path) ->
|
||||
@open: (path, options) ->
|
||||
try
|
||||
new Git(path)
|
||||
new Git(path, options)
|
||||
catch e
|
||||
null
|
||||
|
||||
@@ -24,9 +23,12 @@ class Git
|
||||
working_dir_typechange: 1 << 10
|
||||
ignore: 1 << 14
|
||||
|
||||
constructor: (path) ->
|
||||
constructor: (path, options={}) ->
|
||||
@repo = new GitRepository(path)
|
||||
@subscribe $(window), 'focus', => @refreshIndex()
|
||||
refreshIndexOnFocus = options.refreshIndexOnFocus ? true
|
||||
if refreshIndexOnFocus
|
||||
$ = require 'jquery'
|
||||
@subscribe $(window), 'focus', => @refreshIndex()
|
||||
|
||||
getRepo: ->
|
||||
unless @repo?
|
||||
|
||||
@@ -35,7 +35,7 @@ class Keymap
|
||||
@loadDirectory(fs.join(config.configDirPath, 'keymaps'))
|
||||
|
||||
loadDirectory: (directoryPath) ->
|
||||
@load(filePath) for filePath in fs.list(directoryPath)
|
||||
@load(filePath) for filePath in fs.list(directoryPath, ['.cson', '.json'])
|
||||
|
||||
load: (path) ->
|
||||
@add(fs.readObject(path))
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
Task = require 'Task'
|
||||
Task = require 'task'
|
||||
|
||||
module.exports =
|
||||
class LoadTextMatePackagesTask extends Task
|
||||
|
||||
@@ -44,17 +44,17 @@ class TextMateTheme extends Theme
|
||||
'color': @translateColor(foreground)
|
||||
|
||||
@rulesets.push
|
||||
selector: '.editor.focused .cursor'
|
||||
selector: '.editor.is-focused .cursor'
|
||||
properties:
|
||||
'border-color': @translateColor(caret)
|
||||
|
||||
@rulesets.push
|
||||
selector: '.editor.focused .selection .region'
|
||||
selector: '.editor.is-focused .selection .region'
|
||||
properties:
|
||||
'background-color': @translateColor(selection)
|
||||
|
||||
@rulesets.push
|
||||
selector: '.editor.focused .line-number.cursor-line-no-selection, .editor.focused .line.cursor-line'
|
||||
selector: '.editor.is-focused .line-number.cursor-line-no-selection, .editor.is-focused .line.cursor-line'
|
||||
properties:
|
||||
'background-color': @translateColor(lineHighlight)
|
||||
|
||||
@@ -75,8 +75,8 @@ class TextMateTheme extends Theme
|
||||
|
||||
if fontStyle
|
||||
fontStyles = fontStyle.split(/\s+/)
|
||||
# properties['font-weight'] = 'bold' if _.contains(fontStyles, 'bold')
|
||||
# properties['font-style'] = 'italic' if _.contains(fontStyles, 'italic')
|
||||
properties['font-weight'] = 'bold' if _.contains(fontStyles, 'bold')
|
||||
properties['font-style'] = 'italic' if _.contains(fontStyles, 'italic')
|
||||
properties['text-decoration'] = 'underline' if _.contains(fontStyles, 'underline')
|
||||
|
||||
properties['color'] = @translateColor(foreground) if foreground
|
||||
|
||||
@@ -11,7 +11,7 @@ class Theme
|
||||
if fs.exists(name)
|
||||
path = name
|
||||
else
|
||||
path = fs.resolve(config.themeDirPaths..., name, ['', '.tmTheme'])
|
||||
path = fs.resolve(config.themeDirPaths..., name, ['', '.tmTheme', '.css'])
|
||||
|
||||
throw new Error("No theme exists named '#{name}'") unless path
|
||||
|
||||
|
||||
@@ -28,6 +28,7 @@ windowAdditions =
|
||||
|
||||
$(window).on 'core:close', => @close()
|
||||
$(window).command 'window:close', => @close()
|
||||
$(window).on 'focus blur', => $("body").toggleClass("is-focused")
|
||||
|
||||
# This method is intended only to be run when starting a normal application
|
||||
# Note: RootView assigns itself on window on initialization so that
|
||||
|
||||
Reference in New Issue
Block a user