Merge branch 'master' into shared-buffers

Conflicts:
	vendor/apm
This commit is contained in:
Kevin Sawicki & Nathan Sobo
2013-07-22 11:54:51 -07:00
17 changed files with 134 additions and 82 deletions

View File

@@ -199,9 +199,10 @@ window.atom =
showSaveDialog: (callback) ->
callback(showSaveDialogSync())
showSaveDialogSync: ->
showSaveDialogSync: (defaultPath) ->
defaultPath ?= project?.getPath()
currentWindow = remote.getCurrentWindow()
dialog.showSaveDialog currentWindow, title: 'Save File'
dialog.showSaveDialog currentWindow, {title: 'Save File', defaultPath}
openDevTools: ->
remote.getCurrentWindow().openDevTools()

View File

@@ -525,7 +525,6 @@ class EditSession
pasteText: (options={}) ->
[text, metadata] = pasteboard.read()
options.autoIndent ?= @shouldAutoIndentPastedText()
if config.get('editor.normalizeIndentOnPaste') and metadata
options.indentBasis ?= metadata.indentBasis
@@ -1166,6 +1165,10 @@ class EditSession
selectToBeginningOfLine: ->
@expandSelectionsBackward (selection) => selection.selectToBeginningOfLine()
# Selects to the first non-whitespace character of the line.
selectToFirstCharacterOfLine: ->
@expandSelectionsBackward (selection) => selection.selectToFirstCharacterOfLine()
# Selects all the text from the current cursor position to the end of the line.
selectToEndOfLine: ->
@expandSelectionsForward (selection) => selection.selectToEndOfLine()
@@ -1312,9 +1315,6 @@ class EditSession
shouldAutoIndent: ->
config.get("editor.autoIndent")
shouldAutoIndentPastedText: ->
config.get("editor.autoIndentOnPaste")
transact: (fn) -> @buffer.transact(fn)
commit: -> @buffer.commit()

View File

@@ -20,7 +20,6 @@ class Editor extends View
showIndentGuide: false
showLineNumbers: true
autoIndent: true
autoIndentOnPaste: false
normalizeIndentOnPaste: true
nonWordCharacters: "./\\()\"':,.;<>~!@#$%^&*|+=[]{}`~?-"
preferredLineLength: 80
@@ -146,6 +145,7 @@ class Editor extends View
'editor:select-to-end-of-word': @selectToEndOfWord
'editor:select-to-beginning-of-word': @selectToBeginningOfWord
'editor:select-to-beginning-of-next-word': @selectToBeginningOfNextWord
'editor:select-to-first-character-of-line': @selectToFirstCharacterOfLine
'editor:add-selection-below': @addSelectionBelow
'editor:add-selection-above': @addSelectionAbove
'editor:select-line': @selectLine
@@ -327,6 +327,9 @@ class Editor extends View
# {Delegates to: EditSession.selectToBeginningOfLine}
selectToBeginningOfLine: -> @activeEditSession.selectToBeginningOfLine()
# {Delegates to: EditSession.selectToFirstCharacterOfLine}
selectToFirstCharacterOfLine: -> @activeEditSession.selectToFirstCharacterOfLine()
# {Delegates to: EditSession.selectToEndOfLine}
selectToEndOfLine: -> @activeEditSession.selectToEndOfLine()

View File

@@ -81,8 +81,10 @@ class LanguageMode
columnEnd = columnStart + match[2].length
buffer.change([[row, columnStart], [row, columnEnd]], "")
else
indent = @minIndentLevelForRowRange(start, end)
indentString = @editSession.buildIndentString(indent)
for row in [start..end]
buffer.insert([row, 0], commentStartString)
buffer.change([[row, 0], [row, indentString.length]], indentString + commentStartString)
# Folds all the foldable lines in the buffer.
foldAll: ->
@@ -180,6 +182,17 @@ class LanguageMode
desiredIndentLevel
# Calculate a minimum indent level for a range of lines excluding empty lines.
#
# startRow - The row {Number} to start at
# endRow - The row {Number} to end at
#
# Returns a {Number} of the indent level of the block of lines.
minIndentLevelForRowRange: (startRow, endRow) ->
indents = (@editSession.indentationForBufferRow(row) for row in [startRow..endRow] when not @editSession.isBufferRowBlank(row))
indents = [0] unless indents.length
Math.min(indents...)
# Indents all the rows between two buffer row numbers.
#
# startRow - The row {Number} to start at

View File

@@ -1,3 +1,4 @@
{dirname} = require 'path'
{View} = require 'space-pen'
$ = require 'jquery'
_ = require 'underscore'
@@ -221,7 +222,10 @@ class Pane extends View
saveItemAs: (item, nextAction) ->
return unless item.saveAs?
path = atom.showSaveDialogSync()
itemPath = item.getUri?()
itemPath = dirname(itemPath) if itemPath
path = atom.showSaveDialogSync(itemPath)
if path
item.saveAs(path)
nextAction?()

View File

@@ -79,9 +79,6 @@ class RootView extends View
@command 'window:toggle-auto-indent', =>
config.set("editor.autoIndent", !config.get("editor.autoIndent"))
@command 'window:toggle-auto-indent-on-paste', =>
config.set("editor.autoIndentOnPaste", !config.get("editor.autoIndentOnPaste"))
@command 'pane:reopen-closed-item', =>
@panes.reopenItem()

View File

@@ -195,6 +195,10 @@ class Selection
selectToBeginningOfLine: ->
@modifySelection => @cursor.moveToBeginningOfLine()
# Selects all the text from the current cursor position to the first character of the line.
selectToFirstCharacterOfLine: ->
@modifySelection => @cursor.moveToFirstCharacterOfLine()
# Selects all the text from the current cursor position to the end of the line.
selectToEndOfLine: ->
@modifySelection => @cursor.moveToEndOfLine()

View File

@@ -1,6 +1,7 @@
$ = require 'jquery'
_ = require 'underscore'
ipc = require 'ipc'
remote = require 'remote'
Subscriber = require 'subscriber'
fsUtils = require 'fs-utils'
@@ -32,6 +33,10 @@ class WindowEventHandler
@subscribe $(document), 'click', 'a', @openLink
@subscribe $(document), 'contextmenu', (e) ->
e.preventDefault()
remote.getCurrentWindow().emit('context-menu', e.pageX, e.pageY)
openLink: (event) =>
location = $(event.target).attr('href')
if location and location[0] isnt '#' and /^https?:\/\//.test(location)

View File

@@ -1,4 +1,6 @@
BrowserWindow = require 'browser-window'
Menu = require 'menu'
MenuItem = require 'menu-item'
app = require 'app'
dialog = require 'dialog'
ipc = require 'ipc'
@@ -9,12 +11,15 @@ _ = require 'underscore'
module.exports =
class AtomWindow
browserWindow: null
contextMenu: null
inspectElementMenuItem: null
constructor: (settings={}) ->
{resourcePath, pathToOpen, isSpec} = settings
global.atomApplication.addWindow(this)
@setupNodePath(resourcePath)
@createContextMenu()
@browserWindow = new BrowserWindow show: false, title: 'Atom'
@handleEvents(isSpec)
@@ -77,8 +82,7 @@ class AtomWindow
buttons: ['Close', 'Keep Waiting']
message: 'Editor is not responsing'
detail: 'The editor is not responding. Would you like to force close it or just keep waiting?'
if chosen is 0
setImmediate => @browserWindow.destroy()
@browserWindow.destroy() if chosen is 0
@browserWindow.on 'crashed', =>
chosen = dialog.showMessageBox @browserWindow,
@@ -87,9 +91,13 @@ class AtomWindow
message: 'The editor has crashed'
detail: 'Please report this issue to https://github.com/github/atom/issues'
switch chosen
when 0 then setImmediate => @browserWindow.destroy()
when 0 then @browserWindow.destroy()
when 1 then @browserWindow.restart()
@browserWindow.on 'context-menu', (x, y) =>
@inspectElementMenuItem.click = => @browserWindow.inspectElement(x, y)
@contextMenu.popup(@browserWindow)
if isSpec
# Spec window's web view should always have focus
@browserWindow.on 'blur', =>
@@ -102,6 +110,11 @@ class AtomWindow
else
@browserWindow.once 'window:loaded', => @openPath(pathToOpen)
createContextMenu: ->
@contextMenu = new Menu
@inspectElementMenuItem = new MenuItem(label: 'Inspect Element')
@contextMenu.append(@inspectElementMenuItem)
sendCommand: (command, args...) ->
ipc.sendChannel @browserWindow.getProcessId(), @browserWindow.getRoutingId(), 'command', command, args...

View File

@@ -16,6 +16,10 @@ class Task
bootstrap = """
require('coffee-script');
require('coffee-cache').setCacheDir('/tmp/atom-coffee-cache');
Object.defineProperty(require.extensions, '.coffee', {
writable: false,
value: require.extensions['.coffee']
});
require('task-bootstrap');
"""