1 ;;; idlw-toolbar.el --- a debugging toolbar for IDLWAVE
3 ;; Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008
4 ;; Free Software Foundation, Inc.
6 ;; Author: Carsten Dominik <dominik@astro.uva.nl>
7 ;; Maintainer: J.D. Smith <jdsmith@as.arizona.edu>
11 ;; This file is part of GNU Emacs.
13 ;; GNU Emacs is free software; you can redistribute it and/or modify
14 ;; it under the terms of the GNU General Public License as published by
15 ;; the Free Software Foundation; either version 3, or (at your option)
18 ;; GNU Emacs is distributed in the hope that it will be useful,
19 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
20 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 ;; GNU General Public License for more details.
23 ;; You should have received a copy of the GNU General Public License
24 ;; along with GNU Emacs; see the file COPYING. If not, write to the
25 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
26 ;; Boston, MA 02110-1301, USA.
30 ;; This file implements a debugging toolbar for IDLWAVE. It requires
31 ;; Emacs or XEmacs with toolbar and xpm support.
33 ;; New versions of IDLWAVE, documentation, and more information
40 (eval-when-compile (require 'cl
))
42 (defun idlwave-toolbar-make-button (image)
43 (if (featurep 'xemacs
)
44 (toolbar-make-button-list image
)
45 (list 'image
:type
'xpm
:data image
)))
47 (defvar idlwave-toolbar
)
48 (defvar default-toolbar
)
49 (defvar idlwave-toolbar-is-possible
)
51 (if (not (or (and (featurep 'xemacs
) ; This is XEmacs
52 (featurep 'xpm
) ; need xpm
53 (featurep 'toolbar
)) ; ... and the toolbar
54 (and (not (featurep 'xemacs
)) ; This is Emacs
55 (boundp 'tool-bar-button-margin
) ; need toolbar
56 (fboundp 'image-type-available-p
) ; need image stuff
57 (image-type-available-p 'xpm
)) ; need xpm
59 ;; oops - cannot do the toolbar
60 (message "Sorry, IDLWAVE xpm toolbar cannot be used on this version of Emacs")
61 ;; OK, we can define a toolbar
63 (defconst idlwave-toolbar-is-possible t
64 "When defined, indicates that a toolbar is possible with this Emacs.")
65 (defvar idlwave-toolbar-compile-icon
66 (idlwave-toolbar-make-button
68 static char * file[] = {
70 \" c None s backgroundToolBarColor\",
71 \". c #000000000000\",
80 \" ................... \",
81 \" ........ ........ \",
84 \" ..... .. ... ..... \",
85 \" ...... .. .. ...... \",
86 \" ..... ... .. ..... \",
89 \" ........ ........ \",
90 \" ................... \",
102 (defvar idlwave-toolbar-next-error-icon
103 (idlwave-toolbar-make-button
105 static char * file[] = {
107 \" c None s backgroundToolBarColor\",
108 \". c #000000000000\",
109 \"R c #FFFF00000000\",
117 \" RRRRRRRRRRRRRRRRRRR \",
124 \" ..... .. ... ..... \",
125 \" ...... .. .. ...... \",
126 \" ..... ... .. ..... \",
127 \" ......... .... \",
128 \" ........ ..... \",
129 \" ........ ........ \",
130 \" ................... \",
138 "The Next Error icon.")
140 (defvar idlwave-toolbar-stop-at-icon
141 (idlwave-toolbar-make-button
143 static char * file[] = {
145 \" c None s backgroundToolBarColor\",
146 \". c #000000000000\",
147 \"R c #FFFF00000000\",
155 \" .RRRRRRRRRRRR. \",
156 \" .RRRRRRRRRRRRRR. \",
157 \" .RRRRRRRRRRRRRRRR. \",
158 \" .RRRRRRRRRRRRRRRRRR. \",
159 \" .RRRRRRRRRRRRRRRRRR. \",
160 \" .RRRRRRRRRRRRRRRRRR. \",
161 \" .RRRRRRRRRRRRRRRRRR. \",
162 \" .RRRRRRRRRRRRRRRRRR. \",
163 \" .RRRRRRRRRRRRRRRRRR. \",
164 \" .RRRRRRRRRRRRRRRRRR. \",
165 \" .RRRRRRRRRRRRRRRRRR. \",
166 \" .RRRRRRRRRRRRRRRR. \",
167 \" .RRRRRRRRRRRRRR. \",
168 \" .RRRRRRRRRRRR. \",
179 (defvar idlwave-toolbar-clear-at-icon
180 (idlwave-toolbar-make-button
182 static char * file[] = {
184 \" c None s backgroundToolBarColor\",
185 \". c #000000000000\",
186 \"R c #FFFF00000000\",
191 \" ... ........ ... \",
192 \" ... .RRRRRRRR. ... \",
193 \" ....RRRRRRRRRR.... \",
194 \" ...RRRRRRRRRR... \",
195 \" ....RRRRRRRR.... \",
196 \" .RR...RRRRRR...RR. \",
197 \" .RRRR...RRRR...RRRR. \",
198 \" .RRRRR...RR...RRRRR. \",
199 \" .RRRRRR......RRRRRR. \",
200 \" .RRRRRRR....RRRRRRR. \",
201 \" .RRRRRRR....RRRRRRR. \",
202 \" .RRRRRR......RRRRRR. \",
203 \" .RRRRR...RR...RRRRR. \",
204 \" .RRRR...RRRR...RRRR. \",
205 \" .RR...RRRRRR...RR. \",
206 \" ....RRRRRRRR.... \",
207 \" ...RRRRRRRRRR... \",
208 \" ....RRRRRRRRRR.... \",
209 \" ... .RRRRRRRR. ... \",
210 \" ... ........ ... \",
215 "The Clear At icon.")
217 (defvar idlwave-toolbar-clear-all-icon
218 (idlwave-toolbar-make-button
220 static char * file[] = {
222 \" c None s backgroundToolBarColor\",
223 \". c #000000000000\",
224 \"X c #FFFFFFFFFFFF\",
225 \"R c #FFFF00000000\",
229 \" .. .... .... .. \",
230 \" ...RRRR. .RRRR... \",
231 \" ...RRRR. .RRRR... \",
232 \" .R...RRRR. .RRRR...R. \",
233 \" .RR...RRR. .RRR...RR. \",
234 \" .RRR...RR. .RR...RRR. \",
235 \" .RRRR...R. .R...RRRR. \",
236 \" .RRRR... ...RRRR. \",
237 \" .RRRR... ...RRRR. \",
238 \" .... ... ... .... \",
241 \" .... ..... .... \",
242 \" .RRRR.... ....RRRR. \",
243 \" .RRRRR... ...RRRRR. \",
244 \" .RRRRR.... ....RRRRR. \",
245 \" .RRRR...R. .R...RRRR. \",
246 \" .RRR...RR. .RR...RRR. \",
247 \" .RR...RRR. .RRR...RR. \",
248 \" ....RRR. .RRR.... \",
249 \" ...RRR. .RRR... \",
250 \" ....... ....... \",
254 "The Clear-All icon.")
256 (defvar idlwave-toolbar-stop-beginning-icon
257 (idlwave-toolbar-make-button
259 static char * file[] = {
261 \" c None s backgroundToolBarColor\",
262 \". c #000000000000\",
263 \"X c #FFFF00000000\",
264 \"_ c #FFFFFFFFFFFF\",
272 \" .XXXXXXXXXXXX. \",
273 \" .XX..XXXXXXXXXX. \",
274 \" .XX.XX.X______XXX. \",
275 \" .XXX.XX.X______XXXX. \",
276 \" .XXXX..XXXXXXXXXXXX. \",
277 \" .XXXXXXXXXX____XXXX. \",
278 \" .XXXXXXXXXX____XXXX. \",
279 \" .XXXXXXXXXXXXXXXXXX. \",
280 \" .XXXXXXXXXX____XXXX. \",
281 \" .XXXXXXXXXX____XXXX. \",
282 \" .XXXXXXXXXXXXXXXXXX. \",
283 \" .XXXXXXXXX____XXX. \",
284 \" .XXXXXXXX____XX. \",
285 \" .XXXXXXXXXXXX. \",
293 "The Stop at Beginning icon.")
295 (defvar idlwave-toolbar-stop-in-icon
296 (idlwave-toolbar-make-button
298 static char * file[] = {
300 \" c None s backgroundToolBarColor\",
301 \"_ c #FFFFFFFFFFFF\",
302 \". c #000000000000\",
303 \"R c #FFFF00000000\",
311 \" .RRRRRRRRRRRR. \",
312 \" .RRR___RR___RRR. \",
313 \" .RRRR__RRRR__RRRR. \",
314 \" .RRRRR__RRRR__RRRRR. \",
315 \" .RRRRR__RRRR__RRRRR. \",
316 \" .RRRRR__RRRR__RRRRR. \",
317 \" .RRRR__RRRRRR__RRRR. \",
318 \" .RRRRR__RRRR__RRRRR. \",
319 \" .RRRRR__RRRR__RRRRR. \",
320 \" .RRRRR__RRRR__RRRRR. \",
321 \" .RRRRR__RRRR__RRRRR. \",
322 \" .RRRR___RR___RRRR. \",
323 \" .RRRRRRRRRRRRRR. \",
324 \" .RRRRRRRRRRRR. \",
334 (defvar idlwave-toolbar-edit-cmd-icon
335 (idlwave-toolbar-make-button
337 static char * file[] = {
339 \" c None s backgroundToolBarColor\",
340 \". c #000000000000\",
359 \" ................. \",
371 (defvar idlwave-toolbar-run-icon
372 (idlwave-toolbar-make-button
374 static char * file[] = {
376 \" c None s backgroundToolBarColor\",
377 \". s FgColor c #000000000000\",
378 \"G c #0000BBBB0000\",
392 \" .GGGGGGG. ....... \",
409 (defvar idlwave-toolbar-cont-icon
410 (idlwave-toolbar-make-button
412 static char * file[] = {
414 \" c None s backgroundToolBarColor\",
415 \". s FgColor c #000000000000\",
416 \"G c #0000BBBB0000\",
423 \" .GGGGGG. ....... \",
432 \" .GGGGGGG. ....... \",
447 (defvar idlwave-toolbar-to-here-icon
448 (idlwave-toolbar-make-button
450 static char * file[] = {
452 \" c None s backgroundToolBarColor\",
453 \". c #000000000000\",
454 \"G c #0000BBBB0000\",
455 \"R c #FFFF00000000\",
462 \" ..... ........ \",
465 \" .GG.... ........ \",
469 \" .GG. .G. ...... \",
471 \" .GGGGGGGG. RRRRRR \",
472 \" .GGGGGGGGG. RRRRRR \",
473 \" .GGGGGGG. RRRRRR \",
484 "The Cont-to-here icon.")
486 (defvar idlwave-toolbar-step-over-icon
487 (idlwave-toolbar-make-button
489 static char * file[] = {
491 \" c None s backgroundToolBarColor\",
492 \". c #000000000000\",
493 \"G c #0000BBBB0000\",
501 \" .GGGG. ....... \",
507 \" .GG. .G. ....... \",
510 \" .GGGGGGGGG. ....... \",
522 "The Step Over icon.")
524 (defvar idlwave-toolbar-step-into-icon
525 (idlwave-toolbar-make-button
527 static char * file[] = {
529 \" c None s backgroundToolBarColor\",
530 \". c #000000000000\",
531 \"G c #0000BBBB0000\",
541 \" .GG.... ........ \",
546 \" .GG...GG. ....... \",
549 \" .GGGGGGG. ....... \",
560 "The Step Into icon.")
562 (defvar idlwave-toolbar-step-out-icon
563 (idlwave-toolbar-make-button
565 static char * file[] = {
567 \" c None s backgroundToolBarColor\",
568 \". c #000000000000\",
569 \"G c #0000BBBB0000\",
580 \" .GGGGGGG. ........ \",
583 \" .GG...GG. ........ \",
588 \" .GG....... ....... \",
591 \" ........ ....... \",
601 (defvar idlwave-toolbar-eval-icon
602 (idlwave-toolbar-make-button
604 static char * file[] = {
606 \" c None s backgroundToolBarColor\",
607 \". c #000000000000\",
636 "The Evaluate icon.")
638 (defvar idlwave-toolbar-stack-up-icon
639 (idlwave-toolbar-make-button
641 static char * file[] = {
643 \" c None s backgroundToolBarColor\",
644 \". s FgColor c #000000000000\",
645 \"_ c #FFFFFFFFFFFF\",
646 \"G c #0000BBBB0000\",
647 \"R c #FFFF00000000\",
655 \" .______. ..... \",
656 \" .______. ....... \",
676 "The Stack Up icon.")
678 (defvar idlwave-toolbar-stack-down-icon
679 (idlwave-toolbar-make-button
681 static char * file[] = {
683 \" c None s backgroundToolBarColor\",
684 \". s FgColor c #000000000000\",
685 \"_ c #FFFFFFFFFFFF\",
686 \"G c #0000BBBB0000\",
687 \"R c #FFFF00000000\",
708 \" .RRRRRR. ....... \",
709 \" .RRRRRR. ..... \",
716 "The Stack Down icon.")
718 (defvar idlwave-toolbar-reset-icon
719 (idlwave-toolbar-make-button
721 static char * file[] = {
723 \" c None s backgroundToolBarColor\",
724 \"G c #0000BBBB0000\",
725 \". c #000000000000\",
756 (defvar idlwave-toolbar-electric-debug-icon
757 (idlwave-toolbar-make-button
759 static char * file[] = {
761 \" c None s backgroundToolBarColor\",
782 \" .++ %%%%%%%%%%% \",
783 \" ++$$ %%%%%%%%%%% \",
784 \" .+@# &&%%%%%%%&& \",
785 \" .++++# &&&&&%%%&&&&& \",
786 \" +++++$ &&%%&&&&&%%&& \",
787 \" $+++$ &&%%&&&&&%%&& \",
788 \" $++@ &&&&&&%&&&&&& \",
789 \" $+@ &&&&&&%&&&&&& \",
790 \" @+ &&%%&&&&&%%&& \",
791 \" ++. &%%&&%&&%%& \",
792 \" +. &&&&%%%&&&& \",
797 "The electric debug icon.")
799 (defvar idlwave-toolbar
801 [idlwave-toolbar-compile-icon
802 idlwave-shell-save-and-compile
804 "Save and Compile this file (or recompile last)"]
805 [idlwave-toolbar-next-error-icon
806 idlwave-shell-goto-next-error
809 [idlwave-toolbar-stop-at-icon
810 idlwave-shell-break-here
811 (eq major-mode
'idlwave-mode
)
812 "Set Breakpoint at selected position"]
813 [idlwave-toolbar-clear-at-icon
814 idlwave-shell-clear-current-bp
816 "Clear Breakpoint at selected position"]
817 [idlwave-toolbar-clear-all-icon
818 idlwave-shell-clear-all-bp
820 "Clear all Breakpoints"]
821 [idlwave-toolbar-stop-beginning-icon
822 idlwave-shell-break-this-module
823 (eq major-mode
'idlwave-mode
)
824 "Stop at beginning of enclosing Routine"]
825 [idlwave-toolbar-stop-in-icon
826 idlwave-shell-break-in
828 "Stop in Routine with name near point"]
829 [idlwave-toolbar-edit-cmd-icon
830 idlwave-shell-edit-default-command-line
832 "Edit Default Command Line"]
833 [idlwave-toolbar-run-icon
834 idlwave-shell-execute-default-command-line
836 "Reset, then Execute Default Command Line"]
837 [idlwave-toolbar-cont-icon
840 "Continue Current Program"]
841 [idlwave-toolbar-to-here-icon
842 idlwave-shell-to-here
843 (eq major-mode
'idlwave-mode
)
844 "Continue to Here (cursor position)"]
845 [idlwave-toolbar-step-over-icon
846 idlwave-shell-stepover
848 "Step Over (aka next)"]
849 [idlwave-toolbar-step-into-icon
852 "Step Into (aka step)"]
853 [idlwave-toolbar-step-out-icon
856 "Step Out (of subroutine)"]
857 [idlwave-toolbar-eval-icon
860 "Print Expression at or before Point"]
861 [idlwave-toolbar-stack-up-icon
862 idlwave-shell-stack-up
864 "Stack Up (towards \"cooler\" - less recently visited - frames)"]
865 [idlwave-toolbar-stack-down-icon
866 idlwave-shell-stack-down
868 "Stack Down (towards \"warmer\" - more recently visited - frames)"]
869 [idlwave-toolbar-reset-icon
872 "Reset IDL (RETALL & CLOSE,/ALL and more)"]
873 [idlwave-toolbar-electric-debug-icon
874 idlwave-shell-electric-debug-mode
875 (eq major-mode
'idlwave-mode
)
876 "Toggle Electric Debug Mode"]
879 ;; When the shell exits, arrange to remove the special toolbar everywhere.
880 (add-hook 'idlwave-shell-cleanup-hook
881 'idlwave-toolbar-remove-everywhere
)
882 );; End can define toolbar
884 (defun idlwave-toolbar-add ()
885 "Add the IDLWAVE toolbar if appropriate."
886 (if (and (featurep 'xemacs
) ; This is a noop on Emacs
887 (boundp 'idlwave-toolbar-is-possible
)
888 (or (eq major-mode
'idlwave-mode
)
889 (eq major-mode
'idlwave-shell-mode
)))
890 (set-specifier default-toolbar
(cons (current-buffer)
893 (defun idlwave-toolbar-remove ()
894 "Add the IDLWAVE toolbar if appropriate."
895 (if (and (featurep 'xemacs
) ; This is a noop on Emacs
896 (boundp 'idlwave-toolbar-is-possible
)
897 (or (eq major-mode
'idlwave-mode
)
898 (eq major-mode
'idlwave-shell-mode
)))
899 (remove-specifier default-toolbar
(current-buffer))))
901 (defvar idlwave-shell-mode-map
)
902 (defvar idlwave-mode-map
)
903 (defvar idlwave-toolbar-visible nil
)
904 (defun idlwave-toolbar-add-everywhere ()
905 "Add the toolbar in all appropriate buffers."
906 (when (boundp 'idlwave-toolbar-is-possible
)
908 ;; First make sure new buffers will get the toolbar
909 (add-hook 'idlwave-mode-hook
'idlwave-toolbar-add
)
910 ;; Then add it to all existing buffers
911 (if (featurep 'xemacs
)
912 ;; For XEmacs, map over all buffers to add toolbar
914 (mapcar (lambda (buf)
916 (idlwave-toolbar-add))
918 ;; For Emacs, add the key definitions to the mode maps
920 (let* ((icon (aref x
0))
924 (key (vector 'tool-bar func
))
925 (def (list 'menu-item
928 :image
(symbol-value icon
)
931 (define-key idlwave-mode-map key def
)
932 (define-key idlwave-shell-mode-map key def
)))
933 (reverse idlwave-toolbar
)))
934 (setq idlwave-toolbar-visible t
)))
936 (defun idlwave-toolbar-remove-everywhere ()
937 "Remove the toolbar in all appropriate buffers."
938 ;; First make sure new buffers won't get the toolbar
939 (when idlwave-toolbar-is-possible
940 (remove-hook 'idlwave-mode-hook
'idlwave-toolbar-add
)
941 ;; Then remove it in all existing buffers.
942 (if (featurep 'xemacs
)
943 ;; For XEmacs, map over all buffers to remove toolbar
945 (mapcar (lambda (buf)
947 (idlwave-toolbar-remove))
949 ;; For Emacs, remove the key definitions from the mode maps
951 (let* (;;(icon (aref x 0))
955 (key (vector 'tool-bar func
)))
956 (define-key idlwave-mode-map key nil
)
957 (define-key idlwave-shell-mode-map key nil
)))
959 (setq idlwave-toolbar-visible nil
)))
961 (defun idlwave-toolbar-toggle (&optional force-on
)
963 (if idlwave-toolbar-visible
964 (or force-on
(idlwave-toolbar-remove-everywhere))
965 (idlwave-toolbar-add-everywhere))
966 ;; Now make sure this
967 (if (featurep 'xemacs
)
968 nil
; no action necessary, toolbar gets updated automatically
969 ;; On Emacs, redraw the frame to make sure the Toolbar is updated.
970 (redraw-frame (selected-frame))))
972 (provide 'idlw-toolbar
)
973 (provide 'idlwave-toolbar
)
975 ;; arch-tag: ec9a3717-c44c-4716-9bda-cdacbe5ddb62
976 ;;; idlw-toolbar.el ends here