annotate editor.js @ 116:9cf3e0b18ecc

Add support for selecting operator expressions in the editor
author Mike Pavone <pavone@retrodev.com>
date Mon, 15 Apr 2013 21:14:55 -0700
parents f2b435509301
children 0a66fe3a368a
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
3d1b8e96f5dc Initial commit
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
1
3d1b8e96f5dc Initial commit
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
2
113
c0bfff39abe3 Basic in and out navigation support added to funcall expressions. Added toHTML methods to listlit and arraylit.
Mike Pavone <pavone@retrodev.com>
parents: 110
diff changeset
3 object.prototype.toHTML = function(node, up) {
c0bfff39abe3 Basic in and out navigation support added to funcall expressions. Added toHTML methods to listlit and arraylit.
Mike Pavone <pavone@retrodev.com>
parents: 110
diff changeset
4 this.up = up;
14
85fb6ba15bc6 Start turning AST into HTML in editor
Mike Pavone <pavone@retrodev.com>
parents: 0
diff changeset
5 var el = newEl('div', {
15
a5ef5af3df0f Add toHTML methods to the rest of the AST nodes. Cleanup the formatting a bit
Mike Pavone <pavone@retrodev.com>
parents: 14
diff changeset
6 className: 'object'
14
85fb6ba15bc6 Start turning AST into HTML in editor
Mike Pavone <pavone@retrodev.com>
parents: 0
diff changeset
7 });
113
c0bfff39abe3 Basic in and out navigation support added to funcall expressions. Added toHTML methods to listlit and arraylit.
Mike Pavone <pavone@retrodev.com>
parents: 110
diff changeset
8 this.domNode = el;
14
85fb6ba15bc6 Start turning AST into HTML in editor
Mike Pavone <pavone@retrodev.com>
parents: 0
diff changeset
9 node.appendChild(el);
85fb6ba15bc6 Start turning AST into HTML in editor
Mike Pavone <pavone@retrodev.com>
parents: 0
diff changeset
10 for (var i in this.messages) {
113
c0bfff39abe3 Basic in and out navigation support added to funcall expressions. Added toHTML methods to listlit and arraylit.
Mike Pavone <pavone@retrodev.com>
parents: 110
diff changeset
11 this.messages[i].toHTML(el, this);
14
85fb6ba15bc6 Start turning AST into HTML in editor
Mike Pavone <pavone@retrodev.com>
parents: 0
diff changeset
12 }
85fb6ba15bc6 Start turning AST into HTML in editor
Mike Pavone <pavone@retrodev.com>
parents: 0
diff changeset
13 };
85fb6ba15bc6 Start turning AST into HTML in editor
Mike Pavone <pavone@retrodev.com>
parents: 0
diff changeset
14
113
c0bfff39abe3 Basic in and out navigation support added to funcall expressions. Added toHTML methods to listlit and arraylit.
Mike Pavone <pavone@retrodev.com>
parents: 110
diff changeset
15 lambda.prototype.toHTML = function(node, up) {
c0bfff39abe3 Basic in and out navigation support added to funcall expressions. Added toHTML methods to listlit and arraylit.
Mike Pavone <pavone@retrodev.com>
parents: 110
diff changeset
16 this.up = up
28
93bbc4c8be95 Allow selection of lambda
Mike Pavone <pavone@retrodev.com>
parents: 26
diff changeset
17 var astNode = this;
14
85fb6ba15bc6 Start turning AST into HTML in editor
Mike Pavone <pavone@retrodev.com>
parents: 0
diff changeset
18 var el = newEl('div', {
28
93bbc4c8be95 Allow selection of lambda
Mike Pavone <pavone@retrodev.com>
parents: 26
diff changeset
19 className: 'lambda',
29
18cec540238a Prevent event bubbling so lambda click handler doesn't get called when clicking on an element inside it
Mike Pavone <pavone@retrodev.com>
parents: 28
diff changeset
20 onclick: function(event) {
104
648659961e0e Get editor working again
Mike Pavone <pavone@retrodev.com>
parents: 29
diff changeset
21 main_module.lambdaClick(this, astNode, event);
28
93bbc4c8be95 Allow selection of lambda
Mike Pavone <pavone@retrodev.com>
parents: 26
diff changeset
22 }
14
85fb6ba15bc6 Start turning AST into HTML in editor
Mike Pavone <pavone@retrodev.com>
parents: 0
diff changeset
23 });
113
c0bfff39abe3 Basic in and out navigation support added to funcall expressions. Added toHTML methods to listlit and arraylit.
Mike Pavone <pavone@retrodev.com>
parents: 110
diff changeset
24 this.domNode = el;
26
fe593c1df568 Display receiver arg in editor. Improve formatting in editor.
Mike Pavone <pavone@retrodev.com>
parents: 25
diff changeset
25 var args = newEl('div', {
fe593c1df568 Display receiver arg in editor. Improve formatting in editor.
Mike Pavone <pavone@retrodev.com>
parents: 25
diff changeset
26 className: 'args'
fe593c1df568 Display receiver arg in editor. Improve formatting in editor.
Mike Pavone <pavone@retrodev.com>
parents: 25
diff changeset
27 });
15
a5ef5af3df0f Add toHTML methods to the rest of the AST nodes. Cleanup the formatting a bit
Mike Pavone <pavone@retrodev.com>
parents: 14
diff changeset
28 for (var i in this.args) {
113
c0bfff39abe3 Basic in and out navigation support added to funcall expressions. Added toHTML methods to listlit and arraylit.
Mike Pavone <pavone@retrodev.com>
parents: 110
diff changeset
29 this.args[i].toHTML(args, this);
15
a5ef5af3df0f Add toHTML methods to the rest of the AST nodes. Cleanup the formatting a bit
Mike Pavone <pavone@retrodev.com>
parents: 14
diff changeset
30 }
a5ef5af3df0f Add toHTML methods to the rest of the AST nodes. Cleanup the formatting a bit
Mike Pavone <pavone@retrodev.com>
parents: 14
diff changeset
31 var body = newEl('div', {
a5ef5af3df0f Add toHTML methods to the rest of the AST nodes. Cleanup the formatting a bit
Mike Pavone <pavone@retrodev.com>
parents: 14
diff changeset
32 className: 'lambdabody'
a5ef5af3df0f Add toHTML methods to the rest of the AST nodes. Cleanup the formatting a bit
Mike Pavone <pavone@retrodev.com>
parents: 14
diff changeset
33 });
a5ef5af3df0f Add toHTML methods to the rest of the AST nodes. Cleanup the formatting a bit
Mike Pavone <pavone@retrodev.com>
parents: 14
diff changeset
34 for (var i in this.expressions) {
113
c0bfff39abe3 Basic in and out navigation support added to funcall expressions. Added toHTML methods to listlit and arraylit.
Mike Pavone <pavone@retrodev.com>
parents: 110
diff changeset
35 this.expressions[i].toHTML(body, this);
15
a5ef5af3df0f Add toHTML methods to the rest of the AST nodes. Cleanup the formatting a bit
Mike Pavone <pavone@retrodev.com>
parents: 14
diff changeset
36 }
26
fe593c1df568 Display receiver arg in editor. Improve formatting in editor.
Mike Pavone <pavone@retrodev.com>
parents: 25
diff changeset
37 el.appendChild(args);
15
a5ef5af3df0f Add toHTML methods to the rest of the AST nodes. Cleanup the formatting a bit
Mike Pavone <pavone@retrodev.com>
parents: 14
diff changeset
38 el.appendChild(body);
14
85fb6ba15bc6 Start turning AST into HTML in editor
Mike Pavone <pavone@retrodev.com>
parents: 0
diff changeset
39 node.appendChild(el);
85fb6ba15bc6 Start turning AST into HTML in editor
Mike Pavone <pavone@retrodev.com>
parents: 0
diff changeset
40 };
85fb6ba15bc6 Start turning AST into HTML in editor
Mike Pavone <pavone@retrodev.com>
parents: 0
diff changeset
41
113
c0bfff39abe3 Basic in and out navigation support added to funcall expressions. Added toHTML methods to listlit and arraylit.
Mike Pavone <pavone@retrodev.com>
parents: 110
diff changeset
42 assignment.prototype.toHTML = function(node, up) {
c0bfff39abe3 Basic in and out navigation support added to funcall expressions. Added toHTML methods to listlit and arraylit.
Mike Pavone <pavone@retrodev.com>
parents: 110
diff changeset
43 this.up = up;
14
85fb6ba15bc6 Start turning AST into HTML in editor
Mike Pavone <pavone@retrodev.com>
parents: 0
diff changeset
44 var base = newEl('div', {
85fb6ba15bc6 Start turning AST into HTML in editor
Mike Pavone <pavone@retrodev.com>
parents: 0
diff changeset
45 className: 'assignment'
85fb6ba15bc6 Start turning AST into HTML in editor
Mike Pavone <pavone@retrodev.com>
parents: 0
diff changeset
46 });
85fb6ba15bc6 Start turning AST into HTML in editor
Mike Pavone <pavone@retrodev.com>
parents: 0
diff changeset
47 var varName = newEl('span', {
85fb6ba15bc6 Start turning AST into HTML in editor
Mike Pavone <pavone@retrodev.com>
parents: 0
diff changeset
48 textContent: this.symbol.name + ' <-'
0
3d1b8e96f5dc Initial commit
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
49 });
113
c0bfff39abe3 Basic in and out navigation support added to funcall expressions. Added toHTML methods to listlit and arraylit.
Mike Pavone <pavone@retrodev.com>
parents: 110
diff changeset
50 this.domNode = base;
14
85fb6ba15bc6 Start turning AST into HTML in editor
Mike Pavone <pavone@retrodev.com>
parents: 0
diff changeset
51 base.appendChild(varName);
85fb6ba15bc6 Start turning AST into HTML in editor
Mike Pavone <pavone@retrodev.com>
parents: 0
diff changeset
52 node.appendChild(base);
113
c0bfff39abe3 Basic in and out navigation support added to funcall expressions. Added toHTML methods to listlit and arraylit.
Mike Pavone <pavone@retrodev.com>
parents: 110
diff changeset
53 this.expression.toHTML(base, this);
14
85fb6ba15bc6 Start turning AST into HTML in editor
Mike Pavone <pavone@retrodev.com>
parents: 0
diff changeset
54 };
85fb6ba15bc6 Start turning AST into HTML in editor
Mike Pavone <pavone@retrodev.com>
parents: 0
diff changeset
55
113
c0bfff39abe3 Basic in and out navigation support added to funcall expressions. Added toHTML methods to listlit and arraylit.
Mike Pavone <pavone@retrodev.com>
parents: 110
diff changeset
56 op.prototype.toHTML = function(node, up) {
c0bfff39abe3 Basic in and out navigation support added to funcall expressions. Added toHTML methods to listlit and arraylit.
Mike Pavone <pavone@retrodev.com>
parents: 110
diff changeset
57 this.up = up;
116
9cf3e0b18ecc Add support for selecting operator expressions in the editor
Mike Pavone <pavone@retrodev.com>
parents: 114
diff changeset
58 var astNode = this;
15
a5ef5af3df0f Add toHTML methods to the rest of the AST nodes. Cleanup the formatting a bit
Mike Pavone <pavone@retrodev.com>
parents: 14
diff changeset
59 var base = newEl('span', {
116
9cf3e0b18ecc Add support for selecting operator expressions in the editor
Mike Pavone <pavone@retrodev.com>
parents: 114
diff changeset
60 className: 'op',
9cf3e0b18ecc Add support for selecting operator expressions in the editor
Mike Pavone <pavone@retrodev.com>
parents: 114
diff changeset
61 onclick: function(event) {
9cf3e0b18ecc Add support for selecting operator expressions in the editor
Mike Pavone <pavone@retrodev.com>
parents: 114
diff changeset
62 main_module.opClick(this, astNode, event);
9cf3e0b18ecc Add support for selecting operator expressions in the editor
Mike Pavone <pavone@retrodev.com>
parents: 114
diff changeset
63 }
15
a5ef5af3df0f Add toHTML methods to the rest of the AST nodes. Cleanup the formatting a bit
Mike Pavone <pavone@retrodev.com>
parents: 14
diff changeset
64 });
113
c0bfff39abe3 Basic in and out navigation support added to funcall expressions. Added toHTML methods to listlit and arraylit.
Mike Pavone <pavone@retrodev.com>
parents: 110
diff changeset
65 this.domNode = base;
c0bfff39abe3 Basic in and out navigation support added to funcall expressions. Added toHTML methods to listlit and arraylit.
Mike Pavone <pavone@retrodev.com>
parents: 110
diff changeset
66 this.left.toHTML(base, this);
15
a5ef5af3df0f Add toHTML methods to the rest of the AST nodes. Cleanup the formatting a bit
Mike Pavone <pavone@retrodev.com>
parents: 14
diff changeset
67 base.appendChild(newEl('span', {
a5ef5af3df0f Add toHTML methods to the rest of the AST nodes. Cleanup the formatting a bit
Mike Pavone <pavone@retrodev.com>
parents: 14
diff changeset
68 textContent: this.op,
a5ef5af3df0f Add toHTML methods to the rest of the AST nodes. Cleanup the formatting a bit
Mike Pavone <pavone@retrodev.com>
parents: 14
diff changeset
69 className: 'opname'
a5ef5af3df0f Add toHTML methods to the rest of the AST nodes. Cleanup the formatting a bit
Mike Pavone <pavone@retrodev.com>
parents: 14
diff changeset
70 }));
114
f2b435509301 Work around desugaring of && and || in editor.
Mike Pavone <pavone@retrodev.com>
parents: 113
diff changeset
71 if (this.op == '&&' || this.op == '||') {
f2b435509301 Work around desugaring of && and || in editor.
Mike Pavone <pavone@retrodev.com>
parents: 113
diff changeset
72 this.right.expressions[0].toHTML(base, this);
f2b435509301 Work around desugaring of && and || in editor.
Mike Pavone <pavone@retrodev.com>
parents: 113
diff changeset
73 } else {
f2b435509301 Work around desugaring of && and || in editor.
Mike Pavone <pavone@retrodev.com>
parents: 113
diff changeset
74 this.right.toHTML(base, this);
f2b435509301 Work around desugaring of && and || in editor.
Mike Pavone <pavone@retrodev.com>
parents: 113
diff changeset
75 }
15
a5ef5af3df0f Add toHTML methods to the rest of the AST nodes. Cleanup the formatting a bit
Mike Pavone <pavone@retrodev.com>
parents: 14
diff changeset
76 node.appendChild(base);
a5ef5af3df0f Add toHTML methods to the rest of the AST nodes. Cleanup the formatting a bit
Mike Pavone <pavone@retrodev.com>
parents: 14
diff changeset
77 };
a5ef5af3df0f Add toHTML methods to the rest of the AST nodes. Cleanup the formatting a bit
Mike Pavone <pavone@retrodev.com>
parents: 14
diff changeset
78
113
c0bfff39abe3 Basic in and out navigation support added to funcall expressions. Added toHTML methods to listlit and arraylit.
Mike Pavone <pavone@retrodev.com>
parents: 110
diff changeset
79 intlit.prototype.toHTML = function(node, up) {
c0bfff39abe3 Basic in and out navigation support added to funcall expressions. Added toHTML methods to listlit and arraylit.
Mike Pavone <pavone@retrodev.com>
parents: 110
diff changeset
80 this.up = up;
c0bfff39abe3 Basic in and out navigation support added to funcall expressions. Added toHTML methods to listlit and arraylit.
Mike Pavone <pavone@retrodev.com>
parents: 110
diff changeset
81 this.domNode = newEl('span', {
14
85fb6ba15bc6 Start turning AST into HTML in editor
Mike Pavone <pavone@retrodev.com>
parents: 0
diff changeset
82 className: 'integer',
15
a5ef5af3df0f Add toHTML methods to the rest of the AST nodes. Cleanup the formatting a bit
Mike Pavone <pavone@retrodev.com>
parents: 14
diff changeset
83 textContent: this.val
113
c0bfff39abe3 Basic in and out navigation support added to funcall expressions. Added toHTML methods to listlit and arraylit.
Mike Pavone <pavone@retrodev.com>
parents: 110
diff changeset
84 });
c0bfff39abe3 Basic in and out navigation support added to funcall expressions. Added toHTML methods to listlit and arraylit.
Mike Pavone <pavone@retrodev.com>
parents: 110
diff changeset
85 node.appendChild(this.domNode);
14
85fb6ba15bc6 Start turning AST into HTML in editor
Mike Pavone <pavone@retrodev.com>
parents: 0
diff changeset
86 };
85fb6ba15bc6 Start turning AST into HTML in editor
Mike Pavone <pavone@retrodev.com>
parents: 0
diff changeset
87
113
c0bfff39abe3 Basic in and out navigation support added to funcall expressions. Added toHTML methods to listlit and arraylit.
Mike Pavone <pavone@retrodev.com>
parents: 110
diff changeset
88 floatlit.prototype.toHTML = function(node, up) {
c0bfff39abe3 Basic in and out navigation support added to funcall expressions. Added toHTML methods to listlit and arraylit.
Mike Pavone <pavone@retrodev.com>
parents: 110
diff changeset
89 this.up = up;
c0bfff39abe3 Basic in and out navigation support added to funcall expressions. Added toHTML methods to listlit and arraylit.
Mike Pavone <pavone@retrodev.com>
parents: 110
diff changeset
90 this.domNode = newEl('span', {
14
85fb6ba15bc6 Start turning AST into HTML in editor
Mike Pavone <pavone@retrodev.com>
parents: 0
diff changeset
91 className: 'float',
15
a5ef5af3df0f Add toHTML methods to the rest of the AST nodes. Cleanup the formatting a bit
Mike Pavone <pavone@retrodev.com>
parents: 14
diff changeset
92 textContent: this.val
113
c0bfff39abe3 Basic in and out navigation support added to funcall expressions. Added toHTML methods to listlit and arraylit.
Mike Pavone <pavone@retrodev.com>
parents: 110
diff changeset
93 });
c0bfff39abe3 Basic in and out navigation support added to funcall expressions. Added toHTML methods to listlit and arraylit.
Mike Pavone <pavone@retrodev.com>
parents: 110
diff changeset
94 node.appendChild(this.domNode);
14
85fb6ba15bc6 Start turning AST into HTML in editor
Mike Pavone <pavone@retrodev.com>
parents: 0
diff changeset
95 };
85fb6ba15bc6 Start turning AST into HTML in editor
Mike Pavone <pavone@retrodev.com>
parents: 0
diff changeset
96
113
c0bfff39abe3 Basic in and out navigation support added to funcall expressions. Added toHTML methods to listlit and arraylit.
Mike Pavone <pavone@retrodev.com>
parents: 110
diff changeset
97 strlit.prototype.toHTML = function(node, up) {
c0bfff39abe3 Basic in and out navigation support added to funcall expressions. Added toHTML methods to listlit and arraylit.
Mike Pavone <pavone@retrodev.com>
parents: 110
diff changeset
98 this.up = up;
c0bfff39abe3 Basic in and out navigation support added to funcall expressions. Added toHTML methods to listlit and arraylit.
Mike Pavone <pavone@retrodev.com>
parents: 110
diff changeset
99 this.domNode = newEl('span', {
14
85fb6ba15bc6 Start turning AST into HTML in editor
Mike Pavone <pavone@retrodev.com>
parents: 0
diff changeset
100 className: 'string',
25
4d87c38404d6 List literals, fixes to implicit self property lookup, import statement and editor improvements
Mike Pavone <pavone@retrodev.com>
parents: 23
diff changeset
101 contentEditable: 'true',
15
a5ef5af3df0f Add toHTML methods to the rest of the AST nodes. Cleanup the formatting a bit
Mike Pavone <pavone@retrodev.com>
parents: 14
diff changeset
102 textContent: this.val
113
c0bfff39abe3 Basic in and out navigation support added to funcall expressions. Added toHTML methods to listlit and arraylit.
Mike Pavone <pavone@retrodev.com>
parents: 110
diff changeset
103 });
c0bfff39abe3 Basic in and out navigation support added to funcall expressions. Added toHTML methods to listlit and arraylit.
Mike Pavone <pavone@retrodev.com>
parents: 110
diff changeset
104 node.appendChild(this.domNode);
c0bfff39abe3 Basic in and out navigation support added to funcall expressions. Added toHTML methods to listlit and arraylit.
Mike Pavone <pavone@retrodev.com>
parents: 110
diff changeset
105 };
c0bfff39abe3 Basic in and out navigation support added to funcall expressions. Added toHTML methods to listlit and arraylit.
Mike Pavone <pavone@retrodev.com>
parents: 110
diff changeset
106
c0bfff39abe3 Basic in and out navigation support added to funcall expressions. Added toHTML methods to listlit and arraylit.
Mike Pavone <pavone@retrodev.com>
parents: 110
diff changeset
107 listlit.prototype.toHTML = function(node, up) {
c0bfff39abe3 Basic in and out navigation support added to funcall expressions. Added toHTML methods to listlit and arraylit.
Mike Pavone <pavone@retrodev.com>
parents: 110
diff changeset
108 this.up = up;
c0bfff39abe3 Basic in and out navigation support added to funcall expressions. Added toHTML methods to listlit and arraylit.
Mike Pavone <pavone@retrodev.com>
parents: 110
diff changeset
109 this.domNode = newEl('span', {
c0bfff39abe3 Basic in and out navigation support added to funcall expressions. Added toHTML methods to listlit and arraylit.
Mike Pavone <pavone@retrodev.com>
parents: 110
diff changeset
110 className: 'list',
c0bfff39abe3 Basic in and out navigation support added to funcall expressions. Added toHTML methods to listlit and arraylit.
Mike Pavone <pavone@retrodev.com>
parents: 110
diff changeset
111 });
c0bfff39abe3 Basic in and out navigation support added to funcall expressions. Added toHTML methods to listlit and arraylit.
Mike Pavone <pavone@retrodev.com>
parents: 110
diff changeset
112 for (var i = 0; i < this.val.length; i++) {
c0bfff39abe3 Basic in and out navigation support added to funcall expressions. Added toHTML methods to listlit and arraylit.
Mike Pavone <pavone@retrodev.com>
parents: 110
diff changeset
113 this.val[i].toHTML(this.domNode, this);
c0bfff39abe3 Basic in and out navigation support added to funcall expressions. Added toHTML methods to listlit and arraylit.
Mike Pavone <pavone@retrodev.com>
parents: 110
diff changeset
114 }
c0bfff39abe3 Basic in and out navigation support added to funcall expressions. Added toHTML methods to listlit and arraylit.
Mike Pavone <pavone@retrodev.com>
parents: 110
diff changeset
115 node.appendChild(this.domNode);
14
85fb6ba15bc6 Start turning AST into HTML in editor
Mike Pavone <pavone@retrodev.com>
parents: 0
diff changeset
116 };
85fb6ba15bc6 Start turning AST into HTML in editor
Mike Pavone <pavone@retrodev.com>
parents: 0
diff changeset
117
113
c0bfff39abe3 Basic in and out navigation support added to funcall expressions. Added toHTML methods to listlit and arraylit.
Mike Pavone <pavone@retrodev.com>
parents: 110
diff changeset
118 arraylit.prototype.toHTML = function(node, up) {
c0bfff39abe3 Basic in and out navigation support added to funcall expressions. Added toHTML methods to listlit and arraylit.
Mike Pavone <pavone@retrodev.com>
parents: 110
diff changeset
119 this.up = up;
c0bfff39abe3 Basic in and out navigation support added to funcall expressions. Added toHTML methods to listlit and arraylit.
Mike Pavone <pavone@retrodev.com>
parents: 110
diff changeset
120 this.domNode = newEl('span', {
c0bfff39abe3 Basic in and out navigation support added to funcall expressions. Added toHTML methods to listlit and arraylit.
Mike Pavone <pavone@retrodev.com>
parents: 110
diff changeset
121 className: 'array',
c0bfff39abe3 Basic in and out navigation support added to funcall expressions. Added toHTML methods to listlit and arraylit.
Mike Pavone <pavone@retrodev.com>
parents: 110
diff changeset
122 });
c0bfff39abe3 Basic in and out navigation support added to funcall expressions. Added toHTML methods to listlit and arraylit.
Mike Pavone <pavone@retrodev.com>
parents: 110
diff changeset
123 for (var i = 0; i < this.val.length; i++) {
c0bfff39abe3 Basic in and out navigation support added to funcall expressions. Added toHTML methods to listlit and arraylit.
Mike Pavone <pavone@retrodev.com>
parents: 110
diff changeset
124 this.val[i].toHTML(this.domNode, this);
c0bfff39abe3 Basic in and out navigation support added to funcall expressions. Added toHTML methods to listlit and arraylit.
Mike Pavone <pavone@retrodev.com>
parents: 110
diff changeset
125 }
c0bfff39abe3 Basic in and out navigation support added to funcall expressions. Added toHTML methods to listlit and arraylit.
Mike Pavone <pavone@retrodev.com>
parents: 110
diff changeset
126 node.appendChild(this.domNode);
c0bfff39abe3 Basic in and out navigation support added to funcall expressions. Added toHTML methods to listlit and arraylit.
Mike Pavone <pavone@retrodev.com>
parents: 110
diff changeset
127 };
c0bfff39abe3 Basic in and out navigation support added to funcall expressions. Added toHTML methods to listlit and arraylit.
Mike Pavone <pavone@retrodev.com>
parents: 110
diff changeset
128
c0bfff39abe3 Basic in and out navigation support added to funcall expressions. Added toHTML methods to listlit and arraylit.
Mike Pavone <pavone@retrodev.com>
parents: 110
diff changeset
129 funcall.prototype.toHTML = function(node, up) {
c0bfff39abe3 Basic in and out navigation support added to funcall expressions. Added toHTML methods to listlit and arraylit.
Mike Pavone <pavone@retrodev.com>
parents: 110
diff changeset
130 this.up = up;
25
4d87c38404d6 List literals, fixes to implicit self property lookup, import statement and editor improvements
Mike Pavone <pavone@retrodev.com>
parents: 23
diff changeset
131 var astNode = this;
15
a5ef5af3df0f Add toHTML methods to the rest of the AST nodes. Cleanup the formatting a bit
Mike Pavone <pavone@retrodev.com>
parents: 14
diff changeset
132 var base = newEl('div', {
113
c0bfff39abe3 Basic in and out navigation support added to funcall expressions. Added toHTML methods to listlit and arraylit.
Mike Pavone <pavone@retrodev.com>
parents: 110
diff changeset
133 className: 'funcall',
c0bfff39abe3 Basic in and out navigation support added to funcall expressions. Added toHTML methods to listlit and arraylit.
Mike Pavone <pavone@retrodev.com>
parents: 110
diff changeset
134 onclick: function(event) {
c0bfff39abe3 Basic in and out navigation support added to funcall expressions. Added toHTML methods to listlit and arraylit.
Mike Pavone <pavone@retrodev.com>
parents: 110
diff changeset
135 main_module.funClick(this, astNode, event);
c0bfff39abe3 Basic in and out navigation support added to funcall expressions. Added toHTML methods to listlit and arraylit.
Mike Pavone <pavone@retrodev.com>
parents: 110
diff changeset
136 }
15
a5ef5af3df0f Add toHTML methods to the rest of the AST nodes. Cleanup the formatting a bit
Mike Pavone <pavone@retrodev.com>
parents: 14
diff changeset
137 });
113
c0bfff39abe3 Basic in and out navigation support added to funcall expressions. Added toHTML methods to listlit and arraylit.
Mike Pavone <pavone@retrodev.com>
parents: 110
diff changeset
138 this.domNode = base;
26
fe593c1df568 Display receiver arg in editor. Improve formatting in editor.
Mike Pavone <pavone@retrodev.com>
parents: 25
diff changeset
139 if (this.receiver) {
113
c0bfff39abe3 Basic in and out navigation support added to funcall expressions. Added toHTML methods to listlit and arraylit.
Mike Pavone <pavone@retrodev.com>
parents: 110
diff changeset
140 this.receiver.toHTML(base, this);
26
fe593c1df568 Display receiver arg in editor. Improve formatting in editor.
Mike Pavone <pavone@retrodev.com>
parents: 25
diff changeset
141 }
15
a5ef5af3df0f Add toHTML methods to the rest of the AST nodes. Cleanup the formatting a bit
Mike Pavone <pavone@retrodev.com>
parents: 14
diff changeset
142 var parts = this.name.split(':');
a5ef5af3df0f Add toHTML methods to the rest of the AST nodes. Cleanup the formatting a bit
Mike Pavone <pavone@retrodev.com>
parents: 14
diff changeset
143 for (var i in parts ) {
a5ef5af3df0f Add toHTML methods to the rest of the AST nodes. Cleanup the formatting a bit
Mike Pavone <pavone@retrodev.com>
parents: 14
diff changeset
144 if(parts[i]) {
25
4d87c38404d6 List literals, fixes to implicit self property lookup, import statement and editor improvements
Mike Pavone <pavone@retrodev.com>
parents: 23
diff changeset
145 base.appendChild(newEl('span', {
26
fe593c1df568 Display receiver arg in editor. Improve formatting in editor.
Mike Pavone <pavone@retrodev.com>
parents: 25
diff changeset
146 textContent: parts[i] + (this.receiver && parts.length == 1 ? '' : ':'),
113
c0bfff39abe3 Basic in and out navigation support added to funcall expressions. Added toHTML methods to listlit and arraylit.
Mike Pavone <pavone@retrodev.com>
parents: 110
diff changeset
147 className: 'funpart'
c0bfff39abe3 Basic in and out navigation support added to funcall expressions. Added toHTML methods to listlit and arraylit.
Mike Pavone <pavone@retrodev.com>
parents: 110
diff changeset
148 }));
15
a5ef5af3df0f Add toHTML methods to the rest of the AST nodes. Cleanup the formatting a bit
Mike Pavone <pavone@retrodev.com>
parents: 14
diff changeset
149 if (this.args[i]) {
113
c0bfff39abe3 Basic in and out navigation support added to funcall expressions. Added toHTML methods to listlit and arraylit.
Mike Pavone <pavone@retrodev.com>
parents: 110
diff changeset
150 this.args[i].toHTML(base, this);
15
a5ef5af3df0f Add toHTML methods to the rest of the AST nodes. Cleanup the formatting a bit
Mike Pavone <pavone@retrodev.com>
parents: 14
diff changeset
151 }
a5ef5af3df0f Add toHTML methods to the rest of the AST nodes. Cleanup the formatting a bit
Mike Pavone <pavone@retrodev.com>
parents: 14
diff changeset
152 }
a5ef5af3df0f Add toHTML methods to the rest of the AST nodes. Cleanup the formatting a bit
Mike Pavone <pavone@retrodev.com>
parents: 14
diff changeset
153 }
a5ef5af3df0f Add toHTML methods to the rest of the AST nodes. Cleanup the formatting a bit
Mike Pavone <pavone@retrodev.com>
parents: 14
diff changeset
154 for (; i < this.args.length; i++) {
113
c0bfff39abe3 Basic in and out navigation support added to funcall expressions. Added toHTML methods to listlit and arraylit.
Mike Pavone <pavone@retrodev.com>
parents: 110
diff changeset
155 this.args[i].toHTML(base, this);
15
a5ef5af3df0f Add toHTML methods to the rest of the AST nodes. Cleanup the formatting a bit
Mike Pavone <pavone@retrodev.com>
parents: 14
diff changeset
156 }
a5ef5af3df0f Add toHTML methods to the rest of the AST nodes. Cleanup the formatting a bit
Mike Pavone <pavone@retrodev.com>
parents: 14
diff changeset
157 node.appendChild(base);
14
85fb6ba15bc6 Start turning AST into HTML in editor
Mike Pavone <pavone@retrodev.com>
parents: 0
diff changeset
158 };
15
a5ef5af3df0f Add toHTML methods to the rest of the AST nodes. Cleanup the formatting a bit
Mike Pavone <pavone@retrodev.com>
parents: 14
diff changeset
159
113
c0bfff39abe3 Basic in and out navigation support added to funcall expressions. Added toHTML methods to listlit and arraylit.
Mike Pavone <pavone@retrodev.com>
parents: 110
diff changeset
160 symbol.prototype.toHTML = function(node, up) {
c0bfff39abe3 Basic in and out navigation support added to funcall expressions. Added toHTML methods to listlit and arraylit.
Mike Pavone <pavone@retrodev.com>
parents: 110
diff changeset
161 this.up = up;
23
068d63627b16 Populate in scope symbol buttons when clicking on a symbol in the source
Mike Pavone <pavone@retrodev.com>
parents: 15
diff changeset
162 var astNode = this;
113
c0bfff39abe3 Basic in and out navigation support added to funcall expressions. Added toHTML methods to listlit and arraylit.
Mike Pavone <pavone@retrodev.com>
parents: 110
diff changeset
163 this.domNode = newEl('span', {
15
a5ef5af3df0f Add toHTML methods to the rest of the AST nodes. Cleanup the formatting a bit
Mike Pavone <pavone@retrodev.com>
parents: 14
diff changeset
164 className: 'symbol',
23
068d63627b16 Populate in scope symbol buttons when clicking on a symbol in the source
Mike Pavone <pavone@retrodev.com>
parents: 15
diff changeset
165 textContent: this.name,
29
18cec540238a Prevent event bubbling so lambda click handler doesn't get called when clicking on an element inside it
Mike Pavone <pavone@retrodev.com>
parents: 28
diff changeset
166 onclick: function(event) {
105
35006a6e1c47 Fixed more editor coderot and improved syntax/selection coloring a bit.
Mike Pavone <pavone@retrodev.com>
parents: 104
diff changeset
167 main_module.symbolClick(this, astNode, event);
23
068d63627b16 Populate in scope symbol buttons when clicking on a symbol in the source
Mike Pavone <pavone@retrodev.com>
parents: 15
diff changeset
168 }
113
c0bfff39abe3 Basic in and out navigation support added to funcall expressions. Added toHTML methods to listlit and arraylit.
Mike Pavone <pavone@retrodev.com>
parents: 110
diff changeset
169 })
c0bfff39abe3 Basic in and out navigation support added to funcall expressions. Added toHTML methods to listlit and arraylit.
Mike Pavone <pavone@retrodev.com>
parents: 110
diff changeset
170 node.appendChild(this.domNode);
15
a5ef5af3df0f Add toHTML methods to the rest of the AST nodes. Cleanup the formatting a bit
Mike Pavone <pavone@retrodev.com>
parents: 14
diff changeset
171 }
110
d715fb3c39ab Implemented clicking on symbols inside inscope box to replace function name in funcall.
Mike Pavone <pavone@retrodev.com>
parents: 105
diff changeset
172
d715fb3c39ab Implemented clicking on symbols inside inscope box to replace function name in funcall.
Mike Pavone <pavone@retrodev.com>
parents: 105
diff changeset
173 function getEl(from, idx)
d715fb3c39ab Implemented clicking on symbols inside inscope box to replace function name in funcall.
Mike Pavone <pavone@retrodev.com>
parents: 105
diff changeset
174 {
d715fb3c39ab Implemented clicking on symbols inside inscope box to replace function name in funcall.
Mike Pavone <pavone@retrodev.com>
parents: 105
diff changeset
175 return from[idx];
d715fb3c39ab Implemented clicking on symbols inside inscope box to replace function name in funcall.
Mike Pavone <pavone@retrodev.com>
parents: 105
diff changeset
176 }
d715fb3c39ab Implemented clicking on symbols inside inscope box to replace function name in funcall.
Mike Pavone <pavone@retrodev.com>
parents: 105
diff changeset
177
d715fb3c39ab Implemented clicking on symbols inside inscope box to replace function name in funcall.
Mike Pavone <pavone@retrodev.com>
parents: 105
diff changeset
178 function setEl(to, idx, val)
d715fb3c39ab Implemented clicking on symbols inside inscope box to replace function name in funcall.
Mike Pavone <pavone@retrodev.com>
parents: 105
diff changeset
179 {
d715fb3c39ab Implemented clicking on symbols inside inscope box to replace function name in funcall.
Mike Pavone <pavone@retrodev.com>
parents: 105
diff changeset
180 to[idx] = val;
d715fb3c39ab Implemented clicking on symbols inside inscope box to replace function name in funcall.
Mike Pavone <pavone@retrodev.com>
parents: 105
diff changeset
181 return to;
d715fb3c39ab Implemented clicking on symbols inside inscope box to replace function name in funcall.
Mike Pavone <pavone@retrodev.com>
parents: 105
diff changeset
182 }