       read: 'full-view'
       present: 'present'
     }[mode] or ''
-    updateView() if old is 'present'
+    if mode in ['read', 'present']
+      editor.setOption 'readOnly', 'nocursor'
+      updateView()
+    else if mode in ['write', '']
+      editor.setOption 'readOnly', no
+      editor.focus()
+      updateView() if mode is ''
   slide: (nr) -> updateView()
   theme: (v) ->
     model.theme = v

  lineNumbers: no
  lineWrapping: yes
  dragDrop: no
editor.on 'change', ->
  updateView()
  if initiated

      updateTitle()

updateView = ->
  switch state.mode
    when 'present'
      md = editor.getValue().split /\n\s*\n\s*(?:[-*]\s*){3,}\n/
      if state.slide < md.length
        viewEl.innerHTML = marked md[state.slide || 0]
      else
        state.slide = md.length - 1
    when 'read', 'write'
      viewEl.innerHTML = marked editor.getValue()
    else
      cline = editor.getCursor().line
      md = editor.getValue().split '\n'
      md[cline] += '<span id="cursor"></span>'
      md = md.join '\n'
      viewEl.innerHTML = marked md
      updateIndex() if state.index
      updateToc() if state.toc
      scrollTop = viewWrapEl.scrollTop
      viewHeight = viewWrapEl.offsetHeight
      cursorSpan = document.getElementById 'cursor'
      cursorTop = cursorSpan.offsetTop
      cursorHeight = cursorSpan.offsetHeight
      if cursorTop < scrollTop or cursorTop > scrollTop + viewHeight - cursorHeight
        viewWrapEl.scrollTop = cursorTop - viewHeight/2

updateTitle = ->
  document.title = (if saved then '' else '*')+docTitle()
