Mercurial > repos > tabletprog
comparison 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 |
comparison
equal
deleted
inserted
replaced
22:40a85f135be5 | 23:068d63627b16 |
---|---|
4 qall <- foreign: :query {} | 4 qall <- foreign: :query {} |
5 each <- foreign: :iterable fun {} | 5 each <- foreign: :iterable fun {} |
6 addClass <- foreign: :node className {} | 6 addClass <- foreign: :node className {} |
7 removeClass <- foreign: :node className {} | 7 removeClass <- foreign: :node className {} |
8 get <- foreign: :url onSuccess onFail onOther {} | 8 get <- foreign: :url onSuccess onFail onOther {} |
9 newEl <- foreign: :tagname props {} | |
9 | 10 |
10 //TP Parser | 11 //TP Parser |
11 parser <- foreign: #{ | 12 parser <- foreign: #{ |
12 parse <- foreign: :str {} | 13 parse <- foreign: :str {} |
13 } | 14 } |
14 | 15 |
15 //js builtins | 16 //js builtins |
16 console <- foreign: #{ | 17 console <- foreign: #{ |
17 log <- foreign: #{} | 18 log <- foreign: :val {} |
18 } | 19 } |
19 window <- #{} | 20 window <- #{} |
21 Object <- foreign: #{ | |
22 keys <- foreign: :object {} | |
23 } | |
20 | 24 |
21 //kernel definitions | 25 //kernel definitions |
22 true <- #{ | 26 true <- #{ |
23 if:else <- :self trueblock :elseblock { | 27 if:else <- :self trueblock :elseblock { |
24 trueblock: | 28 trueblock: |
36 addClass: (q: "body") "editorMode" | 40 addClass: (q: "body") "editorMode" |
37 src <- request responseText | 41 src <- request responseText |
38 console log: src | 42 console log: src |
39 ast <- parser parse: src | 43 ast <- parser parse: src |
40 console log: ast | 44 console log: ast |
45 ast populateSymbols: (foreign: null) | |
41 ast toHTML: (q: "#src") | 46 ast toHTML: (q: "#src") |
47 } | |
48 } | |
49 | |
50 symbolClick <- :domnode astnode { | |
51 inscope <- q: "#inscope" | |
52 inscope innerHTML!: "" | |
53 console log: astnode | |
54 syms <- (astnode symbols) allSymbols | |
55 each: ((Object keys: syms) sort) :idx key { | |
56 inscope appendChild: (newEl: "li" #{ | |
57 textContent <- key | |
58 }) | |
42 } | 59 } |
43 } | 60 } |
44 | 61 |
45 //editor code | 62 //editor code |
46 main <- { | 63 main <- { |
65 } | 82 } |
66 (q: "#ops_button") onclick!: :event { | 83 (q: "#ops_button") onclick!: :event { |
67 addClass: (q: ".controls") "showops" | 84 addClass: (q: ".controls") "showops" |
68 } | 85 } |
69 | 86 |
70 (q: "#builtin_button") onclick!: :event { | |
71 removeClass: (q: ".controls") "showops" | |
72 } | |
73 | |
74 path <- (window location) pathname | 87 path <- (window location) pathname |
75 if: (path indexOf: "/edit/") = 0 { | 88 if: (path indexOf: "/edit/") = 0 { |
76 editFile: (path substr: 5) | 89 editFile: (path substr: 5) |
77 } else: {} | 90 } else: {} |
78 } | 91 } |