       if old.isLessThan(nu) && text.match /^\r?\n\s*$/
         r.marker.setHeadBufferPosition old
 
-  showBody: (r) ->
-    r.body.style.display = null
-    r.hidden = false
-
-  hideBody: (r) ->
-    r.body.style.display = 'none'
-    r.hidden = true
-
-  toggle: (r) ->
-    if r.hidden then @showBody r else @hideBody r
-
   forLines: (ed, start, end) ->
     ed.findMarkers().filter((m)->m.result? &&
                                  m.getBufferRange().intersectsRowRange(start, end))

    body.classList.add 'body'
    body

  result: (ed, opts) ->
    view = document.createElement 'div'
    view.classList.add 'ink', 'inline', 'result'
    view.style.position = 'relative'
    view.style.top = -ed.getLineHeightInPixels() + 'px'
    view.style.left = '10px'
    header = @header()
    body = @body()
    view.appendChild header
    view.appendChild body
    header.innerText = opts.header
    body.innerText = opts.body
    view: view
    header: header
    body: body

  methods: (r) ->
    r.destroy = => @remove r
    r.invalidate = => @invalidate r
    r.validate = => @validate r
    r.show = => @showBody r
    r.hide = => @hideBody r
    r.toggle = => @toggle r

  show: (ed, mark, {watch, header, body}={}) ->
    mark.getBufferRange().isReversed and throw "Cannot add result to reversed marker"

# TODO: esc key to remove current result
# In general this is weird and needs a refactor

tree = require './tree'

module.exports =
  timeout: (t, f) -> setTimeout f, t
