annotate editor.js @ 240:dc5f487247ee

Don't rename the symbol self in quote blocks
author Mike Pavone <pavone@retrodev.com>
date Sun, 05 Jan 2014 20:53:35 -0800
parents 15aac5334b64
children
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;
120
d5dc9507d612 Basic support for selecting objects in the editor.
Mike Pavone <pavone@retrodev.com>
parents: 119
diff changeset
5 var astNode = this;
14
85fb6ba15bc6 Start turning AST into HTML in editor
Mike Pavone <pavone@retrodev.com>
parents: 0
diff changeset
6 var el = newEl('div', {
120
d5dc9507d612 Basic support for selecting objects in the editor.
Mike Pavone <pavone@retrodev.com>
parents: 119
diff changeset
7 className: 'object',
d5dc9507d612 Basic support for selecting objects in the editor.
Mike Pavone <pavone@retrodev.com>
parents: 119
diff changeset
8 onclick: function(event) {
d5dc9507d612 Basic support for selecting objects in the editor.
Mike Pavone <pavone@retrodev.com>
parents: 119
diff changeset
9 main_module.objectClick(this, astNode, event);
d5dc9507d612 Basic support for selecting objects in the editor.
Mike Pavone <pavone@retrodev.com>
parents: 119
diff changeset
10 }
14
85fb6ba15bc6 Start turning AST into HTML in editor
Mike Pavone <pavone@retrodev.com>
parents: 0
diff changeset
11 });
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
12 this.domNode = el;
14
85fb6ba15bc6 Start turning AST into HTML in editor
Mike Pavone <pavone@retrodev.com>
parents: 0
diff changeset
13 node.appendChild(el);
85fb6ba15bc6 Start turning AST into HTML in editor
Mike Pavone <pavone@retrodev.com>
parents: 0
diff changeset
14 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
15 this.messages[i].toHTML(el, this);
14
85fb6ba15bc6 Start turning AST into HTML in editor
Mike Pavone <pavone@retrodev.com>
parents: 0
diff changeset
16 }
85fb6ba15bc6 Start turning AST into HTML in editor
Mike Pavone <pavone@retrodev.com>
parents: 0
diff changeset
17 };
85fb6ba15bc6 Start turning AST into HTML in editor
Mike Pavone <pavone@retrodev.com>
parents: 0
diff changeset
18
131
8285784f5ff5 Implement previous and next buttons
Mike Pavone <pavone@retrodev.com>
parents: 127
diff changeset
19 object.prototype.getNext = function(curNode) {
8285784f5ff5 Implement previous and next buttons
Mike Pavone <pavone@retrodev.com>
parents: 127
diff changeset
20 for (var i = 0; i < this.messages.length-1; i++) {
8285784f5ff5 Implement previous and next buttons
Mike Pavone <pavone@retrodev.com>
parents: 127
diff changeset
21 if (this.messages[i] == curNode) {
8285784f5ff5 Implement previous and next buttons
Mike Pavone <pavone@retrodev.com>
parents: 127
diff changeset
22 return this.messages[i+1];
8285784f5ff5 Implement previous and next buttons
Mike Pavone <pavone@retrodev.com>
parents: 127
diff changeset
23 }
8285784f5ff5 Implement previous and next buttons
Mike Pavone <pavone@retrodev.com>
parents: 127
diff changeset
24 }
8285784f5ff5 Implement previous and next buttons
Mike Pavone <pavone@retrodev.com>
parents: 127
diff changeset
25 return this.up.getNext(this);
8285784f5ff5 Implement previous and next buttons
Mike Pavone <pavone@retrodev.com>
parents: 127
diff changeset
26 };
8285784f5ff5 Implement previous and next buttons
Mike Pavone <pavone@retrodev.com>
parents: 127
diff changeset
27
8285784f5ff5 Implement previous and next buttons
Mike Pavone <pavone@retrodev.com>
parents: 127
diff changeset
28 object.prototype.getPrev = function(curNode) {
8285784f5ff5 Implement previous and next buttons
Mike Pavone <pavone@retrodev.com>
parents: 127
diff changeset
29 for (var i = 1; i < this.messages.length; i++) {
8285784f5ff5 Implement previous and next buttons
Mike Pavone <pavone@retrodev.com>
parents: 127
diff changeset
30 if (this.messages[i] == curNode) {
8285784f5ff5 Implement previous and next buttons
Mike Pavone <pavone@retrodev.com>
parents: 127
diff changeset
31 return this.messages[i - 1];
8285784f5ff5 Implement previous and next buttons
Mike Pavone <pavone@retrodev.com>
parents: 127
diff changeset
32 }
8285784f5ff5 Implement previous and next buttons
Mike Pavone <pavone@retrodev.com>
parents: 127
diff changeset
33 }
8285784f5ff5 Implement previous and next buttons
Mike Pavone <pavone@retrodev.com>
parents: 127
diff changeset
34 return this.up.getPrev(this);
8285784f5ff5 Implement previous and next buttons
Mike Pavone <pavone@retrodev.com>
parents: 127
diff changeset
35 };
8285784f5ff5 Implement previous and next buttons
Mike Pavone <pavone@retrodev.com>
parents: 127
diff changeset
36
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
37 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
38 this.up = up
28
93bbc4c8be95 Allow selection of lambda
Mike Pavone <pavone@retrodev.com>
parents: 26
diff changeset
39 var astNode = this;
14
85fb6ba15bc6 Start turning AST into HTML in editor
Mike Pavone <pavone@retrodev.com>
parents: 0
diff changeset
40 var el = newEl('div', {
28
93bbc4c8be95 Allow selection of lambda
Mike Pavone <pavone@retrodev.com>
parents: 26
diff changeset
41 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
42 onclick: function(event) {
104
648659961e0e Get editor working again
Mike Pavone <pavone@retrodev.com>
parents: 29
diff changeset
43 main_module.lambdaClick(this, astNode, event);
28
93bbc4c8be95 Allow selection of lambda
Mike Pavone <pavone@retrodev.com>
parents: 26
diff changeset
44 }
14
85fb6ba15bc6 Start turning AST into HTML in editor
Mike Pavone <pavone@retrodev.com>
parents: 0
diff changeset
45 });
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
46 this.domNode = el;
26
fe593c1df568 Display receiver arg in editor. Improve formatting in editor.
Mike Pavone <pavone@retrodev.com>
parents: 25
diff changeset
47 var args = newEl('div', {
fe593c1df568 Display receiver arg in editor. Improve formatting in editor.
Mike Pavone <pavone@retrodev.com>
parents: 25
diff changeset
48 className: 'args'
fe593c1df568 Display receiver arg in editor. Improve formatting in editor.
Mike Pavone <pavone@retrodev.com>
parents: 25
diff changeset
49 });
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
50 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
51 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
52 }
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
53 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
54 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
55 });
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
56 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
57 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
58 }
26
fe593c1df568 Display receiver arg in editor. Improve formatting in editor.
Mike Pavone <pavone@retrodev.com>
parents: 25
diff changeset
59 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
60 el.appendChild(body);
14
85fb6ba15bc6 Start turning AST into HTML in editor
Mike Pavone <pavone@retrodev.com>
parents: 0
diff changeset
61 node.appendChild(el);
85fb6ba15bc6 Start turning AST into HTML in editor
Mike Pavone <pavone@retrodev.com>
parents: 0
diff changeset
62 };
85fb6ba15bc6 Start turning AST into HTML in editor
Mike Pavone <pavone@retrodev.com>
parents: 0
diff changeset
63
131
8285784f5ff5 Implement previous and next buttons
Mike Pavone <pavone@retrodev.com>
parents: 127
diff changeset
64 lambda.prototype.getNext = function(curNode) {
8285784f5ff5 Implement previous and next buttons
Mike Pavone <pavone@retrodev.com>
parents: 127
diff changeset
65 for (var i = 0; i < this.args.length; i++) {
8285784f5ff5 Implement previous and next buttons
Mike Pavone <pavone@retrodev.com>
parents: 127
diff changeset
66 if (this.args[i] == curNode) {
8285784f5ff5 Implement previous and next buttons
Mike Pavone <pavone@retrodev.com>
parents: 127
diff changeset
67 if ((i + 1) < this.args.length) {
8285784f5ff5 Implement previous and next buttons
Mike Pavone <pavone@retrodev.com>
parents: 127
diff changeset
68 return this.args[i+1];
8285784f5ff5 Implement previous and next buttons
Mike Pavone <pavone@retrodev.com>
parents: 127
diff changeset
69 } else if(this.expressions.length) {
8285784f5ff5 Implement previous and next buttons
Mike Pavone <pavone@retrodev.com>
parents: 127
diff changeset
70 return this.expressions[0];
8285784f5ff5 Implement previous and next buttons
Mike Pavone <pavone@retrodev.com>
parents: 127
diff changeset
71 } else {
8285784f5ff5 Implement previous and next buttons
Mike Pavone <pavone@retrodev.com>
parents: 127
diff changeset
72 break;
8285784f5ff5 Implement previous and next buttons
Mike Pavone <pavone@retrodev.com>
parents: 127
diff changeset
73 }
8285784f5ff5 Implement previous and next buttons
Mike Pavone <pavone@retrodev.com>
parents: 127
diff changeset
74 }
8285784f5ff5 Implement previous and next buttons
Mike Pavone <pavone@retrodev.com>
parents: 127
diff changeset
75 }
8285784f5ff5 Implement previous and next buttons
Mike Pavone <pavone@retrodev.com>
parents: 127
diff changeset
76 for (var i = 0; i < this.expressions.length-1; i++) {
8285784f5ff5 Implement previous and next buttons
Mike Pavone <pavone@retrodev.com>
parents: 127
diff changeset
77 if (this.expressions[i] == curNode) {
8285784f5ff5 Implement previous and next buttons
Mike Pavone <pavone@retrodev.com>
parents: 127
diff changeset
78 return this.expressions[i+1];
8285784f5ff5 Implement previous and next buttons
Mike Pavone <pavone@retrodev.com>
parents: 127
diff changeset
79 }
8285784f5ff5 Implement previous and next buttons
Mike Pavone <pavone@retrodev.com>
parents: 127
diff changeset
80 }
8285784f5ff5 Implement previous and next buttons
Mike Pavone <pavone@retrodev.com>
parents: 127
diff changeset
81 return this.up.getNext(this);
8285784f5ff5 Implement previous and next buttons
Mike Pavone <pavone@retrodev.com>
parents: 127
diff changeset
82 };
8285784f5ff5 Implement previous and next buttons
Mike Pavone <pavone@retrodev.com>
parents: 127
diff changeset
83
8285784f5ff5 Implement previous and next buttons
Mike Pavone <pavone@retrodev.com>
parents: 127
diff changeset
84 lambda.prototype.getPrev = function(curNode) {
8285784f5ff5 Implement previous and next buttons
Mike Pavone <pavone@retrodev.com>
parents: 127
diff changeset
85 for (var i = 0; i < this.args.length; i++) {
8285784f5ff5 Implement previous and next buttons
Mike Pavone <pavone@retrodev.com>
parents: 127
diff changeset
86 if (this.args[i] == curNode) {
8285784f5ff5 Implement previous and next buttons
Mike Pavone <pavone@retrodev.com>
parents: 127
diff changeset
87 if (i > 0) {
8285784f5ff5 Implement previous and next buttons
Mike Pavone <pavone@retrodev.com>
parents: 127
diff changeset
88 return this.args[i-1];
8285784f5ff5 Implement previous and next buttons
Mike Pavone <pavone@retrodev.com>
parents: 127
diff changeset
89 } else {
8285784f5ff5 Implement previous and next buttons
Mike Pavone <pavone@retrodev.com>
parents: 127
diff changeset
90 return this.up.getPrev(this);
8285784f5ff5 Implement previous and next buttons
Mike Pavone <pavone@retrodev.com>
parents: 127
diff changeset
91 }
8285784f5ff5 Implement previous and next buttons
Mike Pavone <pavone@retrodev.com>
parents: 127
diff changeset
92 }
8285784f5ff5 Implement previous and next buttons
Mike Pavone <pavone@retrodev.com>
parents: 127
diff changeset
93 }
8285784f5ff5 Implement previous and next buttons
Mike Pavone <pavone@retrodev.com>
parents: 127
diff changeset
94 for (var i = 0; i < this.expressions.length; i++) {
8285784f5ff5 Implement previous and next buttons
Mike Pavone <pavone@retrodev.com>
parents: 127
diff changeset
95 if (this.expressions[i] == curNode) {
8285784f5ff5 Implement previous and next buttons
Mike Pavone <pavone@retrodev.com>
parents: 127
diff changeset
96 if (i > 0) {
8285784f5ff5 Implement previous and next buttons
Mike Pavone <pavone@retrodev.com>
parents: 127
diff changeset
97 return this.expressions[i-1];
8285784f5ff5 Implement previous and next buttons
Mike Pavone <pavone@retrodev.com>
parents: 127
diff changeset
98 } else if(this.args.length) {
8285784f5ff5 Implement previous and next buttons
Mike Pavone <pavone@retrodev.com>
parents: 127
diff changeset
99 return this.args[this.args.length-1];
8285784f5ff5 Implement previous and next buttons
Mike Pavone <pavone@retrodev.com>
parents: 127
diff changeset
100 } else {
8285784f5ff5 Implement previous and next buttons
Mike Pavone <pavone@retrodev.com>
parents: 127
diff changeset
101 break;
8285784f5ff5 Implement previous and next buttons
Mike Pavone <pavone@retrodev.com>
parents: 127
diff changeset
102 }
8285784f5ff5 Implement previous and next buttons
Mike Pavone <pavone@retrodev.com>
parents: 127
diff changeset
103 }
8285784f5ff5 Implement previous and next buttons
Mike Pavone <pavone@retrodev.com>
parents: 127
diff changeset
104 }
8285784f5ff5 Implement previous and next buttons
Mike Pavone <pavone@retrodev.com>
parents: 127
diff changeset
105 return this.up.getPrev(this);
8285784f5ff5 Implement previous and next buttons
Mike Pavone <pavone@retrodev.com>
parents: 127
diff changeset
106 };
8285784f5ff5 Implement previous and next buttons
Mike Pavone <pavone@retrodev.com>
parents: 127
diff changeset
107
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 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
109 this.up = up;
118
0a66fe3a368a Allow selection and navigation of assignment nodes.
Mike Pavone <pavone@retrodev.com>
parents: 116
diff changeset
110 var astNode = this;
14
85fb6ba15bc6 Start turning AST into HTML in editor
Mike Pavone <pavone@retrodev.com>
parents: 0
diff changeset
111 var base = newEl('div', {
118
0a66fe3a368a Allow selection and navigation of assignment nodes.
Mike Pavone <pavone@retrodev.com>
parents: 116
diff changeset
112 className: 'assignment',
0a66fe3a368a Allow selection and navigation of assignment nodes.
Mike Pavone <pavone@retrodev.com>
parents: 116
diff changeset
113 onclick: function(event) {
0a66fe3a368a Allow selection and navigation of assignment nodes.
Mike Pavone <pavone@retrodev.com>
parents: 116
diff changeset
114 main_module.assignClick(this, astNode, event);
0a66fe3a368a Allow selection and navigation of assignment nodes.
Mike Pavone <pavone@retrodev.com>
parents: 116
diff changeset
115 }
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 var varName = newEl('span', {
118
0a66fe3a368a Allow selection and navigation of assignment nodes.
Mike Pavone <pavone@retrodev.com>
parents: 116
diff changeset
118 textContent: this.symbol.name,
0a66fe3a368a Allow selection and navigation of assignment nodes.
Mike Pavone <pavone@retrodev.com>
parents: 116
diff changeset
119 className: 'varname'
0
3d1b8e96f5dc Initial commit
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
120 });
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
121 this.domNode = base;
14
85fb6ba15bc6 Start turning AST into HTML in editor
Mike Pavone <pavone@retrodev.com>
parents: 0
diff changeset
122 base.appendChild(varName);
85fb6ba15bc6 Start turning AST into HTML in editor
Mike Pavone <pavone@retrodev.com>
parents: 0
diff changeset
123 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
124 this.expression.toHTML(base, this);
14
85fb6ba15bc6 Start turning AST into HTML in editor
Mike Pavone <pavone@retrodev.com>
parents: 0
diff changeset
125 };
85fb6ba15bc6 Start turning AST into HTML in editor
Mike Pavone <pavone@retrodev.com>
parents: 0
diff changeset
126
131
8285784f5ff5 Implement previous and next buttons
Mike Pavone <pavone@retrodev.com>
parents: 127
diff changeset
127 assignment.prototype.getNext = function(curNode) {
8285784f5ff5 Implement previous and next buttons
Mike Pavone <pavone@retrodev.com>
parents: 127
diff changeset
128 return this.up.getNext(this);
8285784f5ff5 Implement previous and next buttons
Mike Pavone <pavone@retrodev.com>
parents: 127
diff changeset
129 };
8285784f5ff5 Implement previous and next buttons
Mike Pavone <pavone@retrodev.com>
parents: 127
diff changeset
130
8285784f5ff5 Implement previous and next buttons
Mike Pavone <pavone@retrodev.com>
parents: 127
diff changeset
131 assignment.prototype.getPrev = function(curNode) {
8285784f5ff5 Implement previous and next buttons
Mike Pavone <pavone@retrodev.com>
parents: 127
diff changeset
132 return this;
8285784f5ff5 Implement previous and next buttons
Mike Pavone <pavone@retrodev.com>
parents: 127
diff changeset
133 };
8285784f5ff5 Implement previous and next buttons
Mike Pavone <pavone@retrodev.com>
parents: 127
diff changeset
134
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
135 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
136 this.up = up;
116
9cf3e0b18ecc Add support for selecting operator expressions in the editor
Mike Pavone <pavone@retrodev.com>
parents: 114
diff changeset
137 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
138 var base = newEl('span', {
116
9cf3e0b18ecc Add support for selecting operator expressions in the editor
Mike Pavone <pavone@retrodev.com>
parents: 114
diff changeset
139 className: 'op',
9cf3e0b18ecc Add support for selecting operator expressions in the editor
Mike Pavone <pavone@retrodev.com>
parents: 114
diff changeset
140 onclick: function(event) {
9cf3e0b18ecc Add support for selecting operator expressions in the editor
Mike Pavone <pavone@retrodev.com>
parents: 114
diff changeset
141 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
142 }
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
143 });
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
144 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
145 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
146 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
147 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
148 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
149 }));
114
f2b435509301 Work around desugaring of && and || in editor.
Mike Pavone <pavone@retrodev.com>
parents: 113
diff changeset
150 if (this.op == '&&' || this.op == '||') {
f2b435509301 Work around desugaring of && and || in editor.
Mike Pavone <pavone@retrodev.com>
parents: 113
diff changeset
151 this.right.expressions[0].toHTML(base, this);
f2b435509301 Work around desugaring of && and || in editor.
Mike Pavone <pavone@retrodev.com>
parents: 113
diff changeset
152 } else {
f2b435509301 Work around desugaring of && and || in editor.
Mike Pavone <pavone@retrodev.com>
parents: 113
diff changeset
153 this.right.toHTML(base, this);
f2b435509301 Work around desugaring of && and || in editor.
Mike Pavone <pavone@retrodev.com>
parents: 113
diff changeset
154 }
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
155 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
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
131
8285784f5ff5 Implement previous and next buttons
Mike Pavone <pavone@retrodev.com>
parents: 127
diff changeset
158 op.prototype.getNext = function(curNode) {
8285784f5ff5 Implement previous and next buttons
Mike Pavone <pavone@retrodev.com>
parents: 127
diff changeset
159 if (this.left == curNode) {
8285784f5ff5 Implement previous and next buttons
Mike Pavone <pavone@retrodev.com>
parents: 127
diff changeset
160 return this.right;
8285784f5ff5 Implement previous and next buttons
Mike Pavone <pavone@retrodev.com>
parents: 127
diff changeset
161 }
8285784f5ff5 Implement previous and next buttons
Mike Pavone <pavone@retrodev.com>
parents: 127
diff changeset
162 return this.up.getNext(this);
8285784f5ff5 Implement previous and next buttons
Mike Pavone <pavone@retrodev.com>
parents: 127
diff changeset
163 };
8285784f5ff5 Implement previous and next buttons
Mike Pavone <pavone@retrodev.com>
parents: 127
diff changeset
164
8285784f5ff5 Implement previous and next buttons
Mike Pavone <pavone@retrodev.com>
parents: 127
diff changeset
165 op.prototype.getPrev = function(curNode) {
8285784f5ff5 Implement previous and next buttons
Mike Pavone <pavone@retrodev.com>
parents: 127
diff changeset
166 if (this.right == curNode) {
8285784f5ff5 Implement previous and next buttons
Mike Pavone <pavone@retrodev.com>
parents: 127
diff changeset
167 return this.left;
8285784f5ff5 Implement previous and next buttons
Mike Pavone <pavone@retrodev.com>
parents: 127
diff changeset
168 }
8285784f5ff5 Implement previous and next buttons
Mike Pavone <pavone@retrodev.com>
parents: 127
diff changeset
169 return this.up.getPrev(this);
8285784f5ff5 Implement previous and next buttons
Mike Pavone <pavone@retrodev.com>
parents: 127
diff changeset
170 };
8285784f5ff5 Implement previous and next buttons
Mike Pavone <pavone@retrodev.com>
parents: 127
diff changeset
171
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
172 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
173 this.up = up;
119
77f7cd65e121 Add selection of number and string literals. Support inward navigation of lambdas.
Mike Pavone <pavone@retrodev.com>
parents: 118
diff changeset
174 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
175 this.domNode = newEl('span', {
14
85fb6ba15bc6 Start turning AST into HTML in editor
Mike Pavone <pavone@retrodev.com>
parents: 0
diff changeset
176 className: 'integer',
119
77f7cd65e121 Add selection of number and string literals. Support inward navigation of lambdas.
Mike Pavone <pavone@retrodev.com>
parents: 118
diff changeset
177 textContent: this.val,
77f7cd65e121 Add selection of number and string literals. Support inward navigation of lambdas.
Mike Pavone <pavone@retrodev.com>
parents: 118
diff changeset
178 onclick: function(event) {
77f7cd65e121 Add selection of number and string literals. Support inward navigation of lambdas.
Mike Pavone <pavone@retrodev.com>
parents: 118
diff changeset
179 main_module.scalarClick(this, astNode, event);
77f7cd65e121 Add selection of number and string literals. Support inward navigation of lambdas.
Mike Pavone <pavone@retrodev.com>
parents: 118
diff changeset
180 }
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
181 });
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
182 node.appendChild(this.domNode);
14
85fb6ba15bc6 Start turning AST into HTML in editor
Mike Pavone <pavone@retrodev.com>
parents: 0
diff changeset
183 };
85fb6ba15bc6 Start turning AST into HTML in editor
Mike Pavone <pavone@retrodev.com>
parents: 0
diff changeset
184
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
185 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
186 this.up = up;
119
77f7cd65e121 Add selection of number and string literals. Support inward navigation of lambdas.
Mike Pavone <pavone@retrodev.com>
parents: 118
diff changeset
187 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
188 this.domNode = newEl('span', {
14
85fb6ba15bc6 Start turning AST into HTML in editor
Mike Pavone <pavone@retrodev.com>
parents: 0
diff changeset
189 className: 'float',
119
77f7cd65e121 Add selection of number and string literals. Support inward navigation of lambdas.
Mike Pavone <pavone@retrodev.com>
parents: 118
diff changeset
190 textContent: this.val,
77f7cd65e121 Add selection of number and string literals. Support inward navigation of lambdas.
Mike Pavone <pavone@retrodev.com>
parents: 118
diff changeset
191 onclick: function(event) {
77f7cd65e121 Add selection of number and string literals. Support inward navigation of lambdas.
Mike Pavone <pavone@retrodev.com>
parents: 118
diff changeset
192 main_module.scalarClick(this, astNode, event);
77f7cd65e121 Add selection of number and string literals. Support inward navigation of lambdas.
Mike Pavone <pavone@retrodev.com>
parents: 118
diff changeset
193 }
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
194 });
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
195 node.appendChild(this.domNode);
14
85fb6ba15bc6 Start turning AST into HTML in editor
Mike Pavone <pavone@retrodev.com>
parents: 0
diff changeset
196 };
85fb6ba15bc6 Start turning AST into HTML in editor
Mike Pavone <pavone@retrodev.com>
parents: 0
diff changeset
197
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
198 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
199 this.up = up;
119
77f7cd65e121 Add selection of number and string literals. Support inward navigation of lambdas.
Mike Pavone <pavone@retrodev.com>
parents: 118
diff changeset
200 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
201 this.domNode = newEl('span', {
14
85fb6ba15bc6 Start turning AST into HTML in editor
Mike Pavone <pavone@retrodev.com>
parents: 0
diff changeset
202 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
203 contentEditable: 'true',
119
77f7cd65e121 Add selection of number and string literals. Support inward navigation of lambdas.
Mike Pavone <pavone@retrodev.com>
parents: 118
diff changeset
204 textContent: this.val,
77f7cd65e121 Add selection of number and string literals. Support inward navigation of lambdas.
Mike Pavone <pavone@retrodev.com>
parents: 118
diff changeset
205 onclick: function(event) {
77f7cd65e121 Add selection of number and string literals. Support inward navigation of lambdas.
Mike Pavone <pavone@retrodev.com>
parents: 118
diff changeset
206 main_module.scalarClick(this, astNode, event);
77f7cd65e121 Add selection of number and string literals. Support inward navigation of lambdas.
Mike Pavone <pavone@retrodev.com>
parents: 118
diff changeset
207 }
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
208 });
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
209 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
210 };
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
211
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
212 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
213 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
214 this.domNode = newEl('span', {
132
a503a329acfa Fix CSS clasnames for list and array literals
Mike Pavone <pavone@retrodev.com>
parents: 131
diff changeset
215 className: 'listlit',
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
216 });
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
217 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
218 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
219 }
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
220 node.appendChild(this.domNode);
14
85fb6ba15bc6 Start turning AST into HTML in editor
Mike Pavone <pavone@retrodev.com>
parents: 0
diff changeset
221 };
85fb6ba15bc6 Start turning AST into HTML in editor
Mike Pavone <pavone@retrodev.com>
parents: 0
diff changeset
222
131
8285784f5ff5 Implement previous and next buttons
Mike Pavone <pavone@retrodev.com>
parents: 127
diff changeset
223 listlit.prototype.getNext = arraylit.prototype.getNext = function(curNode) {
8285784f5ff5 Implement previous and next buttons
Mike Pavone <pavone@retrodev.com>
parents: 127
diff changeset
224 for (var i = 0; i < this.val.length; i++) {
8285784f5ff5 Implement previous and next buttons
Mike Pavone <pavone@retrodev.com>
parents: 127
diff changeset
225 if (this.val[i] == curNode) {
8285784f5ff5 Implement previous and next buttons
Mike Pavone <pavone@retrodev.com>
parents: 127
diff changeset
226 if ((i + 1) < this.val.length) {
8285784f5ff5 Implement previous and next buttons
Mike Pavone <pavone@retrodev.com>
parents: 127
diff changeset
227 return this.val[i+1];
8285784f5ff5 Implement previous and next buttons
Mike Pavone <pavone@retrodev.com>
parents: 127
diff changeset
228 } else {
8285784f5ff5 Implement previous and next buttons
Mike Pavone <pavone@retrodev.com>
parents: 127
diff changeset
229 break;
8285784f5ff5 Implement previous and next buttons
Mike Pavone <pavone@retrodev.com>
parents: 127
diff changeset
230 }
8285784f5ff5 Implement previous and next buttons
Mike Pavone <pavone@retrodev.com>
parents: 127
diff changeset
231 }
8285784f5ff5 Implement previous and next buttons
Mike Pavone <pavone@retrodev.com>
parents: 127
diff changeset
232 }
8285784f5ff5 Implement previous and next buttons
Mike Pavone <pavone@retrodev.com>
parents: 127
diff changeset
233 return this.up.getNext(this);
8285784f5ff5 Implement previous and next buttons
Mike Pavone <pavone@retrodev.com>
parents: 127
diff changeset
234 };
8285784f5ff5 Implement previous and next buttons
Mike Pavone <pavone@retrodev.com>
parents: 127
diff changeset
235
8285784f5ff5 Implement previous and next buttons
Mike Pavone <pavone@retrodev.com>
parents: 127
diff changeset
236 listlit.prototype.getPrev = arraylit.prototype.getPrev = function(curNode) {
8285784f5ff5 Implement previous and next buttons
Mike Pavone <pavone@retrodev.com>
parents: 127
diff changeset
237 for (var i = 0; i < this.val.length; i++) {
8285784f5ff5 Implement previous and next buttons
Mike Pavone <pavone@retrodev.com>
parents: 127
diff changeset
238 if (this.val[i] == curNode) {
8285784f5ff5 Implement previous and next buttons
Mike Pavone <pavone@retrodev.com>
parents: 127
diff changeset
239 if (i > 0) {
8285784f5ff5 Implement previous and next buttons
Mike Pavone <pavone@retrodev.com>
parents: 127
diff changeset
240 return this.val[i-1];
8285784f5ff5 Implement previous and next buttons
Mike Pavone <pavone@retrodev.com>
parents: 127
diff changeset
241 } else {
8285784f5ff5 Implement previous and next buttons
Mike Pavone <pavone@retrodev.com>
parents: 127
diff changeset
242 break;
8285784f5ff5 Implement previous and next buttons
Mike Pavone <pavone@retrodev.com>
parents: 127
diff changeset
243 }
8285784f5ff5 Implement previous and next buttons
Mike Pavone <pavone@retrodev.com>
parents: 127
diff changeset
244 }
8285784f5ff5 Implement previous and next buttons
Mike Pavone <pavone@retrodev.com>
parents: 127
diff changeset
245 }
8285784f5ff5 Implement previous and next buttons
Mike Pavone <pavone@retrodev.com>
parents: 127
diff changeset
246 return this.up.getPrev(this);
8285784f5ff5 Implement previous and next buttons
Mike Pavone <pavone@retrodev.com>
parents: 127
diff changeset
247 };
8285784f5ff5 Implement previous and next buttons
Mike Pavone <pavone@retrodev.com>
parents: 127
diff changeset
248
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
249 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
250 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
251 this.domNode = newEl('span', {
132
a503a329acfa Fix CSS clasnames for list and array literals
Mike Pavone <pavone@retrodev.com>
parents: 131
diff changeset
252 className: 'arraylit',
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
253 });
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
254 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
255 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
256 }
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
257 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
258 };
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
259
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
260 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
261 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
262 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
263 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
264 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
265 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
266 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
267 }
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
268 });
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
269 this.domNode = base;
26
fe593c1df568 Display receiver arg in editor. Improve formatting in editor.
Mike Pavone <pavone@retrodev.com>
parents: 25
diff changeset
270 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
271 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
272 }
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
273 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
274 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
275 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
276 base.appendChild(newEl('span', {
26
fe593c1df568 Display receiver arg in editor. Improve formatting in editor.
Mike Pavone <pavone@retrodev.com>
parents: 25
diff changeset
277 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
278 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
279 }));
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
280 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
281 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
282 }
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
283 }
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
284 }
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
285 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
286 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
287 }
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
288 node.appendChild(base);
14
85fb6ba15bc6 Start turning AST into HTML in editor
Mike Pavone <pavone@retrodev.com>
parents: 0
diff changeset
289 };
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
290
131
8285784f5ff5 Implement previous and next buttons
Mike Pavone <pavone@retrodev.com>
parents: 127
diff changeset
291 funcall.prototype.getNext = function(curNode) {
8285784f5ff5 Implement previous and next buttons
Mike Pavone <pavone@retrodev.com>
parents: 127
diff changeset
292 if (this.receiver == curNode && this.args.length) {
8285784f5ff5 Implement previous and next buttons
Mike Pavone <pavone@retrodev.com>
parents: 127
diff changeset
293 return this.args[0];
8285784f5ff5 Implement previous and next buttons
Mike Pavone <pavone@retrodev.com>
parents: 127
diff changeset
294 }
8285784f5ff5 Implement previous and next buttons
Mike Pavone <pavone@retrodev.com>
parents: 127
diff changeset
295 for (var i = 0; i < this.args.length-1; i++) {
8285784f5ff5 Implement previous and next buttons
Mike Pavone <pavone@retrodev.com>
parents: 127
diff changeset
296 if (this.args[i] == curNode) {
8285784f5ff5 Implement previous and next buttons
Mike Pavone <pavone@retrodev.com>
parents: 127
diff changeset
297 return this.args[i+1];
8285784f5ff5 Implement previous and next buttons
Mike Pavone <pavone@retrodev.com>
parents: 127
diff changeset
298 }
8285784f5ff5 Implement previous and next buttons
Mike Pavone <pavone@retrodev.com>
parents: 127
diff changeset
299 }
8285784f5ff5 Implement previous and next buttons
Mike Pavone <pavone@retrodev.com>
parents: 127
diff changeset
300 return this.up.getNext(this);
8285784f5ff5 Implement previous and next buttons
Mike Pavone <pavone@retrodev.com>
parents: 127
diff changeset
301 };
8285784f5ff5 Implement previous and next buttons
Mike Pavone <pavone@retrodev.com>
parents: 127
diff changeset
302
8285784f5ff5 Implement previous and next buttons
Mike Pavone <pavone@retrodev.com>
parents: 127
diff changeset
303 funcall.prototype.getPrev = function(curNode) {
8285784f5ff5 Implement previous and next buttons
Mike Pavone <pavone@retrodev.com>
parents: 127
diff changeset
304 for (var i = 0; i < this.args.length; i++) {
8285784f5ff5 Implement previous and next buttons
Mike Pavone <pavone@retrodev.com>
parents: 127
diff changeset
305 if (this.args[i] == curNode) {
8285784f5ff5 Implement previous and next buttons
Mike Pavone <pavone@retrodev.com>
parents: 127
diff changeset
306 if (i > 0) {
8285784f5ff5 Implement previous and next buttons
Mike Pavone <pavone@retrodev.com>
parents: 127
diff changeset
307 return this.args[i-1];
8285784f5ff5 Implement previous and next buttons
Mike Pavone <pavone@retrodev.com>
parents: 127
diff changeset
308 } else if (this.receiver) {
8285784f5ff5 Implement previous and next buttons
Mike Pavone <pavone@retrodev.com>
parents: 127
diff changeset
309 return this.receiver;
8285784f5ff5 Implement previous and next buttons
Mike Pavone <pavone@retrodev.com>
parents: 127
diff changeset
310 } else {
8285784f5ff5 Implement previous and next buttons
Mike Pavone <pavone@retrodev.com>
parents: 127
diff changeset
311 break;
8285784f5ff5 Implement previous and next buttons
Mike Pavone <pavone@retrodev.com>
parents: 127
diff changeset
312 }
8285784f5ff5 Implement previous and next buttons
Mike Pavone <pavone@retrodev.com>
parents: 127
diff changeset
313 }
8285784f5ff5 Implement previous and next buttons
Mike Pavone <pavone@retrodev.com>
parents: 127
diff changeset
314 }
8285784f5ff5 Implement previous and next buttons
Mike Pavone <pavone@retrodev.com>
parents: 127
diff changeset
315 return this.up.getPrev(this);
8285784f5ff5 Implement previous and next buttons
Mike Pavone <pavone@retrodev.com>
parents: 127
diff changeset
316 };
8285784f5ff5 Implement previous and next buttons
Mike Pavone <pavone@retrodev.com>
parents: 127
diff changeset
317
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
318 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
319 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
320 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
321 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
322 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
323 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
324 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
325 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
326 }
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
327 })
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
328 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
329 }
110
d715fb3c39ab Implemented clicking on symbols inside inscope box to replace function name in funcall.
Mike Pavone <pavone@retrodev.com>
parents: 105
diff changeset
330
d715fb3c39ab Implemented clicking on symbols inside inscope box to replace function name in funcall.
Mike Pavone <pavone@retrodev.com>
parents: 105
diff changeset
331 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
332 {
d715fb3c39ab Implemented clicking on symbols inside inscope box to replace function name in funcall.
Mike Pavone <pavone@retrodev.com>
parents: 105
diff changeset
333 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
334 }
d715fb3c39ab Implemented clicking on symbols inside inscope box to replace function name in funcall.
Mike Pavone <pavone@retrodev.com>
parents: 105
diff changeset
335
d715fb3c39ab Implemented clicking on symbols inside inscope box to replace function name in funcall.
Mike Pavone <pavone@retrodev.com>
parents: 105
diff changeset
336 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
337 {
d715fb3c39ab Implemented clicking on symbols inside inscope box to replace function name in funcall.
Mike Pavone <pavone@retrodev.com>
parents: 105
diff changeset
338 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
339 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
340 }
127
2b25d0ce2946 Add fullscreen support and improve experience on tablet browsers by tweaking button text size and disabling zooming.
Mike Pavone <pavone@retrodev.com>
parents: 120
diff changeset
341
2b25d0ce2946 Add fullscreen support and improve experience on tablet browsers by tweaking button text size and disabling zooming.
Mike Pavone <pavone@retrodev.com>
parents: 120
diff changeset
342 function goFullScreen()
2b25d0ce2946 Add fullscreen support and improve experience on tablet browsers by tweaking button text size and disabling zooming.
Mike Pavone <pavone@retrodev.com>
parents: 120
diff changeset
343 {
2b25d0ce2946 Add fullscreen support and improve experience on tablet browsers by tweaking button text size and disabling zooming.
Mike Pavone <pavone@retrodev.com>
parents: 120
diff changeset
344 var el = q('body');
2b25d0ce2946 Add fullscreen support and improve experience on tablet browsers by tweaking button text size and disabling zooming.
Mike Pavone <pavone@retrodev.com>
parents: 120
diff changeset
345 if (el.requestFullscreen) {
2b25d0ce2946 Add fullscreen support and improve experience on tablet browsers by tweaking button text size and disabling zooming.
Mike Pavone <pavone@retrodev.com>
parents: 120
diff changeset
346 el.requestFullscreen();
2b25d0ce2946 Add fullscreen support and improve experience on tablet browsers by tweaking button text size and disabling zooming.
Mike Pavone <pavone@retrodev.com>
parents: 120
diff changeset
347 } else if (el.mozRequestFullScreen) {
2b25d0ce2946 Add fullscreen support and improve experience on tablet browsers by tweaking button text size and disabling zooming.
Mike Pavone <pavone@retrodev.com>
parents: 120
diff changeset
348 el.mozRequestFullScreen();
2b25d0ce2946 Add fullscreen support and improve experience on tablet browsers by tweaking button text size and disabling zooming.
Mike Pavone <pavone@retrodev.com>
parents: 120
diff changeset
349 } else {
2b25d0ce2946 Add fullscreen support and improve experience on tablet browsers by tweaking button text size and disabling zooming.
Mike Pavone <pavone@retrodev.com>
parents: 120
diff changeset
350 el.webkitRequestFullscreen();
2b25d0ce2946 Add fullscreen support and improve experience on tablet browsers by tweaking button text size and disabling zooming.
Mike Pavone <pavone@retrodev.com>
parents: 120
diff changeset
351 }
2b25d0ce2946 Add fullscreen support and improve experience on tablet browsers by tweaking button text size and disabling zooming.
Mike Pavone <pavone@retrodev.com>
parents: 120
diff changeset
352 }
141
15aac5334b64 Started work on replacing nodes with a symbol when a symbol button is clicked
Mike Pavone <pavone@retrodev.com>
parents: 132
diff changeset
353
15aac5334b64 Started work on replacing nodes with a symbol when a symbol button is clicked
Mike Pavone <pavone@retrodev.com>
parents: 132
diff changeset
354 function create_symbol(name)
15aac5334b64 Started work on replacing nodes with a symbol when a symbol button is clicked
Mike Pavone <pavone@retrodev.com>
parents: 132
diff changeset
355 {
15aac5334b64 Started work on replacing nodes with a symbol when a symbol button is clicked
Mike Pavone <pavone@retrodev.com>
parents: 132
diff changeset
356 return new symbol(name);
15aac5334b64 Started work on replacing nodes with a symbol when a symbol button is clicked
Mike Pavone <pavone@retrodev.com>
parents: 132
diff changeset
357 }