1 ;;; idlw-toolbar.el --- a debugging toolbar for IDLWAVE
3 ;; Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009
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 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 (eq major-mode
'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 (eq major-mode
'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 (eq major-mode
'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 (eq major-mode
'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 (or (eq major-mode
'idlwave-mode
)
887 (eq major-mode
'idlwave-shell-mode
)))
888 (set-specifier default-toolbar
(cons (current-buffer)
891 (defun idlwave-toolbar-remove ()
892 "Add the IDLWAVE toolbar if appropriate."
893 (if (and (featurep 'xemacs
) ; This is a noop on Emacs
894 (boundp 'idlwave-toolbar-is-possible
)
895 (or (eq major-mode
'idlwave-mode
)
896 (eq major-mode
'idlwave-shell-mode
)))
897 (remove-specifier default-toolbar
(current-buffer))))
899 (defvar idlwave-shell-mode-map
)
900 (defvar idlwave-mode-map
)
901 (defvar idlwave-toolbar-visible nil
)
902 (defun idlwave-toolbar-add-everywhere ()
903 "Add the toolbar in all appropriate buffers."
904 (when (boundp 'idlwave-toolbar-is-possible
)
906 ;; First make sure new buffers will get the toolbar
907 (add-hook 'idlwave-mode-hook
'idlwave-toolbar-add
)
908 ;; Then add it to all existing buffers
909 (if (featurep 'xemacs
)
910 ;; For XEmacs, map over all buffers to add toolbar
912 (mapcar (lambda (buf)
914 (idlwave-toolbar-add))
916 ;; For Emacs, add the key definitions to the mode maps
918 (let* ((icon (aref x
0))
922 (key (vector 'tool-bar func
))
923 (def (list 'menu-item
926 :image
(symbol-value icon
)
929 (define-key idlwave-mode-map key def
)
930 (define-key idlwave-shell-mode-map key def
)))
931 (reverse idlwave-toolbar
)))
932 (setq idlwave-toolbar-visible t
)))
934 (defun idlwave-toolbar-remove-everywhere ()
935 "Remove the toolbar in all appropriate buffers."
936 ;; First make sure new buffers won't get the toolbar
937 (when idlwave-toolbar-is-possible
938 (remove-hook 'idlwave-mode-hook
'idlwave-toolbar-add
)
939 ;; Then remove it in all existing buffers.
940 (if (featurep 'xemacs
)
941 ;; For XEmacs, map over all buffers to remove toolbar
943 (mapcar (lambda (buf)
945 (idlwave-toolbar-remove))
947 ;; For Emacs, remove the key definitions from the mode maps
949 (let* (;;(icon (aref x 0))
953 (key (vector 'tool-bar func
)))
954 (define-key idlwave-mode-map key nil
)
955 (define-key idlwave-shell-mode-map key nil
)))
957 (setq idlwave-toolbar-visible nil
)))
959 (defun idlwave-toolbar-toggle (&optional force-on
)
961 (if idlwave-toolbar-visible
962 (or force-on
(idlwave-toolbar-remove-everywhere))
963 (idlwave-toolbar-add-everywhere))
964 ;; Now make sure this
965 (if (featurep 'xemacs
)
966 nil
; no action necessary, toolbar gets updated automatically
967 ;; On Emacs, redraw the frame to make sure the Toolbar is updated.
968 (redraw-frame (selected-frame))))
970 (provide 'idlw-toolbar
)
971 (provide 'idlwave-toolbar
)
973 ;; arch-tag: ec9a3717-c44c-4716-9bda-cdacbe5ddb62
974 ;;; idlw-toolbar.el ends here