mirror of
https://github.com/atom/atom.git
synced 2026-01-24 14:28:14 -05:00
Remove old unused Anchor class
This commit is contained in:
@@ -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)
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
Point = require 'point'
|
||||
Range = require 'range'
|
||||
Anchor = require 'new-anchor'
|
||||
Anchor = require 'anchor'
|
||||
EventEmitter = require 'event-emitter'
|
||||
_ = require 'underscore'
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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'
|
||||
|
||||
Reference in New Issue
Block a user