 
 
 moveCellCursorDown = () ->
-  console.log "moveCellCursorDown"
   cursor = findOrCreateCellCursor()
   cell = $(cursor).next("div.cell")
   if cell
     insertCellCursorAfter(cell)
 
 moveCellCursorUp = () ->
-  console.log "moveCellCursorUp"
   cursor = findOrCreateCellCursor()
   cell = $(cursor).prev("div.cell")
   if cell
     insertCellCursorBefore(cell)
 
 moveCellCursorRight = () ->
-  console.log "moveCellCursorRight"
   cursor = findOrCreateCellCursor()
   nextCell = $(cursor).next(".cell")
   textarea = nextCell.children("textarea")

$(document).bind 'keydown', 'up', (ev) -> moveCellCursorUp()
$(document).bind 'keydown', 'right', (ev) -> moveCellCursorRight()
$(document).bind 'keydown', 'left', (ev) -> moveCellCursorLeft()

  editor.focus()
  cursor.remove()

setCursorToEndOfDoc = (editor) ->
  editor.setCursor editor.lineCount() - 1, editor.getLine(editor.lineCount() - 1).length

moveCellCursorLeft = () ->
  cursor = findOrCreateCellCursor()
  previousCell = $(cursor).prev(".cell")
  textarea = previousCell.children("textarea")
  editor = textarea[0].editor
  editor.focus()
  setCursorToEndOfDoc(editor)
  cursor.remove()


