mirror of
https://github.com/atom/atom.git
synced 2026-01-25 06:48:28 -05:00
Add word and line selection methods to EditSession
This commit is contained in:
@@ -351,12 +351,24 @@ class EditSession
|
||||
selectToEndOfLine: ->
|
||||
@expandSelectionsForward (selection) => selection.selectToEndOfLine()
|
||||
|
||||
selectLine: ->
|
||||
@expandSelectionsForward (selection) => selection.selectLine()
|
||||
|
||||
expandLastSelectionOverLine: ->
|
||||
@getLastSelection().expandOverLine()
|
||||
|
||||
selectToBeginningOfWord: ->
|
||||
@expandSelectionsBackward (selection) => selection.selectToBeginningOfWord()
|
||||
|
||||
selectToEndOfWord: ->
|
||||
@expandSelectionsForward (selection) => selection.selectToEndOfWord()
|
||||
|
||||
selectWord: ->
|
||||
@expandSelectionsForward (selection) => selection.selectWord()
|
||||
|
||||
expandLastSelectionOverWord: ->
|
||||
@getLastSelection().expandOverWord()
|
||||
|
||||
mergeCursors: ->
|
||||
positions = []
|
||||
for cursor in new Array(@getCursors()...)
|
||||
|
||||
@@ -174,24 +174,24 @@ class Editor extends View
|
||||
@renderedLines.on 'mousedown', (e) =>
|
||||
clickCount = e.originalEvent.detail
|
||||
|
||||
screenPosition = @screenPositionFromMouseEvent(e)
|
||||
if clickCount == 1
|
||||
screenPosition = @screenPositionFromMouseEvent(e)
|
||||
if e.metaKey
|
||||
@addCursorAtScreenPosition(screenPosition)
|
||||
else if e.shiftKey
|
||||
@selectToScreenPosition(@screenPositionFromMouseEvent(e))
|
||||
@selectToScreenPosition(screenPosition)
|
||||
else
|
||||
@setCursorScreenPosition(screenPosition)
|
||||
else if clickCount == 2
|
||||
if e.shiftKey
|
||||
@activeEditSession.getLastSelection().expandOverWord()
|
||||
@activeEditSession.expandLastSelectionOverWord()
|
||||
else
|
||||
@activeEditSession.getLastSelection().selectWord()
|
||||
@activeEditSession.selectWord()
|
||||
else if clickCount >= 3
|
||||
if e.shiftKey
|
||||
@activeEditSession.getLastSelection().expandOverLine()
|
||||
@activeEditSession.expandLastSelectionOverLine()
|
||||
else
|
||||
@activeEditSession.getLastSelection().selectLine()
|
||||
@activeEditSession.selectLine()
|
||||
|
||||
@selectOnMousemoveUntilMouseup()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user