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>
6 ;; Date: $Date: 2000/12/11 12:44:44 $
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.
34 (eval-when-compile (require 'cl))
36 (defun idlwave-toolbar-make-button (image)
37 (if (featurep 'xemacs)
38 (toolbar-make-button-list image)
39 (list 'image :type 'xpm :data image)))
41 (defvar default-toolbar)
42 (if (not (or (and (featurep 'xemacs) ; This is XEmacs
43 (featurep 'xpm) ; need xpm
44 (featurep 'toolbar)) ; ... and the toolbar
45 (and (not (featurep 'xemacs)) ; This is Emacs
46 (boundp 'tool-bar-button-margin) ; need toolbar
47 (fboundp 'image-type-available-p) ; need image stuff
48 (image-type-available-p 'xpm)) ; need xpm
50 ;; oops - cannot do the toolbar
51 (message "Sorry, IDLWAVE xpm toolbar cannot be used on this version of Emacs")
52 ;; OK, we can define a toolbar
54 (defconst idlwave-toolbar-is-possible t
55 "When defined, indicates that a toolbar is possible with this Emacs.")
56 (defvar idlwave-toolbar-compile-icon
57 (idlwave-toolbar-make-button
59 static char * file[] = {
61 \" c #C8C8C8C8C8C8 s backgroundToolBarColor\",
62 \". c #000000000000\",
71 \" ................... \",
72 \" ........ ........ \",
75 \" ..... .. ... ..... \",
76 \" ...... .. .. ...... \",
77 \" ..... ... .. ..... \",
80 \" ........ ........ \",
81 \" ................... \",
93 (defvar idlwave-toolbar-next-error-icon
94 (idlwave-toolbar-make-button
96 static char * file[] = {
98 \" c #C8C8C8C8C8C8 s backgroundToolBarColor\",
99 \". c #000000000000\",
100 \"R c #FFFF00000000\",
108 \" RRRRRRRRRRRRRRRRRRR \",
115 \" ..... .. ... ..... \",
116 \" ...... .. .. ...... \",
117 \" ..... ... .. ..... \",
118 \" ......... .... \",
119 \" ........ ..... \",
120 \" ........ ........ \",
121 \" ................... \",
129 "The Next Error icon.")
131 (defvar idlwave-toolbar-stop-at-icon
132 (idlwave-toolbar-make-button
134 static char * file[] = {
136 \" c #C8C8C8C8C8C8 s backgroundToolBarColor\",
137 \". c #000000000000\",
138 \"R c #FFFF00000000\",
146 \" .RRRRRRRRRRRR. \",
147 \" .RRRRRRRRRRRRRR. \",
148 \" .RRRRRRRRRRRRRRRR. \",
149 \" .RRRRRRRRRRRRRRRRRR. \",
150 \" .RRRRRRRRRRRRRRRRRR. \",
151 \" .RRRRRRRRRRRRRRRRRR. \",
152 \" .RRRRRRRRRRRRRRRRRR. \",
153 \" .RRRRRRRRRRRRRRRRRR. \",
154 \" .RRRRRRRRRRRRRRRRRR. \",
155 \" .RRRRRRRRRRRRRRRRRR. \",
156 \" .RRRRRRRRRRRRRRRRRR. \",
157 \" .RRRRRRRRRRRRRRRR. \",
158 \" .RRRRRRRRRRRRRR. \",
159 \" .RRRRRRRRRRRR. \",
169 (defvar idlwave-toolbar-stop-in-icon
170 (idlwave-toolbar-make-button
172 static char * file[] = {
174 \" c #C8C8C8C8C8C8 s backgroundToolBarColor\",
175 \"_ c #FFFFFFFFFFFF\",
176 \". c #000000000000\",
177 \"R c #FFFF00000000\",
185 \" .RRRRRRRRRRRR. \",
186 \" .RRR___RR___RRR. \",
187 \" .RRRR__RRRR__RRRR. \",
188 \" .RRRRR__RRRR__RRRRR. \",
189 \" .RRRRR__RRRR__RRRRR. \",
190 \" .RRRRR__RRRR__RRRRR. \",
191 \" .RRRR__RRRRRR__RRRR. \",
192 \" .RRRRR__RRRR__RRRRR. \",
193 \" .RRRRR__RRRR__RRRRR. \",
194 \" .RRRRR__RRRR__RRRRR. \",
195 \" .RRRRR__RRRR__RRRRR. \",
196 \" .RRRR___RR___RRRR. \",
197 \" .RRRRRRRRRRRRRR. \",
198 \" .RRRRRRRRRRRR. \",
209 (defvar idlwave-toolbar-clear-at-icon
210 (idlwave-toolbar-make-button
212 static char * file[] = {
214 \" c #C8C8C8C8C8C8 s backgroundToolBarColor\",
215 \". c #000000000000\",
216 \"R c #FFFF00000000\",
221 \" ... ........ ... \",
222 \" ... .RRRRRRRR. ... \",
223 \" ....RRRRRRRRRR.... \",
224 \" ...RRRRRRRRRR... \",
225 \" ....RRRRRRRR.... \",
226 \" .RR...RRRRRR...RR. \",
227 \" .RRRR...RRRR...RRRR. \",
228 \" .RRRRR...RR...RRRRR. \",
229 \" .RRRRRR......RRRRRR. \",
230 \" .RRRRRRR....RRRRRRR. \",
231 \" .RRRRRRR....RRRRRRR. \",
232 \" .RRRRRR......RRRRRR. \",
233 \" .RRRRR...RR...RRRRR. \",
234 \" .RRRR...RRRR...RRRR. \",
235 \" .RR...RRRRRR...RR. \",
236 \" ....RRRRRRRR.... \",
237 \" ...RRRRRRRRRR... \",
238 \" ....RRRRRRRRRR.... \",
239 \" ... .RRRRRRRR. ... \",
240 \" ... ........ ... \",
245 "The Clear At icon.")
247 (defvar idlwave-toolbar-clear-all-icon
248 (idlwave-toolbar-make-button
250 static char * file[] = {
252 \" c #C8C8C8C8C8C8 s backgroundToolBarColor\",
253 \". c #000000000000\",
254 \"X c #FFFFFFFFFFFF\",
255 \"R c #FFFF00000000\",
259 \" .. .... .... .. \",
260 \" ...RRRR. .RRRR... \",
261 \" ...RRRR. .RRRR... \",
262 \" .R...RRRR. .RRRR...R. \",
263 \" .RR...RRR. .RRR...RR. \",
264 \" .RRR...RR. .RR...RRR. \",
265 \" .RRRR...R. .R...RRRR. \",
266 \" .RRRR... ...RRRR. \",
267 \" .RRRR... ...RRRR. \",
268 \" .... ... ... .... \",
271 \" .... ..... .... \",
272 \" .RRRR.... ....RRRR. \",
273 \" .RRRRR... ...RRRRR. \",
274 \" .RRRRR.... ....RRRRR. \",
275 \" .RRRR...R. .R...RRRR. \",
276 \" .RRR...RR. .RR...RRR. \",
277 \" .RR...RRR. .RRR...RR. \",
278 \" ....RRR. .RRR.... \",
279 \" ...RRR. .RRR... \",
280 \" ....... ....... \",
284 "The Clear-All icon.")
286 (defvar idlwave-toolbar-edit-cmd-icon
287 (idlwave-toolbar-make-button
289 static char * file[] = {
291 \" c #C8C8C8C8C8C8 s backgroundToolBarColor\",
292 \". c #000000000000\",
311 \" ................. \",
323 (defvar idlwave-toolbar-run-icon
324 (idlwave-toolbar-make-button
326 static char * file[] = {
328 \" c #C8C8C8C8C8C8 s backgroundToolBarColor\",
329 \". s FgColor c #000000000000\",
330 \"G c #0000BBBB0000\",
344 \" .GGGGGGG. ....... \",
361 (defvar idlwave-toolbar-cont-icon
362 (idlwave-toolbar-make-button
364 static char * file[] = {
366 \" c #C8C8C8C8C8C8 s backgroundToolBarColor\",
367 \". s FgColor c #000000000000\",
368 \"G c #0000BBBB0000\",
375 \" .GGGGGG. ....... \",
384 \" .GGGGGGG. ....... \",
399 (defvar idlwave-toolbar-to-here-icon
400 (idlwave-toolbar-make-button
402 static char * file[] = {
404 \" c #C8C8C8C8C8C8 s backgroundToolBarColor\",
405 \". c #000000000000\",
406 \"G c #0000BBBB0000\",
407 \"R c #FFFF00000000\",
414 \" ..... ........ \",
417 \" .GG.... ........ \",
421 \" .GG. .G. ...... \",
423 \" .GGGGGGGG. RRRRRR \",
424 \" .GGGGGGGGG. RRRRRR \",
425 \" .GGGGGGG. RRRRRR \",
436 "The Cont-to-here icon.")
438 (defvar idlwave-toolbar-step-over-icon
439 (idlwave-toolbar-make-button
441 static char * file[] = {
443 \" c #C8C8C8C8C8C8 s backgroundToolBarColor\",
444 \". c #000000000000\",
445 \"G c #0000BBBB0000\",
453 \" .GGGG. ....... \",
459 \" .GG. .G. ....... \",
462 \" .GGGGGGGGG. ....... \",
474 "The Step Over icon.")
476 (defvar idlwave-toolbar-step-into-icon
477 (idlwave-toolbar-make-button
479 static char * file[] = {
481 \" c #C8C8C8C8C8C8 s backgroundToolBarColor\",
482 \". c #000000000000\",
483 \"G c #0000BBBB0000\",
493 \" .GG.... ........ \",
498 \" .GG...GG. ....... \",
501 \" .GGGGGGG. ....... \",
512 "The Step Into icon.")
514 (defvar idlwave-toolbar-step-out-icon
515 (idlwave-toolbar-make-button
517 static char * file[] = {
519 \" c #C8C8C8C8C8C8 s backgroundToolBarColor\",
520 \". c #000000000000\",
521 \"G c #0000BBBB0000\",
532 \" .GGGGGGG. ........ \",
535 \" .GG...GG. ........ \",
540 \" .GG....... ....... \",
543 \" ........ ....... \",
553 (defvar idlwave-toolbar-eval-icon
554 (idlwave-toolbar-make-button
556 static char * file[] = {
558 \" c #C8C8C8C8C8C8 s backgroundToolBarColor\",
559 \". c #000000000000\",
588 "The Evaluate icon.")
590 (defvar idlwave-toolbar-stack-up-icon
591 (idlwave-toolbar-make-button
593 static char * file[] = {
595 \" c #C8C8C8C8C8C8 s backgroundToolBarColor\",
596 \". s FgColor c #000000000000\",
597 \"_ c #FFFFFFFFFFFF\",
598 \"G c #0000BBBB0000\",
599 \"R c #FFFF00000000\",
607 \" .______. ..... \",
608 \" .______. ....... \",
628 "The Stack Up icon.")
630 (defvar idlwave-toolbar-stack-down-icon
631 (idlwave-toolbar-make-button
633 static char * file[] = {
635 \" c #C8C8C8C8C8C8 s backgroundToolBarColor\",
636 \". s FgColor c #000000000000\",
637 \"_ c #FFFFFFFFFFFF\",
638 \"G c #0000BBBB0000\",
639 \"R c #FFFF00000000\",
660 \" .RRRRRR. ....... \",
661 \" .RRRRRR. ..... \",
668 "The Stack Down icon.")
670 (defvar idlwave-toolbar-reset-icon
671 (idlwave-toolbar-make-button
673 static char * file[] = {
675 \" c #C8C8C8C8C8C8 s backgroundToolBarColor\",
676 \"G c #0000BBBB0000\",
677 \". c #000000000000\",
708 (defvar idlwave-toolbar
710 [idlwave-toolbar-compile-icon
711 idlwave-shell-save-and-compile
713 "Save and Compile this file (or recompile last)"]
714 [idlwave-toolbar-next-error-icon
715 idlwave-shell-goto-next-error
718 [idlwave-toolbar-stop-at-icon
719 idlwave-shell-break-here
720 (eq major-mode 'idlwave-mode)
721 "Set Breakpoint at selected position"]
722 [idlwave-toolbar-stop-in-icon
723 idlwave-shell-break-in
725 "Stop in Function with name near at point"]
726 [idlwave-toolbar-clear-at-icon
727 idlwave-shell-clear-current-bp
729 "Clear Breakpoint at selected position"]
730 [idlwave-toolbar-clear-all-icon
731 idlwave-shell-clear-all-bp
733 "Clear all Breakpoints"]
734 [idlwave-toolbar-edit-cmd-icon
735 idlwave-shell-edit-default-command-line
737 "Edit Default Command Line"]
738 [idlwave-toolbar-run-icon
739 idlwave-shell-execute-default-command-line
741 "Reset, then Execute Default Command Line"]
742 [idlwave-toolbar-cont-icon
745 "Continue Current Program"]
746 [idlwave-toolbar-to-here-icon
747 idlwave-shell-to-here
748 (eq major-mode 'idlwave-mode)
749 "Continue to Here (cursor position)"]
750 [idlwave-toolbar-step-over-icon
751 idlwave-shell-stepover
753 "Step Over (aka next)"]
754 [idlwave-toolbar-step-into-icon
757 "Step Into (aka step)"]
758 [idlwave-toolbar-step-out-icon
761 "Step Out (of subroutine)"]
762 [idlwave-toolbar-eval-icon
765 "Print Expression at or before Point"]
766 [idlwave-toolbar-stack-up-icon
767 idlwave-shell-stack-up
769 "Stack Up (towards \"cooler\" - less recently visited - frames)"]
770 [idlwave-toolbar-stack-down-icon
771 idlwave-shell-stack-down
773 "Stack Down (towards \"warmer\" - more recently visited - frames)"]
774 [idlwave-toolbar-reset-icon
777 "Reset IDL (RETALL & CLOSE,/ALL and more)"]
780 ;; When the shell exits, arrange to remove the special toolbar everywhere.
781 (add-hook 'idlwave-shell-cleanup-hook
782 'idlwave-toolbar-remove-everywhere)
783 );; End can define toolbar
785 (defun idlwave-toolbar-add ()
786 "Add the IDLWAVE toolbar if appropriate."
787 (if (and (featurep 'xemacs) ; This is a noop on Emacs
788 (boundp 'idlwave-toolbar-is-possible)
789 (or (eq major-mode 'idlwave-mode)
790 (eq major-mode 'idlwave-shell-mode)))
791 (set-specifier default-toolbar (cons (current-buffer)
794 (defun idlwave-toolbar-remove ()
795 "Add the IDLWAVE toolbar if appropriate."
796 (if (and (featurep 'xemacs) ; This is a noop on Emacs
797 (boundp 'idlwave-toolbar-is-possible)
798 (or (eq major-mode 'idlwave-mode)
799 (eq major-mode 'idlwave-shell-mode)))
800 (remove-specifier default-toolbar (current-buffer))))
802 (defvar idlwave-shell-mode-map)
803 (defvar idlwave-mode-map)
804 (defvar idlwave-toolbar-visible nil)
805 (defun idlwave-toolbar-add-everywhere ()
806 "Add the toolbar in all appropriate buffers."
807 (when (boundp 'idlwave-toolbar-is-possible)
809 ;; First make sure new buffers will get the toolbar
810 (add-hook 'idlwave-mode-hook 'idlwave-toolbar-add)
811 ;; Then add it to all existing buffers
812 (if (featurep 'xemacs)
813 ;; For XEmacs, map over all buffers to add toolbar
815 (mapcar (lambda (buf)
817 (idlwave-toolbar-add))
819 ;; For Emacs, add the key definitions to the mode maps
821 (let* ((icon (aref x 0))
825 (key (vector 'tool-bar func))
826 (def (list 'menu-item
829 :image (symbol-value icon)
831 (define-key idlwave-mode-map key def)
832 (define-key idlwave-shell-mode-map key def)))
833 (reverse idlwave-toolbar)))
834 (setq idlwave-toolbar-visible t)))
836 (defun idlwave-toolbar-remove-everywhere ()
837 "Remove the toolbar in all appropriate buffers."
838 ;; First make sure new buffers won't get the toolbar
839 (when idlwave-toolbar-is-possible
840 (remove-hook 'idlwave-mode-hook 'idlwave-toolbar-add)
841 ;; Then remove it in all existing buffers.
842 (if (featurep 'xemacs)
843 ;; For XEmacs, map over all buffers to remove toolbar
845 (mapcar (lambda (buf)
847 (idlwave-toolbar-remove))
849 ;; For Emacs, remove the key definitions from the mode maps
851 (let* (;;(icon (aref x 0))
855 (key (vector 'tool-bar func)))
856 (define-key idlwave-mode-map key nil)
857 (define-key idlwave-shell-mode-map key nil)))
859 (setq idlwave-toolbar-visible nil)))
861 (defun idlwave-toolbar-toggle (&optional force-on)
863 (if idlwave-toolbar-visible
864 (or force-on (idlwave-toolbar-remove-everywhere))
865 (idlwave-toolbar-add-everywhere))
866 ;; Now make sure this
867 (if (featurep 'xemacs)
868 nil ; no action necessary, toolbar gets updated automatically
869 ;; On Emacs, redraw the frame to make sure the Toolbar is updated.
870 (redraw-frame (selected-frame))))
872 (provide 'idlw-toolbar)
873 (provide 'idlwave-toolbar)
875 ;;; idlw-toolbar.el ends here