   clone: () ->
     return new Cursor @view, @row, @col, @moveCol
 
+  _setRow: (row) ->
+    @emit 'rowChange', @row, row
+    @row = row
+
+  _setCol: (col) ->
+    @emit 'colChange', @col, col
+    @col = col
+
   from: (other) ->
-    @row = other.row
-    @col = other.col
+    @_setRow other.row
+    @_setCol other.col
     @moveCol = other.moveCol
 
   # cursorOptions:

  #   - keepProperties:  for movement, whether we should keep italic/bold state

  set: (row, col, cursorOptions) ->
    @row = row
    @setCol col, cursorOptions

  setRow: (row, cursorOptions) ->
    @row = row
    @_fromMoveCol cursorOptions

  _setRow: (row) ->
    @row = row

  setCol: (moveCol, cursorOptions = {pastEnd: true}) ->
    @moveCol = moveCol

if module?
  global.utils = require('./utils.coffee')
  global.constants = require('./constants.coffee')
  global.EventEmitter = require('./eventEmitter.coffee')

###
Cursor represents a cursor with a view
it handles movement logic, insert mode line properties (e.g. bold/italic)
###
class Cursor extends EventEmitter
  constructor: (view, row = null, col = null, moveCol = null) ->
    super
    @view = view
    @data = view.data
    @row = row ? (@data.getChildren @data.viewRoot)[0]
