Mercurial > repos > tabletprog
changeset 119:77f7cd65e121
Add selection of number and string literals. Support inward navigation of lambdas.
author | Mike Pavone <pavone@retrodev.com> |
---|---|
date | Wed, 17 Apr 2013 00:23:05 -0700 |
parents | 0a66fe3a368a |
children | d5dc9507d612 |
files | editor.js src/editor.tp |
diffstat | 2 files changed, 34 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/editor.js Mon Apr 15 21:55:26 2013 -0700 +++ b/editor.js Wed Apr 17 00:23:05 2013 -0700 @@ -83,28 +83,40 @@ intlit.prototype.toHTML = function(node, up) { this.up = up; + var astNode = this; this.domNode = newEl('span', { className: 'integer', - textContent: this.val + 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 + 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 + textContent: this.val, + onclick: function(event) { + main_module.scalarClick(this, astNode, event); + } }); node.appendChild(this.domNode); };
--- a/src/editor.tp Mon Apr 15 21:55:26 2013 -0700 +++ b/src/editor.tp Wed Apr 17 00:23:05 2013 -0700 @@ -131,6 +131,13 @@ } } +scalarClick <- :domnode astnode event { + selectNode: domnode + setSelection: astnode + event stopPropagation: (foreign: undefined) + //TODO: set focus +} + symbolClick <- :domnode astnode event { selectNode: domnode popInscope: ((astnode symbols) allSymbols: (foreign: undefined)) onClick: :key { @@ -221,7 +228,18 @@ } lambdaClick <- :domnode astnode event { - symbolClick: domnode astnode event + selectNode: domnode + popInscope: ((astnode symbols) allSymbols: (foreign: undefined)) onClick: :key { + domnode textContent!: key + astnode name!: key + } + inner <- if: ((astnode args) length) > 0 { + (astnode args) getEl: 0 + } else: { + (astnode expressions) getEl: 0 + } + setSelection: astnode withInNode: inner + event stopPropagation: (foreign: undefined) } visible <- "showops"