From 7dae03de0d276ff2ccf4168fdc8a75455b40d6d1 Mon Sep 17 00:00:00 2001 From: Corey Johnson Date: Mon, 2 Apr 2012 14:26:43 -0700 Subject: [PATCH] :lipstick --- src/atom/composite-selection.coffee | 38 ++++++++++++++--------------- src/atom/selection.coffee | 33 +++++++++---------------- 2 files changed, 29 insertions(+), 42 deletions(-) diff --git a/src/atom/composite-selection.coffee b/src/atom/composite-selection.coffee index b2aa79e54..9fa9f05ec 100644 --- a/src/atom/composite-selection.coffee +++ b/src/atom/composite-selection.coffee @@ -64,45 +64,43 @@ class CompositeSeleciton selectToScreenPosition: (position) -> @getLastSelection().selectToScreenPosition(position) - selectRight: -> - selection.selectRight() for selection in @getSelections() + moveSelections: (fn) -> + fn(selection) for selection in @getSelections() @mergeIntersectingSelections() + reverseMoveSelections: (fn) -> + fn(selection) for selection in @getSelections() + @mergeIntersectingSelections(reverse: true) + + selectRight: -> + @moveSelections (selection) => selection.selectRight() + selectLeft: -> - selection.selectLeft() for selection in @getSelections() - @mergeIntersectingSelections reverse: true + @reverseMoveSelections (selection) => selection.selectLeft() selectUp: -> - selection.selectUp() for selection in @getSelections() - @mergeIntersectingSelections reverse: true + @reverseMoveSelections (selection) => selection.selectUp() selectDown: -> - selection.selectDown() for selection in @getSelections() - @mergeIntersectingSelections() + @moveSelections (selection) => selection.selectDown() selectToTop: -> - selection.selectToTop() for selection in @getSelections() - @mergeIntersectingSelections reverse: true + @reverseMoveSelections (selection) => selection.selectToTop() selectToBottom: -> - selection.selectToBottom() for selection in @getSelections() - @mergeIntersectingSelections() + @moveSelections (selection) => selection.selectToBottom() selectToBeginningOfLine: -> - selection.selectToBeginningOfLine() for selection in @getSelections() - @mergeIntersectingSelections reverse: true + @reverseMoveSelections (selection) => selection.selectToBeginningOfLine() selectToEndOfLine: -> - selection.selectToEndOfLine() for selection in @getSelections() - @mergeIntersectingSelections() + @moveSelections (selection) => selection.selectToEndOfLine() selectToBeginningOfWord: -> - selection.selectToBeginningOfWord() for selection in @getSelections() - @mergeIntersectingSelections reverse: true + @reverseMoveSelections (selection) => selection.selectToBeginningOfWord() selectToEndOfWord: -> - selection.selectToEndOfWord() for selection in @getSelections() - @mergeIntersectingSelections() + @moveSelections (selection) => selection.selectToEndOfWord() setBufferRange: (bufferRange, options) -> @getLastSelection().setBufferRange(bufferRange, options) diff --git a/src/atom/selection.coffee b/src/atom/selection.coffee index 6b2f7dc24..4ee6a68fb 100644 --- a/src/atom/selection.coffee +++ b/src/atom/selection.coffee @@ -98,8 +98,7 @@ class Selection extends View [start, end] = [end, start] if reverse @cursor.setScreenPosition(start) - @modifySelection => - @cursor.setScreenPosition(end) + @modifySelection => @cursor.setScreenPosition(end) getBufferRange: -> @editor.bufferRangeForScreenRange(@getScreenRange()) @@ -209,44 +208,34 @@ class Selection extends View @setBufferRange new Range([row, 0], [row, rowLength]) selectRight: -> - @modifySelection => - @cursor.moveRight() + @modifySelection => @cursor.moveRight() selectLeft: -> - @modifySelection => - @cursor.moveLeft() + @modifySelection => @cursor.moveLeft() selectUp: -> - @modifySelection => - @cursor.moveUp() + @modifySelection => @cursor.moveUp() selectDown: -> - @modifySelection => - @cursor.moveDown() + @modifySelection => @cursor.moveDown() selectToTop: -> - @modifySelection => - @cursor.moveToTop() + @modifySelection => @cursor.moveToTop() selectToBottom: -> - @modifySelection => - @cursor.moveToBottom() + @modifySelection => @cursor.moveToBottom() selectToBeginningOfLine: -> - @modifySelection => - @cursor.moveToBeginningOfLine() + @modifySelection => @cursor.moveToBeginningOfLine() selectToEndOfLine: -> - @modifySelection => - @cursor.moveToEndOfLine() + @modifySelection => @cursor.moveToEndOfLine() selectToBeginningOfWord: -> - @modifySelection => - @cursor.moveToBeginningOfWord() + @modifySelection => @cursor.moveToBeginningOfWord() selectToEndOfWord: -> - @modifySelection => - @cursor.moveToEndOfWord() + @modifySelection => @cursor.moveToEndOfWord() cut: (maintainPasteboard=false) -> @copy(maintainPasteboard)