Add select-to-beginning-of-line and select-to-end-of-line

This commit is contained in:
Corey Johnson & Nathan Sobo
2012-03-28 15:07:44 -07:00
parent a90380bc63
commit 2d85825126
4 changed files with 56 additions and 2 deletions

View File

@@ -87,6 +87,14 @@ class CompositeSeleciton
selection.selectToBottom() for selection in @getSelections()
@mergeIntersectingSelections()
selectToBeginningOfLine: ->
selection.selectToBeginningOfLine() for selection in @getSelections()
@mergeIntersectingSelections reverse: true
selectToEndOfLine: ->
selection.selectToEndOfLine() for selection in @getSelections()
@mergeIntersectingSelections()
setBufferRange: (bufferRange, options) ->
@getLastSelection().setBufferRange(bufferRange, options)

View File

@@ -106,12 +106,14 @@ class Editor extends View
@on 'close', => @remove(); false
@on 'move-to-top', => @moveCursorToTop()
@on 'select-to-top', => @selectToTop()
@on 'move-to-bottom', => @moveCursorToBottom()
@on 'select-to-bottom', => @selectToBottom()
@on 'move-to-beginning-of-line', => @moveCursorToBeginningOfLine()
@on 'move-to-end-of-line', => @moveCursorToEndOfLine()
@on 'move-to-first-character-of-line', => @moveCursorToFirstCharacterOfLine()
@on 'select-to-top', => @selectToTop()
@on 'select-to-bottom', => @selectToBottom()
@on 'select-to-end-of-line', => @selectToEndOfLine()
@on 'select-to-beginning-of-line', => @selectToBeginningOfLine()
buildCursorAndSelection: ->
@compositeSelection = new CompositeSelection(this)
@@ -390,6 +392,8 @@ class Editor extends View
selectDown: -> @compositeSelection.selectDown()
selectToTop: -> @compositeSelection.selectToTop()
selectToBottom: -> @compositeSelection.selectToBottom()
selectToEndOfLine: -> @compositeSelection.selectToEndOfLine()
selectToBeginningOfLine: -> @compositeSelection.selectToBeginningOfLine()
selectToScreenPosition: (position) -> @compositeSelection.selectToScreenPosition(position)
clearSelections: -> @compositeSelection.clearSelections()

View File

@@ -228,6 +228,14 @@ class Selection extends View
@modifySelection =>
@cursor.setScreenPosition(position)
selectToBeginningOfLine: ->
@modifySelection =>
@cursor.moveToBeginningOfLine()
selectToEndOfLine: ->
@modifySelection =>
@cursor.moveToEndOfLine()
cut: (maintainPasteboard=false) ->
@copy(maintainPasteboard)
@delete()