1 ;;; idlw-toolbar.el --- a debugging toolbar for IDLWAVE
2 ;; Copyright (c) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006
3 ;; Free Software Foundation
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 2, or (at your option)
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; see the file COPYING. If not, write to the
24 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
25 ;; Boston, MA 02110-1301, USA.
29 ;; This file implements a debugging toolbar for IDLWAVE. It requires
30 ;; Emacs or XEmacs with toolbar and xpm support.
32 ;; New versions of IDLWAVE, documentation, and more information
39 (eval-when-compile (require 'cl
))
41 (defun idlwave-toolbar-make-button (image)
42 (if (featurep 'xemacs
)
43 (toolbar-make-button-list image
)
44 (list 'image
:type
'xpm
:data image
)))
46 (defvar idlwave-toolbar
)
47 (defvar default-toolbar
)
48 (defvar idlwave-toolbar-is-possible
)
50 (if (not (or (and (featurep 'xemacs
) ; This is XEmacs
51 (featurep 'xpm
) ; need xpm
52 (featurep 'toolbar
)) ; ... and the toolbar
53 (and (not (featurep 'xemacs
)) ; This is Emacs
54 (boundp 'tool-bar-button-margin
) ; need toolbar
55 (fboundp 'image-type-available-p
) ; need image stuff
56 (image-type-available-p 'xpm
)) ; need xpm
58 ;; oops - cannot do the toolbar
59 (message "Sorry, IDLWAVE xpm toolbar cannot be used on this version of Emacs")
60 ;; OK, we can define a toolbar
62 (defconst idlwave-toolbar-is-possible t
63 "When defined, indicates that a toolbar is possible with this Emacs.")
64 (defvar idlwave-toolbar-compile-icon
65 (idlwave-toolbar-make-button
67 static char * file[] = {
69 \" c None s backgroundToolBarColor\",
70 \". c #000000000000\",
79 \" ................... \",
80 \" ........ ........ \",
83 \" ..... .. ... ..... \",
84 \" ...... .. .. ...... \",
85 \" ..... ... .. ..... \",
88 \" ........ ........ \",
89 \" ................... \",
101 (defvar idlwave-toolbar-next-error-icon
102 (idlwave-toolbar-make-button
104 static char * file[] = {
106 \" c None s backgroundToolBarColor\",
107 \". c #000000000000\",
108 \"R c #FFFF00000000\",
116 \" RRRRRRRRRRRRRRRRRRR \",
123 \" ..... .. ... ..... \",
124 \" ...... .. .. ...... \",
125 \" ..... ... .. ..... \",
126 \" ......... .... \",
127 \" ........ ..... \",
128 \" ........ ........ \",
129 \" ................... \",
137 "The Next Error icon.")
139 (defvar idlwave-toolbar-stop-at-icon
140 (idlwave-toolbar-make-button
142 static char * file[] = {
144 \" c None s backgroundToolBarColor\",
145 \". c #000000000000\",
146 \"R c #FFFF00000000\",
154 \" .RRRRRRRRRRRR. \",
155 \" .RRRRRRRRRRRRRR. \",
156 \" .RRRRRRRRRRRRRRRR. \",
157 \" .RRRRRRRRRRRRRRRRRR. \",
158 \" .RRRRRRRRRRRRRRRRRR. \",
159 \" .RRRRRRRRRRRRRRRRRR. \",
160 \" .RRRRRRRRRRRRRRRRRR. \",
161 \" .RRRRRRRRRRRRRRRRRR. \",
162 \" .RRRRRRRRRRRRRRRRRR. \",
163 \" .RRRRRRRRRRRRRRRRRR. \",
164 \" .RRRRRRRRRRRRRRRRRR. \",
165 \" .RRRRRRRRRRRRRRRR. \",
166 \" .RRRRRRRRRRRRRR. \",
167 \" .RRRRRRRRRRRR. \",
178 (defvar idlwave-toolbar-clear-at-icon
179 (idlwave-toolbar-make-button
181 static char * file[] = {
183 \" c None s backgroundToolBarColor\",
184 \". c #000000000000\",
185 \"R c #FFFF00000000\",
190 \" ... ........ ... \",
191 \" ... .RRRRRRRR. ... \",
192 \" ....RRRRRRRRRR.... \",
193 \" ...RRRRRRRRRR... \",
194 \" ....RRRRRRRR.... \",
195 \" .RR...RRRRRR...RR. \",
196 \" .RRRR...RRRR...RRRR. \",
197 \" .RRRRR...RR...RRRRR. \",
198 \" .RRRRRR......RRRRRR. \",
199 \" .RRRRRRR....RRRRRRR. \",
200 \" .RRRRRRR....RRRRRRR. \",
201 \" .RRRRRR......RRRRRR. \",
202 \" .RRRRR...RR...RRRRR. \",
203 \" .RRRR...RRRR...RRRR. \",
204 \" .RR...RRRRRR...RR. \",
205 \" ....RRRRRRRR.... \",
206 \" ...RRRRRRRRRR... \",
207 \" ....RRRRRRRRRR.... \",
208 \" ... .RRRRRRRR. ... \",
209 \" ... ........ ... \",
214 "The Clear At icon.")
216 (defvar idlwave-toolbar-clear-all-icon
217 (idlwave-toolbar-make-button
219 static char * file[] = {
221 \" c None s backgroundToolBarColor\",
222 \". c #000000000000\",
223 \"X c #FFFFFFFFFFFF\",
224 \"R c #FFFF00000000\",
228 \" .. .... .... .. \",
229 \" ...RRRR. .RRRR... \",
230 \" ...RRRR. .RRRR... \",
231 \" .R...RRRR. .RRRR...R. \",
232 \" .RR...RRR. .RRR...RR. \",
233 \" .RRR...RR. .RR...RRR. \",
234 \" .RRRR...R. .R...RRRR. \",
235 \" .RRRR... ...RRRR. \",
236 \" .RRRR... ...RRRR. \",
237 \" .... ... ... .... \",
240 \" .... ..... .... \",
241 \" .RRRR.... ....RRRR. \",
242 \" .RRRRR... ...RRRRR. \",
243 \" .RRRRR.... ....RRRRR. \",
244 \" .RRRR...R. .R...RRRR. \",
245 \" .RRR...RR. .RR...RRR. \",
246 \" .RR...RRR. .RRR...RR. \",
247 \" ....RRR. .RRR.... \",
248 \" ...RRR. .RRR... \",
249 \" ....... ....... \",
253 "The Clear-All icon.")
255 (defvar idlwave-toolbar-stop-beginning-icon
256 (idlwave-toolbar-make-button
258 static char * file[] = {
260 \" c None s backgroundToolBarColor\",
261 \". c #000000000000\",
262 \"X c #FFFF00000000\",
263 \"_ c #FFFFFFFFFFFF\",
271 \" .XXXXXXXXXXXX. \",
272 \" .XX..XXXXXXXXXX. \",
273 \" .XX.XX.X______XXX. \",
274 \" .XXX.XX.X______XXXX. \",
275 \" .XXXX..XXXXXXXXXXXX. \",
276 \" .XXXXXXXXXX____XXXX. \",
277 \" .XXXXXXXXXX____XXXX. \",
278 \" .XXXXXXXXXXXXXXXXXX. \",
279 \" .XXXXXXXXXX____XXXX. \",
280 \" .XXXXXXXXXX____XXXX. \",
281 \" .XXXXXXXXXXXXXXXXXX. \",
282 \" .XXXXXXXXX____XXX. \",
283 \" .XXXXXXXX____XX. \",
284 \" .XXXXXXXXXXXX. \",
292 "The Stop at Beginning icon.")
294 (defvar idlwave-toolbar-stop-in-icon
295 (idlwave-toolbar-make-button
297 static char * file[] = {
299 \" c None s backgroundToolBarColor\",
300 \"_ c #FFFFFFFFFFFF\",
301 \". c #000000000000\",
302 \"R c #FFFF00000000\",
310 \" .RRRRRRRRRRRR. \",
311 \" .RRR___RR___RRR. \",
312 \" .RRRR__RRRR__RRRR. \",
313 \" .RRRRR__RRRR__RRRRR. \",
314 \" .RRRRR__RRRR__RRRRR. \",
315 \" .RRRRR__RRRR__RRRRR. \",
316 \" .RRRR__RRRRRR__RRRR. \",
317 \" .RRRRR__RRRR__RRRRR. \",
318 \" .RRRRR__RRRR__RRRRR. \",
319 \" .RRRRR__RRRR__RRRRR. \",
320 \" .RRRRR__RRRR__RRRRR. \",
321 \" .RRRR___RR___RRRR. \",
322 \" .RRRRRRRRRRRRRR. \",
323 \" .RRRRRRRRRRRR. \",
333 (defvar idlwave-toolbar-edit-cmd-icon
334 (idlwave-toolbar-make-button
336 static char * file[] = {
338 \" c None s backgroundToolBarColor\",
339 \". c #000000000000\",
358 \" ................. \",
370 (defvar idlwave-toolbar-run-icon
371 (idlwave-toolbar-make-button
373 static char * file[] = {
375 \" c None s backgroundToolBarColor\",
376 \". s FgColor c #000000000000\",
377 \"G c #0000BBBB0000\",
391 \" .GGGGGGG. ....... \",
408 (defvar idlwave-toolbar-cont-icon
409 (idlwave-toolbar-make-button
411 static char * file[] = {
413 \" c None s backgroundToolBarColor\",
414 \". s FgColor c #000000000000\",
415 \"G c #0000BBBB0000\",
422 \" .GGGGGG. ....... \",
431 \" .GGGGGGG. ....... \",
446 (defvar idlwave-toolbar-to-here-icon
447 (idlwave-toolbar-make-button
449 static char * file[] = {
451 \" c None s backgroundToolBarColor\",
452 \". c #000000000000\",
453 \"G c #0000BBBB0000\",
454 \"R c #FFFF00000000\",
461 \" ..... ........ \",
464 \" .GG.... ........ \",
468 \" .GG. .G. ...... \",
470 \" .GGGGGGGG. RRRRRR \",
471 \" .GGGGGGGGG. RRRRRR \",
472 \" .GGGGGGG. RRRRRR \",
483 "The Cont-to-here icon.")
485 (defvar idlwave-toolbar-step-over-icon
486 (idlwave-toolbar-make-button
488 static char * file[] = {
490 \" c None s backgroundToolBarColor\",
491 \". c #000000000000\",
492 \"G c #0000BBBB0000\",
500 \" .GGGG. ....... \",
506 \" .GG. .G. ....... \",
509 \" .GGGGGGGGG. ....... \",
521 "The Step Over icon.")
523 (defvar idlwave-toolbar-step-into-icon
524 (idlwave-toolbar-make-button
526 static char * file[] = {
528 \" c None s backgroundToolBarColor\",
529 \". c #000000000000\",
530 \"G c #0000BBBB0000\",
540 \" .GG.... ........ \",
545 \" .GG...GG. ....... \",
548 \" .GGGGGGG. ....... \",
559 "The Step Into icon.")
561 (defvar idlwave-toolbar-step-out-icon
562 (idlwave-toolbar-make-button
564 static char * file[] = {
566 \" c None s backgroundToolBarColor\",
567 \". c #000000000000\",
568 \"G c #0000BBBB0000\",
579 \" .GGGGGGG. ........ \",
582 \" .GG...GG. ........ \",
587 \" .GG....... ....... \",
590 \" ........ ....... \",
600 (defvar idlwave-toolbar-eval-icon
601 (idlwave-toolbar-make-button
603 static char * file[] = {
605 \" c None s backgroundToolBarColor\",
606 \". c #000000000000\",
635 "The Evaluate icon.")
637 (defvar idlwave-toolbar-stack-up-icon
638 (idlwave-toolbar-make-button
640 static char * file[] = {
642 \" c None s backgroundToolBarColor\",
643 \". s FgColor c #000000000000\",
644 \"_ c #FFFFFFFFFFFF\",
645 \"G c #0000BBBB0000\",
646 \"R c #FFFF00000000\",
654 \" .______. ..... \",
655 \" .______. ....... \",
675 "The Stack Up icon.")
677 (defvar idlwave-toolbar-stack-down-icon
678 (idlwave-toolbar-make-button
680 static char * file[] = {
682 \" c None s backgroundToolBarColor\",
683 \". s FgColor c #000000000000\",
684 \"_ c #FFFFFFFFFFFF\",
685 \"G c #0000BBBB0000\",
686 \"R c #FFFF00000000\",
707 \" .RRRRRR. ....... \",
708 \" .RRRRRR. ..... \",
715 "The Stack Down icon.")
717 (defvar idlwave-toolbar-reset-icon
718 (idlwave-toolbar-make-button
720 static char * file[] = {
722 \" c None s backgroundToolBarColor\",
723 \"G c #0000BBBB0000\",
724 \". c #000000000000\",
755 (defvar idlwave-toolbar-electric-debug-icon
756 (idlwave-toolbar-make-button
758 static char * file[] = {
760 \" c None s backgroundToolBarColor\",
781 \" .++ %%%%%%%%%%% \",
782 \" ++$$ %%%%%%%%%%% \",
783 \" .+@# &&%%%%%%%&& \",
784 \" .++++# &&&&&%%%&&&&& \",
785 \" +++++$ &&%%&&&&&%%&& \",
786 \" $+++$ &&%%&&&&&%%&& \",
787 \" $++@ &&&&&&%&&&&&& \",
788 \" $+@ &&&&&&%&&&&&& \",
789 \" @+ &&%%&&&&&%%&& \",
790 \" ++. &%%&&%&&%%& \",
791 \" +. &&&&%%%&&&& \",
796 "The electric debug icon.")
798 (defvar idlwave-toolbar
800 [idlwave-toolbar-compile-icon
801 idlwave-shell-save-and-compile
803 "Save and Compile this file (or recompile last)"]
804 [idlwave-toolbar-next-error-icon
805 idlwave-shell-goto-next-error
808 [idlwave-toolbar-stop-at-icon
809 idlwave-shell-break-here
810 (eq major-mode
'idlwave-mode
)
811 "Set Breakpoint at selected position"]
812 [idlwave-toolbar-clear-at-icon
813 idlwave-shell-clear-current-bp
815 "Clear Breakpoint at selected position"]
816 [idlwave-toolbar-clear-all-icon
817 idlwave-shell-clear-all-bp
819 "Clear all Breakpoints"]
820 [idlwave-toolbar-stop-beginning-icon
821 idlwave-shell-break-this-module
822 (eq major-mode
'idlwave-mode
)
823 "Stop at beginning of enclosing Routine"]
824 [idlwave-toolbar-stop-in-icon
825 idlwave-shell-break-in
827 "Stop in Routine with name near point"]
828 [idlwave-toolbar-edit-cmd-icon
829 idlwave-shell-edit-default-command-line
831 "Edit Default Command Line"]
832 [idlwave-toolbar-run-icon
833 idlwave-shell-execute-default-command-line
835 "Reset, then Execute Default Command Line"]
836 [idlwave-toolbar-cont-icon
839 "Continue Current Program"]
840 [idlwave-toolbar-to-here-icon
841 idlwave-shell-to-here
842 (eq major-mode
'idlwave-mode
)
843 "Continue to Here (cursor position)"]
844 [idlwave-toolbar-step-over-icon
845 idlwave-shell-stepover
847 "Step Over (aka next)"]
848 [idlwave-toolbar-step-into-icon
851 "Step Into (aka step)"]
852 [idlwave-toolbar-step-out-icon
855 "Step Out (of subroutine)"]
856 [idlwave-toolbar-eval-icon
859 "Print Expression at or before Point"]
860 [idlwave-toolbar-stack-up-icon
861 idlwave-shell-stack-up
863 "Stack Up (towards \"cooler\" - less recently visited - frames)"]
864 [idlwave-toolbar-stack-down-icon
865 idlwave-shell-stack-down
867 "Stack Down (towards \"warmer\" - more recently visited - frames)"]
868 [idlwave-toolbar-reset-icon
871 "Reset IDL (RETALL & CLOSE,/ALL and more)"]
872 [idlwave-toolbar-electric-debug-icon
873 idlwave-shell-electric-debug-mode
874 (eq major-mode
'idlwave-mode
)
875 "Toggle Electric Debug Mode"]
878 ;; When the shell exits, arrange to remove the special toolbar everywhere.
879 (add-hook 'idlwave-shell-cleanup-hook
880 'idlwave-toolbar-remove-everywhere
)
881 );; End can define toolbar
883 (defun idlwave-toolbar-add ()
884 "Add the IDLWAVE toolbar if appropriate."
885 (if (and (featurep 'xemacs
) ; This is a noop on Emacs
886 (boundp 'idlwave-toolbar-is-possible
)
887 (or (eq major-mode
'idlwave-mode
)
888 (eq major-mode
'idlwave-shell-mode
)))
889 (set-specifier default-toolbar
(cons (current-buffer)
892 (defun idlwave-toolbar-remove ()
893 "Add the IDLWAVE toolbar if appropriate."
894 (if (and (featurep 'xemacs
) ; This is a noop on Emacs
895 (boundp 'idlwave-toolbar-is-possible
)
896 (or (eq major-mode
'idlwave-mode
)
897 (eq major-mode
'idlwave-shell-mode
)))
898 (remove-specifier default-toolbar
(current-buffer))))
900 (defvar idlwave-shell-mode-map
)
901 (defvar idlwave-mode-map
)
902 (defvar idlwave-toolbar-visible nil
)
903 (defun idlwave-toolbar-add-everywhere ()
904 "Add the toolbar in all appropriate buffers."
905 (when (boundp 'idlwave-toolbar-is-possible
)
907 ;; First make sure new buffers will get the toolbar
908 (add-hook 'idlwave-mode-hook
'idlwave-toolbar-add
)
909 ;; Then add it to all existing buffers
910 (if (featurep 'xemacs
)
911 ;; For XEmacs, map over all buffers to add toolbar
913 (mapcar (lambda (buf)
915 (idlwave-toolbar-add))
917 ;; For Emacs, add the key definitions to the mode maps
919 (let* ((icon (aref x
0))
923 (key (vector 'tool-bar func
))
924 (def (list 'menu-item
927 :image
(symbol-value icon
)
930 (define-key idlwave-mode-map key def
)
931 (define-key idlwave-shell-mode-map key def
)))
932 (reverse idlwave-toolbar
)))
933 (setq idlwave-toolbar-visible t
)))
935 (defun idlwave-toolbar-remove-everywhere ()
936 "Remove the toolbar in all appropriate buffers."
937 ;; First make sure new buffers won't get the toolbar
938 (when idlwave-toolbar-is-possible
939 (remove-hook 'idlwave-mode-hook
'idlwave-toolbar-add
)
940 ;; Then remove it in all existing buffers.
941 (if (featurep 'xemacs
)
942 ;; For XEmacs, map over all buffers to remove toolbar
944 (mapcar (lambda (buf)
946 (idlwave-toolbar-remove))
948 ;; For Emacs, remove the key definitions from the mode maps
950 (let* (;;(icon (aref x 0))
954 (key (vector 'tool-bar func
)))
955 (define-key idlwave-mode-map key nil
)
956 (define-key idlwave-shell-mode-map key nil
)))
958 (setq idlwave-toolbar-visible nil
)))
960 (defun idlwave-toolbar-toggle (&optional force-on
)
962 (if idlwave-toolbar-visible
963 (or force-on
(idlwave-toolbar-remove-everywhere))
964 (idlwave-toolbar-add-everywhere))
965 ;; Now make sure this
966 (if (featurep 'xemacs
)
967 nil
; no action necessary, toolbar gets updated automatically
968 ;; On Emacs, redraw the frame to make sure the Toolbar is updated.
969 (redraw-frame (selected-frame))))
971 (provide 'idlw-toolbar
)
972 (provide 'idlwave-toolbar
)
974 ;; arch-tag: ec9a3717-c44c-4716-9bda-cdacbe5ddb62
975 ;;; idlw-toolbar.el ends here