Mercurial > repos > tabletprog
view editor.js @ 124:1157639353e7
Add dummy handler for clicking a symbol while a lambda is selected. Fix the code for selecting the first inner node of an object literal.
author | Mike Pavone <pavone@retrodev.com> |
---|---|
date | Mon, 05 Aug 2013 21:38:38 -0700 |
parents | d5dc9507d612 |
children | 2b25d0ce2946 |
line wrap: on
line source
object.prototype.toHTML = function(node, up) { this.up = up; var astNode = this; var el = newEl('div', { className: 'object', onclick: function(event) { main_module.objectClick(this, astNode, event); } }); this.domNode = el; node.appendChild(el); for (var i in this.messages) { this.messages[i].toHTML(el, this); } }; lambda.prototype.toHTML = function(node, up) { this.up = up var astNode = this; var el = newEl('div', { className: 'lambda', onclick: function(event) { main_module.lambdaClick(this, astNode, event); } }); this.domNode = el; var args = newEl('div', { className: 'args' }); for (var i in this.args) { this.args[i].toHTML(args, this); } var body = newEl('div', { className: 'lambdabody' }); for (var i in this.expressions) { this.expressions[i].toHTML(body, this); } el.appendChild(args); el.appendChild(body); node.appendChild(el); }; assignment.prototype.toHTML = function(node, up) { this.up = up; var astNode = this; var base = newEl('div', { className: 'assignment', onclick: function(event) { main_module.assignClick(this, astNode, event); } }); var varName = newEl('span', { textContent: this.symbol.name, className: 'varname' }); this.domNode = base; base.appendChild(varName); node.appendChild(base); this.expression.toHTML(base, this); }; op.prototype.toHTML = function(node, up) { this.up = up; var astNode = this; var base = newEl('span', { className: 'op', onclick: function(event) { main_module.opClick(this, astNode, event); } }); this.domNode = base; this.left.toHTML(base, this); base.appendChild(newEl('span', { textContent: this.op, className: 'opname' })); if (this.op == '&&' || this.op == '||') { this.right.expressions[0].toHTML(base, this); } else { this.right.toHTML(base, this); } node.appendChild(base); }; intlit.prototype.toHTML = function(node, up) { this.up = up; var astNode = this; this.domNode = newEl('span', { className: 'integer', textContent: this.val, onclick: function(event) { main_module.scalarClick(this, astNode, event); } }); node.appendChild(this.domNode); }; floatlit.prototype.toHTML = function(node, up) { this.up = up; var astNode = this; this.domNode = newEl('span', { className: 'float', textContent: this.val, onclick: function(event) { main_module.scalarClick(this, astNode, event); } }); node.appendChild(this.domNode); }; strlit.prototype.toHTML = function(node, up) { this.up = up; var astNode = this; this.domNode = newEl('span', { className: 'string', contentEditable: 'true', textContent: this.val, onclick: function(event) { main_module.scalarClick(this, astNode, event); } }); node.appendChild(this.domNode); }; listlit.prototype.toHTML = function(node, up) { this.up = up; this.domNode = newEl('span', { className: 'list', }); for (var i = 0; i < this.val.length; i++) { this.val[i].toHTML(this.domNode, this); } node.appendChild(this.domNode); }; arraylit.prototype.toHTML = function(node, up) { this.up = up; this.domNode = newEl('span', { className: 'array', }); for (var i = 0; i < this.val.length; i++) { this.val[i].toHTML(this.domNode, this); } node.appendChild(this.domNode); }; funcall.prototype.toHTML = function(node, up) { this.up = up; var astNode = this; var base = newEl('div', { className: 'funcall', onclick: function(event) { main_module.funClick(this, astNode, event); } }); this.domNode = base; if (this.receiver) { this.receiver.toHTML(base, this); } var parts = this.name.split(':'); for (var i in parts ) { if(parts[i]) { base.appendChild(newEl('span', { textContent: parts[i] + (this.receiver && parts.length == 1 ? '' : ':'), className: 'funpart' })); if (this.args[i]) { this.args[i].toHTML(base, this); } } } for (; i < this.args.length; i++) { this.args[i].toHTML(base, this); } node.appendChild(base); }; symbol.prototype.toHTML = function(node, up) { this.up = up; var astNode = this; this.domNode = newEl('span', { className: 'symbol', textContent: this.name, onclick: function(event) { main_module.symbolClick(this, astNode, event); } }) node.appendChild(this.domNode); } function getEl(from, idx) { return from[idx]; } function setEl(to, idx, val) { to[idx] = val; return to; }