Mercurial > repos > tabletprog
annotate src/editor.tp @ 113:c0bfff39abe3
Basic in and out navigation support added to funcall expressions. Added toHTML methods to listlit and arraylit.
author | Mike Pavone <pavone@retrodev.com> |
---|---|
date | Sun, 14 Apr 2013 23:09:46 -0700 |
parents | b2a3f202d485 |
children | 9cf3e0b18ecc |
rev | line source |
---|---|
11 | 1 #{ |
2 //mquery functions | |
3 q <- foreign: :query {} | |
4 qall <- foreign: :query {} | |
5 each <- foreign: :iterable fun {} | |
6 addClass <- foreign: :node className {} | |
7 removeClass <- foreign: :node className {} | |
110
d715fb3c39ab
Implemented clicking on symbols inside inscope box to replace function name in funcall.
Mike Pavone <pavone@retrodev.com>
parents:
109
diff
changeset
|
8 hasClass <- foreign: :node className {} |
12
6e4851a204a5
Add ability to load code into editor
Mike Pavone <pavone@retrodev.com>
parents:
11
diff
changeset
|
9 get <- foreign: :url onSuccess onFail onOther {} |
110
d715fb3c39ab
Implemented clicking on symbols inside inscope box to replace function name in funcall.
Mike Pavone <pavone@retrodev.com>
parents:
109
diff
changeset
|
10 getEl <- foreign: :from idx {} |
d715fb3c39ab
Implemented clicking on symbols inside inscope box to replace function name in funcall.
Mike Pavone <pavone@retrodev.com>
parents:
109
diff
changeset
|
11 setEl <- foreign: :to idx val {} |
23
068d63627b16
Populate in scope symbol buttons when clicking on a symbol in the source
Mike Pavone <pavone@retrodev.com>
parents:
21
diff
changeset
|
12 newEl <- foreign: :tagname props {} |
11 | 13 |
14
85fb6ba15bc6
Start turning AST into HTML in editor
Mike Pavone <pavone@retrodev.com>
parents:
12
diff
changeset
|
14 //TP Parser |
85fb6ba15bc6
Start turning AST into HTML in editor
Mike Pavone <pavone@retrodev.com>
parents:
12
diff
changeset
|
15 parser <- foreign: #{ |
85fb6ba15bc6
Start turning AST into HTML in editor
Mike Pavone <pavone@retrodev.com>
parents:
12
diff
changeset
|
16 parse <- foreign: :str {} |
85fb6ba15bc6
Start turning AST into HTML in editor
Mike Pavone <pavone@retrodev.com>
parents:
12
diff
changeset
|
17 } |
25
4d87c38404d6
List literals, fixes to implicit self property lookup, import statement and editor improvements
Mike Pavone <pavone@retrodev.com>
parents:
24
diff
changeset
|
18 isLambda <- foreign: :astnode {} |
14
85fb6ba15bc6
Start turning AST into HTML in editor
Mike Pavone <pavone@retrodev.com>
parents:
12
diff
changeset
|
19 |
11 | 20 //js builtins |
21 console <- foreign: #{ | |
23
068d63627b16
Populate in scope symbol buttons when clicking on a symbol in the source
Mike Pavone <pavone@retrodev.com>
parents:
21
diff
changeset
|
22 log <- foreign: :val {} |
11 | 23 } |
25
4d87c38404d6
List literals, fixes to implicit self property lookup, import statement and editor improvements
Mike Pavone <pavone@retrodev.com>
parents:
24
diff
changeset
|
24 window <- foreign: #{} |
23
068d63627b16
Populate in scope symbol buttons when clicking on a symbol in the source
Mike Pavone <pavone@retrodev.com>
parents:
21
diff
changeset
|
25 Object <- foreign: #{ |
068d63627b16
Populate in scope symbol buttons when clicking on a symbol in the source
Mike Pavone <pavone@retrodev.com>
parents:
21
diff
changeset
|
26 keys <- foreign: :object {} |
068d63627b16
Populate in scope symbol buttons when clicking on a symbol in the source
Mike Pavone <pavone@retrodev.com>
parents:
21
diff
changeset
|
27 } |
11 | 28 |
17
7400bb42e0c9
Add direct file edit link support
Mike Pavone <pavone@retrodev.com>
parents:
14
diff
changeset
|
29 //kernel definitions |
104 | 30 //import: kernel |
25
4d87c38404d6
List literals, fixes to implicit self property lookup, import statement and editor improvements
Mike Pavone <pavone@retrodev.com>
parents:
24
diff
changeset
|
31 |
108
5099c1a96e3f
Mostly fix clicking on the function name in a funcall expression
Mike Pavone <pavone@retrodev.com>
parents:
107
diff
changeset
|
32 filter <- :arr pred { |
5099c1a96e3f
Mostly fix clicking on the function name in a funcall expression
Mike Pavone <pavone@retrodev.com>
parents:
107
diff
changeset
|
33 output <- arr slice: 0 0 |
5099c1a96e3f
Mostly fix clicking on the function name in a funcall expression
Mike Pavone <pavone@retrodev.com>
parents:
107
diff
changeset
|
34 each: arr :idx el { |
5099c1a96e3f
Mostly fix clicking on the function name in a funcall expression
Mike Pavone <pavone@retrodev.com>
parents:
107
diff
changeset
|
35 if: (pred: el) { |
5099c1a96e3f
Mostly fix clicking on the function name in a funcall expression
Mike Pavone <pavone@retrodev.com>
parents:
107
diff
changeset
|
36 output push: el |
5099c1a96e3f
Mostly fix clicking on the function name in a funcall expression
Mike Pavone <pavone@retrodev.com>
parents:
107
diff
changeset
|
37 } else: {} |
5099c1a96e3f
Mostly fix clicking on the function name in a funcall expression
Mike Pavone <pavone@retrodev.com>
parents:
107
diff
changeset
|
38 } |
5099c1a96e3f
Mostly fix clicking on the function name in a funcall expression
Mike Pavone <pavone@retrodev.com>
parents:
107
diff
changeset
|
39 output |
5099c1a96e3f
Mostly fix clicking on the function name in a funcall expression
Mike Pavone <pavone@retrodev.com>
parents:
107
diff
changeset
|
40 } |
5099c1a96e3f
Mostly fix clicking on the function name in a funcall expression
Mike Pavone <pavone@retrodev.com>
parents:
107
diff
changeset
|
41 |
25
4d87c38404d6
List literals, fixes to implicit self property lookup, import statement and editor improvements
Mike Pavone <pavone@retrodev.com>
parents:
24
diff
changeset
|
42 //editor code |
113
c0bfff39abe3
Basic in and out navigation support added to funcall expressions. Added toHTML methods to listlit and arraylit.
Mike Pavone <pavone@retrodev.com>
parents:
111
diff
changeset
|
43 selection <- #{ |
c0bfff39abe3
Basic in and out navigation support added to funcall expressions. Added toHTML methods to listlit and arraylit.
Mike Pavone <pavone@retrodev.com>
parents:
111
diff
changeset
|
44 valid? <- false |
c0bfff39abe3
Basic in and out navigation support added to funcall expressions. Added toHTML methods to listlit and arraylit.
Mike Pavone <pavone@retrodev.com>
parents:
111
diff
changeset
|
45 } |
c0bfff39abe3
Basic in and out navigation support added to funcall expressions. Added toHTML methods to listlit and arraylit.
Mike Pavone <pavone@retrodev.com>
parents:
111
diff
changeset
|
46 |
17
7400bb42e0c9
Add direct file edit link support
Mike Pavone <pavone@retrodev.com>
parents:
14
diff
changeset
|
47 editFile <- :path { |
7400bb42e0c9
Add direct file edit link support
Mike Pavone <pavone@retrodev.com>
parents:
14
diff
changeset
|
48 get: path :request { |
7400bb42e0c9
Add direct file edit link support
Mike Pavone <pavone@retrodev.com>
parents:
14
diff
changeset
|
49 addClass: (q: "body") "editorMode" |
21
6c8ae6b47ab5
Small improvements to property support and elimination of setP and getP functions as they are no longer needed
Mike Pavone <pavone@retrodev.com>
parents:
18
diff
changeset
|
50 src <- request responseText |
17
7400bb42e0c9
Add direct file edit link support
Mike Pavone <pavone@retrodev.com>
parents:
14
diff
changeset
|
51 ast <- parser parse: src |
23
068d63627b16
Populate in scope symbol buttons when clicking on a symbol in the source
Mike Pavone <pavone@retrodev.com>
parents:
21
diff
changeset
|
52 ast populateSymbols: (foreign: null) |
17
7400bb42e0c9
Add direct file edit link support
Mike Pavone <pavone@retrodev.com>
parents:
14
diff
changeset
|
53 ast toHTML: (q: "#src") |
7400bb42e0c9
Add direct file edit link support
Mike Pavone <pavone@retrodev.com>
parents:
14
diff
changeset
|
54 } |
7400bb42e0c9
Add direct file edit link support
Mike Pavone <pavone@retrodev.com>
parents:
14
diff
changeset
|
55 } |
7400bb42e0c9
Add direct file edit link support
Mike Pavone <pavone@retrodev.com>
parents:
14
diff
changeset
|
56 |
25
4d87c38404d6
List literals, fixes to implicit self property lookup, import statement and editor improvements
Mike Pavone <pavone@retrodev.com>
parents:
24
diff
changeset
|
57 selectNode <- :node { |
4d87c38404d6
List literals, fixes to implicit self property lookup, import statement and editor improvements
Mike Pavone <pavone@retrodev.com>
parents:
24
diff
changeset
|
58 each: (qall: ".selected") :idx el { |
4d87c38404d6
List literals, fixes to implicit self property lookup, import statement and editor improvements
Mike Pavone <pavone@retrodev.com>
parents:
24
diff
changeset
|
59 removeClass: el "selected" |
4d87c38404d6
List literals, fixes to implicit self property lookup, import statement and editor improvements
Mike Pavone <pavone@retrodev.com>
parents:
24
diff
changeset
|
60 } |
4d87c38404d6
List literals, fixes to implicit self property lookup, import statement and editor improvements
Mike Pavone <pavone@retrodev.com>
parents:
24
diff
changeset
|
61 addClass: node "selected" |
4d87c38404d6
List literals, fixes to implicit self property lookup, import statement and editor improvements
Mike Pavone <pavone@retrodev.com>
parents:
24
diff
changeset
|
62 } |
4d87c38404d6
List literals, fixes to implicit self property lookup, import statement and editor improvements
Mike Pavone <pavone@retrodev.com>
parents:
24
diff
changeset
|
63 |
4d87c38404d6
List literals, fixes to implicit self property lookup, import statement and editor improvements
Mike Pavone <pavone@retrodev.com>
parents:
24
diff
changeset
|
64 selectQuery <- :selector { |
4d87c38404d6
List literals, fixes to implicit self property lookup, import statement and editor improvements
Mike Pavone <pavone@retrodev.com>
parents:
24
diff
changeset
|
65 selectQuery: selector in: (foreign: undefined) |
4d87c38404d6
List literals, fixes to implicit self property lookup, import statement and editor improvements
Mike Pavone <pavone@retrodev.com>
parents:
24
diff
changeset
|
66 } |
4d87c38404d6
List literals, fixes to implicit self property lookup, import statement and editor improvements
Mike Pavone <pavone@retrodev.com>
parents:
24
diff
changeset
|
67 |
4d87c38404d6
List literals, fixes to implicit self property lookup, import statement and editor improvements
Mike Pavone <pavone@retrodev.com>
parents:
24
diff
changeset
|
68 selectQuery:in <- :selector :context { |
4d87c38404d6
List literals, fixes to implicit self property lookup, import statement and editor improvements
Mike Pavone <pavone@retrodev.com>
parents:
24
diff
changeset
|
69 each: (qall: ".selected") :idx el { |
4d87c38404d6
List literals, fixes to implicit self property lookup, import statement and editor improvements
Mike Pavone <pavone@retrodev.com>
parents:
24
diff
changeset
|
70 removeClass: el "selected" |
4d87c38404d6
List literals, fixes to implicit self property lookup, import statement and editor improvements
Mike Pavone <pavone@retrodev.com>
parents:
24
diff
changeset
|
71 } |
4d87c38404d6
List literals, fixes to implicit self property lookup, import statement and editor improvements
Mike Pavone <pavone@retrodev.com>
parents:
24
diff
changeset
|
72 each: (qall: selector context) :idx el { |
4d87c38404d6
List literals, fixes to implicit self property lookup, import statement and editor improvements
Mike Pavone <pavone@retrodev.com>
parents:
24
diff
changeset
|
73 addClass: el "selected" |
4d87c38404d6
List literals, fixes to implicit self property lookup, import statement and editor improvements
Mike Pavone <pavone@retrodev.com>
parents:
24
diff
changeset
|
74 } |
4d87c38404d6
List literals, fixes to implicit self property lookup, import statement and editor improvements
Mike Pavone <pavone@retrodev.com>
parents:
24
diff
changeset
|
75 } |
4d87c38404d6
List literals, fixes to implicit self property lookup, import statement and editor improvements
Mike Pavone <pavone@retrodev.com>
parents:
24
diff
changeset
|
76 |
4d87c38404d6
List literals, fixes to implicit self property lookup, import statement and editor improvements
Mike Pavone <pavone@retrodev.com>
parents:
24
diff
changeset
|
77 selectParent <- :node { |
4d87c38404d6
List literals, fixes to implicit self property lookup, import statement and editor improvements
Mike Pavone <pavone@retrodev.com>
parents:
24
diff
changeset
|
78 each: (qall: ".selectParent") :idx el { |
109
a647cdad620b
Small fix to selecting a funcall method/function name
Mike Pavone <pavone@retrodev.com>
parents:
108
diff
changeset
|
79 removeClass: el "selectParent" |
25
4d87c38404d6
List literals, fixes to implicit self property lookup, import statement and editor improvements
Mike Pavone <pavone@retrodev.com>
parents:
24
diff
changeset
|
80 } |
113
c0bfff39abe3
Basic in and out navigation support added to funcall expressions. Added toHTML methods to listlit and arraylit.
Mike Pavone <pavone@retrodev.com>
parents:
111
diff
changeset
|
81 addClass: node "selectParent" |
25
4d87c38404d6
List literals, fixes to implicit self property lookup, import statement and editor improvements
Mike Pavone <pavone@retrodev.com>
parents:
24
diff
changeset
|
82 } |
4d87c38404d6
List literals, fixes to implicit self property lookup, import statement and editor improvements
Mike Pavone <pavone@retrodev.com>
parents:
24
diff
changeset
|
83 |
4d87c38404d6
List literals, fixes to implicit self property lookup, import statement and editor improvements
Mike Pavone <pavone@retrodev.com>
parents:
24
diff
changeset
|
84 popInscope:onClick <- :syms :handler { |
23
068d63627b16
Populate in scope symbol buttons when clicking on a symbol in the source
Mike Pavone <pavone@retrodev.com>
parents:
21
diff
changeset
|
85 inscope <- q: "#inscope" |
068d63627b16
Populate in scope symbol buttons when clicking on a symbol in the source
Mike Pavone <pavone@retrodev.com>
parents:
21
diff
changeset
|
86 inscope innerHTML!: "" |
24
fe3533494ce9
Display symbols order first by depth. Eliminate extraneous setter symbols
Mike Pavone <pavone@retrodev.com>
parents:
23
diff
changeset
|
87 each: syms :idx key { |
23
068d63627b16
Populate in scope symbol buttons when clicking on a symbol in the source
Mike Pavone <pavone@retrodev.com>
parents:
21
diff
changeset
|
88 inscope appendChild: (newEl: "li" #{ |
068d63627b16
Populate in scope symbol buttons when clicking on a symbol in the source
Mike Pavone <pavone@retrodev.com>
parents:
21
diff
changeset
|
89 textContent <- key |
107
152b6cfb98b6
Click-to-select no longer selects the whole lambda when it shouldn't and no longer replaces the selected code with a single symbol.
Mike Pavone <pavone@retrodev.com>
parents:
105
diff
changeset
|
90 onclick <- :Event { handler: key } |
23
068d63627b16
Populate in scope symbol buttons when clicking on a symbol in the source
Mike Pavone <pavone@retrodev.com>
parents:
21
diff
changeset
|
91 }) |
068d63627b16
Populate in scope symbol buttons when clicking on a symbol in the source
Mike Pavone <pavone@retrodev.com>
parents:
21
diff
changeset
|
92 } |
068d63627b16
Populate in scope symbol buttons when clicking on a symbol in the source
Mike Pavone <pavone@retrodev.com>
parents:
21
diff
changeset
|
93 } |
068d63627b16
Populate in scope symbol buttons when clicking on a symbol in the source
Mike Pavone <pavone@retrodev.com>
parents:
21
diff
changeset
|
94 |
29
18cec540238a
Prevent event bubbling so lambda click handler doesn't get called when clicking on an element inside it
Mike Pavone <pavone@retrodev.com>
parents:
28
diff
changeset
|
95 symbolClick <- :domnode astnode event { |
25
4d87c38404d6
List literals, fixes to implicit self property lookup, import statement and editor improvements
Mike Pavone <pavone@retrodev.com>
parents:
24
diff
changeset
|
96 selectNode: domnode |
105
35006a6e1c47
Fixed more editor coderot and improved syntax/selection coloring a bit.
Mike Pavone <pavone@retrodev.com>
parents:
104
diff
changeset
|
97 popInscope: ((astnode symbols) allSymbols: (foreign: undefined)) onClick: :key { |
25
4d87c38404d6
List literals, fixes to implicit self property lookup, import statement and editor improvements
Mike Pavone <pavone@retrodev.com>
parents:
24
diff
changeset
|
98 domnode textContent!: key |
4d87c38404d6
List literals, fixes to implicit self property lookup, import statement and editor improvements
Mike Pavone <pavone@retrodev.com>
parents:
24
diff
changeset
|
99 astnode name!: key |
4d87c38404d6
List literals, fixes to implicit self property lookup, import statement and editor improvements
Mike Pavone <pavone@retrodev.com>
parents:
24
diff
changeset
|
100 } |
107
152b6cfb98b6
Click-to-select no longer selects the whole lambda when it shouldn't and no longer replaces the selected code with a single symbol.
Mike Pavone <pavone@retrodev.com>
parents:
105
diff
changeset
|
101 event stopPropagation: (foreign: undefined) |
25
4d87c38404d6
List literals, fixes to implicit self property lookup, import statement and editor improvements
Mike Pavone <pavone@retrodev.com>
parents:
24
diff
changeset
|
102 } |
4d87c38404d6
List literals, fixes to implicit self property lookup, import statement and editor improvements
Mike Pavone <pavone@retrodev.com>
parents:
24
diff
changeset
|
103 |
29
18cec540238a
Prevent event bubbling so lambda click handler doesn't get called when clicking on an element inside it
Mike Pavone <pavone@retrodev.com>
parents:
28
diff
changeset
|
104 funClick <- :domnode astnode event { |
25
4d87c38404d6
List literals, fixes to implicit self property lookup, import statement and editor improvements
Mike Pavone <pavone@retrodev.com>
parents:
24
diff
changeset
|
105 selectParent: domnode |
113
c0bfff39abe3
Basic in and out navigation support added to funcall expressions. Added toHTML methods to listlit and arraylit.
Mike Pavone <pavone@retrodev.com>
parents:
111
diff
changeset
|
106 selectQuery: ".selectParent > .funpart" in: domnode |
25
4d87c38404d6
List literals, fixes to implicit self property lookup, import statement and editor improvements
Mike Pavone <pavone@retrodev.com>
parents:
24
diff
changeset
|
107 symtable <- astnode symbols |
108
5099c1a96e3f
Mostly fix clicking on the function name in a funcall expression
Mike Pavone <pavone@retrodev.com>
parents:
107
diff
changeset
|
108 syms <- filter: (symtable allSymbols: (foreign: undefined)) :sym { |
25
4d87c38404d6
List literals, fixes to implicit self property lookup, import statement and editor improvements
Mike Pavone <pavone@retrodev.com>
parents:
24
diff
changeset
|
109 isLambda: ((symtable find: sym) def) |
4d87c38404d6
List literals, fixes to implicit self property lookup, import statement and editor improvements
Mike Pavone <pavone@retrodev.com>
parents:
24
diff
changeset
|
110 } |
113
c0bfff39abe3
Basic in and out navigation support added to funcall expressions. Added toHTML methods to listlit and arraylit.
Mike Pavone <pavone@retrodev.com>
parents:
111
diff
changeset
|
111 self selection!: #{ |
c0bfff39abe3
Basic in and out navigation support added to funcall expressions. Added toHTML methods to listlit and arraylit.
Mike Pavone <pavone@retrodev.com>
parents:
111
diff
changeset
|
112 valid? <- true |
c0bfff39abe3
Basic in and out navigation support added to funcall expressions. Added toHTML methods to listlit and arraylit.
Mike Pavone <pavone@retrodev.com>
parents:
111
diff
changeset
|
113 in <- { |
c0bfff39abe3
Basic in and out navigation support added to funcall expressions. Added toHTML methods to listlit and arraylit.
Mike Pavone <pavone@retrodev.com>
parents:
111
diff
changeset
|
114 fakeEvent <- #{ |
c0bfff39abe3
Basic in and out navigation support added to funcall expressions. Added toHTML methods to listlit and arraylit.
Mike Pavone <pavone@retrodev.com>
parents:
111
diff
changeset
|
115 stopPropagation <- :Blah { |
c0bfff39abe3
Basic in and out navigation support added to funcall expressions. Added toHTML methods to listlit and arraylit.
Mike Pavone <pavone@retrodev.com>
parents:
111
diff
changeset
|
116 } |
c0bfff39abe3
Basic in and out navigation support added to funcall expressions. Added toHTML methods to listlit and arraylit.
Mike Pavone <pavone@retrodev.com>
parents:
111
diff
changeset
|
117 } |
c0bfff39abe3
Basic in and out navigation support added to funcall expressions. Added toHTML methods to listlit and arraylit.
Mike Pavone <pavone@retrodev.com>
parents:
111
diff
changeset
|
118 if: (astnode receiver) != (foreign: null) { |
c0bfff39abe3
Basic in and out navigation support added to funcall expressions. Added toHTML methods to listlit and arraylit.
Mike Pavone <pavone@retrodev.com>
parents:
111
diff
changeset
|
119 ((astnode receiver) domNode) onclick: fakeEvent |
c0bfff39abe3
Basic in and out navigation support added to funcall expressions. Added toHTML methods to listlit and arraylit.
Mike Pavone <pavone@retrodev.com>
parents:
111
diff
changeset
|
120 } else: { |
c0bfff39abe3
Basic in and out navigation support added to funcall expressions. Added toHTML methods to listlit and arraylit.
Mike Pavone <pavone@retrodev.com>
parents:
111
diff
changeset
|
121 if: ((astnode args) length) > 0 { |
c0bfff39abe3
Basic in and out navigation support added to funcall expressions. Added toHTML methods to listlit and arraylit.
Mike Pavone <pavone@retrodev.com>
parents:
111
diff
changeset
|
122 (((astnode args) getEl: 0) domNode) onclick: fakeEvent |
c0bfff39abe3
Basic in and out navigation support added to funcall expressions. Added toHTML methods to listlit and arraylit.
Mike Pavone <pavone@retrodev.com>
parents:
111
diff
changeset
|
123 } |
c0bfff39abe3
Basic in and out navigation support added to funcall expressions. Added toHTML methods to listlit and arraylit.
Mike Pavone <pavone@retrodev.com>
parents:
111
diff
changeset
|
124 } |
c0bfff39abe3
Basic in and out navigation support added to funcall expressions. Added toHTML methods to listlit and arraylit.
Mike Pavone <pavone@retrodev.com>
parents:
111
diff
changeset
|
125 } |
c0bfff39abe3
Basic in and out navigation support added to funcall expressions. Added toHTML methods to listlit and arraylit.
Mike Pavone <pavone@retrodev.com>
parents:
111
diff
changeset
|
126 out <- { |
c0bfff39abe3
Basic in and out navigation support added to funcall expressions. Added toHTML methods to listlit and arraylit.
Mike Pavone <pavone@retrodev.com>
parents:
111
diff
changeset
|
127 fakeEvent <- #{ |
c0bfff39abe3
Basic in and out navigation support added to funcall expressions. Added toHTML methods to listlit and arraylit.
Mike Pavone <pavone@retrodev.com>
parents:
111
diff
changeset
|
128 stopPropagation <- :Blah { |
c0bfff39abe3
Basic in and out navigation support added to funcall expressions. Added toHTML methods to listlit and arraylit.
Mike Pavone <pavone@retrodev.com>
parents:
111
diff
changeset
|
129 } |
c0bfff39abe3
Basic in and out navigation support added to funcall expressions. Added toHTML methods to listlit and arraylit.
Mike Pavone <pavone@retrodev.com>
parents:
111
diff
changeset
|
130 } |
c0bfff39abe3
Basic in and out navigation support added to funcall expressions. Added toHTML methods to listlit and arraylit.
Mike Pavone <pavone@retrodev.com>
parents:
111
diff
changeset
|
131 ((astnode up) domNode) onclick: fakeEvent |
c0bfff39abe3
Basic in and out navigation support added to funcall expressions. Added toHTML methods to listlit and arraylit.
Mike Pavone <pavone@retrodev.com>
parents:
111
diff
changeset
|
132 } |
c0bfff39abe3
Basic in and out navigation support added to funcall expressions. Added toHTML methods to listlit and arraylit.
Mike Pavone <pavone@retrodev.com>
parents:
111
diff
changeset
|
133 } |
110
d715fb3c39ab
Implemented clicking on symbols inside inscope box to replace function name in funcall.
Mike Pavone <pavone@retrodev.com>
parents:
109
diff
changeset
|
134 popInscope: syms onClick: :key { |
d715fb3c39ab
Implemented clicking on symbols inside inscope box to replace function name in funcall.
Mike Pavone <pavone@retrodev.com>
parents:
109
diff
changeset
|
135 astnode name!: key |
d715fb3c39ab
Implemented clicking on symbols inside inscope box to replace function name in funcall.
Mike Pavone <pavone@retrodev.com>
parents:
109
diff
changeset
|
136 parts <- key split: ":" |
d715fb3c39ab
Implemented clicking on symbols inside inscope box to replace function name in funcall.
Mike Pavone <pavone@retrodev.com>
parents:
109
diff
changeset
|
137 nodes <- [] |
113
c0bfff39abe3
Basic in and out navigation support added to funcall expressions. Added toHTML methods to listlit and arraylit.
Mike Pavone <pavone@retrodev.com>
parents:
111
diff
changeset
|
138 each: (domnode children) :idx val{ |
110
d715fb3c39ab
Implemented clicking on symbols inside inscope box to replace function name in funcall.
Mike Pavone <pavone@retrodev.com>
parents:
109
diff
changeset
|
139 nodes push: val |
d715fb3c39ab
Implemented clicking on symbols inside inscope box to replace function name in funcall.
Mike Pavone <pavone@retrodev.com>
parents:
109
diff
changeset
|
140 } |
d715fb3c39ab
Implemented clicking on symbols inside inscope box to replace function name in funcall.
Mike Pavone <pavone@retrodev.com>
parents:
109
diff
changeset
|
141 partIdx <- 0 |
d715fb3c39ab
Implemented clicking on symbols inside inscope box to replace function name in funcall.
Mike Pavone <pavone@retrodev.com>
parents:
109
diff
changeset
|
142 nodeIdx <- 0 |
d715fb3c39ab
Implemented clicking on symbols inside inscope box to replace function name in funcall.
Mike Pavone <pavone@retrodev.com>
parents:
109
diff
changeset
|
143 lastWasNamePart <- true |
d715fb3c39ab
Implemented clicking on symbols inside inscope box to replace function name in funcall.
Mike Pavone <pavone@retrodev.com>
parents:
109
diff
changeset
|
144 while: { partIdx < (parts length) || nodeIdx < (nodes length) } do: { |
d715fb3c39ab
Implemented clicking on symbols inside inscope box to replace function name in funcall.
Mike Pavone <pavone@retrodev.com>
parents:
109
diff
changeset
|
145 if: nodeIdx < (nodes length) { |
d715fb3c39ab
Implemented clicking on symbols inside inscope box to replace function name in funcall.
Mike Pavone <pavone@retrodev.com>
parents:
109
diff
changeset
|
146 node <-getEl: nodes nodeIdx |
d715fb3c39ab
Implemented clicking on symbols inside inscope box to replace function name in funcall.
Mike Pavone <pavone@retrodev.com>
parents:
109
diff
changeset
|
147 nodeIdx <- nodeIdx + 1 |
d715fb3c39ab
Implemented clicking on symbols inside inscope box to replace function name in funcall.
Mike Pavone <pavone@retrodev.com>
parents:
109
diff
changeset
|
148 if: (hasClass: node "funpart") { |
d715fb3c39ab
Implemented clicking on symbols inside inscope box to replace function name in funcall.
Mike Pavone <pavone@retrodev.com>
parents:
109
diff
changeset
|
149 if: partIdx < (parts length) { |
d715fb3c39ab
Implemented clicking on symbols inside inscope box to replace function name in funcall.
Mike Pavone <pavone@retrodev.com>
parents:
109
diff
changeset
|
150 postfix <- if: partIdx = 0 && nodeIdx = 2 && (parts length) = 1 && (nodes length) = 2 { "" } else: { ":" } |
d715fb3c39ab
Implemented clicking on symbols inside inscope box to replace function name in funcall.
Mike Pavone <pavone@retrodev.com>
parents:
109
diff
changeset
|
151 t <- (getEl: parts partIdx) |
d715fb3c39ab
Implemented clicking on symbols inside inscope box to replace function name in funcall.
Mike Pavone <pavone@retrodev.com>
parents:
109
diff
changeset
|
152 node textContent!: (getEl: parts partIdx) . postfix |
d715fb3c39ab
Implemented clicking on symbols inside inscope box to replace function name in funcall.
Mike Pavone <pavone@retrodev.com>
parents:
109
diff
changeset
|
153 partIdx <- partIdx + 1 |
d715fb3c39ab
Implemented clicking on symbols inside inscope box to replace function name in funcall.
Mike Pavone <pavone@retrodev.com>
parents:
109
diff
changeset
|
154 } else: { |
113
c0bfff39abe3
Basic in and out navigation support added to funcall expressions. Added toHTML methods to listlit and arraylit.
Mike Pavone <pavone@retrodev.com>
parents:
111
diff
changeset
|
155 domnode removeChild: node |
110
d715fb3c39ab
Implemented clicking on symbols inside inscope box to replace function name in funcall.
Mike Pavone <pavone@retrodev.com>
parents:
109
diff
changeset
|
156 } |
d715fb3c39ab
Implemented clicking on symbols inside inscope box to replace function name in funcall.
Mike Pavone <pavone@retrodev.com>
parents:
109
diff
changeset
|
157 lastWasNamePart <- true |
d715fb3c39ab
Implemented clicking on symbols inside inscope box to replace function name in funcall.
Mike Pavone <pavone@retrodev.com>
parents:
109
diff
changeset
|
158 } else: { |
d715fb3c39ab
Implemented clicking on symbols inside inscope box to replace function name in funcall.
Mike Pavone <pavone@retrodev.com>
parents:
109
diff
changeset
|
159 if: (not: lastWasNamePart) && partIdx < (parts length) && nodeIdx > 0 { |
113
c0bfff39abe3
Basic in and out navigation support added to funcall expressions. Added toHTML methods to listlit and arraylit.
Mike Pavone <pavone@retrodev.com>
parents:
111
diff
changeset
|
160 domnode insertBefore: (newEl: "span" #{ |
110
d715fb3c39ab
Implemented clicking on symbols inside inscope box to replace function name in funcall.
Mike Pavone <pavone@retrodev.com>
parents:
109
diff
changeset
|
161 className <- "funpart selected" |
d715fb3c39ab
Implemented clicking on symbols inside inscope box to replace function name in funcall.
Mike Pavone <pavone@retrodev.com>
parents:
109
diff
changeset
|
162 textContent <- (getEl: parts partIdx) . ":" |
d715fb3c39ab
Implemented clicking on symbols inside inscope box to replace function name in funcall.
Mike Pavone <pavone@retrodev.com>
parents:
109
diff
changeset
|
163 }) node |
d715fb3c39ab
Implemented clicking on symbols inside inscope box to replace function name in funcall.
Mike Pavone <pavone@retrodev.com>
parents:
109
diff
changeset
|
164 partIdx <- partIdx + 1 |
d715fb3c39ab
Implemented clicking on symbols inside inscope box to replace function name in funcall.
Mike Pavone <pavone@retrodev.com>
parents:
109
diff
changeset
|
165 } |
d715fb3c39ab
Implemented clicking on symbols inside inscope box to replace function name in funcall.
Mike Pavone <pavone@retrodev.com>
parents:
109
diff
changeset
|
166 lastWasNamePart <- false |
d715fb3c39ab
Implemented clicking on symbols inside inscope box to replace function name in funcall.
Mike Pavone <pavone@retrodev.com>
parents:
109
diff
changeset
|
167 } |
d715fb3c39ab
Implemented clicking on symbols inside inscope box to replace function name in funcall.
Mike Pavone <pavone@retrodev.com>
parents:
109
diff
changeset
|
168 } else: { |
d715fb3c39ab
Implemented clicking on symbols inside inscope box to replace function name in funcall.
Mike Pavone <pavone@retrodev.com>
parents:
109
diff
changeset
|
169 console log: "part: " . (getEl: parts partIdx) |
113
c0bfff39abe3
Basic in and out navigation support added to funcall expressions. Added toHTML methods to listlit and arraylit.
Mike Pavone <pavone@retrodev.com>
parents:
111
diff
changeset
|
170 domnode appendChild: (newEl: "span" #{ |
110
d715fb3c39ab
Implemented clicking on symbols inside inscope box to replace function name in funcall.
Mike Pavone <pavone@retrodev.com>
parents:
109
diff
changeset
|
171 className <- "funpart selected" |
d715fb3c39ab
Implemented clicking on symbols inside inscope box to replace function name in funcall.
Mike Pavone <pavone@retrodev.com>
parents:
109
diff
changeset
|
172 textContent <- (getEl: parts partIdx) . ":" |
d715fb3c39ab
Implemented clicking on symbols inside inscope box to replace function name in funcall.
Mike Pavone <pavone@retrodev.com>
parents:
109
diff
changeset
|
173 }) |
d715fb3c39ab
Implemented clicking on symbols inside inscope box to replace function name in funcall.
Mike Pavone <pavone@retrodev.com>
parents:
109
diff
changeset
|
174 partIdx <- partIdx + 1 |
d715fb3c39ab
Implemented clicking on symbols inside inscope box to replace function name in funcall.
Mike Pavone <pavone@retrodev.com>
parents:
109
diff
changeset
|
175 } |
d715fb3c39ab
Implemented clicking on symbols inside inscope box to replace function name in funcall.
Mike Pavone <pavone@retrodev.com>
parents:
109
diff
changeset
|
176 } |
d715fb3c39ab
Implemented clicking on symbols inside inscope box to replace function name in funcall.
Mike Pavone <pavone@retrodev.com>
parents:
109
diff
changeset
|
177 } |
107
152b6cfb98b6
Click-to-select no longer selects the whole lambda when it shouldn't and no longer replaces the selected code with a single symbol.
Mike Pavone <pavone@retrodev.com>
parents:
105
diff
changeset
|
178 event stopPropagation: (foreign: undefined) |
25
4d87c38404d6
List literals, fixes to implicit self property lookup, import statement and editor improvements
Mike Pavone <pavone@retrodev.com>
parents:
24
diff
changeset
|
179 } |
4d87c38404d6
List literals, fixes to implicit self property lookup, import statement and editor improvements
Mike Pavone <pavone@retrodev.com>
parents:
24
diff
changeset
|
180 |
29
18cec540238a
Prevent event bubbling so lambda click handler doesn't get called when clicking on an element inside it
Mike Pavone <pavone@retrodev.com>
parents:
28
diff
changeset
|
181 lambdaClick <- :domnode astnode event { |
18cec540238a
Prevent event bubbling so lambda click handler doesn't get called when clicking on an element inside it
Mike Pavone <pavone@retrodev.com>
parents:
28
diff
changeset
|
182 symbolClick: domnode astnode event |
28 | 183 } |
184 | |
11 | 185 main <- { |
30
608eb70fe261
Fix some compiler bugs and do initial work on module import
Mike Pavone <pavone@retrodev.com>
parents:
29
diff
changeset
|
186 get: "/src/" :data { |
608eb70fe261
Fix some compiler bugs and do initial work on module import
Mike Pavone <pavone@retrodev.com>
parents:
29
diff
changeset
|
187 fakeEl <- newEl: "div" #{ |
608eb70fe261
Fix some compiler bugs and do initial work on module import
Mike Pavone <pavone@retrodev.com>
parents:
29
diff
changeset
|
188 innerHTML <- data response |
608eb70fe261
Fix some compiler bugs and do initial work on module import
Mike Pavone <pavone@retrodev.com>
parents:
29
diff
changeset
|
189 } |
608eb70fe261
Fix some compiler bugs and do initial work on module import
Mike Pavone <pavone@retrodev.com>
parents:
29
diff
changeset
|
190 each: (qall: "a" fakeEl) :idx el { |
608eb70fe261
Fix some compiler bugs and do initial work on module import
Mike Pavone <pavone@retrodev.com>
parents:
29
diff
changeset
|
191 if: ((el textContent) = "../") {} else: { |
608eb70fe261
Fix some compiler bugs and do initial work on module import
Mike Pavone <pavone@retrodev.com>
parents:
29
diff
changeset
|
192 nel <- newEl: "a" #{ |
608eb70fe261
Fix some compiler bugs and do initial work on module import
Mike Pavone <pavone@retrodev.com>
parents:
29
diff
changeset
|
193 href <- "/edit/src/" + (el textContent) |
608eb70fe261
Fix some compiler bugs and do initial work on module import
Mike Pavone <pavone@retrodev.com>
parents:
29
diff
changeset
|
194 textContent <- el textContent |
608eb70fe261
Fix some compiler bugs and do initial work on module import
Mike Pavone <pavone@retrodev.com>
parents:
29
diff
changeset
|
195 } |
608eb70fe261
Fix some compiler bugs and do initial work on module import
Mike Pavone <pavone@retrodev.com>
parents:
29
diff
changeset
|
196 nel onclick!: :event { |
608eb70fe261
Fix some compiler bugs and do initial work on module import
Mike Pavone <pavone@retrodev.com>
parents:
29
diff
changeset
|
197 link <- foreign: this |
608eb70fe261
Fix some compiler bugs and do initial work on module import
Mike Pavone <pavone@retrodev.com>
parents:
29
diff
changeset
|
198 path <- link href |
608eb70fe261
Fix some compiler bugs and do initial work on module import
Mike Pavone <pavone@retrodev.com>
parents:
29
diff
changeset
|
199 path <- path substr: (path indexOf: "/edit/") + 5 |
608eb70fe261
Fix some compiler bugs and do initial work on module import
Mike Pavone <pavone@retrodev.com>
parents:
29
diff
changeset
|
200 editFile: path |
608eb70fe261
Fix some compiler bugs and do initial work on module import
Mike Pavone <pavone@retrodev.com>
parents:
29
diff
changeset
|
201 foreign: false |
608eb70fe261
Fix some compiler bugs and do initial work on module import
Mike Pavone <pavone@retrodev.com>
parents:
29
diff
changeset
|
202 } |
608eb70fe261
Fix some compiler bugs and do initial work on module import
Mike Pavone <pavone@retrodev.com>
parents:
29
diff
changeset
|
203 li <- newEl: "li" |
608eb70fe261
Fix some compiler bugs and do initial work on module import
Mike Pavone <pavone@retrodev.com>
parents:
29
diff
changeset
|
204 li appendChild: nel |
608eb70fe261
Fix some compiler bugs and do initial work on module import
Mike Pavone <pavone@retrodev.com>
parents:
29
diff
changeset
|
205 (q: "#browser ul") appendChild: li |
608eb70fe261
Fix some compiler bugs and do initial work on module import
Mike Pavone <pavone@retrodev.com>
parents:
29
diff
changeset
|
206 } |
12
6e4851a204a5
Add ability to load code into editor
Mike Pavone <pavone@retrodev.com>
parents:
11
diff
changeset
|
207 } |
6e4851a204a5
Add ability to load code into editor
Mike Pavone <pavone@retrodev.com>
parents:
11
diff
changeset
|
208 } |
6e4851a204a5
Add ability to load code into editor
Mike Pavone <pavone@retrodev.com>
parents:
11
diff
changeset
|
209 |
6e4851a204a5
Add ability to load code into editor
Mike Pavone <pavone@retrodev.com>
parents:
11
diff
changeset
|
210 //bind handlers for editor buttons |
6e4851a204a5
Add ability to load code into editor
Mike Pavone <pavone@retrodev.com>
parents:
11
diff
changeset
|
211 each: (qall: ".controls li") :idx el { |
21
6c8ae6b47ab5
Small improvements to property support and elimination of setP and getP functions as they are no longer needed
Mike Pavone <pavone@retrodev.com>
parents:
18
diff
changeset
|
212 el onclick!: :event { |
11 | 213 srcel <- (q: "#src") |
21
6c8ae6b47ab5
Small improvements to property support and elimination of setP and getP functions as they are no longer needed
Mike Pavone <pavone@retrodev.com>
parents:
18
diff
changeset
|
214 srcel textContent!: (srcel textContent) + (el textContent) |
11 | 215 } |
216 } | |
111
b2a3f202d485
Fleshed out the UI a little. Added a "literal" button that replaces the operator panel with a literal panel. Added the navigation buttons, but they're not functional yet.
Mike Pavone <pavone@retrodev.com>
parents:
110
diff
changeset
|
217 visible <- "showops" |
21
6c8ae6b47ab5
Small improvements to property support and elimination of setP and getP functions as they are no longer needed
Mike Pavone <pavone@retrodev.com>
parents:
18
diff
changeset
|
218 (q: "#ops_button") onclick!: :event { |
25
4d87c38404d6
List literals, fixes to implicit self property lookup, import statement and editor improvements
Mike Pavone <pavone@retrodev.com>
parents:
24
diff
changeset
|
219 each: (qall: ".controls") :idx el { |
111
b2a3f202d485
Fleshed out the UI a little. Added a "literal" button that replaces the operator panel with a literal panel. Added the navigation buttons, but they're not functional yet.
Mike Pavone <pavone@retrodev.com>
parents:
110
diff
changeset
|
220 removeClass: el visible |
25
4d87c38404d6
List literals, fixes to implicit self property lookup, import statement and editor improvements
Mike Pavone <pavone@retrodev.com>
parents:
24
diff
changeset
|
221 addClass: el "showops" |
4d87c38404d6
List literals, fixes to implicit self property lookup, import statement and editor improvements
Mike Pavone <pavone@retrodev.com>
parents:
24
diff
changeset
|
222 } |
111
b2a3f202d485
Fleshed out the UI a little. Added a "literal" button that replaces the operator panel with a literal panel. Added the navigation buttons, but they're not functional yet.
Mike Pavone <pavone@retrodev.com>
parents:
110
diff
changeset
|
223 visible <- "showops" |
b2a3f202d485
Fleshed out the UI a little. Added a "literal" button that replaces the operator panel with a literal panel. Added the navigation buttons, but they're not functional yet.
Mike Pavone <pavone@retrodev.com>
parents:
110
diff
changeset
|
224 } |
b2a3f202d485
Fleshed out the UI a little. Added a "literal" button that replaces the operator panel with a literal panel. Added the navigation buttons, but they're not functional yet.
Mike Pavone <pavone@retrodev.com>
parents:
110
diff
changeset
|
225 (q: "#lit_button") onclick!: :event { |
b2a3f202d485
Fleshed out the UI a little. Added a "literal" button that replaces the operator panel with a literal panel. Added the navigation buttons, but they're not functional yet.
Mike Pavone <pavone@retrodev.com>
parents:
110
diff
changeset
|
226 each: (qall: ".controls") :idx el { |
b2a3f202d485
Fleshed out the UI a little. Added a "literal" button that replaces the operator panel with a literal panel. Added the navigation buttons, but they're not functional yet.
Mike Pavone <pavone@retrodev.com>
parents:
110
diff
changeset
|
227 removeClass: el visible |
b2a3f202d485
Fleshed out the UI a little. Added a "literal" button that replaces the operator panel with a literal panel. Added the navigation buttons, but they're not functional yet.
Mike Pavone <pavone@retrodev.com>
parents:
110
diff
changeset
|
228 addClass: el "showlit" |
b2a3f202d485
Fleshed out the UI a little. Added a "literal" button that replaces the operator panel with a literal panel. Added the navigation buttons, but they're not functional yet.
Mike Pavone <pavone@retrodev.com>
parents:
110
diff
changeset
|
229 } |
b2a3f202d485
Fleshed out the UI a little. Added a "literal" button that replaces the operator panel with a literal panel. Added the navigation buttons, but they're not functional yet.
Mike Pavone <pavone@retrodev.com>
parents:
110
diff
changeset
|
230 visible <- "showlit" |
11 | 231 } |
232 | |
113
c0bfff39abe3
Basic in and out navigation support added to funcall expressions. Added toHTML methods to listlit and arraylit.
Mike Pavone <pavone@retrodev.com>
parents:
111
diff
changeset
|
233 (q: "#in") onclick!: :event { |
c0bfff39abe3
Basic in and out navigation support added to funcall expressions. Added toHTML methods to listlit and arraylit.
Mike Pavone <pavone@retrodev.com>
parents:
111
diff
changeset
|
234 console log: "inwards" |
c0bfff39abe3
Basic in and out navigation support added to funcall expressions. Added toHTML methods to listlit and arraylit.
Mike Pavone <pavone@retrodev.com>
parents:
111
diff
changeset
|
235 if: (selection valid?) { |
c0bfff39abe3
Basic in and out navigation support added to funcall expressions. Added toHTML methods to listlit and arraylit.
Mike Pavone <pavone@retrodev.com>
parents:
111
diff
changeset
|
236 selection in |
c0bfff39abe3
Basic in and out navigation support added to funcall expressions. Added toHTML methods to listlit and arraylit.
Mike Pavone <pavone@retrodev.com>
parents:
111
diff
changeset
|
237 } |
c0bfff39abe3
Basic in and out navigation support added to funcall expressions. Added toHTML methods to listlit and arraylit.
Mike Pavone <pavone@retrodev.com>
parents:
111
diff
changeset
|
238 } |
c0bfff39abe3
Basic in and out navigation support added to funcall expressions. Added toHTML methods to listlit and arraylit.
Mike Pavone <pavone@retrodev.com>
parents:
111
diff
changeset
|
239 |
c0bfff39abe3
Basic in and out navigation support added to funcall expressions. Added toHTML methods to listlit and arraylit.
Mike Pavone <pavone@retrodev.com>
parents:
111
diff
changeset
|
240 (q: "#out") onclick!: :event { |
c0bfff39abe3
Basic in and out navigation support added to funcall expressions. Added toHTML methods to listlit and arraylit.
Mike Pavone <pavone@retrodev.com>
parents:
111
diff
changeset
|
241 console log: "outwards" |
c0bfff39abe3
Basic in and out navigation support added to funcall expressions. Added toHTML methods to listlit and arraylit.
Mike Pavone <pavone@retrodev.com>
parents:
111
diff
changeset
|
242 if: (selection valid?) { |
c0bfff39abe3
Basic in and out navigation support added to funcall expressions. Added toHTML methods to listlit and arraylit.
Mike Pavone <pavone@retrodev.com>
parents:
111
diff
changeset
|
243 selection out |
c0bfff39abe3
Basic in and out navigation support added to funcall expressions. Added toHTML methods to listlit and arraylit.
Mike Pavone <pavone@retrodev.com>
parents:
111
diff
changeset
|
244 } |
c0bfff39abe3
Basic in and out navigation support added to funcall expressions. Added toHTML methods to listlit and arraylit.
Mike Pavone <pavone@retrodev.com>
parents:
111
diff
changeset
|
245 } |
c0bfff39abe3
Basic in and out navigation support added to funcall expressions. Added toHTML methods to listlit and arraylit.
Mike Pavone <pavone@retrodev.com>
parents:
111
diff
changeset
|
246 |
21
6c8ae6b47ab5
Small improvements to property support and elimination of setP and getP functions as they are no longer needed
Mike Pavone <pavone@retrodev.com>
parents:
18
diff
changeset
|
247 path <- (window location) pathname |
17
7400bb42e0c9
Add direct file edit link support
Mike Pavone <pavone@retrodev.com>
parents:
14
diff
changeset
|
248 if: (path indexOf: "/edit/") = 0 { |
7400bb42e0c9
Add direct file edit link support
Mike Pavone <pavone@retrodev.com>
parents:
14
diff
changeset
|
249 editFile: (path substr: 5) |
113
c0bfff39abe3
Basic in and out navigation support added to funcall expressions. Added toHTML methods to listlit and arraylit.
Mike Pavone <pavone@retrodev.com>
parents:
111
diff
changeset
|
250 } |
11 | 251 } |
252 | |
253 } |