Merge remote-tracking branch 'origin/master' into cj-warn-deprecations

Conflicts:
	package.json
This commit is contained in:
probablycorey
2014-04-04 14:43:54 -07:00
39 changed files with 220 additions and 122 deletions

View File

@@ -25,7 +25,7 @@ WindowEventHandler = require './window-event-handler'
# * `atom.config` - A {Config} instance
# * `atom.contextMenu` - A {ContextMenuManager} instance
# * `atom.deserializers` - A {DeserializerManager} instance
# * `atom.keymap` - A {Keymap} instance
# * `atom.keymaps` - A {Keymap} instance
# * `atom.menu` - A {MenuManager} instance
# * `atom.packages` - A {PackageManager} instance
# * `atom.project` - A {Project} instance
@@ -141,7 +141,7 @@ class Atom extends Model
@loadTime = null
Config = require './config'
Keymap = require './keymap-extensions'
KeymapManager = require './keymap-extensions'
PackageManager = require './package-manager'
Clipboard = require './clipboard'
Syntax = require './syntax'
@@ -158,7 +158,8 @@ class Atom extends Model
process.env.NODE_PATH = exportsPath
@config = new Config({configDirPath, resourcePath})
@keymap = new Keymap({configDirPath, resourcePath})
@keymaps = new KeymapManager({configDirPath, resourcePath})
@keymap = @keymaps # Deprecated
@packages = new PackageManager({devMode, configDirPath, resourcePath})
@themes = new ThemeManager({packageManager: @packages, configDirPath, resourcePath})
@contextMenu = new ContextMenuManager(devMode)
@@ -247,7 +248,7 @@ class Atom extends Model
WorkspaceView = require './workspace-view'
@workspace = Workspace.deserialize(@state.workspace) ? new Workspace
@workspaceView = new WorkspaceView(@workspace)
@keymap.defaultTarget = @workspaceView[0]
@keymaps.defaultTarget = @workspaceView[0]
$(@workspaceViewParentSelector).append(@workspaceView)
deserializePackageStates: ->
@@ -272,12 +273,12 @@ class Atom extends Model
@config.load()
@config.setDefaults('core', require('./workspace-view').configDefaults)
@config.setDefaults('editor', require('./editor-view').configDefaults)
@keymap.loadBundledKeymaps()
@keymaps.loadBundledKeymaps()
@themes.loadBaseStylesheets()
@packages.loadPackages()
@deserializeEditorWindow()
@packages.activate()
@keymap.loadUserKeymap()
@keymaps.loadUserKeymap()
@requireUserInitScript()
@menu.update()
@@ -301,7 +302,7 @@ class Atom extends Model
@workspaceView = null
@project.destroy()
@windowEventHandler?.unsubscribe()
@keymap.destroy()
@keymaps.destroy()
@windowState = null
loadThemes: ->

View File

@@ -147,7 +147,6 @@ class ApplicationMenu
modifiers = firstKeystroke.split('-')
key = modifiers.pop()
modifiers.push("Shift") if key != key.toLowerCase()
modifiers = modifiers.map (modifier) ->
modifier.replace(/shift/ig, "Shift")
.replace(/cmd/ig, "Command")

View File

@@ -125,7 +125,7 @@ class AtomApplication
# Configures required javascript environment flags.
setupJavaScriptArguments: ->
app.commandLine.appendSwitch 'js-flags', '--harmony_collections --harmony-proxies'
app.commandLine.appendSwitch 'js-flags', '--harmony'
# Enable updates unless running from a local build of Atom.
setupAutoUpdater: ->
@@ -169,25 +169,30 @@ class AtomApplication
# Registers basic application commands, non-idempotent.
handleEvents: ->
@on 'application:about', -> Menu.sendActionToFirstResponder('orderFrontStandardAboutPanel:')
@on 'application:run-all-specs', -> @runSpecs(exitWhenDone: false, resourcePath: global.devResourcePath)
@on 'application:run-benchmarks', -> @runBenchmarks()
@on 'application:quit', -> app.quit()
@on 'application:hide', -> Menu.sendActionToFirstResponder('hide:')
@on 'application:hide-other-applications', -> Menu.sendActionToFirstResponder('hideOtherApplications:')
@on 'application:unhide-all-applications', -> Menu.sendActionToFirstResponder('unhideAllApplications:')
@on 'application:new-window', -> @openPath(initialSize: @getFocusedWindowSize())
@on 'application:new-file', -> (@focusedWindow() ? this).openPath()
@on 'application:open', -> @promptForPath()
@on 'application:open-dev', -> @promptForPath(devMode: true)
@on 'application:minimize', -> Menu.sendActionToFirstResponder('performMiniaturize:')
@on 'application:zoom', -> Menu.sendActionToFirstResponder('zoom:')
@on 'application:bring-all-windows-to-front', -> Menu.sendActionToFirstResponder('arrangeInFront:')
@on 'application:inspect', ({x,y}) -> @focusedWindow().browserWindow.inspectElement(x, y)
@on 'application:open-documentation', -> shell.openExternal('https://atom.io/docs/latest/?app')
@on 'application:install-update', -> autoUpdater.quitAndInstall()
@on 'application:check-for-update', => @checkForUpdate()
if process.platform is 'darwin'
@on 'application:about', -> Menu.sendActionToFirstResponder('orderFrontStandardAboutPanel:')
@on 'application:bring-all-windows-to-front', -> Menu.sendActionToFirstResponder('arrangeInFront:')
@on 'application:hide', -> Menu.sendActionToFirstResponder('hide:')
@on 'application:hide-other-applications', -> Menu.sendActionToFirstResponder('hideOtherApplications:')
@on 'application:minimize', -> Menu.sendActionToFirstResponder('performMiniaturize:')
@on 'application:unhide-all-applications', -> Menu.sendActionToFirstResponder('unhideAllApplications:')
@on 'application:zoom', -> Menu.sendActionToFirstResponder('zoom:')
else
@on 'application:minimize', -> @focusedWindow()?.minimize()
@on 'application:zoom', -> @focusedWindow()?.maximize()
@openPathOnEvent('application:show-settings', 'atom://config')
@openPathOnEvent('application:open-your-config', 'atom://.atom/config')
@openPathOnEvent('application:open-your-init-script', 'atom://.atom/init-script')

View File

@@ -138,6 +138,10 @@ class AtomWindow
getSize: -> @browserWindow.getSize()
minimize: -> @browserWindow.minimize()
maximize: -> @browserWindow.maximize()
handlesAtomCommands: ->
not @isSpecWindow() and @isWebViewFocused()

View File

@@ -86,7 +86,7 @@ class Config
hash = hash[key]
_.extend hash, defaults
@update()
@emit 'updated'
# Public: Get the path to the config file being used.
getUserConfigPath: ->

View File

@@ -315,12 +315,14 @@ class Cursor
# :includeNonWordCharacters - A {Boolean} indicating whether to include
# non-word characters in the default word regex.
# Has no effect if wordRegex is set.
# :allowPrevious - A {Boolean} indicating whether the beginning of the
# previous word can be returned.
#
# Returns a {Range}.
getBeginningOfCurrentWordBufferPosition: (options = {}) ->
allowPrevious = options.allowPrevious ? true
currentBufferPosition = @getBufferPosition()
previousNonBlankRow = @editor.buffer.previousNonBlankRow(currentBufferPosition.row)
previousNonBlankRow = @editor.buffer.previousNonBlankRow(currentBufferPosition.row) ? 0
scanRange = [[previousNonBlankRow, 0], currentBufferPosition]
beginningOfWordPosition = null
@@ -330,7 +332,12 @@ class Cursor
if not beginningOfWordPosition?.isEqual(currentBufferPosition)
stop()
beginningOfWordPosition or currentBufferPosition
if beginningOfWordPosition?
beginningOfWordPosition
else if allowPrevious
new Point(0, 0)
else
currentBufferPosition
# Public: Retrieves buffer position of previous word boundary. It might be on
# the current word, or the previous word.

View File

@@ -343,7 +343,6 @@ class EditorView extends View
@subscribe atom.config.observe 'editor.fontFamily', (fontFamily) => @setFontFamily(fontFamily)
@subscribe atom.config.observe 'editor.lineHeight', (lineHeight) => @setLineHeight(lineHeight)
handleEvents: ->
@on 'focus', =>
@hiddenInput.focus()

View File

@@ -623,11 +623,18 @@ class Editor extends Model
# Public: For each cursor, insert a newline at the end of the preceding line.
insertNewlineAbove: ->
@transact =>
onFirstLine = @getCursorBufferPosition().row is 0
bufferRow = @getCursorBufferPosition().row
indentLevel = @indentationForBufferRow(bufferRow)
onFirstLine = bufferRow is 0
@moveCursorToBeginningOfLine()
@moveCursorLeft()
@insertNewline()
@moveCursorUp() if onFirstLine
@setIndentationForBufferRow(bufferRow, indentLevel) if @shouldAutoIndent()
if onFirstLine
@moveCursorUp()
@moveCursorToEndOfLine()
# Indent all lines intersecting selections. See {Selection::indent} for more
# information.

View File

@@ -71,6 +71,9 @@ class Git
@statuses = {}
@upstream = {ahead: 0, behind: 0}
for submodulePath, submoduleRepo of @repo.submodules
submoduleRepo.upstream = {ahead: 0, behind: 0}
{@project, refreshOnWindowFocus} = options
refreshOnWindowFocus ?= true

View File

@@ -1,27 +1,27 @@
fs = require 'fs-plus'
path = require 'path'
Keymap = require 'atom-keymap'
KeymapManager = require 'atom-keymap'
CSON = require 'season'
{jQuery} = require 'space-pen'
Keymap::loadBundledKeymaps = ->
@loadKeyBindings(path.join(@resourcePath, 'keymaps'))
KeymapManager::loadBundledKeymaps = ->
@loadKeymap(path.join(@resourcePath, 'keymaps'))
@emit('bundled-keymaps-loaded')
Keymap::getUserKeymapPath = ->
KeymapManager::getUserKeymapPath = ->
if userKeymapPath = CSON.resolve(path.join(@configDirPath, 'keymap'))
userKeymapPath
else
path.join(@configDirPath, 'keymap.cson')
Keymap::loadUserKeymap = ->
KeymapManager::loadUserKeymap = ->
userKeymapPath = @getUserKeymapPath()
if fs.isFileSync(userKeymapPath)
@loadKeyBindings(userKeymapPath, watch: true, suppressErrors: true)
@loadKeymap(userKeymapPath, watch: true, suppressErrors: true)
# This enables command handlers registered via jQuery to call
# `.abortKeyBinding()` on the `jQuery.Event` object passed to the handler.
jQuery.Event::abortKeyBinding = ->
@originalEvent?.abortKeyBinding?()
module.exports = Keymap
module.exports = KeymapManager

View File

@@ -74,7 +74,10 @@ class LanguageMode
columnEnd = columnStart + match[2].length
buffer.change([[row, columnStart], [row, columnEnd]], "")
else
indent = @minIndentLevelForRowRange(start, end)
if start is end
indent = @editor.indentationForBufferRow(start)
else
indent = @minIndentLevelForRowRange(start, end)
indentString = @editor.buildIndentString(indent)
tabLength = @editor.getTabLength()
indentRegex = new RegExp("(\t|[ ]{#{tabLength}}){#{Math.floor(indent)}}")

View File

@@ -14,7 +14,7 @@ class MenuManager
constructor: ({@resourcePath}) ->
@pendingUpdateOperation = null
@template = []
atom.keymap.on 'bundled-keymaps-loaded', => @loadPlatformItems()
atom.keymaps.on 'bundled-keymaps-loaded', => @loadPlatformItems()
# Public: Adds the given item definition to the existing template.
#
@@ -59,7 +59,8 @@ class MenuManager
testBody.classList.add(@classesForElement(document.body)...)
testWorkspace = document.createElement('body')
workspaceClasses = @classesForElement(document.body.querySelector('.workspace')) ? ['.workspace']
workspaceClasses = @classesForElement(document.body.querySelector('.workspace'))
workspaceClasses = ['workspace'] if workspaceClasses.length is 0
testWorkspace.classList.add(workspaceClasses...)
testBody.appendChild(testWorkspace)
@@ -75,7 +76,7 @@ class MenuManager
clearImmediate(@pendingUpdateOperation) if @pendingUpdateOperation?
@pendingUpdateOperation = setImmediate =>
keystrokesByCommand = {}
for binding in atom.keymap.getKeyBindings() when @includeSelector(binding.selector)
for binding in atom.keymaps.getKeyBindings() when @includeSelector(binding.selector)
keystrokesByCommand[binding.command] ?= []
keystrokesByCommand[binding.command].unshift binding.keystroke
@sendToBrowserProcess(@template, keystrokesByCommand)
@@ -116,10 +117,10 @@ class MenuManager
normalizeLabel: (label) ->
return undefined unless label?
if process.platform is 'win32'
label.replace(/\&/g, '')
else
if process.platform is 'darwin'
label
else
label.replace(/\&/g, '')
# Get an {Array} of {String} classes for the given element.
classesForElement: (element) ->

View File

@@ -124,7 +124,7 @@ class Package
@stylesheetsActivated = true
activateResources: ->
atom.keymap.add(keymapPath, map) for [keymapPath, map] in @keymaps
atom.keymaps.add(keymapPath, map) for [keymapPath, map] in @keymaps
atom.contextMenu.add(menuPath, map['context-menu']) for [menuPath, map] in @menus
atom.menu.add(map.menu) for [menuPath, map] in @menus when map.menu
@@ -232,7 +232,7 @@ class Package
deactivateResources: ->
grammar.deactivate() for grammar in @grammars
scopedProperties.deactivate() for scopedProperties in @scopedProperties
atom.keymap.remove(keymapPath) for [keymapPath] in @keymaps
atom.keymaps.remove(keymapPath) for [keymapPath] in @keymaps
atom.themes.removeStylesheet(stylesheetPath) for [stylesheetPath] in @stylesheets
@stylesheetsActivated = false
@grammarsActivated = false

View File

@@ -40,9 +40,9 @@ jQuery.fn.setTooltip = (tooltipOptions, {command, commandElement}={}) ->
tooltipOptions = {title: tooltipOptions} if _.isString(tooltipOptions)
if commandElement
bindings = atom.keymap.keyBindingsForCommandMatchingElement(command, commandElement)
bindings = atom.keymaps.keyBindingsForCommandMatchingElement(command, commandElement)
else if command
bindings = atom.keymap.keyBindingsForCommand(command)
bindings = atom.keymaps.keyBindingsForCommand(command)
tooltipOptions.title = "#{tooltipOptions.title} #{getKeystroke(bindings)}"

View File

@@ -55,7 +55,7 @@ class WindowEventHandler
@subscribeToCommand $(document), 'core:focus-previous', @focusPrevious
@subscribe $(document), 'keydown', (event) ->
atom.keymap.handleKeyEvent(event)
atom.keymaps.handleKeyEvent(event)
@subscribe $(document), 'drop', (e) ->
e.preventDefault()

View File

@@ -79,7 +79,7 @@ class WorkspaceView extends View
@div class: 'panes', outlet: 'panes'
initialize: (@model) ->
@model ?= new Workspace
@model = atom.workspace ? new Workspace unless @model?
panes = new PaneContainerView(@model.paneContainer)
@panes.replaceWith(panes)

View File

@@ -34,7 +34,7 @@ class Workspace extends Model
when 'atom://.atom/stylesheet'
@open(atom.themes.getUserStylesheetPath())
when 'atom://.atom/keymap'
@open(atom.keymap.getUserKeymapPath())
@open(atom.keymaps.getUserKeymapPath())
when 'atom://.atom/config'
@open(atom.config.getUserConfigPath())
when 'atom://.atom/init-script'