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>
9 ;; This file is part of GNU Emacs.
11 ;; GNU Emacs is free software; you can redistribute it and/or modify
12 ;; it under the terms of the GNU General Public License as published by
13 ;; the Free Software Foundation; either version 2, or (at your option)
16 ;; GNU Emacs is distributed in the hope that it will be useful,
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 ;; GNU General Public License for more details.
21 ;; You should have received a copy of the GNU General Public License
22 ;; along with GNU Emacs; see the file COPYING. If not, write to the
23 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
24 ;; Boston, MA 02111-1307, USA.
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 default-toolbar)
46 (if (not (or (and (featurep 'xemacs) ; This is XEmacs
47 (featurep 'xpm) ; need xpm
48 (featurep 'toolbar)) ; ... and the toolbar
49 (and (not (featurep 'xemacs)) ; This is Emacs
50 (boundp 'tool-bar-button-margin) ; need toolbar
51 (fboundp 'image-type-available-p) ; need image stuff
52 (image-type-available-p 'xpm)) ; need xpm
54 ;; oops - cannot do the toolbar
55 (message "Sorry, IDLWAVE xpm toolbar cannot be used on this version of Emacs")
56 ;; OK, we can define a toolbar
58 (defconst idlwave-toolbar-is-possible t
59 "When defined, indicates that a toolbar is possible with this Emacs.")
60 (defvar idlwave-toolbar-compile-icon
61 (idlwave-toolbar-make-button
63 static char * file[] = {
65 \" c None s backgroundToolBarColor\",
66 \". c #000000000000\",
75 \" ................... \",
76 \" ........ ........ \",
79 \" ..... .. ... ..... \",
80 \" ...... .. .. ...... \",
81 \" ..... ... .. ..... \",
84 \" ........ ........ \",
85 \" ................... \",
97 (defvar idlwave-toolbar-next-error-icon
98 (idlwave-toolbar-make-button
100 static char * file[] = {
102 \" c None s backgroundToolBarColor\",
103 \". c #000000000000\",
104 \"R c #FFFF00000000\",
112 \" RRRRRRRRRRRRRRRRRRR \",
119 \" ..... .. ... ..... \",
120 \" ...... .. .. ...... \",
121 \" ..... ... .. ..... \",
122 \" ......... .... \",
123 \" ........ ..... \",
124 \" ........ ........ \",
125 \" ................... \",
133 "The Next Error icon.")
135 (defvar idlwave-toolbar-stop-at-icon
136 (idlwave-toolbar-make-button
138 static char * file[] = {
140 \" c None s backgroundToolBarColor\",
141 \". c #000000000000\",
142 \"R c #FFFF00000000\",
150 \" .RRRRRRRRRRRR. \",
151 \" .RRRRRRRRRRRRRR. \",
152 \" .RRRRRRRRRRRRRRRR. \",
153 \" .RRRRRRRRRRRRRRRRRR. \",
154 \" .RRRRRRRRRRRRRRRRRR. \",
155 \" .RRRRRRRRRRRRRRRRRR. \",
156 \" .RRRRRRRRRRRRRRRRRR. \",
157 \" .RRRRRRRRRRRRRRRRRR. \",
158 \" .RRRRRRRRRRRRRRRRRR. \",
159 \" .RRRRRRRRRRRRRRRRRR. \",
160 \" .RRRRRRRRRRRRRRRRRR. \",
161 \" .RRRRRRRRRRRRRRRR. \",
162 \" .RRRRRRRRRRRRRR. \",
163 \" .RRRRRRRRRRRR. \",
173 (defvar idlwave-toolbar-stop-in-icon
174 (idlwave-toolbar-make-button
176 static char * file[] = {
178 \" c None s backgroundToolBarColor\",
179 \"_ c #FFFFFFFFFFFF\",
180 \". c #000000000000\",
181 \"R c #FFFF00000000\",
189 \" .RRRRRRRRRRRR. \",
190 \" .RRR___RR___RRR. \",
191 \" .RRRR__RRRR__RRRR. \",
192 \" .RRRRR__RRRR__RRRRR. \",
193 \" .RRRRR__RRRR__RRRRR. \",
194 \" .RRRRR__RRRR__RRRRR. \",
195 \" .RRRR__RRRRRR__RRRR. \",
196 \" .RRRRR__RRRR__RRRRR. \",
197 \" .RRRRR__RRRR__RRRRR. \",
198 \" .RRRRR__RRRR__RRRRR. \",
199 \" .RRRRR__RRRR__RRRRR. \",
200 \" .RRRR___RR___RRRR. \",
201 \" .RRRRRRRRRRRRRR. \",
202 \" .RRRRRRRRRRRR. \",
213 (defvar idlwave-toolbar-clear-at-icon
214 (idlwave-toolbar-make-button
216 static char * file[] = {
218 \" c None s backgroundToolBarColor\",
219 \". c #000000000000\",
220 \"R c #FFFF00000000\",
225 \" ... ........ ... \",
226 \" ... .RRRRRRRR. ... \",
227 \" ....RRRRRRRRRR.... \",
228 \" ...RRRRRRRRRR... \",
229 \" ....RRRRRRRR.... \",
230 \" .RR...RRRRRR...RR. \",
231 \" .RRRR...RRRR...RRRR. \",
232 \" .RRRRR...RR...RRRRR. \",
233 \" .RRRRRR......RRRRRR. \",
234 \" .RRRRRRR....RRRRRRR. \",
235 \" .RRRRRRR....RRRRRRR. \",
236 \" .RRRRRR......RRRRRR. \",
237 \" .RRRRR...RR...RRRRR. \",
238 \" .RRRR...RRRR...RRRR. \",
239 \" .RR...RRRRRR...RR. \",
240 \" ....RRRRRRRR.... \",
241 \" ...RRRRRRRRRR... \",
242 \" ....RRRRRRRRRR.... \",
243 \" ... .RRRRRRRR. ... \",
244 \" ... ........ ... \",
249 "The Clear At icon.")
251 (defvar idlwave-toolbar-clear-all-icon
252 (idlwave-toolbar-make-button
254 static char * file[] = {
256 \" c None s backgroundToolBarColor\",
257 \". c #000000000000\",
258 \"X c #FFFFFFFFFFFF\",
259 \"R c #FFFF00000000\",
263 \" .. .... .... .. \",
264 \" ...RRRR. .RRRR... \",
265 \" ...RRRR. .RRRR... \",
266 \" .R...RRRR. .RRRR...R. \",
267 \" .RR...RRR. .RRR...RR. \",
268 \" .RRR...RR. .RR...RRR. \",
269 \" .RRRR...R. .R...RRRR. \",
270 \" .RRRR... ...RRRR. \",
271 \" .RRRR... ...RRRR. \",
272 \" .... ... ... .... \",
275 \" .... ..... .... \",
276 \" .RRRR.... ....RRRR. \",
277 \" .RRRRR... ...RRRRR. \",
278 \" .RRRRR.... ....RRRRR. \",
279 \" .RRRR...R. .R...RRRR. \",
280 \" .RRR...RR. .RR...RRR. \",
281 \" .RR...RRR. .RRR...RR. \",
282 \" ....RRR. .RRR.... \",
283 \" ...RRR. .RRR... \",
284 \" ....... ....... \",
288 "The Clear-All icon.")
290 (defvar idlwave-toolbar-edit-cmd-icon
291 (idlwave-toolbar-make-button
293 static char * file[] = {
295 \" c None s backgroundToolBarColor\",
296 \". c #000000000000\",
315 \" ................. \",
327 (defvar idlwave-toolbar-run-icon
328 (idlwave-toolbar-make-button
330 static char * file[] = {
332 \" c None s backgroundToolBarColor\",
333 \". s FgColor c #000000000000\",
334 \"G c #0000BBBB0000\",
348 \" .GGGGGGG. ....... \",
365 (defvar idlwave-toolbar-cont-icon
366 (idlwave-toolbar-make-button
368 static char * file[] = {
370 \" c None s backgroundToolBarColor\",
371 \". s FgColor c #000000000000\",
372 \"G c #0000BBBB0000\",
379 \" .GGGGGG. ....... \",
388 \" .GGGGGGG. ....... \",
403 (defvar idlwave-toolbar-to-here-icon
404 (idlwave-toolbar-make-button
406 static char * file[] = {
408 \" c None s backgroundToolBarColor\",
409 \". c #000000000000\",
410 \"G c #0000BBBB0000\",
411 \"R c #FFFF00000000\",
418 \" ..... ........ \",
421 \" .GG.... ........ \",
425 \" .GG. .G. ...... \",
427 \" .GGGGGGGG. RRRRRR \",
428 \" .GGGGGGGGG. RRRRRR \",
429 \" .GGGGGGG. RRRRRR \",
440 "The Cont-to-here icon.")
442 (defvar idlwave-toolbar-step-over-icon
443 (idlwave-toolbar-make-button
445 static char * file[] = {
447 \" c None s backgroundToolBarColor\",
448 \". c #000000000000\",
449 \"G c #0000BBBB0000\",
457 \" .GGGG. ....... \",
463 \" .GG. .G. ....... \",
466 \" .GGGGGGGGG. ....... \",
478 "The Step Over icon.")
480 (defvar idlwave-toolbar-step-into-icon
481 (idlwave-toolbar-make-button
483 static char * file[] = {
485 \" c None s backgroundToolBarColor\",
486 \". c #000000000000\",
487 \"G c #0000BBBB0000\",
497 \" .GG.... ........ \",
502 \" .GG...GG. ....... \",
505 \" .GGGGGGG. ....... \",
516 "The Step Into icon.")
518 (defvar idlwave-toolbar-step-out-icon
519 (idlwave-toolbar-make-button
521 static char * file[] = {
523 \" c None s backgroundToolBarColor\",
524 \". c #000000000000\",
525 \"G c #0000BBBB0000\",
536 \" .GGGGGGG. ........ \",
539 \" .GG...GG. ........ \",
544 \" .GG....... ....... \",
547 \" ........ ....... \",
557 (defvar idlwave-toolbar-eval-icon
558 (idlwave-toolbar-make-button
560 static char * file[] = {
562 \" c None s backgroundToolBarColor\",
563 \". c #000000000000\",
592 "The Evaluate icon.")
594 (defvar idlwave-toolbar-stack-up-icon
595 (idlwave-toolbar-make-button
597 static char * file[] = {
599 \" c None s backgroundToolBarColor\",
600 \". s FgColor c #000000000000\",
601 \"_ c #FFFFFFFFFFFF\",
602 \"G c #0000BBBB0000\",
603 \"R c #FFFF00000000\",
611 \" .______. ..... \",
612 \" .______. ....... \",
632 "The Stack Up icon.")
634 (defvar idlwave-toolbar-stack-down-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\",
664 \" .RRRRRR. ....... \",
665 \" .RRRRRR. ..... \",
672 "The Stack Down icon.")
674 (defvar idlwave-toolbar-reset-icon
675 (idlwave-toolbar-make-button
677 static char * file[] = {
679 \" c None s backgroundToolBarColor\",
680 \"G c #0000BBBB0000\",
681 \". c #000000000000\",
712 (defvar idlwave-toolbar
714 [idlwave-toolbar-compile-icon
715 idlwave-shell-save-and-compile
717 "Save and Compile this file (or recompile last)"]
718 [idlwave-toolbar-next-error-icon
719 idlwave-shell-goto-next-error
722 [idlwave-toolbar-stop-at-icon
723 idlwave-shell-break-here
724 (eq major-mode 'idlwave-mode)
725 "Set Breakpoint at selected position"]
726 [idlwave-toolbar-stop-in-icon
727 idlwave-shell-break-in
729 "Stop in Function with name near at point"]
730 [idlwave-toolbar-clear-at-icon
731 idlwave-shell-clear-current-bp
733 "Clear Breakpoint at selected position"]
734 [idlwave-toolbar-clear-all-icon
735 idlwave-shell-clear-all-bp
737 "Clear all Breakpoints"]
738 [idlwave-toolbar-edit-cmd-icon
739 idlwave-shell-edit-default-command-line
741 "Edit Default Command Line"]
742 [idlwave-toolbar-run-icon
743 idlwave-shell-execute-default-command-line
745 "Reset, then Execute Default Command Line"]
746 [idlwave-toolbar-cont-icon
749 "Continue Current Program"]
750 [idlwave-toolbar-to-here-icon
751 idlwave-shell-to-here
752 (eq major-mode 'idlwave-mode)
753 "Continue to Here (cursor position)"]
754 [idlwave-toolbar-step-over-icon
755 idlwave-shell-stepover
757 "Step Over (aka next)"]
758 [idlwave-toolbar-step-into-icon
761 "Step Into (aka step)"]
762 [idlwave-toolbar-step-out-icon
765 "Step Out (of subroutine)"]
766 [idlwave-toolbar-eval-icon
769 "Print Expression at or before Point"]
770 [idlwave-toolbar-stack-up-icon
771 idlwave-shell-stack-up
773 "Stack Up (towards \"cooler\" - less recently visited - frames)"]
774 [idlwave-toolbar-stack-down-icon
775 idlwave-shell-stack-down
777 "Stack Down (towards \"warmer\" - more recently visited - frames)"]
778 [idlwave-toolbar-reset-icon
781 "Reset IDL (RETALL & CLOSE,/ALL and more)"]
784 ;; When the shell exits, arrange to remove the special toolbar everywhere.
785 (add-hook 'idlwave-shell-cleanup-hook
786 'idlwave-toolbar-remove-everywhere)
787 );; End can define toolbar
789 (defun idlwave-toolbar-add ()
790 "Add the IDLWAVE toolbar if appropriate."
791 (if (and (featurep 'xemacs) ; This is a noop on Emacs
792 (boundp 'idlwave-toolbar-is-possible)
793 (or (eq major-mode 'idlwave-mode)
794 (eq major-mode 'idlwave-shell-mode)))
795 (set-specifier default-toolbar (cons (current-buffer)
798 (defun idlwave-toolbar-remove ()
799 "Add the IDLWAVE toolbar if appropriate."
800 (if (and (featurep 'xemacs) ; This is a noop on Emacs
801 (boundp 'idlwave-toolbar-is-possible)
802 (or (eq major-mode 'idlwave-mode)
803 (eq major-mode 'idlwave-shell-mode)))
804 (remove-specifier default-toolbar (current-buffer))))
806 (defvar idlwave-shell-mode-map)
807 (defvar idlwave-mode-map)
808 (defvar idlwave-toolbar-visible nil)
809 (defun idlwave-toolbar-add-everywhere ()
810 "Add the toolbar in all appropriate buffers."
811 (when (boundp 'idlwave-toolbar-is-possible)
813 ;; First make sure new buffers will get the toolbar
814 (add-hook 'idlwave-mode-hook 'idlwave-toolbar-add)
815 ;; Then add it to all existing buffers
816 (if (featurep 'xemacs)
817 ;; For XEmacs, map over all buffers to add toolbar
819 (mapcar (lambda (buf)
821 (idlwave-toolbar-add))
823 ;; For Emacs, add the key definitions to the mode maps
825 (let* ((icon (aref x 0))
829 (key (vector 'tool-bar func))
830 (def (list 'menu-item
833 :image (symbol-value icon)
835 (define-key idlwave-mode-map key def)
836 (define-key idlwave-shell-mode-map key def)))
837 (reverse idlwave-toolbar)))
838 (setq idlwave-toolbar-visible t)))
840 (defun idlwave-toolbar-remove-everywhere ()
841 "Remove the toolbar in all appropriate buffers."
842 ;; First make sure new buffers won't get the toolbar
843 (when idlwave-toolbar-is-possible
844 (remove-hook 'idlwave-mode-hook 'idlwave-toolbar-add)
845 ;; Then remove it in all existing buffers.
846 (if (featurep 'xemacs)
847 ;; For XEmacs, map over all buffers to remove toolbar
849 (mapcar (lambda (buf)
851 (idlwave-toolbar-remove))
853 ;; For Emacs, remove the key definitions from the mode maps
855 (let* (;;(icon (aref x 0))
859 (key (vector 'tool-bar func)))
860 (define-key idlwave-mode-map key nil)
861 (define-key idlwave-shell-mode-map key nil)))
863 (setq idlwave-toolbar-visible nil)))
865 (defun idlwave-toolbar-toggle (&optional force-on)
867 (if idlwave-toolbar-visible
868 (or force-on (idlwave-toolbar-remove-everywhere))
869 (idlwave-toolbar-add-everywhere))
870 ;; Now make sure this
871 (if (featurep 'xemacs)
872 nil ; no action necessary, toolbar gets updated automatically
873 ;; On Emacs, redraw the frame to make sure the Toolbar is updated.
874 (redraw-frame (selected-frame))))
876 (provide 'idlw-toolbar)
877 (provide 'idlwave-toolbar)
879 ;;; idlw-toolbar.el ends here
882 ;;; arch-tag: ec9a3717-c44c-4716-9bda-cdacbe5ddb62