Mercurial > repos > tabletprog
annotate editor.js @ 118:0a66fe3a368a
Allow selection and navigation of assignment nodes.
author | Mike Pavone <pavone@retrodev.com> |
---|---|
date | Mon, 15 Apr 2013 21:55:26 -0700 |
parents | 9cf3e0b18ecc |
children | 77f7cd65e121 |
rev | line source |
---|---|
0 | 1 |
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 | 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 | 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 | 21 main_module.lambdaClick(this, astNode, event); |
28 | 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; |
118
0a66fe3a368a
Allow selection and navigation of assignment nodes.
Mike Pavone <pavone@retrodev.com>
parents:
116
diff
changeset
|
44 var astNode = this; |
14
85fb6ba15bc6
Start turning AST into HTML in editor
Mike Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
45 var base = newEl('div', { |
118
0a66fe3a368a
Allow selection and navigation of assignment nodes.
Mike Pavone <pavone@retrodev.com>
parents:
116
diff
changeset
|
46 className: 'assignment', |
0a66fe3a368a
Allow selection and navigation of assignment nodes.
Mike Pavone <pavone@retrodev.com>
parents:
116
diff
changeset
|
47 onclick: function(event) { |
0a66fe3a368a
Allow selection and navigation of assignment nodes.
Mike Pavone <pavone@retrodev.com>
parents:
116
diff
changeset
|
48 main_module.assignClick(this, astNode, event); |
0a66fe3a368a
Allow selection and navigation of assignment nodes.
Mike Pavone <pavone@retrodev.com>
parents:
116
diff
changeset
|
49 } |
14
85fb6ba15bc6
Start turning AST into HTML in editor
Mike Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
50 }); |
85fb6ba15bc6
Start turning AST into HTML in editor
Mike Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
51 var varName = newEl('span', { |
118
0a66fe3a368a
Allow selection and navigation of assignment nodes.
Mike Pavone <pavone@retrodev.com>
parents:
116
diff
changeset
|
52 textContent: this.symbol.name, |
0a66fe3a368a
Allow selection and navigation of assignment nodes.
Mike Pavone <pavone@retrodev.com>
parents:
116
diff
changeset
|
53 className: 'varname' |
0 | 54 }); |
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
|
55 this.domNode = base; |
14
85fb6ba15bc6
Start turning AST into HTML in editor
Mike Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
56 base.appendChild(varName); |
85fb6ba15bc6
Start turning AST into HTML in editor
Mike Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
57 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
|
58 this.expression.toHTML(base, this); |
14
85fb6ba15bc6
Start turning AST into HTML in editor
Mike Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
59 }; |
85fb6ba15bc6
Start turning AST into HTML in editor
Mike Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
60 |
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
|
61 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
|
62 this.up = up; |
116
9cf3e0b18ecc
Add support for selecting operator expressions in the editor
Mike Pavone <pavone@retrodev.com>
parents:
114
diff
changeset
|
63 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
|
64 var base = newEl('span', { |
116
9cf3e0b18ecc
Add support for selecting operator expressions in the editor
Mike Pavone <pavone@retrodev.com>
parents:
114
diff
changeset
|
65 className: 'op', |
9cf3e0b18ecc
Add support for selecting operator expressions in the editor
Mike Pavone <pavone@retrodev.com>
parents:
114
diff
changeset
|
66 onclick: function(event) { |
9cf3e0b18ecc
Add support for selecting operator expressions in the editor
Mike Pavone <pavone@retrodev.com>
parents:
114
diff
changeset
|
67 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
|
68 } |
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
|
69 }); |
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
|
70 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
|
71 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
|
72 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
|
73 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
|
74 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
|
75 })); |
114
f2b435509301
Work around desugaring of && and || in editor.
Mike Pavone <pavone@retrodev.com>
parents:
113
diff
changeset
|
76 if (this.op == '&&' || this.op == '||') { |
f2b435509301
Work around desugaring of && and || in editor.
Mike Pavone <pavone@retrodev.com>
parents:
113
diff
changeset
|
77 this.right.expressions[0].toHTML(base, this); |
f2b435509301
Work around desugaring of && and || in editor.
Mike Pavone <pavone@retrodev.com>
parents:
113
diff
changeset
|
78 } else { |
f2b435509301
Work around desugaring of && and || in editor.
Mike Pavone <pavone@retrodev.com>
parents:
113
diff
changeset
|
79 this.right.toHTML(base, this); |
f2b435509301
Work around desugaring of && and || in editor.
Mike Pavone <pavone@retrodev.com>
parents:
113
diff
changeset
|
80 } |
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
|
81 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
|
82 }; |
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 |
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 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
|
85 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
|
86 this.domNode = newEl('span', { |
14
85fb6ba15bc6
Start turning AST into HTML in editor
Mike Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
87 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
|
88 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
|
89 }); |
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 node.appendChild(this.domNode); |
14
85fb6ba15bc6
Start turning AST into HTML in editor
Mike Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
91 }; |
85fb6ba15bc6
Start turning AST into HTML in editor
Mike Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
92 |
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 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
|
94 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
|
95 this.domNode = newEl('span', { |
14
85fb6ba15bc6
Start turning AST into HTML in editor
Mike Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
96 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
|
97 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
|
98 }); |
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 node.appendChild(this.domNode); |
14
85fb6ba15bc6
Start turning AST into HTML in editor
Mike Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
100 }; |
85fb6ba15bc6
Start turning AST into HTML in editor
Mike Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
101 |
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
|
102 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
|
103 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
|
104 this.domNode = newEl('span', { |
14
85fb6ba15bc6
Start turning AST into HTML in editor
Mike Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
105 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
|
106 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
|
107 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
|
108 }); |
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 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
|
110 }; |
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 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
|
113 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
|
114 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
|
115 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
|
116 }); |
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
|
117 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
|
118 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
|
119 } |
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 node.appendChild(this.domNode); |
14
85fb6ba15bc6
Start turning AST into HTML in editor
Mike Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
121 }; |
85fb6ba15bc6
Start turning AST into HTML in editor
Mike Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
122 |
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
|
123 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
|
124 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
|
125 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
|
126 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
|
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 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
|
129 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
|
130 } |
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
|
131 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
|
132 }; |
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 |
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 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
|
135 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
|
136 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
|
137 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
|
138 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
|
139 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
|
140 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
|
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 }); |
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
|
143 this.domNode = base; |
26
fe593c1df568
Display receiver arg in editor. Improve formatting in editor.
Mike Pavone <pavone@retrodev.com>
parents:
25
diff
changeset
|
144 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
|
145 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
|
146 } |
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
|
147 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
|
148 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
|
149 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
|
150 base.appendChild(newEl('span', { |
26
fe593c1df568
Display receiver arg in editor. Improve formatting in editor.
Mike Pavone <pavone@retrodev.com>
parents:
25
diff
changeset
|
151 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
|
152 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
|
153 })); |
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
|
154 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
|
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 } |
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
|
158 } |
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 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
|
160 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
|
161 } |
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
|
162 node.appendChild(base); |
14
85fb6ba15bc6
Start turning AST into HTML in editor
Mike Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
163 }; |
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 |
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
|
165 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
|
166 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
|
167 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
|
168 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
|
169 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
|
170 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
|
171 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
|
172 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
|
173 } |
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
|
174 }) |
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
|
175 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
|
176 } |
110
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 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
|
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 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
|
181 } |
d715fb3c39ab
Implemented clicking on symbols inside inscope box to replace function name in funcall.
Mike Pavone <pavone@retrodev.com>
parents:
105
diff
changeset
|
182 |
d715fb3c39ab
Implemented clicking on symbols inside inscope box to replace function name in funcall.
Mike Pavone <pavone@retrodev.com>
parents:
105
diff
changeset
|
183 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
|
184 { |
d715fb3c39ab
Implemented clicking on symbols inside inscope box to replace function name in funcall.
Mike Pavone <pavone@retrodev.com>
parents:
105
diff
changeset
|
185 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
|
186 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
|
187 } |