1 ;;; idlw-toolbar.el --- A debugging toolbar for IDLWAVE
2 ;; Copyright (c) 1999 Carsten Dominik
3 ;; Copyright (c) 1999 Free Software Foundation
5 ;; Author: Carsten Dominik <dominik@strw.leidenuniv.nl>
7 ;; Date: $Date: 2000/01/03 14:26:03 $
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 'toolbar-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 (defvar idlwave-toolbar-compile-icon
56 (idlwave-toolbar-make-button
58 static char * file[] = {
60 \" c #C8C8C8C8C8C8 s backgroundToolBarColor\",
61 \". c #000000000000\",
70 \" ................... \",
71 \" ........ ........ \",
74 \" ..... .. ... ..... \",
75 \" ...... .. .. ...... \",
76 \" ..... ... .. ..... \",
79 \" ........ ........ \",
80 \" ................... \",
92 (defvar idlwave-toolbar-next-error-icon
93 (idlwave-toolbar-make-button
95 static char * file[] = {
97 \" c #C8C8C8C8C8C8 s backgroundToolBarColor\",
98 \". c #000000000000\",
99 \"R c #FFFF00000000\",
107 \" RRRRRRRRRRRRRRRRRRR \",
114 \" ..... .. ... ..... \",
115 \" ...... .. .. ...... \",
116 \" ..... ... .. ..... \",
117 \" ......... .... \",
118 \" ........ ..... \",
119 \" ........ ........ \",
120 \" ................... \",
128 "The Next Error icon.")
130 (defvar idlwave-toolbar-stop-at-icon
131 (idlwave-toolbar-make-button
133 static char * file[] = {
135 \" c #C8C8C8C8C8C8 s backgroundToolBarColor\",
136 \". c #000000000000\",
137 \"R c #FFFF00000000\",
145 \" .RRRRRRRRRRRR. \",
146 \" .RRRRRRRRRRRRRR. \",
147 \" .RRRRRRRRRRRRRRRR. \",
148 \" .RRRRRRRRRRRRRRRRRR. \",
149 \" .RRRRRRRRRRRRRRRRRR. \",
150 \" .RRRRRRRRRRRRRRRRRR. \",
151 \" .RRRRRRRRRRRRRRRRRR. \",
152 \" .RRRRRRRRRRRRRRRRRR. \",
153 \" .RRRRRRRRRRRRRRRRRR. \",
154 \" .RRRRRRRRRRRRRRRRRR. \",
155 \" .RRRRRRRRRRRRRRRRRR. \",
156 \" .RRRRRRRRRRRRRRRR. \",
157 \" .RRRRRRRRRRRRRR. \",
158 \" .RRRRRRRRRRRR. \",
168 (defvar idlwave-toolbar-stop-in-icon
169 (idlwave-toolbar-make-button
171 static char * file[] = {
173 \" c #C8C8C8C8C8C8 s backgroundToolBarColor\",
174 \"_ c #FFFFFFFFFFFF\",
175 \". c #000000000000\",
176 \"R c #FFFF00000000\",
184 \" .RRRRRRRRRRRR. \",
185 \" .RRR___RR___RRR. \",
186 \" .RRRR__RRRR__RRRR. \",
187 \" .RRRRR__RRRR__RRRRR. \",
188 \" .RRRRR__RRRR__RRRRR. \",
189 \" .RRRRR__RRRR__RRRRR. \",
190 \" .RRRR__RRRRRR__RRRR. \",
191 \" .RRRRR__RRRR__RRRRR. \",
192 \" .RRRRR__RRRR__RRRRR. \",
193 \" .RRRRR__RRRR__RRRRR. \",
194 \" .RRRRR__RRRR__RRRRR. \",
195 \" .RRRR___RR___RRRR. \",
196 \" .RRRRRRRRRRRRRR. \",
197 \" .RRRRRRRRRRRR. \",
208 (defvar idlwave-toolbar-clear-at-icon
209 (idlwave-toolbar-make-button
211 static char * file[] = {
213 \" c #C8C8C8C8C8C8 s backgroundToolBarColor\",
214 \". c #000000000000\",
215 \"R c #FFFF00000000\",
220 \" ... ........ ... \",
221 \" ... .RRRRRRRR. ... \",
222 \" ....RRRRRRRRRR.... \",
223 \" ...RRRRRRRRRR... \",
224 \" ....RRRRRRRR.... \",
225 \" .RR...RRRRRR...RR. \",
226 \" .RRRR...RRRR...RRRR. \",
227 \" .RRRRR...RR...RRRRR. \",
228 \" .RRRRRR......RRRRRR. \",
229 \" .RRRRRRR....RRRRRRR. \",
230 \" .RRRRRRR....RRRRRRR. \",
231 \" .RRRRRR......RRRRRR. \",
232 \" .RRRRR...RR...RRRRR. \",
233 \" .RRRR...RRRR...RRRR. \",
234 \" .RR...RRRRRR...RR. \",
235 \" ....RRRRRRRR.... \",
236 \" ...RRRRRRRRRR... \",
237 \" ....RRRRRRRRRR.... \",
238 \" ... .RRRRRRRR. ... \",
239 \" ... ........ ... \",
244 "The Clear At icon.")
246 (defvar idlwave-toolbar-clear-all-icon
247 (idlwave-toolbar-make-button
249 static char * file[] = {
251 \" c #C8C8C8C8C8C8 s backgroundToolBarColor\",
252 \". c #000000000000\",
253 \"X c #FFFFFFFFFFFF\",
254 \"R c #FFFF00000000\",
258 \" .. .... .... .. \",
259 \" ...RRRR. .RRRR... \",
260 \" ...RRRR. .RRRR... \",
261 \" .R...RRRR. .RRRR...R. \",
262 \" .RR...RRR. .RRR...RR. \",
263 \" .RRR...RR. .RR...RRR. \",
264 \" .RRRR...R. .R...RRRR. \",
265 \" .RRRR... ...RRRR. \",
266 \" .RRRR... ...RRRR. \",
267 \" .... ... ... .... \",
270 \" .... ..... .... \",
271 \" .RRRR.... ....RRRR. \",
272 \" .RRRRR... ...RRRRR. \",
273 \" .RRRRR.... ....RRRRR. \",
274 \" .RRRR...R. .R...RRRR. \",
275 \" .RRR...RR. .RR...RRR. \",
276 \" .RR...RRR. .RRR...RR. \",
277 \" ....RRR. .RRR.... \",
278 \" ...RRR. .RRR... \",
279 \" ....... ....... \",
283 "The Clear-All icon.")
285 (defvar idlwave-toolbar-edit-cmd-icon
286 (idlwave-toolbar-make-button
288 static char * file[] = {
290 \" c #C8C8C8C8C8C8 s backgroundToolBarColor\",
291 \". c #000000000000\",
310 \" ................. \",
322 (defvar idlwave-toolbar-run-icon
323 (idlwave-toolbar-make-button
325 static char * file[] = {
327 \" c #C8C8C8C8C8C8 s backgroundToolBarColor\",
328 \". s FgColor c #000000000000\",
329 \"G c #0000BBBB0000\",
343 \" .GGGGGGG. ....... \",
360 (defvar idlwave-toolbar-cont-icon
361 (idlwave-toolbar-make-button
363 static char * file[] = {
365 \" c #C8C8C8C8C8C8 s backgroundToolBarColor\",
366 \". s FgColor c #000000000000\",
367 \"G c #0000BBBB0000\",
374 \" .GGGGGG. ....... \",
383 \" .GGGGGGG. ....... \",
398 (defvar idlwave-toolbar-to-here-icon
399 (idlwave-toolbar-make-button
401 static char * file[] = {
403 \" c #C8C8C8C8C8C8 s backgroundToolBarColor\",
404 \". c #000000000000\",
405 \"G c #0000BBBB0000\",
406 \"R c #FFFF00000000\",
413 \" ..... ........ \",
416 \" .GG.... ........ \",
420 \" .GG. .G. ...... \",
422 \" .GGGGGGGG. RRRRRR \",
423 \" .GGGGGGGGG. RRRRRR \",
424 \" .GGGGGGG. RRRRRR \",
435 "The Cont-to-here icon.")
437 (defvar idlwave-toolbar-step-over-icon
438 (idlwave-toolbar-make-button
440 static char * file[] = {
442 \" c #C8C8C8C8C8C8 s backgroundToolBarColor\",
443 \". c #000000000000\",
444 \"G c #0000BBBB0000\",
452 \" .GGGG. ....... \",
458 \" .GG. .G. ....... \",
461 \" .GGGGGGGGG. ....... \",
473 "The Step Over icon.")
475 (defvar idlwave-toolbar-step-into-icon
476 (idlwave-toolbar-make-button
478 static char * file[] = {
480 \" c #C8C8C8C8C8C8 s backgroundToolBarColor\",
481 \". c #000000000000\",
482 \"G c #0000BBBB0000\",
492 \" .GG.... ........ \",
497 \" .GG...GG. ....... \",
500 \" .GGGGGGG. ....... \",
511 "The Step Into icon.")
513 (defvar idlwave-toolbar-step-out-icon
514 (idlwave-toolbar-make-button
516 static char * file[] = {
518 \" c #C8C8C8C8C8C8 s backgroundToolBarColor\",
519 \". c #000000000000\",
520 \"G c #0000BBBB0000\",
531 \" .GGGGGGG. ........ \",
534 \" .GG...GG. ........ \",
539 \" .GG....... ....... \",
542 \" ........ ....... \",
552 (defvar idlwave-toolbar-eval-icon
553 (idlwave-toolbar-make-button
555 static char * file[] = {
557 \" c #C8C8C8C8C8C8 s backgroundToolBarColor\",
558 \". c #000000000000\",
587 "The Evaluate icon.")
589 (defvar idlwave-toolbar-stack-up-icon
590 (idlwave-toolbar-make-button
592 static char * file[] = {
594 \" c #C8C8C8C8C8C8 s backgroundToolBarColor\",
595 \". s FgColor c #000000000000\",
596 \"_ c #FFFFFFFFFFFF\",
597 \"G c #0000BBBB0000\",
598 \"R c #FFFF00000000\",
606 \" .______. ..... \",
607 \" .______. ....... \",
627 "The Stack Up icon.")
629 (defvar idlwave-toolbar-stack-down-icon
630 (idlwave-toolbar-make-button
632 static char * file[] = {
634 \" c #C8C8C8C8C8C8 s backgroundToolBarColor\",
635 \". s FgColor c #000000000000\",
636 \"_ c #FFFFFFFFFFFF\",
637 \"G c #0000BBBB0000\",
638 \"R c #FFFF00000000\",
659 \" .RRRRRR. ....... \",
660 \" .RRRRRR. ..... \",
667 "The Stack Down icon.")
669 (defvar idlwave-toolbar-reset-icon
670 (idlwave-toolbar-make-button
672 static char * file[] = {
674 \" c #C8C8C8C8C8C8 s backgroundToolBarColor\",
675 \"G c #0000BBBB0000\",
676 \". c #000000000000\",
707 (defvar idlwave-toolbar
709 [idlwave-toolbar-compile-icon
710 idlwave-shell-save-and-compile
712 "Save and Compile this file (or recompile last)"]
713 [idlwave-toolbar-next-error-icon
714 idlwave-shell-goto-next-error
717 [idlwave-toolbar-stop-at-icon
718 idlwave-shell-break-here
719 (eq major-mode 'idlwave-mode)
720 "Set Breakpoint at selected position"]
721 [idlwave-toolbar-stop-in-icon
722 idlwave-shell-break-in
724 "Stop in Function with name near at point"]
725 [idlwave-toolbar-clear-at-icon
726 idlwave-shell-clear-current-bp
728 "Clear Breakpoint at selected position"]
729 [idlwave-toolbar-clear-all-icon
730 idlwave-shell-clear-all-bp
732 "Clear all Breakpoints"]
733 [idlwave-toolbar-edit-cmd-icon
734 idlwave-shell-edit-default-command-line
736 "Edit Default Command Line"]
737 [idlwave-toolbar-run-icon
738 idlwave-shell-execute-default-command-line
740 "Reset, then Execute Default Command Line"]
741 [idlwave-toolbar-cont-icon
744 "Continue Current Program"]
745 [idlwave-toolbar-to-here-icon
746 idlwave-shell-to-here
747 (eq major-mode 'idlwave-mode)
748 "Continue to Here (cursor position)"]
749 [idlwave-toolbar-step-over-icon
750 idlwave-shell-stepover
752 "Step Over (aka next)"]
753 [idlwave-toolbar-step-into-icon
756 "Step Into (aka step)"]
757 [idlwave-toolbar-step-out-icon
760 "Step Out (of subroutine)"]
761 [idlwave-toolbar-eval-icon
764 "Print Expression at or before Point"]
765 [idlwave-toolbar-stack-up-icon
766 idlwave-shell-stack-up
768 "Stack Up (towards \"cooler\" - less recently visited - frames)"]
769 [idlwave-toolbar-stack-down-icon
770 idlwave-shell-stack-down
772 "Stack Down (towards \"warmer\" - more recently visited - frames)"]
773 [idlwave-toolbar-reset-icon
776 "Reset IDL (RETALL & CLOSE,/ALL and more)"]
780 ;; Add the toolbar to all open idlwave buffers when the shell starts.
781 (add-hook 'idlwave-shell-mode-hook 'idlwave-toolbar-add-everywhere)
782 ;; Make sure the toolbar will be added to any future idlwave-mode buffers
783 (add-hook 'idlwave-mode-hook 'idlwave-toolbar-add)
784 ;; When the shell exits, 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 (or (eq major-mode 'idlwave-mode)
793 (eq major-mode 'idlwave-shell-mode)))
794 (set-specifier default-toolbar (cons (current-buffer)
797 (defun idlwave-toolbar-remove ()
798 "Add the IDLWAVE toolbar if appropriate."
799 (if (and (featurep 'xemacs) ; This is a noop on Emacs
800 (or (eq major-mode 'idlwave-mode)
801 (eq major-mode 'idlwave-shell-mode)))
802 (remove-specifier default-toolbar (current-buffer))))
804 (defvar idlwave-shell-mode-map)
805 (defvar idlwave-toolbar-visible nil)
806 (defun idlwave-toolbar-add-everywhere ()
807 "Add the toolbar in all appropriate buffers."
808 (if (featurep 'xemacs)
809 ;; For XEmacs, map over all buffers to add toolbar
811 (mapcar (lambda (buf)
813 (idlwave-toolbar-add))
815 ;; For Emacs, add the key definitions to the mode maps
817 (let* ((icon (aref x 0))
821 (key (vector 'toolbar func))
822 (def (list 'menu-item
825 :image (symbol-value icon)
827 (define-key idlwave-mode-map key def)
828 (define-key idlwave-shell-mode-map key def)))
829 (reverse idlwave-toolbar)))
830 (setq idlwave-toolbar-visible t))
832 (defun idlwave-toolbar-remove-everywhere ()
833 "Remove the toolbar in all appropriate buffers."
834 ;; First make sure new buffers won't get the toolbar
835 (remove-hook 'idlwave-mode-hook 'idlwave-toolbar-add)
836 ;; Then remove it in all existing buffers.
837 (if (featurep 'xemacs)
838 ;; For XEmacs, map over all buffers to remove toolbar
840 (mapcar (lambda (buf)
842 (idlwave-toolbar-remove))
844 ;; For Emacs, remove the key definitions from the mode maps
846 (let* (;;(icon (aref x 0))
850 (key (vector 'toolbar func)))
851 (define-key idlwave-mode-map key nil)
852 (define-key idlwave-shell-mode-map key nil)))
854 (setq idlwave-toolbar-visible nil))
856 (defun idlwave-toolbar-toggle ()
858 (if idlwave-toolbar-visible
859 (idlwave-toolbar-remove-everywhere)
860 (idlwave-toolbar-add-everywhere)))
862 (provide 'idlw-toolbar)
863 (provide 'idlwave-toolbar)
865 ;;; idlw-toolbar.el ends here