Mercurial > repos > tabletprog
annotate src/editor.tp @ 372:e857104bd183
Added reverse method to arrays
author | Michael Pavone <pavone@retrodev.com> |
---|---|
date | Wed, 12 Aug 2015 19:16:41 -0700 |
parents | 15aac5334b64 |
children |
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 {} |
127
2b25d0ce2946
Add fullscreen support and improve experience on tablet browsers by tweaking button text size and disabling zooming.
Mike Pavone <pavone@retrodev.com>
parents:
124
diff
changeset
|
10 newEl <- foreign: :tagname props {} |
2b25d0ce2946
Add fullscreen support and improve experience on tablet browsers by tweaking button text size and disabling zooming.
Mike Pavone <pavone@retrodev.com>
parents:
124
diff
changeset
|
11 |
2b25d0ce2946
Add fullscreen support and improve experience on tablet browsers by tweaking button text size and disabling zooming.
Mike Pavone <pavone@retrodev.com>
parents:
124
diff
changeset
|
12 //editor.js functions |
110
d715fb3c39ab
Implemented clicking on symbols inside inscope box to replace function name in funcall.
Mike Pavone <pavone@retrodev.com>
parents:
109
diff
changeset
|
13 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
|
14 setEl <- foreign: :to idx val {} |
127
2b25d0ce2946
Add fullscreen support and improve experience on tablet browsers by tweaking button text size and disabling zooming.
Mike Pavone <pavone@retrodev.com>
parents:
124
diff
changeset
|
15 goFullScreen <- foreign: {} |
141
15aac5334b64
Started work on replacing nodes with a symbol when a symbol button is clicked
Mike Pavone <pavone@retrodev.com>
parents:
131
diff
changeset
|
16 create_symbol <- foreign: :name {} |
11 | 17 |
14
85fb6ba15bc6
Start turning AST into HTML in editor
Mike Pavone <pavone@retrodev.com>
parents:
12
diff
changeset
|
18 //TP Parser |
85fb6ba15bc6
Start turning AST into HTML in editor
Mike Pavone <pavone@retrodev.com>
parents:
12
diff
changeset
|
19 parser <- foreign: #{ |
85fb6ba15bc6
Start turning AST into HTML in editor
Mike Pavone <pavone@retrodev.com>
parents:
12
diff
changeset
|
20 parse <- foreign: :str {} |
85fb6ba15bc6
Start turning AST into HTML in editor
Mike Pavone <pavone@retrodev.com>
parents:
12
diff
changeset
|
21 } |
25
4d87c38404d6
List literals, fixes to implicit self property lookup, import statement and editor improvements
Mike Pavone <pavone@retrodev.com>
parents:
24
diff
changeset
|
22 isLambda <- foreign: :astnode {} |
14
85fb6ba15bc6
Start turning AST into HTML in editor
Mike Pavone <pavone@retrodev.com>
parents:
12
diff
changeset
|
23 |
11 | 24 //js builtins |
25 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
|
26 log <- foreign: :val {} |
11 | 27 } |
25
4d87c38404d6
List literals, fixes to implicit self property lookup, import statement and editor improvements
Mike Pavone <pavone@retrodev.com>
parents:
24
diff
changeset
|
28 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
|
29 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
|
30 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
|
31 } |
11 | 32 |
108
5099c1a96e3f
Mostly fix clicking on the function name in a funcall expression
Mike Pavone <pavone@retrodev.com>
parents:
107
diff
changeset
|
33 filter <- :arr pred { |
5099c1a96e3f
Mostly fix clicking on the function name in a funcall expression
Mike Pavone <pavone@retrodev.com>
parents:
107
diff
changeset
|
34 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
|
35 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
|
36 if: (pred: el) { |
5099c1a96e3f
Mostly fix clicking on the function name in a funcall expression
Mike Pavone <pavone@retrodev.com>
parents:
107
diff
changeset
|
37 output push: el |
5099c1a96e3f
Mostly fix clicking on the function name in a funcall expression
Mike Pavone <pavone@retrodev.com>
parents:
107
diff
changeset
|
38 } else: {} |
5099c1a96e3f
Mostly fix clicking on the function name in a funcall expression
Mike Pavone <pavone@retrodev.com>
parents:
107
diff
changeset
|
39 } |
5099c1a96e3f
Mostly fix clicking on the function name in a funcall expression
Mike Pavone <pavone@retrodev.com>
parents:
107
diff
changeset
|
40 output |
5099c1a96e3f
Mostly fix clicking on the function name in a funcall expression
Mike Pavone <pavone@retrodev.com>
parents:
107
diff
changeset
|
41 } |
5099c1a96e3f
Mostly fix clicking on the function name in a funcall expression
Mike Pavone <pavone@retrodev.com>
parents:
107
diff
changeset
|
42 |
25
4d87c38404d6
List literals, fixes to implicit self property lookup, import statement and editor improvements
Mike Pavone <pavone@retrodev.com>
parents:
24
diff
changeset
|
43 //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
|
44 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
|
45 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
|
46 } |
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
|
47 |
117
f4e464a17579
Cleanup selection code in editor.
Mike Pavone <pavone@retrodev.com>
parents:
116
diff
changeset
|
48 setSelection:withInNode <- :astnode :innode { |
f4e464a17579
Cleanup selection code in editor.
Mike Pavone <pavone@retrodev.com>
parents:
116
diff
changeset
|
49 fakeEvent <- #{ |
f4e464a17579
Cleanup selection code in editor.
Mike Pavone <pavone@retrodev.com>
parents:
116
diff
changeset
|
50 stopPropagation <- :Blah { |
f4e464a17579
Cleanup selection code in editor.
Mike Pavone <pavone@retrodev.com>
parents:
116
diff
changeset
|
51 } |
f4e464a17579
Cleanup selection code in editor.
Mike Pavone <pavone@retrodev.com>
parents:
116
diff
changeset
|
52 } |
131
8285784f5ff5
Implement previous and next buttons
Mike Pavone <pavone@retrodev.com>
parents:
127
diff
changeset
|
53 |
117
f4e464a17579
Cleanup selection code in editor.
Mike Pavone <pavone@retrodev.com>
parents:
116
diff
changeset
|
54 selection <- #{ |
f4e464a17579
Cleanup selection code in editor.
Mike Pavone <pavone@retrodev.com>
parents:
116
diff
changeset
|
55 valid? <- true |
f4e464a17579
Cleanup selection code in editor.
Mike Pavone <pavone@retrodev.com>
parents:
116
diff
changeset
|
56 in <- { |
f4e464a17579
Cleanup selection code in editor.
Mike Pavone <pavone@retrodev.com>
parents:
116
diff
changeset
|
57 (innode domNode) onclick: fakeEvent |
f4e464a17579
Cleanup selection code in editor.
Mike Pavone <pavone@retrodev.com>
parents:
116
diff
changeset
|
58 } |
f4e464a17579
Cleanup selection code in editor.
Mike Pavone <pavone@retrodev.com>
parents:
116
diff
changeset
|
59 out <- { |
f4e464a17579
Cleanup selection code in editor.
Mike Pavone <pavone@retrodev.com>
parents:
116
diff
changeset
|
60 ((astnode up) domNode) onclick: fakeEvent |
f4e464a17579
Cleanup selection code in editor.
Mike Pavone <pavone@retrodev.com>
parents:
116
diff
changeset
|
61 } |
131
8285784f5ff5
Implement previous and next buttons
Mike Pavone <pavone@retrodev.com>
parents:
127
diff
changeset
|
62 next <- { |
8285784f5ff5
Implement previous and next buttons
Mike Pavone <pavone@retrodev.com>
parents:
127
diff
changeset
|
63 (((astnode up) getNext: astnode) domNode) onclick: fakeEvent |
8285784f5ff5
Implement previous and next buttons
Mike Pavone <pavone@retrodev.com>
parents:
127
diff
changeset
|
64 } |
8285784f5ff5
Implement previous and next buttons
Mike Pavone <pavone@retrodev.com>
parents:
127
diff
changeset
|
65 |
8285784f5ff5
Implement previous and next buttons
Mike Pavone <pavone@retrodev.com>
parents:
127
diff
changeset
|
66 previous <- { |
8285784f5ff5
Implement previous and next buttons
Mike Pavone <pavone@retrodev.com>
parents:
127
diff
changeset
|
67 (((astnode up) getPrev: astnode) domNode) onclick: fakeEvent |
8285784f5ff5
Implement previous and next buttons
Mike Pavone <pavone@retrodev.com>
parents:
127
diff
changeset
|
68 } |
117
f4e464a17579
Cleanup selection code in editor.
Mike Pavone <pavone@retrodev.com>
parents:
116
diff
changeset
|
69 } |
f4e464a17579
Cleanup selection code in editor.
Mike Pavone <pavone@retrodev.com>
parents:
116
diff
changeset
|
70 } |
f4e464a17579
Cleanup selection code in editor.
Mike Pavone <pavone@retrodev.com>
parents:
116
diff
changeset
|
71 |
118
0a66fe3a368a
Allow selection and navigation of assignment nodes.
Mike Pavone <pavone@retrodev.com>
parents:
117
diff
changeset
|
72 setSelection <- :astnode { |
0a66fe3a368a
Allow selection and navigation of assignment nodes.
Mike Pavone <pavone@retrodev.com>
parents:
117
diff
changeset
|
73 fakeEvent <- #{ |
0a66fe3a368a
Allow selection and navigation of assignment nodes.
Mike Pavone <pavone@retrodev.com>
parents:
117
diff
changeset
|
74 stopPropagation <- :Blah { |
0a66fe3a368a
Allow selection and navigation of assignment nodes.
Mike Pavone <pavone@retrodev.com>
parents:
117
diff
changeset
|
75 } |
0a66fe3a368a
Allow selection and navigation of assignment nodes.
Mike Pavone <pavone@retrodev.com>
parents:
117
diff
changeset
|
76 } |
0a66fe3a368a
Allow selection and navigation of assignment nodes.
Mike Pavone <pavone@retrodev.com>
parents:
117
diff
changeset
|
77 selection <- #{ |
0a66fe3a368a
Allow selection and navigation of assignment nodes.
Mike Pavone <pavone@retrodev.com>
parents:
117
diff
changeset
|
78 valid? <- true |
0a66fe3a368a
Allow selection and navigation of assignment nodes.
Mike Pavone <pavone@retrodev.com>
parents:
117
diff
changeset
|
79 in <- { |
0a66fe3a368a
Allow selection and navigation of assignment nodes.
Mike Pavone <pavone@retrodev.com>
parents:
117
diff
changeset
|
80 } |
0a66fe3a368a
Allow selection and navigation of assignment nodes.
Mike Pavone <pavone@retrodev.com>
parents:
117
diff
changeset
|
81 out <- { |
0a66fe3a368a
Allow selection and navigation of assignment nodes.
Mike Pavone <pavone@retrodev.com>
parents:
117
diff
changeset
|
82 fakeEvent <- #{ |
0a66fe3a368a
Allow selection and navigation of assignment nodes.
Mike Pavone <pavone@retrodev.com>
parents:
117
diff
changeset
|
83 stopPropagation <- :Blah { |
0a66fe3a368a
Allow selection and navigation of assignment nodes.
Mike Pavone <pavone@retrodev.com>
parents:
117
diff
changeset
|
84 } |
0a66fe3a368a
Allow selection and navigation of assignment nodes.
Mike Pavone <pavone@retrodev.com>
parents:
117
diff
changeset
|
85 } |
0a66fe3a368a
Allow selection and navigation of assignment nodes.
Mike Pavone <pavone@retrodev.com>
parents:
117
diff
changeset
|
86 ((astnode up) domNode) onclick: fakeEvent |
0a66fe3a368a
Allow selection and navigation of assignment nodes.
Mike Pavone <pavone@retrodev.com>
parents:
117
diff
changeset
|
87 } |
131
8285784f5ff5
Implement previous and next buttons
Mike Pavone <pavone@retrodev.com>
parents:
127
diff
changeset
|
88 next <- { |
8285784f5ff5
Implement previous and next buttons
Mike Pavone <pavone@retrodev.com>
parents:
127
diff
changeset
|
89 console log: "selection next" |
8285784f5ff5
Implement previous and next buttons
Mike Pavone <pavone@retrodev.com>
parents:
127
diff
changeset
|
90 (((astnode up) getNext: astnode) domNode) onclick: fakeEvent |
8285784f5ff5
Implement previous and next buttons
Mike Pavone <pavone@retrodev.com>
parents:
127
diff
changeset
|
91 } |
8285784f5ff5
Implement previous and next buttons
Mike Pavone <pavone@retrodev.com>
parents:
127
diff
changeset
|
92 previous <- { |
8285784f5ff5
Implement previous and next buttons
Mike Pavone <pavone@retrodev.com>
parents:
127
diff
changeset
|
93 (((astnode up) getPrev: astnode) domNode) onclick: fakeEvent |
8285784f5ff5
Implement previous and next buttons
Mike Pavone <pavone@retrodev.com>
parents:
127
diff
changeset
|
94 } |
118
0a66fe3a368a
Allow selection and navigation of assignment nodes.
Mike Pavone <pavone@retrodev.com>
parents:
117
diff
changeset
|
95 } |
0a66fe3a368a
Allow selection and navigation of assignment nodes.
Mike Pavone <pavone@retrodev.com>
parents:
117
diff
changeset
|
96 } |
0a66fe3a368a
Allow selection and navigation of assignment nodes.
Mike Pavone <pavone@retrodev.com>
parents:
117
diff
changeset
|
97 |
17
7400bb42e0c9
Add direct file edit link support
Mike Pavone <pavone@retrodev.com>
parents:
14
diff
changeset
|
98 editFile <- :path { |
7400bb42e0c9
Add direct file edit link support
Mike Pavone <pavone@retrodev.com>
parents:
14
diff
changeset
|
99 get: path :request { |
7400bb42e0c9
Add direct file edit link support
Mike Pavone <pavone@retrodev.com>
parents:
14
diff
changeset
|
100 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
|
101 src <- request responseText |
17
7400bb42e0c9
Add direct file edit link support
Mike Pavone <pavone@retrodev.com>
parents:
14
diff
changeset
|
102 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
|
103 ast populateSymbols: (foreign: null) |
17
7400bb42e0c9
Add direct file edit link support
Mike Pavone <pavone@retrodev.com>
parents:
14
diff
changeset
|
104 ast toHTML: (q: "#src") |
7400bb42e0c9
Add direct file edit link support
Mike Pavone <pavone@retrodev.com>
parents:
14
diff
changeset
|
105 } |
7400bb42e0c9
Add direct file edit link support
Mike Pavone <pavone@retrodev.com>
parents:
14
diff
changeset
|
106 } |
7400bb42e0c9
Add direct file edit link support
Mike Pavone <pavone@retrodev.com>
parents:
14
diff
changeset
|
107 |
25
4d87c38404d6
List literals, fixes to implicit self property lookup, import statement and editor improvements
Mike Pavone <pavone@retrodev.com>
parents:
24
diff
changeset
|
108 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
|
109 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
|
110 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
|
111 } |
4d87c38404d6
List literals, fixes to implicit self property lookup, import statement and editor improvements
Mike Pavone <pavone@retrodev.com>
parents:
24
diff
changeset
|
112 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
|
113 } |
4d87c38404d6
List literals, fixes to implicit self property lookup, import statement and editor improvements
Mike Pavone <pavone@retrodev.com>
parents:
24
diff
changeset
|
114 |
4d87c38404d6
List literals, fixes to implicit self property lookup, import statement and editor improvements
Mike Pavone <pavone@retrodev.com>
parents:
24
diff
changeset
|
115 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
|
116 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
|
117 } |
4d87c38404d6
List literals, fixes to implicit self property lookup, import statement and editor improvements
Mike Pavone <pavone@retrodev.com>
parents:
24
diff
changeset
|
118 |
4d87c38404d6
List literals, fixes to implicit self property lookup, import statement and editor improvements
Mike Pavone <pavone@retrodev.com>
parents:
24
diff
changeset
|
119 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
|
120 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
|
121 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
|
122 } |
4d87c38404d6
List literals, fixes to implicit self property lookup, import statement and editor improvements
Mike Pavone <pavone@retrodev.com>
parents:
24
diff
changeset
|
123 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
|
124 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
|
125 } |
4d87c38404d6
List literals, fixes to implicit self property lookup, import statement and editor improvements
Mike Pavone <pavone@retrodev.com>
parents:
24
diff
changeset
|
126 } |
4d87c38404d6
List literals, fixes to implicit self property lookup, import statement and editor improvements
Mike Pavone <pavone@retrodev.com>
parents:
24
diff
changeset
|
127 |
4d87c38404d6
List literals, fixes to implicit self property lookup, import statement and editor improvements
Mike Pavone <pavone@retrodev.com>
parents:
24
diff
changeset
|
128 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
|
129 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
|
130 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
|
131 } |
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
|
132 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
|
133 } |
4d87c38404d6
List literals, fixes to implicit self property lookup, import statement and editor improvements
Mike Pavone <pavone@retrodev.com>
parents:
24
diff
changeset
|
134 |
4d87c38404d6
List literals, fixes to implicit self property lookup, import statement and editor improvements
Mike Pavone <pavone@retrodev.com>
parents:
24
diff
changeset
|
135 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
|
136 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
|
137 inscope innerHTML!: "" |
24
fe3533494ce9
Display symbols order first by depth. Eliminate extraneous setter symbols
Mike Pavone <pavone@retrodev.com>
parents:
23
diff
changeset
|
138 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
|
139 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
|
140 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
|
141 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
|
142 }) |
068d63627b16
Populate in scope symbol buttons when clicking on a symbol in the source
Mike Pavone <pavone@retrodev.com>
parents:
21
diff
changeset
|
143 } |
068d63627b16
Populate in scope symbol buttons when clicking on a symbol in the source
Mike Pavone <pavone@retrodev.com>
parents:
21
diff
changeset
|
144 } |
068d63627b16
Populate in scope symbol buttons when clicking on a symbol in the source
Mike Pavone <pavone@retrodev.com>
parents:
21
diff
changeset
|
145 |
119
77f7cd65e121
Add selection of number and string literals. Support inward navigation of lambdas.
Mike Pavone <pavone@retrodev.com>
parents:
118
diff
changeset
|
146 scalarClick <- :domnode astnode event { |
77f7cd65e121
Add selection of number and string literals. Support inward navigation of lambdas.
Mike Pavone <pavone@retrodev.com>
parents:
118
diff
changeset
|
147 selectNode: domnode |
77f7cd65e121
Add selection of number and string literals. Support inward navigation of lambdas.
Mike Pavone <pavone@retrodev.com>
parents:
118
diff
changeset
|
148 setSelection: astnode |
77f7cd65e121
Add selection of number and string literals. Support inward navigation of lambdas.
Mike Pavone <pavone@retrodev.com>
parents:
118
diff
changeset
|
149 event stopPropagation: (foreign: undefined) |
77f7cd65e121
Add selection of number and string literals. Support inward navigation of lambdas.
Mike Pavone <pavone@retrodev.com>
parents:
118
diff
changeset
|
150 //TODO: set focus |
77f7cd65e121
Add selection of number and string literals. Support inward navigation of lambdas.
Mike Pavone <pavone@retrodev.com>
parents:
118
diff
changeset
|
151 } |
77f7cd65e121
Add selection of number and string literals. Support inward navigation of lambdas.
Mike Pavone <pavone@retrodev.com>
parents:
118
diff
changeset
|
152 |
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
|
153 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
|
154 selectNode: domnode |
105
35006a6e1c47
Fixed more editor coderot and improved syntax/selection coloring a bit.
Mike Pavone <pavone@retrodev.com>
parents:
104
diff
changeset
|
155 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
|
156 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
|
157 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
|
158 } |
118
0a66fe3a368a
Allow selection and navigation of assignment nodes.
Mike Pavone <pavone@retrodev.com>
parents:
117
diff
changeset
|
159 setSelection: astnode |
0a66fe3a368a
Allow selection and navigation of assignment nodes.
Mike Pavone <pavone@retrodev.com>
parents:
117
diff
changeset
|
160 event stopPropagation: (foreign: undefined) |
0a66fe3a368a
Allow selection and navigation of assignment nodes.
Mike Pavone <pavone@retrodev.com>
parents:
117
diff
changeset
|
161 } |
0a66fe3a368a
Allow selection and navigation of assignment nodes.
Mike Pavone <pavone@retrodev.com>
parents:
117
diff
changeset
|
162 |
0a66fe3a368a
Allow selection and navigation of assignment nodes.
Mike Pavone <pavone@retrodev.com>
parents:
117
diff
changeset
|
163 assignClick <- :domnode astnode event { |
0a66fe3a368a
Allow selection and navigation of assignment nodes.
Mike Pavone <pavone@retrodev.com>
parents:
117
diff
changeset
|
164 selectParent: domnode |
0a66fe3a368a
Allow selection and navigation of assignment nodes.
Mike Pavone <pavone@retrodev.com>
parents:
117
diff
changeset
|
165 selectQuery: ".selectParent > .varname" in: domnode |
0a66fe3a368a
Allow selection and navigation of assignment nodes.
Mike Pavone <pavone@retrodev.com>
parents:
117
diff
changeset
|
166 popInscope: ((astnode symbols) allSymbols: (foreign: undefined)) onClick: :key { |
0a66fe3a368a
Allow selection and navigation of assignment nodes.
Mike Pavone <pavone@retrodev.com>
parents:
117
diff
changeset
|
167 (domnode firstChild) textContent!: key |
0a66fe3a368a
Allow selection and navigation of assignment nodes.
Mike Pavone <pavone@retrodev.com>
parents:
117
diff
changeset
|
168 (astnode symbol) name!: key |
0a66fe3a368a
Allow selection and navigation of assignment nodes.
Mike Pavone <pavone@retrodev.com>
parents:
117
diff
changeset
|
169 } |
0a66fe3a368a
Allow selection and navigation of assignment nodes.
Mike Pavone <pavone@retrodev.com>
parents:
117
diff
changeset
|
170 setSelection: astnode withInNode: (astnode expression) |
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
|
171 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
|
172 } |
4d87c38404d6
List literals, fixes to implicit self property lookup, import statement and editor improvements
Mike Pavone <pavone@retrodev.com>
parents:
24
diff
changeset
|
173 |
116
9cf3e0b18ecc
Add support for selecting operator expressions in the editor
Mike Pavone <pavone@retrodev.com>
parents:
113
diff
changeset
|
174 opClick <- :domnode astnode event { |
9cf3e0b18ecc
Add support for selecting operator expressions in the editor
Mike Pavone <pavone@retrodev.com>
parents:
113
diff
changeset
|
175 selectParent: domnode |
9cf3e0b18ecc
Add support for selecting operator expressions in the editor
Mike Pavone <pavone@retrodev.com>
parents:
113
diff
changeset
|
176 selectQuery: ".selectParent > .opname" in: domnode |
9cf3e0b18ecc
Add support for selecting operator expressions in the editor
Mike Pavone <pavone@retrodev.com>
parents:
113
diff
changeset
|
177 showOps |
117
f4e464a17579
Cleanup selection code in editor.
Mike Pavone <pavone@retrodev.com>
parents:
116
diff
changeset
|
178 setSelection: astnode withInNode: (astnode left) |
116
9cf3e0b18ecc
Add support for selecting operator expressions in the editor
Mike Pavone <pavone@retrodev.com>
parents:
113
diff
changeset
|
179 event stopPropagation: (foreign: undefined) |
9cf3e0b18ecc
Add support for selecting operator expressions in the editor
Mike Pavone <pavone@retrodev.com>
parents:
113
diff
changeset
|
180 } |
9cf3e0b18ecc
Add support for selecting operator expressions in the editor
Mike Pavone <pavone@retrodev.com>
parents:
113
diff
changeset
|
181 |
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
|
182 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
|
183 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
|
184 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
|
185 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
|
186 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
|
187 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
|
188 } |
117
f4e464a17579
Cleanup selection code in editor.
Mike Pavone <pavone@retrodev.com>
parents:
116
diff
changeset
|
189 inner <- if: (astnode receiver) != (foreign: null) { |
f4e464a17579
Cleanup selection code in editor.
Mike Pavone <pavone@retrodev.com>
parents:
116
diff
changeset
|
190 astnode receiver |
f4e464a17579
Cleanup selection code in editor.
Mike Pavone <pavone@retrodev.com>
parents:
116
diff
changeset
|
191 } else: { |
f4e464a17579
Cleanup selection code in editor.
Mike Pavone <pavone@retrodev.com>
parents:
116
diff
changeset
|
192 (astnode args) getEl: 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
|
193 } |
117
f4e464a17579
Cleanup selection code in editor.
Mike Pavone <pavone@retrodev.com>
parents:
116
diff
changeset
|
194 setSelection: astnode withInNode: inner |
110
d715fb3c39ab
Implemented clicking on symbols inside inscope box to replace function name in funcall.
Mike Pavone <pavone@retrodev.com>
parents:
109
diff
changeset
|
195 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
|
196 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
|
197 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
|
198 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
|
199 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
|
200 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
|
201 } |
d715fb3c39ab
Implemented clicking on symbols inside inscope box to replace function name in funcall.
Mike Pavone <pavone@retrodev.com>
parents:
109
diff
changeset
|
202 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
|
203 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
|
204 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
|
205 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
|
206 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
|
207 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
|
208 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
|
209 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
|
210 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
|
211 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
|
212 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
|
213 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
|
214 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
|
215 } 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
|
216 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
|
217 } |
d715fb3c39ab
Implemented clicking on symbols inside inscope box to replace function name in funcall.
Mike Pavone <pavone@retrodev.com>
parents:
109
diff
changeset
|
218 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
|
219 } else: { |
d715fb3c39ab
Implemented clicking on symbols inside inscope box to replace function name in funcall.
Mike Pavone <pavone@retrodev.com>
parents:
109
diff
changeset
|
220 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
|
221 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
|
222 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
|
223 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
|
224 }) node |
d715fb3c39ab
Implemented clicking on symbols inside inscope box to replace function name in funcall.
Mike Pavone <pavone@retrodev.com>
parents:
109
diff
changeset
|
225 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
|
226 } |
d715fb3c39ab
Implemented clicking on symbols inside inscope box to replace function name in funcall.
Mike Pavone <pavone@retrodev.com>
parents:
109
diff
changeset
|
227 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
|
228 } |
d715fb3c39ab
Implemented clicking on symbols inside inscope box to replace function name in funcall.
Mike Pavone <pavone@retrodev.com>
parents:
109
diff
changeset
|
229 } else: { |
d715fb3c39ab
Implemented clicking on symbols inside inscope box to replace function name in funcall.
Mike Pavone <pavone@retrodev.com>
parents:
109
diff
changeset
|
230 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
|
231 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
|
232 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
|
233 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
|
234 }) |
d715fb3c39ab
Implemented clicking on symbols inside inscope box to replace function name in funcall.
Mike Pavone <pavone@retrodev.com>
parents:
109
diff
changeset
|
235 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
|
236 } |
d715fb3c39ab
Implemented clicking on symbols inside inscope box to replace function name in funcall.
Mike Pavone <pavone@retrodev.com>
parents:
109
diff
changeset
|
237 } |
d715fb3c39ab
Implemented clicking on symbols inside inscope box to replace function name in funcall.
Mike Pavone <pavone@retrodev.com>
parents:
109
diff
changeset
|
238 } |
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
|
239 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
|
240 } |
4d87c38404d6
List literals, fixes to implicit self property lookup, import statement and editor improvements
Mike Pavone <pavone@retrodev.com>
parents:
24
diff
changeset
|
241 |
141
15aac5334b64
Started work on replacing nodes with a symbol when a symbol button is clicked
Mike Pavone <pavone@retrodev.com>
parents:
131
diff
changeset
|
242 replaceNode:with <- :astnode domnode :newnode { |
15aac5334b64
Started work on replacing nodes with a symbol when a symbol button is clicked
Mike Pavone <pavone@retrodev.com>
parents:
131
diff
changeset
|
243 |
15aac5334b64
Started work on replacing nodes with a symbol when a symbol button is clicked
Mike Pavone <pavone@retrodev.com>
parents:
131
diff
changeset
|
244 } |
15aac5334b64
Started work on replacing nodes with a symbol when a symbol button is clicked
Mike Pavone <pavone@retrodev.com>
parents:
131
diff
changeset
|
245 |
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
|
246 lambdaClick <- :domnode astnode event { |
119
77f7cd65e121
Add selection of number and string literals. Support inward navigation of lambdas.
Mike Pavone <pavone@retrodev.com>
parents:
118
diff
changeset
|
247 selectNode: domnode |
77f7cd65e121
Add selection of number and string literals. Support inward navigation of lambdas.
Mike Pavone <pavone@retrodev.com>
parents:
118
diff
changeset
|
248 popInscope: ((astnode symbols) allSymbols: (foreign: undefined)) onClick: :key { |
141
15aac5334b64
Started work on replacing nodes with a symbol when a symbol button is clicked
Mike Pavone <pavone@retrodev.com>
parents:
131
diff
changeset
|
249 replaceNode: astnode domnode with: (create_symbol: key) |
119
77f7cd65e121
Add selection of number and string literals. Support inward navigation of lambdas.
Mike Pavone <pavone@retrodev.com>
parents:
118
diff
changeset
|
250 } |
77f7cd65e121
Add selection of number and string literals. Support inward navigation of lambdas.
Mike Pavone <pavone@retrodev.com>
parents:
118
diff
changeset
|
251 inner <- if: ((astnode args) length) > 0 { |
77f7cd65e121
Add selection of number and string literals. Support inward navigation of lambdas.
Mike Pavone <pavone@retrodev.com>
parents:
118
diff
changeset
|
252 (astnode args) getEl: 0 |
77f7cd65e121
Add selection of number and string literals. Support inward navigation of lambdas.
Mike Pavone <pavone@retrodev.com>
parents:
118
diff
changeset
|
253 } else: { |
77f7cd65e121
Add selection of number and string literals. Support inward navigation of lambdas.
Mike Pavone <pavone@retrodev.com>
parents:
118
diff
changeset
|
254 (astnode expressions) getEl: 0 |
77f7cd65e121
Add selection of number and string literals. Support inward navigation of lambdas.
Mike Pavone <pavone@retrodev.com>
parents:
118
diff
changeset
|
255 } |
77f7cd65e121
Add selection of number and string literals. Support inward navigation of lambdas.
Mike Pavone <pavone@retrodev.com>
parents:
118
diff
changeset
|
256 setSelection: astnode withInNode: inner |
77f7cd65e121
Add selection of number and string literals. Support inward navigation of lambdas.
Mike Pavone <pavone@retrodev.com>
parents:
118
diff
changeset
|
257 event stopPropagation: (foreign: undefined) |
28 | 258 } |
259 | |
120
d5dc9507d612
Basic support for selecting objects in the editor.
Mike Pavone <pavone@retrodev.com>
parents:
119
diff
changeset
|
260 objectClick <- :domnode astnode event { |
d5dc9507d612
Basic support for selecting objects in the editor.
Mike Pavone <pavone@retrodev.com>
parents:
119
diff
changeset
|
261 selectNode: domnode |
d5dc9507d612
Basic support for selecting objects in the editor.
Mike Pavone <pavone@retrodev.com>
parents:
119
diff
changeset
|
262 popInscope: ((astnode symbols) allSymbols: (foreign: undefined)) onClick: :key { |
d5dc9507d612
Basic support for selecting objects in the editor.
Mike Pavone <pavone@retrodev.com>
parents:
119
diff
changeset
|
263 console log: "fooobar!" |
d5dc9507d612
Basic support for selecting objects in the editor.
Mike Pavone <pavone@retrodev.com>
parents:
119
diff
changeset
|
264 } |
124
1157639353e7
Add dummy handler for clicking a symbol while a lambda is selected. Fix the code for selecting the first inner node of an object literal.
Mike Pavone <pavone@retrodev.com>
parents:
120
diff
changeset
|
265 setSelection: astnode withInNode: ((astnode messages) getEl: 0) |
120
d5dc9507d612
Basic support for selecting objects in the editor.
Mike Pavone <pavone@retrodev.com>
parents:
119
diff
changeset
|
266 event stopPropagation: (foreign: undefined) |
d5dc9507d612
Basic support for selecting objects in the editor.
Mike Pavone <pavone@retrodev.com>
parents:
119
diff
changeset
|
267 } |
d5dc9507d612
Basic support for selecting objects in the editor.
Mike Pavone <pavone@retrodev.com>
parents:
119
diff
changeset
|
268 |
116
9cf3e0b18ecc
Add support for selecting operator expressions in the editor
Mike Pavone <pavone@retrodev.com>
parents:
113
diff
changeset
|
269 visible <- "showops" |
9cf3e0b18ecc
Add support for selecting operator expressions in the editor
Mike Pavone <pavone@retrodev.com>
parents:
113
diff
changeset
|
270 |
9cf3e0b18ecc
Add support for selecting operator expressions in the editor
Mike Pavone <pavone@retrodev.com>
parents:
113
diff
changeset
|
271 showOps <- { |
9cf3e0b18ecc
Add support for selecting operator expressions in the editor
Mike Pavone <pavone@retrodev.com>
parents:
113
diff
changeset
|
272 each: (qall: ".controls") :idx el { |
9cf3e0b18ecc
Add support for selecting operator expressions in the editor
Mike Pavone <pavone@retrodev.com>
parents:
113
diff
changeset
|
273 removeClass: el visible |
9cf3e0b18ecc
Add support for selecting operator expressions in the editor
Mike Pavone <pavone@retrodev.com>
parents:
113
diff
changeset
|
274 addClass: el "showops" |
9cf3e0b18ecc
Add support for selecting operator expressions in the editor
Mike Pavone <pavone@retrodev.com>
parents:
113
diff
changeset
|
275 } |
9cf3e0b18ecc
Add support for selecting operator expressions in the editor
Mike Pavone <pavone@retrodev.com>
parents:
113
diff
changeset
|
276 visible <- "showops" |
9cf3e0b18ecc
Add support for selecting operator expressions in the editor
Mike Pavone <pavone@retrodev.com>
parents:
113
diff
changeset
|
277 } |
9cf3e0b18ecc
Add support for selecting operator expressions in the editor
Mike Pavone <pavone@retrodev.com>
parents:
113
diff
changeset
|
278 |
9cf3e0b18ecc
Add support for selecting operator expressions in the editor
Mike Pavone <pavone@retrodev.com>
parents:
113
diff
changeset
|
279 showLit <- { |
9cf3e0b18ecc
Add support for selecting operator expressions in the editor
Mike Pavone <pavone@retrodev.com>
parents:
113
diff
changeset
|
280 each: (qall: ".controls") :idx el { |
9cf3e0b18ecc
Add support for selecting operator expressions in the editor
Mike Pavone <pavone@retrodev.com>
parents:
113
diff
changeset
|
281 removeClass: el visible |
9cf3e0b18ecc
Add support for selecting operator expressions in the editor
Mike Pavone <pavone@retrodev.com>
parents:
113
diff
changeset
|
282 addClass: el "showlit" |
9cf3e0b18ecc
Add support for selecting operator expressions in the editor
Mike Pavone <pavone@retrodev.com>
parents:
113
diff
changeset
|
283 } |
9cf3e0b18ecc
Add support for selecting operator expressions in the editor
Mike Pavone <pavone@retrodev.com>
parents:
113
diff
changeset
|
284 visible <- "showlit" |
9cf3e0b18ecc
Add support for selecting operator expressions in the editor
Mike Pavone <pavone@retrodev.com>
parents:
113
diff
changeset
|
285 } |
9cf3e0b18ecc
Add support for selecting operator expressions in the editor
Mike Pavone <pavone@retrodev.com>
parents:
113
diff
changeset
|
286 |
11 | 287 main <- { |
30
608eb70fe261
Fix some compiler bugs and do initial work on module import
Mike Pavone <pavone@retrodev.com>
parents:
29
diff
changeset
|
288 get: "/src/" :data { |
608eb70fe261
Fix some compiler bugs and do initial work on module import
Mike Pavone <pavone@retrodev.com>
parents:
29
diff
changeset
|
289 fakeEl <- newEl: "div" #{ |
608eb70fe261
Fix some compiler bugs and do initial work on module import
Mike Pavone <pavone@retrodev.com>
parents:
29
diff
changeset
|
290 innerHTML <- data response |
608eb70fe261
Fix some compiler bugs and do initial work on module import
Mike Pavone <pavone@retrodev.com>
parents:
29
diff
changeset
|
291 } |
608eb70fe261
Fix some compiler bugs and do initial work on module import
Mike Pavone <pavone@retrodev.com>
parents:
29
diff
changeset
|
292 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
|
293 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
|
294 nel <- newEl: "a" #{ |
608eb70fe261
Fix some compiler bugs and do initial work on module import
Mike Pavone <pavone@retrodev.com>
parents:
29
diff
changeset
|
295 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
|
296 textContent <- el textContent |
608eb70fe261
Fix some compiler bugs and do initial work on module import
Mike Pavone <pavone@retrodev.com>
parents:
29
diff
changeset
|
297 } |
608eb70fe261
Fix some compiler bugs and do initial work on module import
Mike Pavone <pavone@retrodev.com>
parents:
29
diff
changeset
|
298 nel onclick!: :event { |
608eb70fe261
Fix some compiler bugs and do initial work on module import
Mike Pavone <pavone@retrodev.com>
parents:
29
diff
changeset
|
299 link <- foreign: this |
608eb70fe261
Fix some compiler bugs and do initial work on module import
Mike Pavone <pavone@retrodev.com>
parents:
29
diff
changeset
|
300 path <- link href |
608eb70fe261
Fix some compiler bugs and do initial work on module import
Mike Pavone <pavone@retrodev.com>
parents:
29
diff
changeset
|
301 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
|
302 editFile: path |
608eb70fe261
Fix some compiler bugs and do initial work on module import
Mike Pavone <pavone@retrodev.com>
parents:
29
diff
changeset
|
303 foreign: false |
608eb70fe261
Fix some compiler bugs and do initial work on module import
Mike Pavone <pavone@retrodev.com>
parents:
29
diff
changeset
|
304 } |
608eb70fe261
Fix some compiler bugs and do initial work on module import
Mike Pavone <pavone@retrodev.com>
parents:
29
diff
changeset
|
305 li <- newEl: "li" |
608eb70fe261
Fix some compiler bugs and do initial work on module import
Mike Pavone <pavone@retrodev.com>
parents:
29
diff
changeset
|
306 li appendChild: nel |
608eb70fe261
Fix some compiler bugs and do initial work on module import
Mike Pavone <pavone@retrodev.com>
parents:
29
diff
changeset
|
307 (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
|
308 } |
12
6e4851a204a5
Add ability to load code into editor
Mike Pavone <pavone@retrodev.com>
parents:
11
diff
changeset
|
309 } |
6e4851a204a5
Add ability to load code into editor
Mike Pavone <pavone@retrodev.com>
parents:
11
diff
changeset
|
310 } |
124
1157639353e7
Add dummy handler for clicking a symbol while a lambda is selected. Fix the code for selecting the first inner node of an object literal.
Mike Pavone <pavone@retrodev.com>
parents:
120
diff
changeset
|
311 |
12
6e4851a204a5
Add ability to load code into editor
Mike Pavone <pavone@retrodev.com>
parents:
11
diff
changeset
|
312 //bind handlers for editor buttons |
6e4851a204a5
Add ability to load code into editor
Mike Pavone <pavone@retrodev.com>
parents:
11
diff
changeset
|
313 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
|
314 el onclick!: :event { |
11 | 315 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
|
316 srcel textContent!: (srcel textContent) + (el textContent) |
11 | 317 } |
318 } | |
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
|
319 (q: "#ops_button") onclick!: :event { |
116
9cf3e0b18ecc
Add support for selecting operator expressions in the editor
Mike Pavone <pavone@retrodev.com>
parents:
113
diff
changeset
|
320 showOps |
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
|
321 } |
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
|
322 (q: "#lit_button") onclick!: :event { |
116
9cf3e0b18ecc
Add support for selecting operator expressions in the editor
Mike Pavone <pavone@retrodev.com>
parents:
113
diff
changeset
|
323 showLit |
11 | 324 } |
124
1157639353e7
Add dummy handler for clicking a symbol while a lambda is selected. Fix the code for selecting the first inner node of an object literal.
Mike Pavone <pavone@retrodev.com>
parents:
120
diff
changeset
|
325 |
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
|
326 (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
|
327 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
|
328 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
|
329 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
|
330 } |
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
|
331 } |
124
1157639353e7
Add dummy handler for clicking a symbol while a lambda is selected. Fix the code for selecting the first inner node of an object literal.
Mike Pavone <pavone@retrodev.com>
parents:
120
diff
changeset
|
332 |
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
|
333 (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
|
334 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
|
335 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
|
336 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
|
337 } |
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
|
338 } |
124
1157639353e7
Add dummy handler for clicking a symbol while a lambda is selected. Fix the code for selecting the first inner node of an object literal.
Mike Pavone <pavone@retrodev.com>
parents:
120
diff
changeset
|
339 |
131
8285784f5ff5
Implement previous and next buttons
Mike Pavone <pavone@retrodev.com>
parents:
127
diff
changeset
|
340 (q: "#next") onclick!: :event { |
8285784f5ff5
Implement previous and next buttons
Mike Pavone <pavone@retrodev.com>
parents:
127
diff
changeset
|
341 if: (selection valid?) { |
8285784f5ff5
Implement previous and next buttons
Mike Pavone <pavone@retrodev.com>
parents:
127
diff
changeset
|
342 selection next |
8285784f5ff5
Implement previous and next buttons
Mike Pavone <pavone@retrodev.com>
parents:
127
diff
changeset
|
343 } |
8285784f5ff5
Implement previous and next buttons
Mike Pavone <pavone@retrodev.com>
parents:
127
diff
changeset
|
344 } |
8285784f5ff5
Implement previous and next buttons
Mike Pavone <pavone@retrodev.com>
parents:
127
diff
changeset
|
345 |
8285784f5ff5
Implement previous and next buttons
Mike Pavone <pavone@retrodev.com>
parents:
127
diff
changeset
|
346 (q: "#prev") onclick!: :event { |
8285784f5ff5
Implement previous and next buttons
Mike Pavone <pavone@retrodev.com>
parents:
127
diff
changeset
|
347 if: (selection valid?) { |
8285784f5ff5
Implement previous and next buttons
Mike Pavone <pavone@retrodev.com>
parents:
127
diff
changeset
|
348 selection previous |
8285784f5ff5
Implement previous and next buttons
Mike Pavone <pavone@retrodev.com>
parents:
127
diff
changeset
|
349 } |
8285784f5ff5
Implement previous and next buttons
Mike Pavone <pavone@retrodev.com>
parents:
127
diff
changeset
|
350 } |
8285784f5ff5
Implement previous and next buttons
Mike Pavone <pavone@retrodev.com>
parents:
127
diff
changeset
|
351 |
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
|
352 path <- (window location) pathname |
17
7400bb42e0c9
Add direct file edit link support
Mike Pavone <pavone@retrodev.com>
parents:
14
diff
changeset
|
353 if: (path indexOf: "/edit/") = 0 { |
7400bb42e0c9
Add direct file edit link support
Mike Pavone <pavone@retrodev.com>
parents:
14
diff
changeset
|
354 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
|
355 } |
127
2b25d0ce2946
Add fullscreen support and improve experience on tablet browsers by tweaking button text size and disabling zooming.
Mike Pavone <pavone@retrodev.com>
parents:
124
diff
changeset
|
356 (q: "#fullscreen") onclick!: :event { |
2b25d0ce2946
Add fullscreen support and improve experience on tablet browsers by tweaking button text size and disabling zooming.
Mike Pavone <pavone@retrodev.com>
parents:
124
diff
changeset
|
357 goFullScreen: |
2b25d0ce2946
Add fullscreen support and improve experience on tablet browsers by tweaking button text size and disabling zooming.
Mike Pavone <pavone@retrodev.com>
parents:
124
diff
changeset
|
358 } |
11 | 359 } |
360 | |
361 } |