diff editor.tp @ 23:068d63627b16

Populate in scope symbol buttons when clicking on a symbol in the source
author Mike Pavone <pavone@retrodev.com>
date Mon, 26 Mar 2012 21:29:03 -0700
parents 6c8ae6b47ab5
children fe3533494ce9
line wrap: on
line diff
--- a/editor.tp	Mon Mar 26 00:06:13 2012 -0700
+++ b/editor.tp	Mon Mar 26 21:29:03 2012 -0700
@@ -6,6 +6,7 @@
 addClass <- foreign: :node className {}
 removeClass <- foreign: :node className {}
 get <- foreign: :url onSuccess onFail onOther {}
+newEl <- foreign: :tagname props {}
 
 //TP Parser
 parser <- foreign: #{
@@ -14,9 +15,12 @@
 
 //js builtins
 console <- foreign: #{
-	log <- foreign: #{}
+	log <- foreign: :val {}
 }
 window <- #{}
+Object <- foreign: #{
+	keys <- foreign: :object {}
+}
 
 //kernel definitions
 true <- #{
@@ -38,10 +42,23 @@
 		console log: src
 		ast <- parser parse: src
 		console log: ast
+		ast populateSymbols: (foreign: null)
 		ast toHTML: (q: "#src")
 	}
 }
 
+symbolClick <- :domnode astnode {
+	inscope <- q: "#inscope"
+	inscope innerHTML!: ""
+	console log: astnode
+	syms <- (astnode symbols) allSymbols
+	each: ((Object keys: syms) sort) :idx key {
+		inscope appendChild: (newEl: "li" #{
+			textContent <- key
+		})
+	}
+}
+
 //editor code
 main <- {
 	//bind handlers for file browser links
@@ -67,10 +84,6 @@
 		addClass: (q: ".controls") "showops"
 	}
 	
-	(q: "#builtin_button") onclick!: :event {
-		removeClass: (q: ".controls") "showops"
-	}
-	
 	path <- (window location) pathname
 	if: (path indexOf: "/edit/") = 0 {
 		editFile: (path substr: 5)