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>
7 ;; Date: $Date: 2003-08-12 12:26:18 $
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., 59 Temple Place - Suite 330,
25 ;; Boston, MA 02111-1307, 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 default-toolbar)
47 (if (not (or (and (featurep 'xemacs) ; This is XEmacs
48 (featurep 'xpm) ; need xpm
49 (featurep 'toolbar)) ; ... and the toolbar
50 (and (not (featurep 'xemacs)) ; This is Emacs
51 (boundp 'tool-bar-button-margin) ; need toolbar
52 (fboundp 'image-type-available-p) ; need image stuff
53 (image-type-available-p 'xpm)) ; need xpm
55 ;; oops - cannot do the toolbar
56 (message "Sorry, IDLWAVE xpm toolbar cannot be used on this version of Emacs")
57 ;; OK, we can define a toolbar
59 (defconst idlwave-toolbar-is-possible t
60 "When defined, indicates that a toolbar is possible with this Emacs.")
61 (defvar idlwave-toolbar-compile-icon
62 (idlwave-toolbar-make-button
64 static char * file[] = {
66 \" c None s backgroundToolBarColor\",
67 \". c #000000000000\",
76 \" ................... \",
77 \" ........ ........ \",
80 \" ..... .. ... ..... \",
81 \" ...... .. .. ...... \",
82 \" ..... ... .. ..... \",
85 \" ........ ........ \",
86 \" ................... \",
98 (defvar idlwave-toolbar-next-error-icon
99 (idlwave-toolbar-make-button
101 static char * file[] = {
103 \" c None s backgroundToolBarColor\",
104 \". c #000000000000\",
105 \"R c #FFFF00000000\",
113 \" RRRRRRRRRRRRRRRRRRR \",
120 \" ..... .. ... ..... \",
121 \" ...... .. .. ...... \",
122 \" ..... ... .. ..... \",
123 \" ......... .... \",
124 \" ........ ..... \",
125 \" ........ ........ \",
126 \" ................... \",
134 "The Next Error icon.")
136 (defvar idlwave-toolbar-stop-at-icon
137 (idlwave-toolbar-make-button
139 static char * file[] = {
141 \" c None s backgroundToolBarColor\",
142 \". c #000000000000\",
143 \"R c #FFFF00000000\",
151 \" .RRRRRRRRRRRR. \",
152 \" .RRRRRRRRRRRRRR. \",
153 \" .RRRRRRRRRRRRRRRR. \",
154 \" .RRRRRRRRRRRRRRRRRR. \",
155 \" .RRRRRRRRRRRRRRRRRR. \",
156 \" .RRRRRRRRRRRRRRRRRR. \",
157 \" .RRRRRRRRRRRRRRRRRR. \",
158 \" .RRRRRRRRRRRRRRRRRR. \",
159 \" .RRRRRRRRRRRRRRRRRR. \",
160 \" .RRRRRRRRRRRRRRRRRR. \",
161 \" .RRRRRRRRRRRRRRRRRR. \",
162 \" .RRRRRRRRRRRRRRRR. \",
163 \" .RRRRRRRRRRRRRR. \",
164 \" .RRRRRRRRRRRR. \",
175 (defvar idlwave-toolbar-clear-at-icon
176 (idlwave-toolbar-make-button
178 static char * file[] = {
180 \" c None s backgroundToolBarColor\",
181 \". c #000000000000\",
182 \"R c #FFFF00000000\",
187 \" ... ........ ... \",
188 \" ... .RRRRRRRR. ... \",
189 \" ....RRRRRRRRRR.... \",
190 \" ...RRRRRRRRRR... \",
191 \" ....RRRRRRRR.... \",
192 \" .RR...RRRRRR...RR. \",
193 \" .RRRR...RRRR...RRRR. \",
194 \" .RRRRR...RR...RRRRR. \",
195 \" .RRRRRR......RRRRRR. \",
196 \" .RRRRRRR....RRRRRRR. \",
197 \" .RRRRRRR....RRRRRRR. \",
198 \" .RRRRRR......RRRRRR. \",
199 \" .RRRRR...RR...RRRRR. \",
200 \" .RRRR...RRRR...RRRR. \",
201 \" .RR...RRRRRR...RR. \",
202 \" ....RRRRRRRR.... \",
203 \" ...RRRRRRRRRR... \",
204 \" ....RRRRRRRRRR.... \",
205 \" ... .RRRRRRRR. ... \",
206 \" ... ........ ... \",
211 "The Clear At icon.")
213 (defvar idlwave-toolbar-clear-all-icon
214 (idlwave-toolbar-make-button
216 static char * file[] = {
218 \" c None s backgroundToolBarColor\",
219 \". c #000000000000\",
220 \"X c #FFFFFFFFFFFF\",
221 \"R c #FFFF00000000\",
225 \" .. .... .... .. \",
226 \" ...RRRR. .RRRR... \",
227 \" ...RRRR. .RRRR... \",
228 \" .R...RRRR. .RRRR...R. \",
229 \" .RR...RRR. .RRR...RR. \",
230 \" .RRR...RR. .RR...RRR. \",
231 \" .RRRR...R. .R...RRRR. \",
232 \" .RRRR... ...RRRR. \",
233 \" .RRRR... ...RRRR. \",
234 \" .... ... ... .... \",
237 \" .... ..... .... \",
238 \" .RRRR.... ....RRRR. \",
239 \" .RRRRR... ...RRRRR. \",
240 \" .RRRRR.... ....RRRRR. \",
241 \" .RRRR...R. .R...RRRR. \",
242 \" .RRR...RR. .RR...RRR. \",
243 \" .RR...RRR. .RRR...RR. \",
244 \" ....RRR. .RRR.... \",
245 \" ...RRR. .RRR... \",
246 \" ....... ....... \",
250 "The Clear-All icon.")
252 (defvar idlwave-toolbar-stop-beginning-icon
253 (idlwave-toolbar-make-button
255 static char * file[] = {
257 \" c None s backgroundToolBarColor\",
258 \". c #000000000000\",
259 \"X c #FFFF00000000\",
260 \"_ c #FFFFFFFFFFFF\",
268 \" .XXXXXXXXXXXX. \",
269 \" .XX..XXXXXXXXXX. \",
270 \" .XX.XX.X______XXX. \",
271 \" .XXX.XX.X______XXXX. \",
272 \" .XXXX..XXXXXXXXXXXX. \",
273 \" .XXXXXXXXXX____XXXX. \",
274 \" .XXXXXXXXXX____XXXX. \",
275 \" .XXXXXXXXXXXXXXXXXX. \",
276 \" .XXXXXXXXXX____XXXX. \",
277 \" .XXXXXXXXXX____XXXX. \",
278 \" .XXXXXXXXXXXXXXXXXX. \",
279 \" .XXXXXXXXX____XXX. \",
280 \" .XXXXXXXX____XX. \",
281 \" .XXXXXXXXXXXX. \",
289 "The Stop at Beginning icon.")
291 (defvar idlwave-toolbar-stop-in-icon
292 (idlwave-toolbar-make-button
294 static char * file[] = {
296 \" c None s backgroundToolBarColor\",
297 \"_ c #FFFFFFFFFFFF\",
298 \". c #000000000000\",
299 \"R c #FFFF00000000\",
307 \" .RRRRRRRRRRRR. \",
308 \" .RRR___RR___RRR. \",
309 \" .RRRR__RRRR__RRRR. \",
310 \" .RRRRR__RRRR__RRRRR. \",
311 \" .RRRRR__RRRR__RRRRR. \",
312 \" .RRRRR__RRRR__RRRRR. \",
313 \" .RRRR__RRRRRR__RRRR. \",
314 \" .RRRRR__RRRR__RRRRR. \",
315 \" .RRRRR__RRRR__RRRRR. \",
316 \" .RRRRR__RRRR__RRRRR. \",
317 \" .RRRRR__RRRR__RRRRR. \",
318 \" .RRRR___RR___RRRR. \",
319 \" .RRRRRRRRRRRRRR. \",
320 \" .RRRRRRRRRRRR. \",
330 (defvar idlwave-toolbar-edit-cmd-icon
331 (idlwave-toolbar-make-button
333 static char * file[] = {
335 \" c None s backgroundToolBarColor\",
336 \". c #000000000000\",
355 \" ................. \",
367 (defvar idlwave-toolbar-run-icon
368 (idlwave-toolbar-make-button
370 static char * file[] = {
372 \" c None s backgroundToolBarColor\",
373 \". s FgColor c #000000000000\",
374 \"G c #0000BBBB0000\",
388 \" .GGGGGGG. ....... \",
405 (defvar idlwave-toolbar-cont-icon
406 (idlwave-toolbar-make-button
408 static char * file[] = {
410 \" c None s backgroundToolBarColor\",
411 \". s FgColor c #000000000000\",
412 \"G c #0000BBBB0000\",
419 \" .GGGGGG. ....... \",
428 \" .GGGGGGG. ....... \",
443 (defvar idlwave-toolbar-to-here-icon
444 (idlwave-toolbar-make-button
446 static char * file[] = {
448 \" c None s backgroundToolBarColor\",
449 \". c #000000000000\",
450 \"G c #0000BBBB0000\",
451 \"R c #FFFF00000000\",
458 \" ..... ........ \",
461 \" .GG.... ........ \",
465 \" .GG. .G. ...... \",
467 \" .GGGGGGGG. RRRRRR \",
468 \" .GGGGGGGGG. RRRRRR \",
469 \" .GGGGGGG. RRRRRR \",
480 "The Cont-to-here icon.")
482 (defvar idlwave-toolbar-step-over-icon
483 (idlwave-toolbar-make-button
485 static char * file[] = {
487 \" c None s backgroundToolBarColor\",
488 \". c #000000000000\",
489 \"G c #0000BBBB0000\",
497 \" .GGGG. ....... \",
503 \" .GG. .G. ....... \",
506 \" .GGGGGGGGG. ....... \",
518 "The Step Over icon.")
520 (defvar idlwave-toolbar-step-into-icon
521 (idlwave-toolbar-make-button
523 static char * file[] = {
525 \" c None s backgroundToolBarColor\",
526 \". c #000000000000\",
527 \"G c #0000BBBB0000\",
537 \" .GG.... ........ \",
542 \" .GG...GG. ....... \",
545 \" .GGGGGGG. ....... \",
556 "The Step Into icon.")
558 (defvar idlwave-toolbar-step-out-icon
559 (idlwave-toolbar-make-button
561 static char * file[] = {
563 \" c None s backgroundToolBarColor\",
564 \". c #000000000000\",
565 \"G c #0000BBBB0000\",
576 \" .GGGGGGG. ........ \",
579 \" .GG...GG. ........ \",
584 \" .GG....... ....... \",
587 \" ........ ....... \",
597 (defvar idlwave-toolbar-eval-icon
598 (idlwave-toolbar-make-button
600 static char * file[] = {
602 \" c None s backgroundToolBarColor\",
603 \". c #000000000000\",
632 "The Evaluate icon.")
634 (defvar idlwave-toolbar-stack-up-icon
635 (idlwave-toolbar-make-button
637 static char * file[] = {
639 \" c None s backgroundToolBarColor\",
640 \". s FgColor c #000000000000\",
641 \"_ c #FFFFFFFFFFFF\",
642 \"G c #0000BBBB0000\",
643 \"R c #FFFF00000000\",
651 \" .______. ..... \",
652 \" .______. ....... \",
672 "The Stack Up icon.")
674 (defvar idlwave-toolbar-stack-down-icon
675 (idlwave-toolbar-make-button
677 static char * file[] = {
679 \" c None s backgroundToolBarColor\",
680 \". s FgColor c #000000000000\",
681 \"_ c #FFFFFFFFFFFF\",
682 \"G c #0000BBBB0000\",
683 \"R c #FFFF00000000\",
704 \" .RRRRRR. ....... \",
705 \" .RRRRRR. ..... \",
712 "The Stack Down icon.")
714 (defvar idlwave-toolbar-reset-icon
715 (idlwave-toolbar-make-button
717 static char * file[] = {
719 \" c None s backgroundToolBarColor\",
720 \"G c #0000BBBB0000\",
721 \". c #000000000000\",
752 (defvar idlwave-toolbar-electric-debug-icon
753 (idlwave-toolbar-make-button
755 static char * file[] = {
757 \" c None s backgroundToolBarColor\",
778 \" .++ %%%%%%%%%%% \",
779 \" ++$$ %%%%%%%%%%% \",
780 \" .+@# &&%%%%%%%&& \",
781 \" .++++# &&&&&%%%&&&&& \",
782 \" +++++$ &&%%&&&&&%%&& \",
783 \" $+++$ &&%%&&&&&%%&& \",
784 \" $++@ &&&&&&%&&&&&& \",
785 \" $+@ &&&&&&%&&&&&& \",
786 \" @+ &&%%&&&&&%%&& \",
787 \" ++. &%%&&%&&%%& \",
788 \" +. &&&&%%%&&&& \",
793 "The electric debug icon.")
795 (defvar idlwave-toolbar
797 [idlwave-toolbar-compile-icon
798 idlwave-shell-save-and-compile
800 "Save and Compile this file (or recompile last)"]
801 [idlwave-toolbar-next-error-icon
802 idlwave-shell-goto-next-error
805 [idlwave-toolbar-stop-at-icon
806 idlwave-shell-break-here
807 (eq major-mode 'idlwave-mode)
808 "Set Breakpoint at selected position"]
809 [idlwave-toolbar-clear-at-icon
810 idlwave-shell-clear-current-bp
812 "Clear Breakpoint at selected position"]
813 [idlwave-toolbar-clear-all-icon
814 idlwave-shell-clear-all-bp
816 "Clear all Breakpoints"]
817 [idlwave-toolbar-stop-beginning-icon
818 idlwave-shell-break-this-module
819 (eq major-mode 'idlwave-mode)
820 "Stop at beginning of enclosing Routine"]
821 [idlwave-toolbar-stop-in-icon
822 idlwave-shell-break-in
824 "Stop in Routine with name near point"]
825 [idlwave-toolbar-edit-cmd-icon
826 idlwave-shell-edit-default-command-line
828 "Edit Default Command Line"]
829 [idlwave-toolbar-run-icon
830 idlwave-shell-execute-default-command-line
832 "Reset, then Execute Default Command Line"]
833 [idlwave-toolbar-cont-icon
836 "Continue Current Program"]
837 [idlwave-toolbar-to-here-icon
838 idlwave-shell-to-here
839 (eq major-mode 'idlwave-mode)
840 "Continue to Here (cursor position)"]
841 [idlwave-toolbar-step-over-icon
842 idlwave-shell-stepover
844 "Step Over (aka next)"]
845 [idlwave-toolbar-step-into-icon
848 "Step Into (aka step)"]
849 [idlwave-toolbar-step-out-icon
852 "Step Out (of subroutine)"]
853 [idlwave-toolbar-eval-icon
856 "Print Expression at or before Point"]
857 [idlwave-toolbar-stack-up-icon
858 idlwave-shell-stack-up
860 "Stack Up (towards \"cooler\" - less recently visited - frames)"]
861 [idlwave-toolbar-stack-down-icon
862 idlwave-shell-stack-down
864 "Stack Down (towards \"warmer\" - more recently visited - frames)"]
865 [idlwave-toolbar-reset-icon
868 "Reset IDL (RETALL & CLOSE,/ALL and more)"]
869 [idlwave-toolbar-electric-debug-icon
870 idlwave-shell-electric-debug-mode
871 (eq major-mode 'idlwave-mode)
872 "Toggle Electric Debug Mode"]
875 ;; When the shell exits, arrange to remove the special toolbar everywhere.
876 (add-hook 'idlwave-shell-cleanup-hook
877 'idlwave-toolbar-remove-everywhere)
878 );; End can define toolbar
880 (defun idlwave-toolbar-add ()
881 "Add the IDLWAVE toolbar if appropriate."
882 (if (and (featurep 'xemacs) ; This is a noop on Emacs
883 (boundp 'idlwave-toolbar-is-possible)
884 (or (eq major-mode 'idlwave-mode)
885 (eq major-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 (or (eq major-mode 'idlwave-mode)
894 (eq major-mode 'idlwave-shell-mode)))
895 (remove-specifier default-toolbar (current-buffer))))
897 (defvar idlwave-shell-mode-map)
898 (defvar idlwave-mode-map)
899 (defvar idlwave-toolbar-visible nil)
900 (defun idlwave-toolbar-add-everywhere ()
901 "Add the toolbar in all appropriate buffers."
902 (when (boundp 'idlwave-toolbar-is-possible)
904 ;; First make sure new buffers will get the toolbar
905 (add-hook 'idlwave-mode-hook 'idlwave-toolbar-add)
906 ;; Then add it to all existing buffers
907 (if (featurep 'xemacs)
908 ;; For XEmacs, map over all buffers to add toolbar
910 (mapcar (lambda (buf)
912 (idlwave-toolbar-add))
914 ;; For Emacs, add the key definitions to the mode maps
916 (let* ((icon (aref x 0))
920 (key (vector 'tool-bar func))
921 (def (list 'menu-item
924 :image (symbol-value icon)
927 (define-key idlwave-mode-map key def)
928 (define-key idlwave-shell-mode-map key def)))
929 (reverse idlwave-toolbar)))
930 (setq idlwave-toolbar-visible t)))
932 (defun idlwave-toolbar-remove-everywhere ()
933 "Remove the toolbar in all appropriate buffers."
934 ;; First make sure new buffers won't get the toolbar
935 (when idlwave-toolbar-is-possible
936 (remove-hook 'idlwave-mode-hook 'idlwave-toolbar-add)
937 ;; Then remove it in all existing buffers.
938 (if (featurep 'xemacs)
939 ;; For XEmacs, map over all buffers to remove toolbar
941 (mapcar (lambda (buf)
943 (idlwave-toolbar-remove))
945 ;; For Emacs, remove the key definitions from the mode maps
947 (let* (;;(icon (aref x 0))
951 (key (vector 'tool-bar func)))
952 (define-key idlwave-mode-map key nil)
953 (define-key idlwave-shell-mode-map key nil)))
955 (setq idlwave-toolbar-visible nil)))
957 (defun idlwave-toolbar-toggle (&optional force-on)
959 (if idlwave-toolbar-visible
960 (or force-on (idlwave-toolbar-remove-everywhere))
961 (idlwave-toolbar-add-everywhere))
962 ;; Now make sure this
963 (if (featurep 'xemacs)
964 nil ; no action necessary, toolbar gets updated automatically
965 ;; On Emacs, redraw the frame to make sure the Toolbar is updated.
966 (redraw-frame (selected-frame))))
968 (provide 'idlw-toolbar)
969 (provide 'idlwave-toolbar)
971 ;;; idlw-toolbar.el ends here