Remove old unused Anchor class

This commit is contained in:
Nathan Sobo
2012-06-13 11:06:41 -06:00
parent e5b5f7b886
commit 09a05141d0
4 changed files with 14 additions and 67 deletions

View File

@@ -6,14 +6,7 @@ class Anchor
bufferPosition: null
screenPosition: null
constructor: (editor, screenPosition) ->
@editor = editor
if screenPosition
@setScreenPosition(screenPosition)
else
@bufferPosition = new Point(0,0)
@screenPosition = new Point(0,0)
constructor: (@editSession) ->
handleBufferChange: (e) ->
{ oldRange, newRange } = e
@@ -33,10 +26,11 @@ class Anchor
getBufferPosition: ->
@bufferPosition
setBufferPosition: (position, options) ->
setBufferPosition: (position, options={}) ->
@bufferPosition = Point.fromObject(position)
screenPosition = @editor.screenPositionForBufferPosition(@bufferPosition, options)
@setScreenPosition(screenPosition, clip: false, assignBufferPosition: false)
clip = options.clip ? true
@bufferPosition = @editSession.clipBufferPosition(@bufferPosition) if clip
@refreshScreenPosition(options)
getScreenPosition: ->
@screenPosition
@@ -46,8 +40,13 @@ class Anchor
clip = options.clip ? true
assignBufferPosition = options.assignBufferPosition ? true
@screenPosition = @editor.clipScreenPosition(@screenPosition, options) if clip
@bufferPosition = @editor.bufferPositionForScreenPosition(@screenPosition, options) if assignBufferPosition
@screenPosition = @editSession.clipScreenPosition(@screenPosition, options) if clip
@bufferPosition = @editSession.bufferPositionForScreenPosition(@screenPosition, options) if assignBufferPosition
Object.freeze @screenPosition
Object.freeze @bufferPosition
refreshScreenPosition: (options) ->
screenPosition = @editSession.screenPositionForBufferPosition(@bufferPosition, options)
@setScreenPosition(screenPosition, clip: false, assignBufferPosition: false)

View File

@@ -1,6 +1,6 @@
Point = require 'point'
Range = require 'range'
Anchor = require 'new-anchor'
Anchor = require 'anchor'
EventEmitter = require 'event-emitter'
_ = require 'underscore'

View File

@@ -1,52 +0,0 @@
Point = require 'point'
module.exports =
class Anchor
editor: null
bufferPosition: null
screenPosition: null
constructor: (@editSession) ->
handleBufferChange: (e) ->
{ oldRange, newRange } = e
position = @getBufferPosition()
return if position.isLessThan(oldRange.end)
newRow = newRange.end.row
newColumn = newRange.end.column
if position.row == oldRange.end.row
newColumn += position.column - oldRange.end.column
else
newColumn = position.column
newRow += position.row - oldRange.end.row
@setBufferPosition [newRow, newColumn]
getBufferPosition: ->
@bufferPosition
setBufferPosition: (position, options={}) ->
@bufferPosition = Point.fromObject(position)
clip = options.clip ? true
@bufferPosition = @editSession.clipBufferPosition(@bufferPosition) if clip
@refreshScreenPosition(options)
getScreenPosition: ->
@screenPosition
setScreenPosition: (position, options={}) ->
@screenPosition = Point.fromObject(position)
clip = options.clip ? true
assignBufferPosition = options.assignBufferPosition ? true
@screenPosition = @editSession.clipScreenPosition(@screenPosition, options) if clip
@bufferPosition = @editSession.bufferPositionForScreenPosition(@screenPosition, options) if assignBufferPosition
Object.freeze @screenPosition
Object.freeze @bufferPosition
refreshScreenPosition: (options) ->
screenPosition = @editSession.screenPositionForBufferPosition(@bufferPosition, options)
@setScreenPosition(screenPosition, clip: false, assignBufferPosition: false)

View File

@@ -1,5 +1,5 @@
Range = require 'range'
Anchor = require 'new-anchor'
Anchor = require 'anchor'
EventEmitter = require 'event-emitter'
AceOutdentAdaptor = require 'ace-outdent-adaptor'
_ = require 'underscore'