Browse files

Slightly better cursor handling.

  • Loading branch information...
1 parent 8e7fdc7 commit d6e8468cad7375cb38ce1e578d89d93716c06a18 @luqui committed Jun 21, 2011
Showing with 16 additions and 9 deletions.
  1. +16 −9 StructuralFramework.js
View
25 StructuralFramework.js
@@ -348,16 +348,23 @@ $$.render_zipper = function(zipper) {
$$.render_cursor = function(cursor, ins) {
if (typeof(ins) === 'undefined') { ins = $([]) }
- var args = cursor.zipper.expr.args.map(function(a,i) {
- var r = render_expr_tree(a);
- return i == cursor.pos ? $(ins).add(elt('span', {'class': 'cursor_selected'}, r)) : r;
- });
- if (args.length > 0 && cursor.pos == cursor.zipper.expr.length) {
- args[args.length-1] = elt('span', {'class': 'cursor_selected_right'}, args[args.length-1], ins);
+
+ if (cursor.zipper.expr.args.length > 0) {
+ var args = cursor.zipper.expr.args.map(function(a,i) {
+ var r = render_expr_tree(a);
+ return i == cursor.pos ? $(ins).add(elt('span', {'class': 'cursor_selected'}, r)) : r;
+ });
+ if (cursor.pos == cursor.zipper.expr.length) {
+ args[args.length-1] = elt('span', {'class': 'cursor_selected_right'}, args[args.length-1], ins);
+ }
+ var h = render_head(cursor.zipper.expr.head, args);
}
- return render_context(
- cursor.zipper.contexts,
- render_head(cursor.zipper.expr.head, args));
+ else {
+ var h = elt('span', {'class': 'cursor_selected'},
+ ins, render_head(cursor.zipper.expr.head, args));
+ }
+
+ return render_context(cursor.zipper.contexts, h);
};
return $$;

0 comments on commit d6e8468

Please sign in to comment.