# HG changeset patch # User Mike Pavone # Date 1366183385 25200 # Node ID 77f7cd65e1214c0b8529d9b3dd597e0462a66bca # Parent 0a66fe3a368a789725cef9a8a929bae51ef85078 Add selection of number and string literals. Support inward navigation of lambdas. diff -r 0a66fe3a368a -r 77f7cd65e121 editor.js --- 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); }; diff -r 0a66fe3a368a -r 77f7cd65e121 src/editor.tp --- 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"