 
       triggerPush = false
 
-      cursorPosition = @editor.getCursorBufferPosition().toArray()
-      cursor = @editor.getCursor()
+      @clearMarkers(data.colour)
+
 
       if data.deletion
         buffer.delete oldRange
         @editor.scrollToBufferPosition(oldRange.start)
-        cursor.setBufferPosition(cursorPosition)
+        @addMarker oldRange.start.toArray()[0], data.colour
       else if oldRange.containsRange(newRange)
         buffer.setTextInRange oldRange, newText
         @editor.scrollToBufferPosition(oldRange.start)
-        cursor.setBufferPosition(cursorPosition)
+        @addMarker oldRange.start.toArray()[0], data.colour
       else
         buffer.insert newRange.start, newText
         @editor.scrollToBufferPosition(newRange.start)
-        cursor.setBufferPosition(cursorPosition)
+        @addMarker newRange.start.toArray()[0], data.colour
 
       triggerPush = true
 
     buffer.onDidChange (event) =>
       return unless triggerPush
       deletion = !(event.newText is "\n") and (event.newText.length is 0)
-      @pairingChannel.trigger 'client-change', {deletion: deletion, event: event, cursorColour: @gutterColour}
+      @pairingChannel.trigger 'client-change', {deletion: deletion, event: event, colour: @markerColour}
+
+    @editor.onDidChangeSelectionRange (event) =>
+      # if @editor.getSelectedText() isnt ""
+      # console.log event
+      console.log(event.newBufferRange.isEqual(event.oldBufferRange))
+
+      console.log event.oldBufferRange.serialize()
+      console.log event.newBufferRange.serialize()
+
+      rows = event.newBufferRange.getRows()
+      @pairingChannel.trigger 'client-text-select', {colour: @markerColour, rows: rows}
+
+
 
   receiveFriendInfo: (data) ->
     friendInfo = {colour: data.colour}


    buffer = @buffer = @editor.buffer

    $('atom-text-editor#pusht::shadow .line-number.cursor-line').addClass(@markerColour)
    @syncMarker()

    @pusher = new Pusher @app_key,
      authTransport: 'client'

    grammar = @editor.getGrammar()
    @pairingChannel.trigger 'client-grammar-sync', grammar.scopeName

  markRows: (rows, colour) ->
    _.each rows, (row) => @addMarker(row, colour)

  clearMarkers: (colour)->
    $("atom-text-editor#pusht::shadow .line-number").each (index, line) =>
