Remove unused methods

This commit is contained in:
Corey Johnson 2012-04-02 14:13:25 -07:00
parent 9a8475b8e3
commit a75441b809
3 changed files with 21 additions and 74 deletions

View File

@ -10,6 +10,7 @@ class Cursor extends View
editor: null
screenPosition: null
bufferPosition: null
wordRegex: /(\w+)|([^\w\s]+)/g
initialize: (@editor) ->
@screenPosition = new Point(0, 0)
@ -65,31 +66,11 @@ class Cursor extends View
getScreenPosition: ->
@screenPosition
getBufferColumn: ->
@getBufferPosition().column
setBufferColumn: (column) ->
{ row } = @getBufferPosition()
@setBufferPosition {row, column}
getScreenColumn: ->
@getScreenPosition().column
setScreenColumn: (column) ->
{ row } = @getScreenPosition()
@setScreenPosition {row, column}
getScreenRow: ->
@getScreenPosition().row
getBufferRow: ->
@getBufferPosition().row
getCurrentBufferLine: ->
@editor.lineForBufferRow(@getBufferRow())
@editor.lineForBufferRow(@getBufferPosition().row)
isOnEOL: ->
@getScreenColumn() == @getCurrentBufferLine().length
@getScreenPosition().column == @getCurrentBufferLine().length
moveUp: ->
{ row, column } = @getScreenPosition()
@ -103,8 +84,6 @@ class Cursor extends View
@setScreenPosition({row: row + 1, column: column})
@goalColumn = column
wordRegex: /(\w+)|([^\w\s]+)/g
moveToNextWord: ->
bufferPosition = @getBufferPosition()
range = [bufferPosition, @editor.getEofPosition()]
@ -155,13 +134,7 @@ class Cursor extends View
moveLeft: ->
{ row, column } = @getScreenPosition()
if column > 0
column--
else
row--
column = Infinity
[row, column] = if column > 0 then [row, column - 1] else [row - 1, Infinity]
@setScreenPosition({row, column})
moveToTop: ->
@ -170,28 +143,6 @@ class Cursor extends View
moveToBottom: ->
@setBufferPosition @editor.getEofPosition()
moveLeftUntilMatch: (regex) ->
row = @getScreenRow()
column = @getScreenColumn()
offset = 0
matchBackwards = =>
line = @editor.buffer.lineForRow(row)
reversedLine = line[0...column].split('').reverse().join('')
regex.exec reversedLine
if not match = matchBackwards()
if row > 0
row--
column = @editor.buffer.lineLengthForRow(row)
match = matchBackwards()
else
column = 0
offset = match and -match[0].length or 0
@setScreenPosition [row, column + offset]
updateAppearance: ->
position = @editor.pixelPositionForScreenPosition(@getScreenPosition())
@css(position)

View File

@ -38,6 +38,15 @@ class Selection extends View
@setAnchorBufferPosition([newRow, newColumn])
isEmpty: ->
@getBufferRange().isEmpty()
isReversed: ->
not @isEmpty() and @cursor.getBufferPosition().isLessThan(@anchorBufferPosition)
intersectsWith: (otherSelection) ->
@getScreenRange().intersectsWith(otherSelection.getScreenRange())
clearSelection: ->
@anchorScreenPosition = null
@updateAppearance()
@ -146,15 +155,6 @@ class Selection extends View
@editor.buffer.delete(range) unless range.isEmpty()
@clearSelection()
isEmpty: ->
@getBufferRange().isEmpty()
isReversed: ->
not @isEmpty() and @cursor.getBufferPosition().isLessThan(@anchorBufferPosition)
intersectsWith: (otherSelection) ->
@getScreenRange().intersectsWith(otherSelection.getScreenRange())
merge: (otherSelection, options) ->
@setScreenRange(@getScreenRange().union(otherSelection.getScreenRange()), options)
otherSelection.remove()
@ -183,9 +183,13 @@ class Selection extends View
@anchorBufferPosition = bufferPosition
@anchorScreenPosition = @editor.screenPositionForBufferPosition(bufferPosition)
selectToScreenPosition: (position) ->
@modifySelection =>
@cursor.setScreenPosition(position)
selectWord: ->
row = @cursor.getScreenRow()
column = @cursor.getScreenColumn()
row = @cursor.getScreenPosition().row
column = @cursor.getScreenPosition().column
{ row, column } = @cursor.getBufferPosition()
@ -228,14 +232,6 @@ class Selection extends View
@modifySelection =>
@cursor.moveToBottom()
selectLeftUntilMatch: (regex) ->
@modifySelection =>
@cursor.moveLeftUntilMatch(regex)
selectToScreenPosition: (position) ->
@modifySelection =>
@cursor.setScreenPosition(position)
selectToBeginningOfLine: ->
@modifySelection =>
@cursor.moveToBeginningOfLine()

View File

@ -32,10 +32,10 @@ class MoveDown extends Motion
class MoveToPreviousWord extends Motion
execute: ->
@editor.getCursor().moveLeftUntilMatch /^\s*(\w+|[^A-Za-z0-9_ ]+)/
@editor.getCursor().moveToBeginningOfWord()
select: ->
@editor.getSelection().selectLeftUntilMatch /^\s*(\w+|[^A-Za-z0-9_ ]+)/
@editor.getSelection().selectToBeginningOfWord()
class MoveToNextWord extends Motion
execute: ->