Add 'editor:add-selection-below' command

It still needs work, but the basic idea is for every selection to
add another another selection over the same column range of the line
below.
This commit is contained in:
Nathan Sobo
2013-04-04 16:46:06 -06:00
parent 9633677bcc
commit 26e53584c1
5 changed files with 24 additions and 0 deletions

View File

@@ -761,6 +761,9 @@ class EditSession
selectLine: ->
@expandSelectionsForward (selection) => selection.selectLine()
addSelectionBelow: ->
@expandSelectionsForward (selection) => selection.addSelectionBelow()
transpose: ->
@mutateSelectedText (selection) =>
if selection.isEmpty()

View File

@@ -122,6 +122,7 @@ class Editor extends View
'editor:select-to-beginning-of-line': @selectToBeginningOfLine
'editor:select-to-end-of-word': @selectToEndOfWord
'editor:select-to-beginning-of-word': @selectToBeginningOfWord
'editor:add-selection-below': @addSelectionBelow
'editor:select-line': @selectLine
'editor:transpose': @transpose
'editor:upper-case': @upperCase
@@ -211,6 +212,7 @@ class Editor extends View
selectAll: -> @activeEditSession.selectAll()
selectToBeginningOfLine: -> @activeEditSession.selectToBeginningOfLine()
selectToEndOfLine: -> @activeEditSession.selectToEndOfLine()
addSelectionBelow: -> @activeEditSession.addSelectionBelow()
selectToBeginningOfWord: -> @activeEditSession.selectToBeginningOfWord()
selectToEndOfWord: -> @activeEditSession.selectToEndOfWord()
selectWord: -> @activeEditSession.selectWord()

View File

@@ -9,6 +9,7 @@
'ctrl-]': 'editor:unfold-current-row'
'ctrl-{': 'editor:fold-all'
'ctrl-}': 'editor:unfold-all'
'ctrl-shift-down': 'editor:add-selection-below'
'alt-meta-ctrl-f': 'editor:fold-selection'
'shift-tab': 'editor:outdent-selected-rows'
'meta-[': 'editor:outdent-selected-rows'

View File

@@ -148,6 +148,12 @@ class Selection
selectToEndOfWord: ->
@modifySelection => @cursor.moveToEndOfWord()
addSelectionBelow: ->
range = @getBufferRange().copy()
range.start.row++
range.end.row++
@editSession.addSelectionForBufferRange(range)
insertText: (text, options={}) ->
oldBufferRange = @getBufferRange()
@editSession.destroyFoldsContainingBufferRow(oldBufferRange.end.row)