Mercurial > emacs
comparison lisp/progmodes/idlw-toolbar.el @ 27605:4f9bc702d860
(idlwave-toolbar-add-everywhere, idlwave-toolbar-remove-everywhere):
Keybindings prefix is now `tool-bar' instead of `toolbar'.
author | Carsten Dominik <dominik@science.uva.nl> |
---|---|
date | Fri, 04 Feb 2000 10:08:49 +0000 |
parents | ae5b17b9c403 |
children | 8eff9cc9cbae |
comparison
equal
deleted
inserted
replaced
27604:0b645a4a64fa | 27605:4f9bc702d860 |
---|---|
1 ;;; idlw-toolbar.el --- A debugging toolbar for IDLWAVE | 1 ;;; idlw-toolbar.el --- A debugging toolbar for IDLWAVE |
2 ;; Copyright (c) 1999 Carsten Dominik | 2 ;; Copyright (c) 1999 Carsten Dominik |
3 ;; Copyright (c) 1999 Free Software Foundation | 3 ;; Copyright (c) 1999 Free Software Foundation |
4 | 4 |
5 ;; Author: Carsten Dominik <dominik@strw.leidenuniv.nl> | 5 ;; Author: Carsten Dominik <dominik@strw.leidenuniv.nl> |
6 ;; Version: 3.12 | 6 ;; Version: 3.15 |
7 ;; Date: $Date: 2000/01/05 12:38:47 $ | 7 ;; Date: $Date: 2000/02/03 15:40:31 $ |
8 ;; Keywords: processes | 8 ;; Keywords: processes |
9 | 9 |
10 ;; This file is part of GNU Emacs. | 10 ;; This file is part of GNU Emacs. |
11 | 11 |
12 ;; GNU Emacs is free software; you can redistribute it and/or modify | 12 ;; GNU Emacs is free software; you can redistribute it and/or modify |
42 (defvar default-toolbar) | 42 (defvar default-toolbar) |
43 (if (not (or (and (featurep 'xemacs) ; This is XEmacs | 43 (if (not (or (and (featurep 'xemacs) ; This is XEmacs |
44 (featurep 'xpm) ; need xpm | 44 (featurep 'xpm) ; need xpm |
45 (featurep 'toolbar)) ; ... and the toolbar | 45 (featurep 'toolbar)) ; ... and the toolbar |
46 (and (not (featurep 'xemacs)) ; This is Emacs | 46 (and (not (featurep 'xemacs)) ; This is Emacs |
47 (boundp 'toolbar-button-margin) ; need toolbar | 47 (boundp 'tool-bar-button-margin) ; need toolbar |
48 (fboundp 'image-type-available-p) ; need image stuff | 48 (fboundp 'image-type-available-p) ; need image stuff |
49 (image-type-available-p 'xpm)) ; need xpm | 49 (image-type-available-p 'xpm)) ; need xpm |
50 )) | 50 )) |
51 ;; oops - cannot do the toolbar | 51 ;; oops - cannot do the toolbar |
52 (message "Sorry, IDLWAVE xpm toolbar cannot be used on this version of Emacs") | 52 (message "Sorry, IDLWAVE xpm toolbar cannot be used on this version of Emacs") |
53 ;; OK, we can define a toolbar | 53 ;; OK, we can define a toolbar |
54 | 54 |
55 (defconst idlwave-toolbar-is-possible t | |
56 "When defined, indicates that a toolbar is possible with this Emacs.") | |
55 (defvar idlwave-toolbar-compile-icon | 57 (defvar idlwave-toolbar-compile-icon |
56 (idlwave-toolbar-make-button | 58 (idlwave-toolbar-make-button |
57 "/* XPM */ | 59 "/* XPM */ |
58 static char * file[] = { | 60 static char * file[] = { |
59 \"28 28 2 1\", | 61 \"28 28 2 1\", |
774 idlwave-shell-reset | 776 idlwave-shell-reset |
775 t | 777 t |
776 "Reset IDL (RETALL & CLOSE,/ALL and more)"] | 778 "Reset IDL (RETALL & CLOSE,/ALL and more)"] |
777 )) | 779 )) |
778 | 780 |
779 | 781 ;; When the shell exits, arrange to remove the special toolbar everywhere. |
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 | 782 (add-hook 'idlwave-shell-cleanup-hook |
786 'idlwave-toolbar-remove-everywhere) | 783 'idlwave-toolbar-remove-everywhere) |
787 );; End can define toolbar | 784 );; End can define toolbar |
788 | 785 |
789 (defun idlwave-toolbar-add () | 786 (defun idlwave-toolbar-add () |
790 "Add the IDLWAVE toolbar if appropriate." | 787 "Add the IDLWAVE toolbar if appropriate." |
791 (if (and (featurep 'xemacs) ; This is a noop on Emacs | 788 (if (and (featurep 'xemacs) ; This is a noop on Emacs |
789 (boundp 'idlwave-toolbar-is-possible) | |
792 (or (eq major-mode 'idlwave-mode) | 790 (or (eq major-mode 'idlwave-mode) |
793 (eq major-mode 'idlwave-shell-mode))) | 791 (eq major-mode 'idlwave-shell-mode))) |
794 (set-specifier default-toolbar (cons (current-buffer) | 792 (set-specifier default-toolbar (cons (current-buffer) |
795 idlwave-toolbar)))) | 793 idlwave-toolbar)))) |
796 | 794 |
797 (defun idlwave-toolbar-remove () | 795 (defun idlwave-toolbar-remove () |
798 "Add the IDLWAVE toolbar if appropriate." | 796 "Add the IDLWAVE toolbar if appropriate." |
799 (if (and (featurep 'xemacs) ; This is a noop on Emacs | 797 (if (and (featurep 'xemacs) ; This is a noop on Emacs |
798 (boundp 'idlwave-toolbar-is-possible) | |
800 (or (eq major-mode 'idlwave-mode) | 799 (or (eq major-mode 'idlwave-mode) |
801 (eq major-mode 'idlwave-shell-mode))) | 800 (eq major-mode 'idlwave-shell-mode))) |
802 (remove-specifier default-toolbar (current-buffer)))) | 801 (remove-specifier default-toolbar (current-buffer)))) |
803 | 802 |
804 (defvar idlwave-shell-mode-map) | 803 (defvar idlwave-shell-mode-map) |
805 (defvar idlwave-toolbar-visible nil) | 804 (defvar idlwave-toolbar-visible nil) |
806 (defun idlwave-toolbar-add-everywhere () | 805 (defun idlwave-toolbar-add-everywhere () |
807 "Add the toolbar in all appropriate buffers." | 806 "Add the toolbar in all appropriate buffers." |
808 (if (featurep 'xemacs) | 807 (when (boundp 'idlwave-toolbar-is-possible) |
809 ;; For XEmacs, map over all buffers to add toolbar | 808 |
810 (save-excursion | 809 ;; First make sure new buffers will get the toolbar |
811 (mapcar (lambda (buf) | 810 (add-hook 'idlwave-mode-hook 'idlwave-toolbar-add) |
812 (set-buffer buf) | 811 ;; Then add it to all existing buffers |
813 (idlwave-toolbar-add)) | 812 (if (featurep 'xemacs) |
814 (buffer-list))) | 813 ;; For XEmacs, map over all buffers to add toolbar |
815 ;; For Emacs, add the key definitions to the mode maps | 814 (save-excursion |
816 (mapcar (lambda (x) | 815 (mapcar (lambda (buf) |
817 (let* ((icon (aref x 0)) | 816 (set-buffer buf) |
818 (func (aref x 1)) | 817 (idlwave-toolbar-add)) |
819 ;;(show (aref x 2)) | 818 (buffer-list))) |
820 (help (aref x 3)) | 819 ;; For Emacs, add the key definitions to the mode maps |
821 (key (vector 'toolbar func)) | 820 (mapcar (lambda (x) |
822 (def (list 'menu-item | 821 (let* ((icon (aref x 0)) |
823 "a" | 822 (func (aref x 1)) |
824 func | 823 ;;(show (aref x 2)) |
825 :image (symbol-value icon) | 824 (help (aref x 3)) |
826 :help help))) | 825 (key (vector 'tool-bar func)) |
827 (define-key idlwave-mode-map key def) | 826 (def (list 'menu-item |
828 (define-key idlwave-shell-mode-map key def))) | 827 "a" |
829 (reverse idlwave-toolbar))) | 828 func |
830 (setq idlwave-toolbar-visible t)) | 829 :image (symbol-value icon) |
830 :help help))) | |
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))) | |
831 | 835 |
832 (defun idlwave-toolbar-remove-everywhere () | 836 (defun idlwave-toolbar-remove-everywhere () |
833 "Remove the toolbar in all appropriate buffers." | 837 "Remove the toolbar in all appropriate buffers." |
834 ;; First make sure new buffers won't get the toolbar | 838 ;; First make sure new buffers won't get the toolbar |
835 (remove-hook 'idlwave-mode-hook 'idlwave-toolbar-add) | 839 (when idlwave-toolbar-is-possible |
836 ;; Then remove it in all existing buffers. | 840 (remove-hook 'idlwave-mode-hook 'idlwave-toolbar-add) |
837 (if (featurep 'xemacs) | 841 ;; Then remove it in all existing buffers. |
838 ;; For XEmacs, map over all buffers to remove toolbar | 842 (if (featurep 'xemacs) |
839 (save-excursion | 843 ;; For XEmacs, map over all buffers to remove toolbar |
840 (mapcar (lambda (buf) | 844 (save-excursion |
841 (set-buffer buf) | 845 (mapcar (lambda (buf) |
842 (idlwave-toolbar-remove)) | 846 (set-buffer buf) |
843 (buffer-list))) | 847 (idlwave-toolbar-remove)) |
844 ;; For Emacs, remove the key definitions from the mode maps | 848 (buffer-list))) |
845 (mapcar (lambda (x) | 849 ;; For Emacs, remove the key definitions from the mode maps |
846 (let* (;;(icon (aref x 0)) | 850 (mapcar (lambda (x) |
847 (func (aref x 1)) | 851 (let* (;;(icon (aref x 0)) |
848 ;;(show (aref x 2)) | 852 (func (aref x 1)) |
849 ;;(help (aref x 3)) | 853 ;;(show (aref x 2)) |
850 (key (vector 'toolbar func))) | 854 ;;(help (aref x 3)) |
851 (define-key idlwave-mode-map key nil) | 855 (key (vector 'tool-bar func))) |
852 (define-key idlwave-shell-mode-map key nil))) | 856 (define-key idlwave-mode-map key nil) |
853 idlwave-toolbar)) | 857 (define-key idlwave-shell-mode-map key nil))) |
854 (setq idlwave-toolbar-visible nil)) | 858 idlwave-toolbar)) |
855 | 859 (setq idlwave-toolbar-visible nil))) |
856 (defun idlwave-toolbar-toggle () | 860 |
861 (defun idlwave-toolbar-toggle (&optional force-on) | |
857 (interactive) | 862 (interactive) |
858 (if idlwave-toolbar-visible | 863 (if idlwave-toolbar-visible |
859 (idlwave-toolbar-remove-everywhere) | 864 (or force-on (idlwave-toolbar-remove-everywhere)) |
860 (idlwave-toolbar-add-everywhere))) | 865 (idlwave-toolbar-add-everywhere))) |
861 | 866 |
862 (provide 'idlw-toolbar) | 867 (provide 'idlw-toolbar) |
863 (provide 'idlwave-toolbar) | 868 (provide 'idlwave-toolbar) |
864 | 869 |