1 ;;; idlw-toolbar.el --- a debugging toolbar for IDLWAVE
3 ;; Copyright (C) 1999-2012 Free Software Foundation, Inc.
5 ;; Author: Carsten Dominik <dominik@astro.uva.nl>
6 ;; 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 of the License, or
16 ;; (at your option) any later version.
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. If not, see <http://www.gnu.org/licenses/>.
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 idlwave-toolbar
)
46 (defvar default-toolbar
)
47 (defvar idlwave-toolbar-is-possible
)
49 (if (not (or (and (featurep 'xemacs
) ; This is XEmacs
50 (featurep 'xpm
) ; need xpm
51 (featurep 'toolbar
)) ; ... and the toolbar
52 (and (not (featurep 'xemacs
)) ; This is Emacs
53 (boundp 'tool-bar-button-margin
) ; need toolbar
54 (fboundp 'image-type-available-p
) ; need image stuff
55 (image-type-available-p 'xpm
)) ; need xpm
57 ;; oops - cannot do the toolbar
58 (message "Sorry, IDLWAVE xpm toolbar cannot be used on this version of Emacs")
59 ;; OK, we can define a toolbar
61 (defconst idlwave-toolbar-is-possible t
62 "When defined, indicates that a toolbar is possible with this Emacs.")
63 (defvar idlwave-toolbar-compile-icon
64 (idlwave-toolbar-make-button
66 static char * file[] = {
68 \" c None s backgroundToolBarColor\",
69 \". c #000000000000\",
78 \" ................... \",
79 \" ........ ........ \",
82 \" ..... .. ... ..... \",
83 \" ...... .. .. ...... \",
84 \" ..... ... .. ..... \",
87 \" ........ ........ \",
88 \" ................... \",
100 (defvar idlwave-toolbar-next-error-icon
101 (idlwave-toolbar-make-button
103 static char * file[] = {
105 \" c None s backgroundToolBarColor\",
106 \". c #000000000000\",
107 \"R c #FFFF00000000\",
115 \" RRRRRRRRRRRRRRRRRRR \",
122 \" ..... .. ... ..... \",
123 \" ...... .. .. ...... \",
124 \" ..... ... .. ..... \",
125 \" ......... .... \",
126 \" ........ ..... \",
127 \" ........ ........ \",
128 \" ................... \",
136 "The Next Error icon.")
138 (defvar idlwave-toolbar-stop-at-icon
139 (idlwave-toolbar-make-button
141 static char * file[] = {
143 \" c None s backgroundToolBarColor\",
144 \". c #000000000000\",
145 \"R c #FFFF00000000\",
153 \" .RRRRRRRRRRRR. \",
154 \" .RRRRRRRRRRRRRR. \",
155 \" .RRRRRRRRRRRRRRRR. \",
156 \" .RRRRRRRRRRRRRRRRRR. \",
157 \" .RRRRRRRRRRRRRRRRRR. \",
158 \" .RRRRRRRRRRRRRRRRRR. \",
159 \" .RRRRRRRRRRRRRRRRRR. \",
160 \" .RRRRRRRRRRRRRRRRRR. \",
161 \" .RRRRRRRRRRRRRRRRRR. \",
162 \" .RRRRRRRRRRRRRRRRRR. \",
163 \" .RRRRRRRRRRRRRRRRRR. \",
164 \" .RRRRRRRRRRRRRRRR. \",
165 \" .RRRRRRRRRRRRRR. \",
166 \" .RRRRRRRRRRRR. \",
177 (defvar idlwave-toolbar-clear-at-icon
178 (idlwave-toolbar-make-button
180 static char * file[] = {
182 \" c None s backgroundToolBarColor\",
183 \". c #000000000000\",
184 \"R c #FFFF00000000\",
189 \" ... ........ ... \",
190 \" ... .RRRRRRRR. ... \",
191 \" ....RRRRRRRRRR.... \",
192 \" ...RRRRRRRRRR... \",
193 \" ....RRRRRRRR.... \",
194 \" .RR...RRRRRR...RR. \",
195 \" .RRRR...RRRR...RRRR. \",
196 \" .RRRRR...RR...RRRRR. \",
197 \" .RRRRRR......RRRRRR. \",
198 \" .RRRRRRR....RRRRRRR. \",
199 \" .RRRRRRR....RRRRRRR. \",
200 \" .RRRRRR......RRRRRR. \",
201 \" .RRRRR...RR...RRRRR. \",
202 \" .RRRR...RRRR...RRRR. \",
203 \" .RR...RRRRRR...RR. \",
204 \" ....RRRRRRRR.... \",
205 \" ...RRRRRRRRRR... \",
206 \" ....RRRRRRRRRR.... \",
207 \" ... .RRRRRRRR. ... \",
208 \" ... ........ ... \",
213 "The Clear At icon.")
215 (defvar idlwave-toolbar-clear-all-icon
216 (idlwave-toolbar-make-button
218 static char * file[] = {
220 \" c None s backgroundToolBarColor\",
221 \". c #000000000000\",
222 \"X c #FFFFFFFFFFFF\",
223 \"R c #FFFF00000000\",
227 \" .. .... .... .. \",
228 \" ...RRRR. .RRRR... \",
229 \" ...RRRR. .RRRR... \",
230 \" .R...RRRR. .RRRR...R. \",
231 \" .RR...RRR. .RRR...RR. \",
232 \" .RRR...RR. .RR...RRR. \",
233 \" .RRRR...R. .R...RRRR. \",
234 \" .RRRR... ...RRRR. \",
235 \" .RRRR... ...RRRR. \",
236 \" .... ... ... .... \",
239 \" .... ..... .... \",
240 \" .RRRR.... ....RRRR. \",
241 \" .RRRRR... ...RRRRR. \",
242 \" .RRRRR.... ....RRRRR. \",
243 \" .RRRR...R. .R...RRRR. \",
244 \" .RRR...RR. .RR...RRR. \",
245 \" .RR...RRR. .RRR...RR. \",
246 \" ....RRR. .RRR.... \",
247 \" ...RRR. .RRR... \",
248 \" ....... ....... \",
252 "The Clear-All icon.")
254 (defvar idlwave-toolbar-stop-beginning-icon
255 (idlwave-toolbar-make-button
257 static char * file[] = {
259 \" c None s backgroundToolBarColor\",
260 \". c #000000000000\",
261 \"X c #FFFF00000000\",
262 \"_ c #FFFFFFFFFFFF\",
270 \" .XXXXXXXXXXXX. \",
271 \" .XX..XXXXXXXXXX. \",
272 \" .XX.XX.X______XXX. \",
273 \" .XXX.XX.X______XXXX. \",
274 \" .XXXX..XXXXXXXXXXXX. \",
275 \" .XXXXXXXXXX____XXXX. \",
276 \" .XXXXXXXXXX____XXXX. \",
277 \" .XXXXXXXXXXXXXXXXXX. \",
278 \" .XXXXXXXXXX____XXXX. \",
279 \" .XXXXXXXXXX____XXXX. \",
280 \" .XXXXXXXXXXXXXXXXXX. \",
281 \" .XXXXXXXXX____XXX. \",
282 \" .XXXXXXXX____XX. \",
283 \" .XXXXXXXXXXXX. \",
291 "The Stop at Beginning icon.")
293 (defvar idlwave-toolbar-stop-in-icon
294 (idlwave-toolbar-make-button
296 static char * file[] = {
298 \" c None s backgroundToolBarColor\",
299 \"_ c #FFFFFFFFFFFF\",
300 \". c #000000000000\",
301 \"R c #FFFF00000000\",
309 \" .RRRRRRRRRRRR. \",
310 \" .RRR___RR___RRR. \",
311 \" .RRRR__RRRR__RRRR. \",
312 \" .RRRRR__RRRR__RRRRR. \",
313 \" .RRRRR__RRRR__RRRRR. \",
314 \" .RRRRR__RRRR__RRRRR. \",
315 \" .RRRR__RRRRRR__RRRR. \",
316 \" .RRRRR__RRRR__RRRRR. \",
317 \" .RRRRR__RRRR__RRRRR. \",
318 \" .RRRRR__RRRR__RRRRR. \",
319 \" .RRRRR__RRRR__RRRRR. \",
320 \" .RRRR___RR___RRRR. \",
321 \" .RRRRRRRRRRRRRR. \",
322 \" .RRRRRRRRRRRR. \",
332 (defvar idlwave-toolbar-edit-cmd-icon
333 (idlwave-toolbar-make-button
335 static char * file[] = {
337 \" c None s backgroundToolBarColor\",
338 \". c #000000000000\",
357 \" ................. \",
369 (defvar idlwave-toolbar-run-icon
370 (idlwave-toolbar-make-button
372 static char * file[] = {
374 \" c None s backgroundToolBarColor\",
375 \". s FgColor c #000000000000\",
376 \"G c #0000BBBB0000\",
390 \" .GGGGGGG. ....... \",
407 (defvar idlwave-toolbar-cont-icon
408 (idlwave-toolbar-make-button
410 static char * file[] = {
412 \" c None s backgroundToolBarColor\",
413 \". s FgColor c #000000000000\",
414 \"G c #0000BBBB0000\",
421 \" .GGGGGG. ....... \",
430 \" .GGGGGGG. ....... \",
445 (defvar idlwave-toolbar-to-here-icon
446 (idlwave-toolbar-make-button
448 static char * file[] = {
450 \" c None s backgroundToolBarColor\",
451 \". c #000000000000\",
452 \"G c #0000BBBB0000\",
453 \"R c #FFFF00000000\",
460 \" ..... ........ \",
463 \" .GG.... ........ \",
467 \" .GG. .G. ...... \",
469 \" .GGGGGGGG. RRRRRR \",
470 \" .GGGGGGGGG. RRRRRR \",
471 \" .GGGGGGG. RRRRRR \",
482 "The Cont-to-here icon.")
484 (defvar idlwave-toolbar-step-over-icon
485 (idlwave-toolbar-make-button
487 static char * file[] = {
489 \" c None s backgroundToolBarColor\",
490 \". c #000000000000\",
491 \"G c #0000BBBB0000\",
499 \" .GGGG. ....... \",
505 \" .GG. .G. ....... \",
508 \" .GGGGGGGGG. ....... \",
520 "The Step Over icon.")
522 (defvar idlwave-toolbar-step-into-icon
523 (idlwave-toolbar-make-button
525 static char * file[] = {
527 \" c None s backgroundToolBarColor\",
528 \". c #000000000000\",
529 \"G c #0000BBBB0000\",
539 \" .GG.... ........ \",
544 \" .GG...GG. ....... \",
547 \" .GGGGGGG. ....... \",
558 "The Step Into icon.")
560 (defvar idlwave-toolbar-step-out-icon
561 (idlwave-toolbar-make-button
563 static char * file[] = {
565 \" c None s backgroundToolBarColor\",
566 \". c #000000000000\",
567 \"G c #0000BBBB0000\",
578 \" .GGGGGGG. ........ \",
581 \" .GG...GG. ........ \",
586 \" .GG....... ....... \",
589 \" ........ ....... \",
599 (defvar idlwave-toolbar-eval-icon
600 (idlwave-toolbar-make-button
602 static char * file[] = {
604 \" c None s backgroundToolBarColor\",
605 \". c #000000000000\",
634 "The Evaluate icon.")
636 (defvar idlwave-toolbar-stack-up-icon
637 (idlwave-toolbar-make-button
639 static char * file[] = {
641 \" c None s backgroundToolBarColor\",
642 \". s FgColor c #000000000000\",
643 \"_ c #FFFFFFFFFFFF\",
644 \"G c #0000BBBB0000\",
645 \"R c #FFFF00000000\",
653 \" .______. ..... \",
654 \" .______. ....... \",
674 "The Stack Up icon.")
676 (defvar idlwave-toolbar-stack-down-icon
677 (idlwave-toolbar-make-button
679 static char * file[] = {
681 \" c None s backgroundToolBarColor\",
682 \". s FgColor c #000000000000\",
683 \"_ c #FFFFFFFFFFFF\",
684 \"G c #0000BBBB0000\",
685 \"R c #FFFF00000000\",
706 \" .RRRRRR. ....... \",
707 \" .RRRRRR. ..... \",
714 "The Stack Down icon.")
716 (defvar idlwave-toolbar-reset-icon
717 (idlwave-toolbar-make-button
719 static char * file[] = {
721 \" c None s backgroundToolBarColor\",
722 \"G c #0000BBBB0000\",
723 \". c #000000000000\",
754 (defvar idlwave-toolbar-electric-debug-icon
755 (idlwave-toolbar-make-button
757 static char * file[] = {
759 \" c None s backgroundToolBarColor\",
780 \" .++ %%%%%%%%%%% \",
781 \" ++$$ %%%%%%%%%%% \",
782 \" .+@# &&%%%%%%%&& \",
783 \" .++++# &&&&&%%%&&&&& \",
784 \" +++++$ &&%%&&&&&%%&& \",
785 \" $+++$ &&%%&&&&&%%&& \",
786 \" $++@ &&&&&&%&&&&&& \",
787 \" $+@ &&&&&&%&&&&&& \",
788 \" @+ &&%%&&&&&%%&& \",
789 \" ++. &%%&&%&&%%& \",
790 \" +. &&&&%%%&&&& \",
795 "The electric debug icon.")
797 (defvar idlwave-toolbar
799 [idlwave-toolbar-compile-icon
800 idlwave-shell-save-and-compile
802 "Save and Compile this file (or recompile last)"]
803 [idlwave-toolbar-next-error-icon
804 idlwave-shell-goto-next-error
807 [idlwave-toolbar-stop-at-icon
808 idlwave-shell-break-here
809 (derived-mode-p 'idlwave-mode
)
810 "Set Breakpoint at selected position"]
811 [idlwave-toolbar-clear-at-icon
812 idlwave-shell-clear-current-bp
814 "Clear Breakpoint at selected position"]
815 [idlwave-toolbar-clear-all-icon
816 idlwave-shell-clear-all-bp
818 "Clear all Breakpoints"]
819 [idlwave-toolbar-stop-beginning-icon
820 idlwave-shell-break-this-module
821 (derived-mode-p 'idlwave-mode
)
822 "Stop at beginning of enclosing Routine"]
823 [idlwave-toolbar-stop-in-icon
824 idlwave-shell-break-in
826 "Stop in Routine with name near point"]
827 [idlwave-toolbar-edit-cmd-icon
828 idlwave-shell-edit-default-command-line
830 "Edit Default Command Line"]
831 [idlwave-toolbar-run-icon
832 idlwave-shell-execute-default-command-line
834 "Reset, then Execute Default Command Line"]
835 [idlwave-toolbar-cont-icon
838 "Continue Current Program"]
839 [idlwave-toolbar-to-here-icon
840 idlwave-shell-to-here
841 (derived-mode-p 'idlwave-mode
)
842 "Continue to Here (cursor position)"]
843 [idlwave-toolbar-step-over-icon
844 idlwave-shell-stepover
846 "Step Over (aka next)"]
847 [idlwave-toolbar-step-into-icon
850 "Step Into (aka step)"]
851 [idlwave-toolbar-step-out-icon
854 "Step Out (of subroutine)"]
855 [idlwave-toolbar-eval-icon
858 "Print Expression at or before Point"]
859 [idlwave-toolbar-stack-up-icon
860 idlwave-shell-stack-up
862 "Stack Up (towards \"cooler\" - less recently visited - frames)"]
863 [idlwave-toolbar-stack-down-icon
864 idlwave-shell-stack-down
866 "Stack Down (towards \"warmer\" - more recently visited - frames)"]
867 [idlwave-toolbar-reset-icon
870 "Reset IDL (RETALL & CLOSE,/ALL and more)"]
871 [idlwave-toolbar-electric-debug-icon
872 idlwave-shell-electric-debug-mode
873 (derived-mode-p 'idlwave-mode
)
874 "Toggle Electric Debug Mode"]
877 ;; When the shell exits, arrange to remove the special toolbar everywhere.
878 (add-hook 'idlwave-shell-cleanup-hook
879 'idlwave-toolbar-remove-everywhere
)
880 );; End can define toolbar
882 (defun idlwave-toolbar-add ()
883 "Add the IDLWAVE toolbar if appropriate."
884 (if (and (featurep 'xemacs
) ; This is a noop on Emacs
885 (boundp 'idlwave-toolbar-is-possible
)
886 (derived-mode-p 'idlwave-mode
'idlwave-shell-mode
))
887 (set-specifier default-toolbar
(cons (current-buffer)
890 (defun idlwave-toolbar-remove ()
891 "Add the IDLWAVE toolbar if appropriate."
892 (if (and (featurep 'xemacs
) ; This is a noop on Emacs
893 (boundp 'idlwave-toolbar-is-possible
)
894 (derived-mode-p 'idlwave-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