   # Note: does note handle column position past line end (returned ix is on following lines)
   characterIndexForPosition: (pos) ->
     pos = Point.fromObj(pos)
-    bufferText = @$textArea.val()
+    bufferText = @getText()
     ix = 0
     row = pos.row
     col = pos.column

    if event.altKey and !event.shiftKey and event.metaKey and !event.ctrlKey or event.ctrlKey and !event.metaKey
      switch event.keyCode
        when 83
          atom.commands.dispatch(null, 'list-edit:select')
        when 88
          atom.commands.dispatch(null, 'list-edit:cut')

        @buffer.setText txt

  init: ($atomEmulator) ->
    $editableDiv = $atomEmulator.find '.edit-buffer'
    atom.workspace.editor.buffer = new Buffer($editableDiv)
    $editableDiv.attr 'spellcheck', false
    $editableDiv.keydown @keyHandler.bind this
    $editableDiv.focus()
    # document.execCommand 'insertText', false, '[ 111\n, 222\n, 333\n]'
    setTimeout ( ->
      atom.notifications.addSuccess 'Atom emulator initialized'
    ), 300 # Small delay to see it appear after page has loaded
