173 ! ! |
173 ! ! |
174 |
174 |
175 !CodeNavigationService methodsFor:'event handling'! |
175 !CodeNavigationService methodsFor:'event handling'! |
176 |
176 |
177 button1Press |
177 button1Press |
178 |element| |
178 | node | |
179 |
179 |
180 (element := codeView syntaxElementSelection) notNil ifTrue:[ |
180 node := codeView currentParseNode. |
181 element type == #selector ifTrue:[self button1PressForSelector: element value. ^true]. |
181 node isNil ifTrue:[ |
182 element type == #class ifTrue:[self browseClass:element value. ^true]. |
182 ^ self |
183 ]. |
183 ]. |
184 ^ false |
184 node isSelector ifTrue:[ |
|
185 self button1PressForMessageNode: node. |
|
186 ^self. |
|
187 ]. |
|
188 node isVariable ifTrue:[ |
|
189 self button1PressForVariableNode: node. |
|
190 ^self. |
|
191 ]. |
|
192 |
|
193 ^self. |
185 |
194 |
186 "Created: / 14-02-2010 / 18:43:03 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
195 "Created: / 14-02-2010 / 18:43:03 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
187 "Modified: / 06-03-2010 / 21:11:30 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
196 "Modified: / 18-11-2011 / 14:58:02 / cg" |
188 "Modified: / 29-08-2013 / 16:24:19 / cg" |
197 "Modified: / 21-02-2012 / 14:30:14 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
198 ! |
|
199 |
|
200 button1PressForMessageNode: node |
|
201 |
|
202 ^self button1PressForSelector: node parent selector. |
|
203 |
|
204 "Created: / 21-02-2012 / 14:30:10 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
189 ! |
205 ! |
190 |
206 |
191 button1PressForSelector: selector |
207 button1PressForSelector: selector |
192 | impls | |
208 | impls | |
193 |
209 |
206 "Modified: / 30-06-2011 / 19:34:50 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
222 "Modified: / 30-06-2011 / 19:34:50 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
207 "Modified: / 07-07-2011 / 17:16:23 / jv" |
223 "Modified: / 07-07-2011 / 17:16:23 / jv" |
208 "Modified (comment): / 29-08-2013 / 16:27:58 / cg" |
224 "Modified (comment): / 29-08-2013 / 16:27:58 / cg" |
209 ! |
225 ! |
210 |
226 |
|
227 button1PressForVariableNode: node |
|
228 | value | |
|
229 |
|
230 node isGlobalVariable ifTrue:[ |
|
231 value := Smalltalk at: node name. |
|
232 value notNil ifTrue:[ |
|
233 value isBehavior ifTrue:[ |
|
234 self browseClass: value. |
|
235 ] ifFalse:[ |
|
236 value inspect. |
|
237 ] |
|
238 ] |
|
239 ] |
|
240 |
|
241 "Created: / 21-02-2012 / 14:30:11 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
242 ! |
|
243 |
211 button2Press |
244 button2Press |
212 | element | |
245 |
213 |
246 | sel | |
214 (element := codeView syntaxElementSelection) notNil ifTrue:[ |
247 sel := codeView syntaxElementSelection. |
215 element type == #selector ifTrue:[self button2PressForSelector: element value. ^ true]. |
248 (sel notNil and:[sel node isMessage]) ifTrue:[^self button2PressForSelector: sel node selector]. |
216 ]. |
|
217 ^ false |
|
218 |
249 |
219 "Created: / 14-02-2010 / 18:43:04 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
250 "Created: / 14-02-2010 / 18:43:04 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
220 "Modified: / 17-06-2011 / 08:58:34 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
251 "Modified: / 08-03-2012 / 16:49:52 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
221 ! |
252 ! |
222 |
253 |
223 button2PressForSelector: selector |
254 button2PressForSelector: selector |
224 | senders | |
255 | senders | |
225 |
256 |
514 0"1" to:0 by:-1 do:[:d | |
545 0"1" to:0 by:-1 do:[:d | |
515 index := (syntaxElements indexForInserting:characterPosition) - d. |
546 index := (syntaxElements indexForInserting:characterPosition) - d. |
516 index > syntaxElements size ifTrue:[^nil]. |
547 index > syntaxElements size ifTrue:[^nil]. |
517 element := syntaxElements at:index ifAbsent:nil. |
548 element := syntaxElements at:index ifAbsent:nil. |
518 element notNil ifTrue:[ |
549 element notNil ifTrue:[ |
519 (characterPosition between: element start - 1 and: element stop) ifTrue:[^element]. |
550 (characterPosition between: element start and: element stop) ifTrue:[^element]. |
520 ]. |
551 ]. |
|
552 index + 1 > syntaxElements size ifTrue:[^nil]. |
|
553 element := syntaxElements at:index + 1 ifAbsent:nil. |
|
554 element notNil ifTrue:[ |
|
555 (characterPosition between: element start and: element stop) ifTrue:[^element]. |
|
556 ]. |
|
557 |
521 ]. |
558 ]. |
522 ^nil |
559 ^nil |
523 |
560 |
524 "Created: / 25-06-2010 / 14:40:03 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
561 "Created: / 25-06-2010 / 14:40:03 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
525 "Modified: / 21-08-2011 / 11:03:29 / cg" |
562 "Modified: / 21-08-2011 / 11:03:29 / cg" |
526 "Modified: / 16-09-2011 / 17:04:06 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
563 "Modified: / 02-10-2013 / 01:22:31 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
527 ! |
564 ! |
528 |
565 |
529 elementAtX:x y:y |
566 elementAtX:x y:y |
530 |visibleLine line col| |
567 |visibleLine line col| |
531 |
568 |
662 "Created: / 14-02-2010 / 16:17:40 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
699 "Created: / 14-02-2010 / 16:17:40 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
663 "Modified: / 06-03-2010 / 19:59:18 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
700 "Modified: / 06-03-2010 / 19:59:18 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
664 ! |
701 ! |
665 |
702 |
666 highlightElementAtLine:line col:col |
703 highlightElementAtLine:line col:col |
667 |characterPosition syntaxElements index elementOrNil| |
704 |elementOrNil| |
668 |
705 |
669 characterPosition := textView characterPositionOfLine:line col:col. |
706 elementOrNil := self elementAtLine: line col: col. |
670 syntaxElements := codeView syntaxElements. |
|
671 syntaxElements isEmptyOrNil ifTrue:[ |
|
672 elementOrNil := nil. |
|
673 ] ifFalse:[ |
|
674 index := syntaxElements indexForInserting:characterPosition. |
|
675 index > syntaxElements size ifTrue:[ |
|
676 elementOrNil := nil. |
|
677 ] ifFalse:[ |
|
678 elementOrNil := syntaxElements at:index. |
|
679 (characterPosition between: elementOrNil start and: elementOrNil stop) ifFalse:[ |
|
680 elementOrNil := nil |
|
681 ]. |
|
682 ] |
|
683 ]. |
|
684 |
|
685 self highlightElement:elementOrNil |
707 self highlightElement:elementOrNil |
686 |
708 |
687 "Created: / 14-02-2010 / 16:17:22 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
709 "Created: / 14-02-2010 / 16:17:22 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
688 "Modified: / 01-08-2010 / 08:50:11 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
710 "Modified: / 02-10-2013 / 01:29:12 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
689 ! |
711 ! |
690 |
712 |
691 highlightElementAtX:x y:y |
713 highlightElementAtX:x y:y |
692 |visibleLine line col| |
714 |visibleLine line col| |
693 |
715 |
726 ifTrue:[ startCol ] |
748 ifTrue:[ startCol ] |
727 ifFalse:[ line indexOfNonSeparator ]. |
749 ifFalse:[ line indexOfNonSeparator ]. |
728 end := (lineNo = endLine) |
750 end := (lineNo = endLine) |
729 ifTrue:[ endCol ] |
751 ifTrue:[ endCol ] |
730 ifFalse:[ line size ]. |
752 ifFalse:[ line size ]. |
731 line |
753 line setRuns:(line runs asArray). |
|
754 "/ JV: CG commented following and added the commtent code below. |
|
755 "/ however, this clear all other emphasis like bold, color and so on!! |
|
756 line |
732 emphasisFrom:(start max: 1) |
757 emphasisFrom:(start max: 1) |
733 to:(end min: line size) |
758 to:(end min: line size) |
734 add: currentEmphasis. |
759 add: currentEmphasis. |
|
760 "/ line |
|
761 "/ emphasizeFrom:(start max: 1) |
|
762 "/ to:(end min: line size) |
|
763 "/ with: currentEmphasis. |
|
764 line setRuns:(line runs asRunArray). |
735 |
765 |
736 linesToRedraw add: lineNo. |
766 linesToRedraw add: lineNo. |
737 |
767 |
738 "Created: / 25-06-2010 / 14:15:39 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
768 "Created: / 25-06-2010 / 14:15:39 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
739 "Modified: / 08-07-2011 / 13:02:51 / cg" |
769 "Modified: / 08-07-2011 / 13:02:51 / cg" |
740 "Modified: / 20-07-2011 / 18:43:57 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
770 "Modified: / 01-07-2013 / 22:09:14 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
741 ! |
771 ! |
742 |
772 |
743 highlightVariable:element |
773 highlightVariable:element |
744 (element notNil and:[ element isVariableOrSelf ]) ifTrue:[ |
774 (element notNil and:[ element isVariableOrSelf ]) ifTrue:[ |
745 self highlightElement:element. |
775 self highlightElement:element. |
803 ! ! |
833 ! ! |
804 |
834 |
805 !CodeNavigationService class methodsFor:'documentation'! |
835 !CodeNavigationService class methodsFor:'documentation'! |
806 |
836 |
807 version |
837 version |
808 ^ '$Header: /cvs/stx/stx/libtool/Tools__CodeNavigationService.st,v 1.40 2013-12-01 23:07:50 cg Exp $' |
838 ^ '$Header: /cvs/stx/stx/libtool/Tools__CodeNavigationService.st,v 1.41 2014-02-05 19:08:25 cg Exp $' |
809 ! |
839 ! |
810 |
840 |
811 version_CVS |
841 version_CVS |
812 ^ '$Header: /cvs/stx/stx/libtool/Tools__CodeNavigationService.st,v 1.40 2013-12-01 23:07:50 cg Exp $' |
842 ^ '$Header: /cvs/stx/stx/libtool/Tools__CodeNavigationService.st,v 1.41 2014-02-05 19:08:25 cg Exp $' |
813 ! |
843 ! |
814 |
844 |
815 version_SVN |
845 version_SVN |
816 ^ '$Id: Tools__CodeNavigationService.st,v 1.40 2013-12-01 23:07:50 cg Exp $' |
846 ^ '$Id: Tools__CodeNavigationService.st,v 1.41 2014-02-05 19:08:25 cg Exp $' |
817 ! ! |
847 ! ! |
818 |
848 |