1 ;;; idlw-toolbar.el --- a debugging toolbar for IDLWAVE
3 ;; Copyright (C) 1999-2013 Free Software Foundation, Inc.
5 ;; Author: Carsten Dominik <dominik@astro.uva.nl>
6 ;; Maintainer: J.D. Smith <jdsmith@as.arizona.edu>
10 ;; This file is part of GNU Emacs.
12 ;; GNU Emacs is free software: you can redistribute it and/or modify
13 ;; it under the terms of the GNU General Public License as published by
14 ;; the Free Software Foundation, either version 3 of the License, or
15 ;; (at your option) any later version.
17 ;; GNU Emacs is distributed in the hope that it will be useful,
18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 ;; GNU General Public License for more details.
22 ;; You should have received a copy of the GNU General Public License
23 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
27 ;; This file implements a debugging toolbar for IDLWAVE. It requires
28 ;; Emacs or XEmacs with toolbar and xpm support.
30 ;; New versions of IDLWAVE, documentation, and more information
37 (eval-when-compile (require 'cl
))
39 (defun idlwave-toolbar-make-button (image)
40 (if (featurep 'xemacs
)
41 (toolbar-make-button-list image
)
42 (list 'image
:type
'xpm
:data image
)))
44 (defvar idlwave-toolbar
)
45 (defvar default-toolbar
)
46 (defvar idlwave-toolbar-is-possible
)
48 (if (not (or (and (featurep 'xemacs
) ; This is XEmacs
49 (featurep 'xpm
) ; need xpm
50 (featurep 'toolbar
)) ; ... and the toolbar
51 (and (not (featurep 'xemacs
)) ; This is Emacs
52 (boundp 'tool-bar-button-margin
) ; need toolbar
53 (fboundp 'image-type-available-p
) ; need image stuff
54 (image-type-available-p 'xpm
)) ; need xpm
56 ;; oops - cannot do the toolbar
57 (message "Sorry, IDLWAVE xpm toolbar cannot be used on this version of Emacs")
58 ;; OK, we can define a toolbar
60 (defconst idlwave-toolbar-is-possible t
61 "When defined, indicates that a toolbar is possible with this Emacs.")
62 (defvar idlwave-toolbar-compile-icon
63 (idlwave-toolbar-make-button
65 static char * file[] = {
67 \" c None s backgroundToolBarColor\",
68 \". c #000000000000\",
77 \" ................... \",
78 \" ........ ........ \",
81 \" ..... .. ... ..... \",
82 \" ...... .. .. ...... \",
83 \" ..... ... .. ..... \",
86 \" ........ ........ \",
87 \" ................... \",
99 (defvar idlwave-toolbar-next-error-icon
100 (idlwave-toolbar-make-button
102 static char * file[] = {
104 \" c None s backgroundToolBarColor\",
105 \". c #000000000000\",
106 \"R c #FFFF00000000\",
114 \" RRRRRRRRRRRRRRRRRRR \",
121 \" ..... .. ... ..... \",
122 \" ...... .. .. ...... \",
123 \" ..... ... .. ..... \",
124 \" ......... .... \",
125 \" ........ ..... \",
126 \" ........ ........ \",
127 \" ................... \",
135 "The Next Error icon.")
137 (defvar idlwave-toolbar-stop-at-icon
138 (idlwave-toolbar-make-button
140 static char * file[] = {
142 \" c None s backgroundToolBarColor\",
143 \". c #000000000000\",
144 \"R c #FFFF00000000\",
152 \" .RRRRRRRRRRRR. \",
153 \" .RRRRRRRRRRRRRR. \",
154 \" .RRRRRRRRRRRRRRRR. \",
155 \" .RRRRRRRRRRRRRRRRRR. \",
156 \" .RRRRRRRRRRRRRRRRRR. \",
157 \" .RRRRRRRRRRRRRRRRRR. \",
158 \" .RRRRRRRRRRRRRRRRRR. \",
159 \" .RRRRRRRRRRRRRRRRRR. \",
160 \" .RRRRRRRRRRRRRRRRRR. \",
161 \" .RRRRRRRRRRRRRRRRRR. \",
162 \" .RRRRRRRRRRRRRRRRRR. \",
163 \" .RRRRRRRRRRRRRRRR. \",
164 \" .RRRRRRRRRRRRRR. \",
165 \" .RRRRRRRRRRRR. \",
176 (defvar idlwave-toolbar-clear-at-icon
177 (idlwave-toolbar-make-button
179 static char * file[] = {
181 \" c None s backgroundToolBarColor\",
182 \". c #000000000000\",
183 \"R c #FFFF00000000\",
188 \" ... ........ ... \",
189 \" ... .RRRRRRRR. ... \",
190 \" ....RRRRRRRRRR.... \",
191 \" ...RRRRRRRRRR... \",
192 \" ....RRRRRRRR.... \",
193 \" .RR...RRRRRR...RR. \",
194 \" .RRRR...RRRR...RRRR. \",
195 \" .RRRRR...RR...RRRRR. \",
196 \" .RRRRRR......RRRRRR. \",
197 \" .RRRRRRR....RRRRRRR. \",
198 \" .RRRRRRR....RRRRRRR. \",
199 \" .RRRRRR......RRRRRR. \",
200 \" .RRRRR...RR...RRRRR. \",
201 \" .RRRR...RRRR...RRRR. \",
202 \" .RR...RRRRRR...RR. \",
203 \" ....RRRRRRRR.... \",
204 \" ...RRRRRRRRRR... \",
205 \" ....RRRRRRRRRR.... \",
206 \" ... .RRRRRRRR. ... \",
207 \" ... ........ ... \",
212 "The Clear At icon.")
214 (defvar idlwave-toolbar-clear-all-icon
215 (idlwave-toolbar-make-button
217 static char * file[] = {
219 \" c None s backgroundToolBarColor\",
220 \". c #000000000000\",
221 \"X c #FFFFFFFFFFFF\",
222 \"R c #FFFF00000000\",
226 \" .. .... .... .. \",
227 \" ...RRRR. .RRRR... \",
228 \" ...RRRR. .RRRR... \",
229 \" .R...RRRR. .RRRR...R. \",
230 \" .RR...RRR. .RRR...RR. \",
231 \" .RRR...RR. .RR...RRR. \",
232 \" .RRRR...R. .R...RRRR. \",
233 \" .RRRR... ...RRRR. \",
234 \" .RRRR... ...RRRR. \",
235 \" .... ... ... .... \",
238 \" .... ..... .... \",
239 \" .RRRR.... ....RRRR. \",
240 \" .RRRRR... ...RRRRR. \",
241 \" .RRRRR.... ....RRRRR. \",
242 \" .RRRR...R. .R...RRRR. \",
243 \" .RRR...RR. .RR...RRR. \",
244 \" .RR...RRR. .RRR...RR. \",
245 \" ....RRR. .RRR.... \",
246 \" ...RRR. .RRR... \",
247 \" ....... ....... \",
251 "The Clear-All icon.")
253 (defvar idlwave-toolbar-stop-beginning-icon
254 (idlwave-toolbar-make-button
256 static char * file[] = {
258 \" c None s backgroundToolBarColor\",
259 \". c #000000000000\",
260 \"X c #FFFF00000000\",
261 \"_ c #FFFFFFFFFFFF\",
269 \" .XXXXXXXXXXXX. \",
270 \" .XX..XXXXXXXXXX. \",
271 \" .XX.XX.X______XXX. \",
272 \" .XXX.XX.X______XXXX. \",
273 \" .XXXX..XXXXXXXXXXXX. \",
274 \" .XXXXXXXXXX____XXXX. \",
275 \" .XXXXXXXXXX____XXXX. \",
276 \" .XXXXXXXXXXXXXXXXXX. \",
277 \" .XXXXXXXXXX____XXXX. \",
278 \" .XXXXXXXXXX____XXXX. \",
279 \" .XXXXXXXXXXXXXXXXXX. \",
280 \" .XXXXXXXXX____XXX. \",
281 \" .XXXXXXXX____XX. \",
282 \" .XXXXXXXXXXXX. \",
290 "The Stop at Beginning icon.")
292 (defvar idlwave-toolbar-stop-in-icon
293 (idlwave-toolbar-make-button
295 static char * file[] = {
297 \" c None s backgroundToolBarColor\",
298 \"_ c #FFFFFFFFFFFF\",
299 \". c #000000000000\",
300 \"R c #FFFF00000000\",
308 \" .RRRRRRRRRRRR. \",
309 \" .RRR___RR___RRR. \",
310 \" .RRRR__RRRR__RRRR. \",
311 \" .RRRRR__RRRR__RRRRR. \",
312 \" .RRRRR__RRRR__RRRRR. \",
313 \" .RRRRR__RRRR__RRRRR. \",
314 \" .RRRR__RRRRRR__RRRR. \",
315 \" .RRRRR__RRRR__RRRRR. \",
316 \" .RRRRR__RRRR__RRRRR. \",
317 \" .RRRRR__RRRR__RRRRR. \",
318 \" .RRRRR__RRRR__RRRRR. \",
319 \" .RRRR___RR___RRRR. \",
320 \" .RRRRRRRRRRRRRR. \",
321 \" .RRRRRRRRRRRR. \",
331 (defvar idlwave-toolbar-edit-cmd-icon
332 (idlwave-toolbar-make-button
334 static char * file[] = {
336 \" c None s backgroundToolBarColor\",
337 \". c #000000000000\",
356 \" ................. \",
368 (defvar idlwave-toolbar-run-icon
369 (idlwave-toolbar-make-button
371 static char * file[] = {
373 \" c None s backgroundToolBarColor\",
374 \". s FgColor c #000000000000\",
375 \"G c #0000BBBB0000\",
389 \" .GGGGGGG. ....... \",
406 (defvar idlwave-toolbar-cont-icon
407 (idlwave-toolbar-make-button
409 static char * file[] = {
411 \" c None s backgroundToolBarColor\",
412 \". s FgColor c #000000000000\",
413 \"G c #0000BBBB0000\",
420 \" .GGGGGG. ....... \",
429 \" .GGGGGGG. ....... \",
444 (defvar idlwave-toolbar-to-here-icon
445 (idlwave-toolbar-make-button
447 static char * file[] = {
449 \" c None s backgroundToolBarColor\",
450 \". c #000000000000\",
451 \"G c #0000BBBB0000\",
452 \"R c #FFFF00000000\",
459 \" ..... ........ \",
462 \" .GG.... ........ \",
466 \" .GG. .G. ...... \",
468 \" .GGGGGGGG. RRRRRR \",
469 \" .GGGGGGGGG. RRRRRR \",
470 \" .GGGGGGG. RRRRRR \",
481 "The Cont-to-here icon.")
483 (defvar idlwave-toolbar-step-over-icon
484 (idlwave-toolbar-make-button
486 static char * file[] = {
488 \" c None s backgroundToolBarColor\",
489 \". c #000000000000\",
490 \"G c #0000BBBB0000\",
498 \" .GGGG. ....... \",
504 \" .GG. .G. ....... \",
507 \" .GGGGGGGGG. ....... \",
519 "The Step Over icon.")
521 (defvar idlwave-toolbar-step-into-icon
522 (idlwave-toolbar-make-button
524 static char * file[] = {
526 \" c None s backgroundToolBarColor\",
527 \". c #000000000000\",
528 \"G c #0000BBBB0000\",
538 \" .GG.... ........ \",
543 \" .GG...GG. ....... \",
546 \" .GGGGGGG. ....... \",
557 "The Step Into icon.")
559 (defvar idlwave-toolbar-step-out-icon
560 (idlwave-toolbar-make-button
562 static char * file[] = {
564 \" c None s backgroundToolBarColor\",
565 \". c #000000000000\",
566 \"G c #0000BBBB0000\",
577 \" .GGGGGGG. ........ \",
580 \" .GG...GG. ........ \",
585 \" .GG....... ....... \",
588 \" ........ ....... \",
598 (defvar idlwave-toolbar-eval-icon
599 (idlwave-toolbar-make-button
601 static char * file[] = {
603 \" c None s backgroundToolBarColor\",
604 \". c #000000000000\",
633 "The Evaluate icon.")
635 (defvar idlwave-toolbar-stack-up-icon
636 (idlwave-toolbar-make-button
638 static char * file[] = {
640 \" c None s backgroundToolBarColor\",
641 \". s FgColor c #000000000000\",
642 \"_ c #FFFFFFFFFFFF\",
643 \"G c #0000BBBB0000\",
644 \"R c #FFFF00000000\",
652 \" .______. ..... \",
653 \" .______. ....... \",
673 "The Stack Up icon.")
675 (defvar idlwave-toolbar-stack-down-icon
676 (idlwave-toolbar-make-button
678 static char * file[] = {
680 \" c None s backgroundToolBarColor\",
681 \". s FgColor c #000000000000\",
682 \"_ c #FFFFFFFFFFFF\",
683 \"G c #0000BBBB0000\",
684 \"R c #FFFF00000000\",
705 \" .RRRRRR. ....... \",
706 \" .RRRRRR. ..... \",
713 "The Stack Down icon.")
715 (defvar idlwave-toolbar-reset-icon
716 (idlwave-toolbar-make-button
718 static char * file[] = {
720 \" c None s backgroundToolBarColor\",
721 \"G c #0000BBBB0000\",
722 \". c #000000000000\",
753 (defvar idlwave-toolbar-electric-debug-icon
754 (idlwave-toolbar-make-button
756 static char * file[] = {
758 \" c None s backgroundToolBarColor\",
779 \" .++ %%%%%%%%%%% \",
780 \" ++$$ %%%%%%%%%%% \",
781 \" .+@# &&%%%%%%%&& \",
782 \" .++++# &&&&&%%%&&&&& \",
783 \" +++++$ &&%%&&&&&%%&& \",
784 \" $+++$ &&%%&&&&&%%&& \",
785 \" $++@ &&&&&&%&&&&&& \",
786 \" $+@ &&&&&&%&&&&&& \",
787 \" @+ &&%%&&&&&%%&& \",
788 \" ++. &%%&&%&&%%& \",
789 \" +. &&&&%%%&&&& \",
794 "The electric debug icon.")
796 (defvar idlwave-toolbar
798 [idlwave-toolbar-compile-icon
799 idlwave-shell-save-and-compile
801 "Save and Compile this file (or recompile last)"]
802 [idlwave-toolbar-next-error-icon
803 idlwave-shell-goto-next-error
806 [idlwave-toolbar-stop-at-icon
807 idlwave-shell-break-here
808 (derived-mode-p 'idlwave-mode
)
809 "Set Breakpoint at selected position"]
810 [idlwave-toolbar-clear-at-icon
811 idlwave-shell-clear-current-bp
813 "Clear Breakpoint at selected position"]
814 [idlwave-toolbar-clear-all-icon
815 idlwave-shell-clear-all-bp
817 "Clear all Breakpoints"]
818 [idlwave-toolbar-stop-beginning-icon
819 idlwave-shell-break-this-module
820 (derived-mode-p 'idlwave-mode
)
821 "Stop at beginning of enclosing Routine"]
822 [idlwave-toolbar-stop-in-icon
823 idlwave-shell-break-in
825 "Stop in Routine with name near point"]
826 [idlwave-toolbar-edit-cmd-icon
827 idlwave-shell-edit-default-command-line
829 "Edit Default Command Line"]
830 [idlwave-toolbar-run-icon
831 idlwave-shell-execute-default-command-line
833 "Reset, then Execute Default Command Line"]
834 [idlwave-toolbar-cont-icon
837 "Continue Current Program"]
838 [idlwave-toolbar-to-here-icon
839 idlwave-shell-to-here
840 (derived-mode-p 'idlwave-mode
)
841 "Continue to Here (cursor position)"]
842 [idlwave-toolbar-step-over-icon
843 idlwave-shell-stepover
845 "Step Over (aka next)"]
846 [idlwave-toolbar-step-into-icon
849 "Step Into (aka step)"]
850 [idlwave-toolbar-step-out-icon
853 "Step Out (of subroutine)"]
854 [idlwave-toolbar-eval-icon
857 "Print Expression at or before Point"]
858 [idlwave-toolbar-stack-up-icon
859 idlwave-shell-stack-up
861 "Stack Up (towards \"cooler\" - less recently visited - frames)"]
862 [idlwave-toolbar-stack-down-icon
863 idlwave-shell-stack-down
865 "Stack Down (towards \"warmer\" - more recently visited - frames)"]
866 [idlwave-toolbar-reset-icon
869 "Reset IDL (RETALL & CLOSE,/ALL and more)"]
870 [idlwave-toolbar-electric-debug-icon
871 idlwave-shell-electric-debug-mode
872 (derived-mode-p 'idlwave-mode
)
873 "Toggle Electric Debug Mode"]
876 ;; When the shell exits, arrange to remove the special toolbar everywhere.
877 (add-hook 'idlwave-shell-cleanup-hook
878 'idlwave-toolbar-remove-everywhere
)
879 );; End can define toolbar
881 (defun idlwave-toolbar-add ()
882 "Add the IDLWAVE toolbar if appropriate."
883 (if (and (featurep 'xemacs
) ; This is a noop on Emacs
884 (boundp 'idlwave-toolbar-is-possible
)
885 (derived-mode-p 'idlwave-mode
'idlwave-shell-mode
))
886 (set-specifier default-toolbar
(cons (current-buffer)
889 (defun idlwave-toolbar-remove ()
890 "Add the IDLWAVE toolbar if appropriate."
891 (if (and (featurep 'xemacs
) ; This is a noop on Emacs
892 (boundp 'idlwave-toolbar-is-possible
)
893 (derived-mode-p 'idlwave-mode
'idlwave-shell-mode
))
894 (remove-specifier default-toolbar
(current-buffer))))
896 (defvar idlwave-shell-mode-map
)
897 (defvar idlwave-mode-map
)
898 (defvar idlwave-toolbar-visible nil
)
899 (defun idlwave-toolbar-add-everywhere ()
900 "Add the toolbar in all appropriate buffers."
901 (when (boundp 'idlwave-toolbar-is-possible
)
903 ;; First make sure new buffers will get the toolbar
904 (add-hook 'idlwave-mode-hook
'idlwave-toolbar-add
)
905 ;; Then add it to all existing buffers
906 (if (featurep 'xemacs
)
907 ;; For XEmacs, map over all buffers to add toolbar
909 (mapcar (lambda (buf)
911 (idlwave-toolbar-add))
913 ;; For Emacs, add the key definitions to the mode maps
915 (let* ((icon (aref x
0))
919 (key (vector 'tool-bar func
))
920 (def (list 'menu-item
923 :image
(symbol-value icon
)
926 (define-key idlwave-mode-map key def
)
927 (define-key idlwave-shell-mode-map key def
)))
928 (reverse idlwave-toolbar
)))
929 (setq idlwave-toolbar-visible t
)))
931 (defun idlwave-toolbar-remove-everywhere ()
932 "Remove the toolbar in all appropriate buffers."
933 ;; First make sure new buffers won't get the toolbar
934 (when idlwave-toolbar-is-possible
935 (remove-hook 'idlwave-mode-hook
'idlwave-toolbar-add
)
936 ;; Then remove it in all existing buffers.
937 (if (featurep 'xemacs
)
938 ;; For XEmacs, map over all buffers to remove toolbar
940 (mapcar (lambda (buf)
942 (idlwave-toolbar-remove))
944 ;; For Emacs, remove the key definitions from the mode maps
946 (let* (;;(icon (aref x 0))
950 (key (vector 'tool-bar func
)))
951 (define-key idlwave-mode-map key nil
)
952 (define-key idlwave-shell-mode-map key nil
)))
954 (setq idlwave-toolbar-visible nil
)))
956 (defun idlwave-toolbar-toggle (&optional force-on
)
958 (if idlwave-toolbar-visible
959 (or force-on
(idlwave-toolbar-remove-everywhere))
960 (idlwave-toolbar-add-everywhere))
961 ;; Now make sure this
962 (if (featurep 'xemacs
)
963 nil
; no action necessary, toolbar gets updated automatically
964 ;; On Emacs, redraw the frame to make sure the Toolbar is updated.
967 (provide 'idlw-toolbar
)
968 (provide 'idlwave-toolbar
)
970 ;;; idlw-toolbar.el ends here