64 " |
64 " |
65 ! ! |
65 ! ! |
66 |
66 |
67 !BreakpointService methodsFor:'event handling'! |
67 !BreakpointService methodsFor:'event handling'! |
68 |
68 |
69 buttonPress: button x:x y:y in: view |
69 buttonPress:button x:x y:y in:view |
70 |
70 codeView methodHolder value isNil ifTrue:[ |
71 codeView methodHolder value isNil ifTrue:[^false]. |
71 ^ false |
72 |
72 ]. |
73 view == gutterView ifTrue:[ |
73 view == gutterView ifTrue:[ |
74 button == 1 ifTrue:[ |
74 button == 1 ifTrue:[ |
75 self setOrToggleBreakpointAtLine: (textView yVisibleToLineNr:y). |
75 self setOrToggleBreakpointAtLine:(textView yVisibleToLineNr:y). |
76 ^true. |
76 ^ true. |
77 ]. |
77 ]. |
78 button == 3 ifTrue:[ |
78 button == 3 ifTrue:[ |
79 |
79 ^ true. |
80 ^true. |
|
81 ] |
80 ] |
82 |
81 ]. |
83 ]. |
82 ^ false |
84 ^false |
|
85 |
83 |
86 "Created: / 17-06-2011 / 13:05:22 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
84 "Created: / 17-06-2011 / 13:05:22 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
87 "Modified: / 28-06-2011 / 08:31:39 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
85 "Modified: / 28-06-2011 / 08:31:39 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
86 "Modified (format): / 05-07-2011 / 21:33:29 / cg" |
88 ! ! |
87 ! ! |
89 |
88 |
90 !BreakpointService methodsFor:'initialization'! |
89 !BreakpointService methodsFor:'initialization'! |
91 |
90 |
92 initialize |
91 initialize |
97 "Created: / 17-06-2011 / 13:49:12 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
96 "Created: / 17-06-2011 / 13:49:12 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
98 ! ! |
97 ! ! |
99 |
98 |
100 !BreakpointService methodsFor:'private'! |
99 !BreakpointService methodsFor:'private'! |
101 |
100 |
102 breakpointAtLine:line |
101 breakpointAtLine:line |
103 |
102 |pos| |
104 | pos | |
103 |
105 pos := textView characterPositionOfLine:line col:1. |
104 pos := textView characterPositionOfLine:line col:1. |
106 ^ breakpoints ? #() detect:[:each | each position = pos ] ifNone:[ nil ] |
105 ^ breakpoints ? #() detect:[:each | each position = pos ] ifNone:[ nil ] |
107 |
106 |
108 "Modified: / 17-06-2011 / 13:59:17 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
107 "Modified: / 17-06-2011 / 13:59:17 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
108 "Modified (format): / 05-07-2011 / 21:33:23 / cg" |
|
109 ! |
|
110 |
|
111 recompile |
|
112 "recompile the current method for changed breakpoints" |
|
113 |
|
114 |method| |
|
115 |
|
116 method := codeView methodHolder value. |
|
117 (method notNil and:[method hasPrimitiveCode not]) ifTrue:[ |
|
118 "/ be careful: if the text has been edited/modified, do not compile |
|
119 textView modified ifTrue:[ |
|
120 self halt |
|
121 ] ifFalse:[ |
|
122 "/ prepare to get reachable bpts |
|
123 breakpoints do:[:bp | bp isReached:false]. |
|
124 |
|
125 ByteCodeCompilerWithBreakpointSupport new |
|
126 breakpoints:breakpoints; |
|
127 |
|
128 compile:method source |
|
129 forClass:method mclass |
|
130 inCategory:method category |
|
131 notifying:nil |
|
132 install:true |
|
133 skipIfSame:false |
|
134 silent:true |
|
135 foldConstants:true |
|
136 ifFail:[ self halt ]. |
|
137 |
|
138 breakpoints := breakpoints select:[:bp | bp isReached] |
|
139 ] |
|
140 ] |
|
141 |
|
142 "Created: / 05-07-2011 / 21:33:13 / cg" |
109 ! |
143 ! |
110 |
144 |
111 setOrToggleBreakpointAtLine:line |
145 setOrToggleBreakpointAtLine:line |
112 |pos bpnt| |
146 |pos bpnt| |
113 |
147 |
114 pos := textView characterPositionOfLine:line col:1. |
148 pos := textView characterPositionOfLine:line col:1. |
115 bpnt := self breakpointAtLine:line. |
149 bpnt := self breakpointAtLine:line. |
116 bpnt isNil |
150 bpnt isNil ifTrue:[ |
117 ifTrue: |
151 breakpoints add:((Breakpoint new) |
118 [ breakpoints add:((Breakpoint new) |
152 position:pos; |
119 position:pos; |
153 line:line). |
120 line:line) ] |
154 self recompile. |
121 ifFalse:[ bpnt toggle. ]. |
155 ] ifFalse:[ |
|
156 bpnt toggle. |
|
157 ]. |
122 gutterView redrawLine:line. |
158 gutterView redrawLine:line. |
123 |
159 |
124 "Created: / 17-06-2011 / 13:45:22 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
160 "Created: / 17-06-2011 / 13:45:22 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
161 "Modified: / 05-07-2011 / 21:32:49 / cg" |
125 ! ! |
162 ! ! |
126 |
163 |
127 !BreakpointService methodsFor:'redrawing'! |
164 !BreakpointService methodsFor:'redrawing'! |
128 |
165 |
129 drawLine:lineNo in: view atX:x y:y width: w height:h from:startCol to:endColOrNil with:fg and:bg |
166 drawLine:lineNo in:view atX:x y:y width:w height:h from:startCol to:endColOrNil with:fg and:bg |
130 |
|
131 "Called by both gutterView and textView (well, not yet) to |
167 "Called by both gutterView and textView (well, not yet) to |
132 allow services to draw custom things on text view. |
168 allow services to draw custom things on text view. |
133 Ask JV what the args means if unsure (I'm lazy to document |
169 Ask JV what the args means if unsure (I'm lazy to document |
134 them, now it is just an experiment...)" |
170 them, now it is just an experiment...)" |
135 |
171 |
136 | bpnt icon dx dy | |
172 |bpnt icon dx dy| |
137 |
173 |
138 codeView methodHolder value isNil ifTrue:[^self]. |
174 codeView methodHolder value isNil ifTrue:[ |
139 |
175 ^ self |
|
176 ]. |
140 view == gutterView ifTrue:[ |
177 view == gutterView ifTrue:[ |
141 |
178 bpnt := self breakpointAtLine:lineNo. |
142 bpnt := self breakpointAtLine: lineNo. |
179 bpnt isNil ifTrue:[ |
143 bpnt isNil ifTrue:[^self]. |
180 ^ self |
144 icon := bpnt icon. |
181 ]. |
145 icon isNil ifTrue:[^self]. |
182 icon := bpnt icon. |
146 |
183 icon isNil ifTrue:[ |
147 dx := ((w - icon width) / 2) rounded. |
184 ^ self |
148 dy := ((h - icon height) / 2) rounded. |
185 ]. |
149 |
186 dx := ((w - icon width) / 2) rounded. |
150 icon displayOn: view x: x+dx y: y-h+dy+4"TODO: Magic constant". |
187 dy := ((h - icon height) / 2) rounded. |
151 |
188 icon |
|
189 displayOn:view |
|
190 x:x + dx |
|
191 y:y - h + dy + 4. "TODO: Magic constant" |
152 ]. |
192 ]. |
153 |
193 |
154 "Created: / 17-06-2011 / 13:52:52 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
194 "Created: / 17-06-2011 / 13:52:52 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
195 "Modified (format): / 05-07-2011 / 22:14:33 / cg" |
155 ! ! |
196 ! ! |
156 |
197 |
157 !BreakpointService class methodsFor:'documentation'! |
198 !BreakpointService class methodsFor:'documentation'! |
158 |
199 |
159 version_CVS |
200 version_CVS |
160 ^ '$Header: /cvs/stx/stx/libtool/Tools__BreakpointService.st,v 1.2 2011-07-03 17:50:05 cg Exp $' |
201 ^ '$Header: /cvs/stx/stx/libtool/Tools__BreakpointService.st,v 1.3 2011-07-05 21:27:49 cg Exp $' |
161 ! |
202 ! |
162 |
203 |
163 version_SVN |
204 version_SVN |
164 ^ '§Id§' |
205 ^ '§Id§' |
165 ! ! |
206 ! ! |