+find_loc_cursor_position = (tree, loc) ->
+ console.log tree, loc
+ for c in tree
+ if c.type is TYPE_TAG or c.type is TYPE_TEXT
+ # FIXME get_el_bounds doesn't work on TYPE_TEXT
+ bounds = get_el_bounds c.el
+ console.log bounds
+ continue if loc.left < bounds.x
+ continue if loc.left > bounds.x + bounds.w
+ continue if loc.top < bounds.y
+ continue if loc.top > bounds.y + bounds.h
+ if c.type is TYPE_TEXT
+ # FIXME find position, don't just pass 0
+ return [c, 0]
+ if c.children.length
+ console.log "in"
+ ret = find_loc_cursor_position c.children, loc
+ console.log 'found', ret if ret?
+ return ret if ret?
+ return null
+