1 ;;; idlw-toolbar.el --- a debugging toolbar for IDLWAVE
2 ;; Copyright (c) 1999, 2000, 2001,2002 Free Software Foundation
4 ;; Author: Carsten Dominik <dominik@astro.uva.nl>
5 ;; Maintainer: J.D. Smith <jdsmith@as.arizona.edu>
9 ;; This file is part of GNU Emacs.
11 ;; GNU Emacs is free software; you can redistribute it and/or modify
12 ;; it under the terms of the GNU General Public License as published by
13 ;; the Free Software Foundation; either version 2, or (at your option)
16 ;; GNU Emacs is distributed in the hope that it will be useful,
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 ;; GNU General Public License for more details.
21 ;; You should have received a copy of the GNU General Public License
22 ;; along with GNU Emacs; see the file COPYING. If not, write to the
23 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
24 ;; Boston, MA 02111-1307, USA.
28 ;; This file implements a debugging toolbar for IDLWAVE. It requires
29 ;; Emacs or XEmacs with toolbar and xpm support.
31 ;; New versions of IDLWAVE, documentation, and more information
38 (eval-when-compile (require 'cl
))
40 (defun idlwave-toolbar-make-button (image)
41 (if (featurep 'xemacs
)
42 (toolbar-make-button-list image
)
43 (list 'image
:type
'xpm
:data image
)))
45 (defvar default-toolbar
)
46 (if (not (or (and (featurep 'xemacs
) ; This is XEmacs
47 (featurep 'xpm
) ; need xpm
48 (featurep 'toolbar
)) ; ... and the toolbar
49 (and (not (featurep 'xemacs
)) ; This is Emacs
50 (boundp 'tool-bar-button-margin
) ; need toolbar
51 (fboundp 'image-type-available-p
) ; need image stuff
52 (image-type-available-p 'xpm
)) ; need xpm
54 ;; oops - cannot do the toolbar
55 (message "Sorry, IDLWAVE xpm toolbar cannot be used on this version of Emacs")
56 ;; OK, we can define a toolbar
58 (defconst idlwave-toolbar-is-possible t
59 "When defined, indicates that a toolbar is possible with this Emacs.")
60 (defvar idlwave-toolbar-compile-icon
61 (idlwave-toolbar-make-button
63 static char * file[] = {
65 \" c None s backgroundToolBarColor\",
66 \". c #000000000000\",
75 \" ................... \",
76 \" ........ ........ \",
79 \" ..... .. ... ..... \",
80 \" ...... .. .. ...... \",
81 \" ..... ... .. ..... \",
84 \" ........ ........ \",
85 \" ................... \",
97 (defvar idlwave-toolbar-next-error-icon
98 (idlwave-toolbar-make-button
100 static char * file[] = {
102 \" c None s backgroundToolBarColor\",
103 \". c #000000000000\",
104 \"R c #FFFF00000000\",
112 \" RRRRRRRRRRRRRRRRRRR \",
119 \" ..... .. ... ..... \",
120 \" ...... .. .. ...... \",
121 \" ..... ... .. ..... \",
122 \" ......... .... \",
123 \" ........ ..... \",
124 \" ........ ........ \",
125 \" ................... \",
133 "The Next Error icon.")
135 (defvar idlwave-toolbar-stop-at-icon
136 (idlwave-toolbar-make-button
138 static char * file[] = {
140 \" c None s backgroundToolBarColor\",
141 \". c #000000000000\",
142 \"R c #FFFF00000000\",
150 \" .RRRRRRRRRRRR. \",
151 \" .RRRRRRRRRRRRRR. \",
152 \" .RRRRRRRRRRRRRRRR. \",
153 \" .RRRRRRRRRRRRRRRRRR. \",
154 \" .RRRRRRRRRRRRRRRRRR. \",
155 \" .RRRRRRRRRRRRRRRRRR. \",
156 \" .RRRRRRRRRRRRRRRRRR. \",
157 \" .RRRRRRRRRRRRRRRRRR. \",
158 \" .RRRRRRRRRRRRRRRRRR. \",
159 \" .RRRRRRRRRRRRRRRRRR. \",
160 \" .RRRRRRRRRRRRRRRRRR. \",
161 \" .RRRRRRRRRRRRRRRR. \",
162 \" .RRRRRRRRRRRRRR. \",
163 \" .RRRRRRRRRRRR. \",
174 (defvar idlwave-toolbar-clear-at-icon
175 (idlwave-toolbar-make-button
177 static char * file[] = {
179 \" c None s backgroundToolBarColor\",
180 \". c #000000000000\",
181 \"R c #FFFF00000000\",
186 \" ... ........ ... \",
187 \" ... .RRRRRRRR. ... \",
188 \" ....RRRRRRRRRR.... \",
189 \" ...RRRRRRRRRR... \",
190 \" ....RRRRRRRR.... \",
191 \" .RR...RRRRRR...RR. \",
192 \" .RRRR...RRRR...RRRR. \",
193 \" .RRRRR...RR...RRRRR. \",
194 \" .RRRRRR......RRRRRR. \",
195 \" .RRRRRRR....RRRRRRR. \",
196 \" .RRRRRRR....RRRRRRR. \",
197 \" .RRRRRR......RRRRRR. \",
198 \" .RRRRR...RR...RRRRR. \",
199 \" .RRRR...RRRR...RRRR. \",
200 \" .RR...RRRRRR...RR. \",
201 \" ....RRRRRRRR.... \",
202 \" ...RRRRRRRRRR... \",
203 \" ....RRRRRRRRRR.... \",
204 \" ... .RRRRRRRR. ... \",
205 \" ... ........ ... \",
210 "The Clear At icon.")
212 (defvar idlwave-toolbar-clear-all-icon
213 (idlwave-toolbar-make-button
215 static char * file[] = {
217 \" c None s backgroundToolBarColor\",
218 \". c #000000000000\",
219 \"X c #FFFFFFFFFFFF\",
220 \"R c #FFFF00000000\",
224 \" .. .... .... .. \",
225 \" ...RRRR. .RRRR... \",
226 \" ...RRRR. .RRRR... \",
227 \" .R...RRRR. .RRRR...R. \",
228 \" .RR...RRR. .RRR...RR. \",
229 \" .RRR...RR. .RR...RRR. \",
230 \" .RRRR...R. .R...RRRR. \",
231 \" .RRRR... ...RRRR. \",
232 \" .RRRR... ...RRRR. \",
233 \" .... ... ... .... \",
236 \" .... ..... .... \",
237 \" .RRRR.... ....RRRR. \",
238 \" .RRRRR... ...RRRRR. \",
239 \" .RRRRR.... ....RRRRR. \",
240 \" .RRRR...R. .R...RRRR. \",
241 \" .RRR...RR. .RR...RRR. \",
242 \" .RR...RRR. .RRR...RR. \",
243 \" ....RRR. .RRR.... \",
244 \" ...RRR. .RRR... \",
245 \" ....... ....... \",
249 "The Clear-All icon.")
251 (defvar idlwave-toolbar-stop-beginning-icon
252 (idlwave-toolbar-make-button
254 static char * file[] = {
256 \" c None s backgroundToolBarColor\",
257 \". c #000000000000\",
258 \"X c #FFFF00000000\",
259 \"_ c #FFFFFFFFFFFF\",
267 \" .XXXXXXXXXXXX. \",
268 \" .XX..XXXXXXXXXX. \",
269 \" .XX.XX.X______XXX. \",
270 \" .XXX.XX.X______XXXX. \",
271 \" .XXXX..XXXXXXXXXXXX. \",
272 \" .XXXXXXXXXX____XXXX. \",
273 \" .XXXXXXXXXX____XXXX. \",
274 \" .XXXXXXXXXXXXXXXXXX. \",
275 \" .XXXXXXXXXX____XXXX. \",
276 \" .XXXXXXXXXX____XXXX. \",
277 \" .XXXXXXXXXXXXXXXXXX. \",
278 \" .XXXXXXXXX____XXX. \",
279 \" .XXXXXXXX____XX. \",
280 \" .XXXXXXXXXXXX. \",
288 "The Stop at Beginning icon.")
290 (defvar idlwave-toolbar-stop-in-icon
291 (idlwave-toolbar-make-button
293 static char * file[] = {
295 \" c None s backgroundToolBarColor\",
296 \"_ c #FFFFFFFFFFFF\",
297 \". c #000000000000\",
298 \"R c #FFFF00000000\",
306 \" .RRRRRRRRRRRR. \",
307 \" .RRR___RR___RRR. \",
308 \" .RRRR__RRRR__RRRR. \",
309 \" .RRRRR__RRRR__RRRRR. \",
310 \" .RRRRR__RRRR__RRRRR. \",
311 \" .RRRRR__RRRR__RRRRR. \",
312 \" .RRRR__RRRRRR__RRRR. \",
313 \" .RRRRR__RRRR__RRRRR. \",
314 \" .RRRRR__RRRR__RRRRR. \",
315 \" .RRRRR__RRRR__RRRRR. \",
316 \" .RRRRR__RRRR__RRRRR. \",
317 \" .RRRR___RR___RRRR. \",
318 \" .RRRRRRRRRRRRRR. \",
319 \" .RRRRRRRRRRRR. \",
329 (defvar idlwave-toolbar-edit-cmd-icon
330 (idlwave-toolbar-make-button
332 static char * file[] = {
334 \" c None s backgroundToolBarColor\",
335 \". c #000000000000\",
354 \" ................. \",
366 (defvar idlwave-toolbar-run-icon
367 (idlwave-toolbar-make-button
369 static char * file[] = {
371 \" c None s backgroundToolBarColor\",
372 \". s FgColor c #000000000000\",
373 \"G c #0000BBBB0000\",
387 \" .GGGGGGG. ....... \",
404 (defvar idlwave-toolbar-cont-icon
405 (idlwave-toolbar-make-button
407 static char * file[] = {
409 \" c None s backgroundToolBarColor\",
410 \". s FgColor c #000000000000\",
411 \"G c #0000BBBB0000\",
418 \" .GGGGGG. ....... \",
427 \" .GGGGGGG. ....... \",
442 (defvar idlwave-toolbar-to-here-icon
443 (idlwave-toolbar-make-button
445 static char * file[] = {
447 \" c None s backgroundToolBarColor\",
448 \". c #000000000000\",
449 \"G c #0000BBBB0000\",
450 \"R c #FFFF00000000\",
457 \" ..... ........ \",
460 \" .GG.... ........ \",
464 \" .GG. .G. ...... \",
466 \" .GGGGGGGG. RRRRRR \",
467 \" .GGGGGGGGG. RRRRRR \",
468 \" .GGGGGGG. RRRRRR \",
479 "The Cont-to-here icon.")
481 (defvar idlwave-toolbar-step-over-icon
482 (idlwave-toolbar-make-button
484 static char * file[] = {
486 \" c None s backgroundToolBarColor\",
487 \". c #000000000000\",
488 \"G c #0000BBBB0000\",
496 \" .GGGG. ....... \",
502 \" .GG. .G. ....... \",
505 \" .GGGGGGGGG. ....... \",
517 "The Step Over icon.")
519 (defvar idlwave-toolbar-step-into-icon
520 (idlwave-toolbar-make-button
522 static char * file[] = {
524 \" c None s backgroundToolBarColor\",
525 \". c #000000000000\",
526 \"G c #0000BBBB0000\",
536 \" .GG.... ........ \",
541 \" .GG...GG. ....... \",
544 \" .GGGGGGG. ....... \",
555 "The Step Into icon.")
557 (defvar idlwave-toolbar-step-out-icon
558 (idlwave-toolbar-make-button
560 static char * file[] = {
562 \" c None s backgroundToolBarColor\",
563 \". c #000000000000\",
564 \"G c #0000BBBB0000\",
575 \" .GGGGGGG. ........ \",
578 \" .GG...GG. ........ \",
583 \" .GG....... ....... \",
586 \" ........ ....... \",
596 (defvar idlwave-toolbar-eval-icon
597 (idlwave-toolbar-make-button
599 static char * file[] = {
601 \" c None s backgroundToolBarColor\",
602 \". c #000000000000\",
631 "The Evaluate icon.")
633 (defvar idlwave-toolbar-stack-up-icon
634 (idlwave-toolbar-make-button
636 static char * file[] = {
638 \" c None s backgroundToolBarColor\",
639 \". s FgColor c #000000000000\",
640 \"_ c #FFFFFFFFFFFF\",
641 \"G c #0000BBBB0000\",
642 \"R c #FFFF00000000\",
650 \" .______. ..... \",
651 \" .______. ....... \",
671 "The Stack Up icon.")
673 (defvar idlwave-toolbar-stack-down-icon
674 (idlwave-toolbar-make-button
676 static char * file[] = {
678 \" c None s backgroundToolBarColor\",
679 \". s FgColor c #000000000000\",
680 \"_ c #FFFFFFFFFFFF\",
681 \"G c #0000BBBB0000\",
682 \"R c #FFFF00000000\",
703 \" .RRRRRR. ....... \",
704 \" .RRRRRR. ..... \",
711 "The Stack Down icon.")
713 (defvar idlwave-toolbar-reset-icon
714 (idlwave-toolbar-make-button
716 static char * file[] = {
718 \" c None s backgroundToolBarColor\",
719 \"G c #0000BBBB0000\",
720 \". c #000000000000\",
751 (defvar idlwave-toolbar-electric-debug-icon
752 (idlwave-toolbar-make-button
754 static char * file[] = {
756 \" c None s backgroundToolBarColor\",
777 \" .++ %%%%%%%%%%% \",
778 \" ++$$ %%%%%%%%%%% \",
779 \" .+@# &&%%%%%%%&& \",
780 \" .++++# &&&&&%%%&&&&& \",
781 \" +++++$ &&%%&&&&&%%&& \",
782 \" $+++$ &&%%&&&&&%%&& \",
783 \" $++@ &&&&&&%&&&&&& \",
784 \" $+@ &&&&&&%&&&&&& \",
785 \" @+ &&%%&&&&&%%&& \",
786 \" ++. &%%&&%&&%%& \",
787 \" +. &&&&%%%&&&& \",
792 "The electric debug icon.")
794 (defvar idlwave-toolbar
796 [idlwave-toolbar-compile-icon
797 idlwave-shell-save-and-compile
799 "Save and Compile this file (or recompile last)"]
800 [idlwave-toolbar-next-error-icon
801 idlwave-shell-goto-next-error
804 [idlwave-toolbar-stop-at-icon
805 idlwave-shell-break-here
806 (eq major-mode
'idlwave-mode
)
807 "Set Breakpoint at selected position"]
808 [idlwave-toolbar-clear-at-icon
809 idlwave-shell-clear-current-bp
811 "Clear Breakpoint at selected position"]
812 [idlwave-toolbar-clear-all-icon
813 idlwave-shell-clear-all-bp
815 "Clear all Breakpoints"]
816 [idlwave-toolbar-stop-beginning-icon
817 idlwave-shell-break-this-module
818 (eq major-mode
'idlwave-mode
)
819 "Stop at beginning of enclosing Routine"]
820 [idlwave-toolbar-stop-in-icon
821 idlwave-shell-break-in
823 "Stop in Routine with name near point"]
824 [idlwave-toolbar-edit-cmd-icon
825 idlwave-shell-edit-default-command-line
827 "Edit Default Command Line"]
828 [idlwave-toolbar-run-icon
829 idlwave-shell-execute-default-command-line
831 "Reset, then Execute Default Command Line"]
832 [idlwave-toolbar-cont-icon
835 "Continue Current Program"]
836 [idlwave-toolbar-to-here-icon
837 idlwave-shell-to-here
838 (eq major-mode
'idlwave-mode
)
839 "Continue to Here (cursor position)"]
840 [idlwave-toolbar-step-over-icon
841 idlwave-shell-stepover
843 "Step Over (aka next)"]
844 [idlwave-toolbar-step-into-icon
847 "Step Into (aka step)"]
848 [idlwave-toolbar-step-out-icon
851 "Step Out (of subroutine)"]
852 [idlwave-toolbar-eval-icon
855 "Print Expression at or before Point"]
856 [idlwave-toolbar-stack-up-icon
857 idlwave-shell-stack-up
859 "Stack Up (towards \"cooler\" - less recently visited - frames)"]
860 [idlwave-toolbar-stack-down-icon
861 idlwave-shell-stack-down
863 "Stack Down (towards \"warmer\" - more recently visited - frames)"]
864 [idlwave-toolbar-reset-icon
867 "Reset IDL (RETALL & CLOSE,/ALL and more)"]
868 [idlwave-toolbar-electric-debug-icon
869 idlwave-shell-electric-debug-mode
870 (eq major-mode
'idlwave-mode
)
871 "Toggle Electric Debug Mode"]
874 ;; When the shell exits, arrange to remove the special toolbar everywhere.
875 (add-hook 'idlwave-shell-cleanup-hook
876 'idlwave-toolbar-remove-everywhere
)
877 );; End can define toolbar
879 (defun idlwave-toolbar-add ()
880 "Add the IDLWAVE toolbar if appropriate."
881 (if (and (featurep 'xemacs
) ; This is a noop on Emacs
882 (boundp 'idlwave-toolbar-is-possible
)
883 (or (eq major-mode
'idlwave-mode
)
884 (eq major-mode
'idlwave-shell-mode
)))
885 (set-specifier default-toolbar
(cons (current-buffer)
888 (defun idlwave-toolbar-remove ()
889 "Add the IDLWAVE toolbar if appropriate."
890 (if (and (featurep 'xemacs
) ; This is a noop on Emacs
891 (boundp 'idlwave-toolbar-is-possible
)
892 (or (eq major-mode
'idlwave-mode
)
893 (eq major-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.
965 (redraw-frame (selected-frame))))
967 (provide 'idlw-toolbar
)
968 (provide 'idlwave-toolbar
)
970 ;; arch-tag: ec9a3717-c44c-4716-9bda-cdacbe5ddb62
971 ;;; idlw-toolbar.el ends here