1 ;;; idlw-toolbar.el --- a debugging toolbar for IDLWAVE
2 ;; Copyright (c) 1999, 2000 Free Software Foundation
4 ;; Author: Carsten Dominik <dominik@strw.leidenuniv.nl>
5 ;; Maintainer: John-David Smith <jdsmith@astro.cornell.edu>
7 ;; Date: $Date: 2001/07/16 12:22:59 $
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.
35 (eval-when-compile (require 'cl
))
37 (defun idlwave-toolbar-make-button (image)
38 (if (featurep 'xemacs
)
39 (toolbar-make-button-list image
)
40 (list 'image
:type
'xpm
:data image
)))
42 (defvar default-toolbar
)
43 (if (not (or (and (featurep 'xemacs
) ; This is XEmacs
44 (featurep 'xpm
) ; need xpm
45 (featurep 'toolbar
)) ; ... and the toolbar
46 (and (not (featurep 'xemacs
)) ; This is Emacs
47 (boundp 'tool-bar-button-margin
) ; need toolbar
48 (fboundp 'image-type-available-p
) ; need image stuff
49 (image-type-available-p 'xpm
)) ; need xpm
51 ;; oops - cannot do the toolbar
52 (message "Sorry, IDLWAVE xpm toolbar cannot be used on this version of Emacs")
53 ;; OK, we can define a toolbar
55 (defconst idlwave-toolbar-is-possible t
56 "When defined, indicates that a toolbar is possible with this Emacs.")
57 (defvar idlwave-toolbar-compile-icon
58 (idlwave-toolbar-make-button
60 static char * file[] = {
62 \" c #C8C8C8C8C8C8 s backgroundToolBarColor\",
63 \". c #000000000000\",
72 \" ................... \",
73 \" ........ ........ \",
76 \" ..... .. ... ..... \",
77 \" ...... .. .. ...... \",
78 \" ..... ... .. ..... \",
81 \" ........ ........ \",
82 \" ................... \",
94 (defvar idlwave-toolbar-next-error-icon
95 (idlwave-toolbar-make-button
97 static char * file[] = {
99 \" c #C8C8C8C8C8C8 s backgroundToolBarColor\",
100 \". c #000000000000\",
101 \"R c #FFFF00000000\",
109 \" RRRRRRRRRRRRRRRRRRR \",
116 \" ..... .. ... ..... \",
117 \" ...... .. .. ...... \",
118 \" ..... ... .. ..... \",
119 \" ......... .... \",
120 \" ........ ..... \",
121 \" ........ ........ \",
122 \" ................... \",
130 "The Next Error icon.")
132 (defvar idlwave-toolbar-stop-at-icon
133 (idlwave-toolbar-make-button
135 static char * file[] = {
137 \" c #C8C8C8C8C8C8 s backgroundToolBarColor\",
138 \". c #000000000000\",
139 \"R c #FFFF00000000\",
147 \" .RRRRRRRRRRRR. \",
148 \" .RRRRRRRRRRRRRR. \",
149 \" .RRRRRRRRRRRRRRRR. \",
150 \" .RRRRRRRRRRRRRRRRRR. \",
151 \" .RRRRRRRRRRRRRRRRRR. \",
152 \" .RRRRRRRRRRRRRRRRRR. \",
153 \" .RRRRRRRRRRRRRRRRRR. \",
154 \" .RRRRRRRRRRRRRRRRRR. \",
155 \" .RRRRRRRRRRRRRRRRRR. \",
156 \" .RRRRRRRRRRRRRRRRRR. \",
157 \" .RRRRRRRRRRRRRRRRRR. \",
158 \" .RRRRRRRRRRRRRRRR. \",
159 \" .RRRRRRRRRRRRRR. \",
160 \" .RRRRRRRRRRRR. \",
170 (defvar idlwave-toolbar-stop-in-icon
171 (idlwave-toolbar-make-button
173 static char * file[] = {
175 \" c #C8C8C8C8C8C8 s backgroundToolBarColor\",
176 \"_ c #FFFFFFFFFFFF\",
177 \". c #000000000000\",
178 \"R c #FFFF00000000\",
186 \" .RRRRRRRRRRRR. \",
187 \" .RRR___RR___RRR. \",
188 \" .RRRR__RRRR__RRRR. \",
189 \" .RRRRR__RRRR__RRRRR. \",
190 \" .RRRRR__RRRR__RRRRR. \",
191 \" .RRRRR__RRRR__RRRRR. \",
192 \" .RRRR__RRRRRR__RRRR. \",
193 \" .RRRRR__RRRR__RRRRR. \",
194 \" .RRRRR__RRRR__RRRRR. \",
195 \" .RRRRR__RRRR__RRRRR. \",
196 \" .RRRRR__RRRR__RRRRR. \",
197 \" .RRRR___RR___RRRR. \",
198 \" .RRRRRRRRRRRRRR. \",
199 \" .RRRRRRRRRRRR. \",
210 (defvar idlwave-toolbar-clear-at-icon
211 (idlwave-toolbar-make-button
213 static char * file[] = {
215 \" c #C8C8C8C8C8C8 s backgroundToolBarColor\",
216 \". c #000000000000\",
217 \"R c #FFFF00000000\",
222 \" ... ........ ... \",
223 \" ... .RRRRRRRR. ... \",
224 \" ....RRRRRRRRRR.... \",
225 \" ...RRRRRRRRRR... \",
226 \" ....RRRRRRRR.... \",
227 \" .RR...RRRRRR...RR. \",
228 \" .RRRR...RRRR...RRRR. \",
229 \" .RRRRR...RR...RRRRR. \",
230 \" .RRRRRR......RRRRRR. \",
231 \" .RRRRRRR....RRRRRRR. \",
232 \" .RRRRRRR....RRRRRRR. \",
233 \" .RRRRRR......RRRRRR. \",
234 \" .RRRRR...RR...RRRRR. \",
235 \" .RRRR...RRRR...RRRR. \",
236 \" .RR...RRRRRR...RR. \",
237 \" ....RRRRRRRR.... \",
238 \" ...RRRRRRRRRR... \",
239 \" ....RRRRRRRRRR.... \",
240 \" ... .RRRRRRRR. ... \",
241 \" ... ........ ... \",
246 "The Clear At icon.")
248 (defvar idlwave-toolbar-clear-all-icon
249 (idlwave-toolbar-make-button
251 static char * file[] = {
253 \" c #C8C8C8C8C8C8 s backgroundToolBarColor\",
254 \". c #000000000000\",
255 \"X c #FFFFFFFFFFFF\",
256 \"R c #FFFF00000000\",
260 \" .. .... .... .. \",
261 \" ...RRRR. .RRRR... \",
262 \" ...RRRR. .RRRR... \",
263 \" .R...RRRR. .RRRR...R. \",
264 \" .RR...RRR. .RRR...RR. \",
265 \" .RRR...RR. .RR...RRR. \",
266 \" .RRRR...R. .R...RRRR. \",
267 \" .RRRR... ...RRRR. \",
268 \" .RRRR... ...RRRR. \",
269 \" .... ... ... .... \",
272 \" .... ..... .... \",
273 \" .RRRR.... ....RRRR. \",
274 \" .RRRRR... ...RRRRR. \",
275 \" .RRRRR.... ....RRRRR. \",
276 \" .RRRR...R. .R...RRRR. \",
277 \" .RRR...RR. .RR...RRR. \",
278 \" .RR...RRR. .RRR...RR. \",
279 \" ....RRR. .RRR.... \",
280 \" ...RRR. .RRR... \",
281 \" ....... ....... \",
285 "The Clear-All icon.")
287 (defvar idlwave-toolbar-edit-cmd-icon
288 (idlwave-toolbar-make-button
290 static char * file[] = {
292 \" c #C8C8C8C8C8C8 s backgroundToolBarColor\",
293 \". c #000000000000\",
312 \" ................. \",
324 (defvar idlwave-toolbar-run-icon
325 (idlwave-toolbar-make-button
327 static char * file[] = {
329 \" c #C8C8C8C8C8C8 s backgroundToolBarColor\",
330 \". s FgColor c #000000000000\",
331 \"G c #0000BBBB0000\",
345 \" .GGGGGGG. ....... \",
362 (defvar idlwave-toolbar-cont-icon
363 (idlwave-toolbar-make-button
365 static char * file[] = {
367 \" c #C8C8C8C8C8C8 s backgroundToolBarColor\",
368 \". s FgColor c #000000000000\",
369 \"G c #0000BBBB0000\",
376 \" .GGGGGG. ....... \",
385 \" .GGGGGGG. ....... \",
400 (defvar idlwave-toolbar-to-here-icon
401 (idlwave-toolbar-make-button
403 static char * file[] = {
405 \" c #C8C8C8C8C8C8 s backgroundToolBarColor\",
406 \". c #000000000000\",
407 \"G c #0000BBBB0000\",
408 \"R c #FFFF00000000\",
415 \" ..... ........ \",
418 \" .GG.... ........ \",
422 \" .GG. .G. ...... \",
424 \" .GGGGGGGG. RRRRRR \",
425 \" .GGGGGGGGG. RRRRRR \",
426 \" .GGGGGGG. RRRRRR \",
437 "The Cont-to-here icon.")
439 (defvar idlwave-toolbar-step-over-icon
440 (idlwave-toolbar-make-button
442 static char * file[] = {
444 \" c #C8C8C8C8C8C8 s backgroundToolBarColor\",
445 \". c #000000000000\",
446 \"G c #0000BBBB0000\",
454 \" .GGGG. ....... \",
460 \" .GG. .G. ....... \",
463 \" .GGGGGGGGG. ....... \",
475 "The Step Over icon.")
477 (defvar idlwave-toolbar-step-into-icon
478 (idlwave-toolbar-make-button
480 static char * file[] = {
482 \" c #C8C8C8C8C8C8 s backgroundToolBarColor\",
483 \". c #000000000000\",
484 \"G c #0000BBBB0000\",
494 \" .GG.... ........ \",
499 \" .GG...GG. ....... \",
502 \" .GGGGGGG. ....... \",
513 "The Step Into icon.")
515 (defvar idlwave-toolbar-step-out-icon
516 (idlwave-toolbar-make-button
518 static char * file[] = {
520 \" c #C8C8C8C8C8C8 s backgroundToolBarColor\",
521 \". c #000000000000\",
522 \"G c #0000BBBB0000\",
533 \" .GGGGGGG. ........ \",
536 \" .GG...GG. ........ \",
541 \" .GG....... ....... \",
544 \" ........ ....... \",
554 (defvar idlwave-toolbar-eval-icon
555 (idlwave-toolbar-make-button
557 static char * file[] = {
559 \" c #C8C8C8C8C8C8 s backgroundToolBarColor\",
560 \". c #000000000000\",
589 "The Evaluate icon.")
591 (defvar idlwave-toolbar-stack-up-icon
592 (idlwave-toolbar-make-button
594 static char * file[] = {
596 \" c #C8C8C8C8C8C8 s backgroundToolBarColor\",
597 \". s FgColor c #000000000000\",
598 \"_ c #FFFFFFFFFFFF\",
599 \"G c #0000BBBB0000\",
600 \"R c #FFFF00000000\",
608 \" .______. ..... \",
609 \" .______. ....... \",
629 "The Stack Up icon.")
631 (defvar idlwave-toolbar-stack-down-icon
632 (idlwave-toolbar-make-button
634 static char * file[] = {
636 \" c #C8C8C8C8C8C8 s backgroundToolBarColor\",
637 \". s FgColor c #000000000000\",
638 \"_ c #FFFFFFFFFFFF\",
639 \"G c #0000BBBB0000\",
640 \"R c #FFFF00000000\",
661 \" .RRRRRR. ....... \",
662 \" .RRRRRR. ..... \",
669 "The Stack Down icon.")
671 (defvar idlwave-toolbar-reset-icon
672 (idlwave-toolbar-make-button
674 static char * file[] = {
676 \" c #C8C8C8C8C8C8 s backgroundToolBarColor\",
677 \"G c #0000BBBB0000\",
678 \". c #000000000000\",
709 (defvar idlwave-toolbar
711 [idlwave-toolbar-compile-icon
712 idlwave-shell-save-and-compile
714 "Save and Compile this file (or recompile last)"]
715 [idlwave-toolbar-next-error-icon
716 idlwave-shell-goto-next-error
719 [idlwave-toolbar-stop-at-icon
720 idlwave-shell-break-here
721 (eq major-mode
'idlwave-mode
)
722 "Set Breakpoint at selected position"]
723 [idlwave-toolbar-stop-in-icon
724 idlwave-shell-break-in
726 "Stop in Function with name near at point"]
727 [idlwave-toolbar-clear-at-icon
728 idlwave-shell-clear-current-bp
730 "Clear Breakpoint at selected position"]
731 [idlwave-toolbar-clear-all-icon
732 idlwave-shell-clear-all-bp
734 "Clear all Breakpoints"]
735 [idlwave-toolbar-edit-cmd-icon
736 idlwave-shell-edit-default-command-line
738 "Edit Default Command Line"]
739 [idlwave-toolbar-run-icon
740 idlwave-shell-execute-default-command-line
742 "Reset, then Execute Default Command Line"]
743 [idlwave-toolbar-cont-icon
746 "Continue Current Program"]
747 [idlwave-toolbar-to-here-icon
748 idlwave-shell-to-here
749 (eq major-mode
'idlwave-mode
)
750 "Continue to Here (cursor position)"]
751 [idlwave-toolbar-step-over-icon
752 idlwave-shell-stepover
754 "Step Over (aka next)"]
755 [idlwave-toolbar-step-into-icon
758 "Step Into (aka step)"]
759 [idlwave-toolbar-step-out-icon
762 "Step Out (of subroutine)"]
763 [idlwave-toolbar-eval-icon
766 "Print Expression at or before Point"]
767 [idlwave-toolbar-stack-up-icon
768 idlwave-shell-stack-up
770 "Stack Up (towards \"cooler\" - less recently visited - frames)"]
771 [idlwave-toolbar-stack-down-icon
772 idlwave-shell-stack-down
774 "Stack Down (towards \"warmer\" - more recently visited - frames)"]
775 [idlwave-toolbar-reset-icon
778 "Reset IDL (RETALL & CLOSE,/ALL and more)"]
781 ;; When the shell exits, arrange to remove the special toolbar everywhere.
782 (add-hook 'idlwave-shell-cleanup-hook
783 'idlwave-toolbar-remove-everywhere
)
784 );; End can define toolbar
786 (defun idlwave-toolbar-add ()
787 "Add the IDLWAVE toolbar if appropriate."
788 (if (and (featurep 'xemacs
) ; This is a noop on Emacs
789 (boundp 'idlwave-toolbar-is-possible
)
790 (or (eq major-mode
'idlwave-mode
)
791 (eq major-mode
'idlwave-shell-mode
)))
792 (set-specifier default-toolbar
(cons (current-buffer)
795 (defun idlwave-toolbar-remove ()
796 "Add the IDLWAVE toolbar if appropriate."
797 (if (and (featurep 'xemacs
) ; This is a noop on Emacs
798 (boundp 'idlwave-toolbar-is-possible
)
799 (or (eq major-mode
'idlwave-mode
)
800 (eq major-mode
'idlwave-shell-mode
)))
801 (remove-specifier default-toolbar
(current-buffer))))
803 (defvar idlwave-shell-mode-map
)
804 (defvar idlwave-mode-map
)
805 (defvar idlwave-toolbar-visible nil
)
806 (defun idlwave-toolbar-add-everywhere ()
807 "Add the toolbar in all appropriate buffers."
808 (when (boundp 'idlwave-toolbar-is-possible
)
810 ;; First make sure new buffers will get the toolbar
811 (add-hook 'idlwave-mode-hook
'idlwave-toolbar-add
)
812 ;; Then add it to all existing buffers
813 (if (featurep 'xemacs
)
814 ;; For XEmacs, map over all buffers to add toolbar
816 (mapcar (lambda (buf)
818 (idlwave-toolbar-add))
820 ;; For Emacs, add the key definitions to the mode maps
822 (let* ((icon (aref x
0))
826 (key (vector 'tool-bar func
))
827 (def (list 'menu-item
830 :image
(symbol-value icon
)
832 (define-key idlwave-mode-map key def
)
833 (define-key idlwave-shell-mode-map key def
)))
834 (reverse idlwave-toolbar
)))
835 (setq idlwave-toolbar-visible t
)))
837 (defun idlwave-toolbar-remove-everywhere ()
838 "Remove the toolbar in all appropriate buffers."
839 ;; First make sure new buffers won't get the toolbar
840 (when idlwave-toolbar-is-possible
841 (remove-hook 'idlwave-mode-hook
'idlwave-toolbar-add
)
842 ;; Then remove it in all existing buffers.
843 (if (featurep 'xemacs
)
844 ;; For XEmacs, map over all buffers to remove toolbar
846 (mapcar (lambda (buf)
848 (idlwave-toolbar-remove))
850 ;; For Emacs, remove the key definitions from the mode maps
852 (let* (;;(icon (aref x 0))
856 (key (vector 'tool-bar func
)))
857 (define-key idlwave-mode-map key nil
)
858 (define-key idlwave-shell-mode-map key nil
)))
860 (setq idlwave-toolbar-visible nil
)))
862 (defun idlwave-toolbar-toggle (&optional force-on
)
864 (if idlwave-toolbar-visible
865 (or force-on
(idlwave-toolbar-remove-everywhere))
866 (idlwave-toolbar-add-everywhere))
867 ;; Now make sure this
868 (if (featurep 'xemacs
)
869 nil
; no action necessary, toolbar gets updated automatically
870 ;; On Emacs, redraw the frame to make sure the Toolbar is updated.
871 (redraw-frame (selected-frame))))
873 (provide 'idlw-toolbar
)
874 (provide 'idlwave-toolbar
)
876 ;;; idlw-toolbar.el ends here