Merge branch 'master' into mb-bundle-line-ending-selector

This commit is contained in:
Nathan Sobo
2015-08-20 14:05:28 -06:00
5 changed files with 115 additions and 65 deletions

View File

@@ -82,21 +82,26 @@ class Pane extends Model
Section: Event Subscription
###
# Public: Invoke the given callback when the pane resize
# Public: Invoke the given callback when the pane resizes
#
# the callback will be invoked when pane's flexScale property changes
# The callback will be invoked when pane's flexScale property changes.
# Use {::getFlexScale} to get the current value.
#
# * `callback` {Function} to be called when the pane is resized
# * `flexScale` {Number} representing the panes `flex-grow`; ability for a
# flex item to grow if necessary.
#
# Returns a {Disposable} on which '.dispose()' can be called to unsubscribe.
onDidChangeFlexScale: (callback) ->
@emitter.on 'did-change-flex-scale', callback
# Public: Invoke the given callback with all current and future items.
# Public: Invoke the given callback with the current and future values of
# {::getFlexScale}.
#
# * `callback` {Function} to be called with current and future items.
# * `item` An item that is present in {::getItems} at the time of
# subscription or that is added at some later time.
# * `callback` {Function} to be called with the current and future values of
# the {::getFlexScale} property.
# * `flexScale` {Number} representing the panes `flex-grow`; ability for a
# flex item to grow if necessary.
#
# Returns a {Disposable} on which `.dispose()` can be called to unsubscribe.
observeFlexScale: (callback) ->

View File

@@ -419,35 +419,43 @@ class TextEditorComponent
@onGutterClick(event)
onGutterClick: (event) =>
clickedBufferRow = @editor.bufferRowForScreenRow(@screenPositionForMouseEvent(event).row)
@editor.setSelectedBufferRange([[clickedBufferRow, 0], [clickedBufferRow + 1, 0]], preserveFolds: true)
@handleGutterDrag(clickedBufferRow)
clickedScreenRow = @screenPositionForMouseEvent(event).row
clickedBufferRow = @editor.bufferRowForScreenRow(clickedScreenRow)
initialScreenRange = @editor.screenRangeForBufferRange([[clickedBufferRow, 0], [clickedBufferRow + 1, 0]])
@editor.setSelectedScreenRange(initialScreenRange, preserveFolds: true)
@handleGutterDrag(initialScreenRange)
onGutterMetaClick: (event) =>
clickedBufferRow = @editor.bufferRowForScreenRow(@screenPositionForMouseEvent(event).row)
@editor.addSelectionForBufferRange([[clickedBufferRow, 0], [clickedBufferRow + 1, 0]], preserveFolds: true)
@handleGutterDrag(clickedBufferRow)
clickedScreenRow = @screenPositionForMouseEvent(event).row
clickedBufferRow = @editor.bufferRowForScreenRow(clickedScreenRow)
initialScreenRange = @editor.screenRangeForBufferRange([[clickedBufferRow, 0], [clickedBufferRow + 1, 0]])
@editor.addSelectionForScreenRange(initialScreenRange, preserveFolds: true)
@handleGutterDrag(initialScreenRange)
onGutterShiftClick: (event) =>
clickedBufferRow = @editor.bufferRowForScreenRow(@screenPositionForMouseEvent(event).row)
tailBufferPosition = @editor.getLastSelection().getTailBufferPosition()
tailScreenPosition = @editor.getLastSelection().getTailScreenPosition()
clickedScreenRow = @screenPositionForMouseEvent(event).row
clickedBufferRow = @editor.bufferRowForScreenRow(clickedScreenRow)
clickedLineScreenRange = @editor.screenRangeForBufferRange([[clickedBufferRow, 0], [clickedBufferRow + 1, 0]])
if clickedBufferRow < tailBufferPosition.row
@editor.selectToBufferPosition([clickedBufferRow, 0], true)
if clickedScreenRow < tailScreenPosition.row
@editor.selectToScreenPosition(clickedLineScreenRange.start, true)
else
@editor.selectToBufferPosition([clickedBufferRow + 1, 0], true)
@editor.selectToScreenPosition(clickedLineScreenRange.end, true)
@handleGutterDrag(tailBufferPosition.row, tailBufferPosition.column)
handleGutterDrag: (tailRow, tailColumn) ->
tailPosition = [tailRow, tailColumn] if tailColumn?
@handleGutterDrag(new Range(tailScreenPosition, tailScreenPosition))
handleGutterDrag: (initialRange) ->
@handleDragUntilMouseUp (screenPosition) =>
dragRow = @editor.bufferPositionForScreenPosition(screenPosition).row
if dragRow < tailRow
@editor.getLastSelection().setBufferRange([[dragRow, 0], tailPosition ? [tailRow + 1, 0]], reversed: true, autoscroll: false, preserveFolds: true)
dragRow = screenPosition.row
if dragRow < initialRange.start.row
startPosition = @editor.clipScreenPosition([dragRow, 0], skipSoftWrapIndentation: true)
screenRange = new Range(startPosition, startPosition).union(initialRange)
@editor.getLastSelection().setScreenRange(screenRange, reversed: true, autoscroll: false, preserveFolds: true)
else
@editor.getLastSelection().setBufferRange([tailPosition ? [tailRow, 0], [dragRow + 1, 0]], reversed: false, autoscroll: false, preserveFolds: true)
endPosition = [dragRow + 1, 0]
screenRange = new Range(endPosition, endPosition).union(initialRange)
@editor.getLastSelection().setScreenRange(screenRange, reversed: false, autoscroll: false, preserveFolds: true)
@editor.getLastCursor().autoscroll()
onStylesheetsChanged: (styleElement) =>
@@ -523,15 +531,17 @@ class TextEditorComponent
onMouseUp() if event.which is 0
onMouseUp = (event) =>
stopDragging()
@editor.finalizeSelections()
@editor.mergeIntersectingSelections()
if dragging
stopDragging()
@editor.finalizeSelections()
@editor.mergeIntersectingSelections()
pasteSelectionClipboard(event)
stopDragging = ->
dragging = false
window.removeEventListener('mousemove', onMouseMove)
window.removeEventListener('mouseup', onMouseUp)
willInsertTextSubscription.dispose()
pasteSelectionClipboard = (event) =>
if event?.which is 2 and process.platform is 'linux'
@@ -540,6 +550,7 @@ class TextEditorComponent
window.addEventListener('mousemove', onMouseMove)
window.addEventListener('mouseup', onMouseUp)
willInsertTextSubscription = @editor.onWillInsertText(onMouseUp)
isVisible: ->
@domNode.offsetHeight > 0 or @domNode.offsetWidth > 0

View File

@@ -410,10 +410,7 @@ class TextEditorPresenter
@updateCursorState(cursor) for cursor in @model.cursors # using property directly to avoid allocation
return
updateCursorState: (cursor, destroyOnly = false) ->
delete @state.content.cursors[cursor.id]
return if destroyOnly
updateCursorState: (cursor) ->
return unless @startRow? and @endRow? and @hasPixelRectRequirements() and @baseCharacterWidth?
return unless cursor.isVisible() and @startRow <= cursor.getScreenRow() < @endRow
@@ -421,8 +418,6 @@ class TextEditorPresenter
pixelRect.width = @baseCharacterWidth if pixelRect.width is 0
@state.content.cursors[cursor.id] = pixelRect
@emitDidUpdateState()
updateOverlaysState: ->
return unless @hasOverlayPositionRequirements()
@@ -1365,20 +1360,22 @@ class TextEditorPresenter
observeCursor: (cursor) ->
didChangePositionDisposable = cursor.onDidChangePosition =>
@shouldUpdateHiddenInputState = true if cursor.isLastCursor()
@shouldUpdateCursorsState = true
@pauseCursorBlinking()
@updateCursorState(cursor)
@emitDidUpdateState()
didChangeVisibilityDisposable = cursor.onDidChangeVisibility =>
@updateCursorState(cursor)
@shouldUpdateCursorsState = true
@emitDidUpdateState()
didDestroyDisposable = cursor.onDidDestroy =>
@disposables.remove(didChangePositionDisposable)
@disposables.remove(didChangeVisibilityDisposable)
@disposables.remove(didDestroyDisposable)
@shouldUpdateHiddenInputState = true
@updateCursorState(cursor, true)
@shouldUpdateCursorsState = true
@emitDidUpdateState()
@@ -1389,8 +1386,9 @@ class TextEditorPresenter
didAddCursor: (cursor) ->
@observeCursor(cursor)
@shouldUpdateHiddenInputState = true
@shouldUpdateCursorsState = true
@pauseCursorBlinking()
@updateCursorState(cursor)
@emitDidUpdateState()
startBlinkingCursors: ->