Mercurial > hg > xemacs-beta
comparison lisp/prim/frame.el @ 70:131b0175ea99 r20-0b30
Import from CVS: tag r20-0b30
author | cvs |
---|---|
date | Mon, 13 Aug 2007 09:02:59 +0200 |
parents | 56c54cf7c5b6 |
children | c0c698873ce1 |
comparison
equal
deleted
inserted
replaced
69:804d1389bcd6 | 70:131b0175ea99 |
---|---|
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
19 ;; General Public License for more details. | 19 ;; General Public License for more details. |
20 | 20 |
21 ;; You should have received a copy of the GNU General Public License | 21 ;; You should have received a copy of the GNU General Public License |
22 ;; along with XEmacs; see the file COPYING. If not, write to the | 22 ;; along with XEmacs; see the file COPYING. If not, write to the |
23 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 23 ;; Free Software Foundation, 59 Temple Place - Suite 330, |
24 ;; Boston, MA 02111-1307, USA. | 24 ;; Boston, MA 02111-1307, USA. |
25 | 25 |
26 ;;; Synched up with: FSF 19.30. | 26 ;;; Synched up with: FSF 19.30. |
27 | 27 |
28 ;;; Code: | 28 ;;; Code: |
437 system. Not currently implemented. | 437 system. Not currently implemented. |
438 win32 A connection to a machine running Microsoft Windows NT or | 438 win32 A connection to a machine running Microsoft Windows NT or |
439 Windows 95. Not currently implemented. | 439 Windows 95. Not currently implemented. |
440 pc A direct-write MS-DOS frame. Not currently implemented. | 440 pc A direct-write MS-DOS frame. Not currently implemented. |
441 | 441 |
442 PROPS should be an plist of properties, as in the call to `make-frame'. | 442 PROPS should be a plist of properties, as in the call to `make-frame'. |
443 | 443 |
444 If a connection to CONNECTION already exists, it is reused; otherwise, | 444 If a connection to CONNECTION already exists, it is reused; otherwise, |
445 a new connection is opened." | 445 a new connection is opened." |
446 (make-frame props (make-device type connection props))) | 446 (make-frame props (make-device type connection props))) |
447 | 447 |
530 (defun frame-type (&optional frame) | 530 (defun frame-type (&optional frame) |
531 "Return the type of the specified frame (e.g. `x' or `tty'). | 531 "Return the type of the specified frame (e.g. `x' or `tty'). |
532 This is equivalent to the type of the frame's device. | 532 This is equivalent to the type of the frame's device. |
533 Value is `tty' for a tty frame (a character-only terminal), | 533 Value is `tty' for a tty frame (a character-only terminal), |
534 `x' for a frame that is an X window, | 534 `x' for a frame that is an X window, |
535 `ns' for a frame that is a NeXTstep window (not yet implemented), | 535 `ns' for a frame that is a NeXTstep window (not yet implemeted), |
536 `win32' for a frame that is a Windows or Windows NT window (not yet | 536 `win32' for a frame that is a Windows or Windows NT window (not yet |
537 implemented), | 537 implemented), |
538 `pc' for a frame that is a direct-write MS-DOS frame (not yet implemented), | 538 `pc' for a frame that is a direct-write MS-DOS frame (not yet implemented), |
539 `stream' for a stream frame (which acts like a stdio stream), and | 539 `stream' for a stream frame (which acts like a stdio stream), and |
540 `dead' for a deleted frame." | 540 `dead' for a deleted frame." |
719 (list frame-icon-title-format map-frame-hook frames) | 719 (list frame-icon-title-format map-frame-hook frames) |
720 frame-icon-title-format icon-name | 720 frame-icon-title-format icon-name |
721 map-frame-hook 'deiconify-emacs) | 721 map-frame-hook 'deiconify-emacs) |
722 (iconify-frame me))) | 722 (iconify-frame me))) |
723 | 723 |
724 | |
725 (defun deiconify-emacs (&optional ignore) | 724 (defun deiconify-emacs (&optional ignore) |
726 (or iconification-data (error "not iconified?")) | 725 (or iconification-data (error "not iconified?")) |
727 (setq frame-icon-title-format (car iconification-data) | 726 (setq frame-icon-title-format (car iconification-data) |
728 map-frame-hook (car (cdr iconification-data)) | 727 map-frame-hook (car (cdr iconification-data)) |
729 iconification-data (car (cdr (cdr iconification-data)))) | 728 iconification-data (car (cdr (cdr iconification-data)))) |
730 (while iconification-data | 729 (while iconification-data |
731 (let ((visibility (cdr (car iconification-data)))) | 730 (let ((visibility (cdr (car iconification-data)))) |
732 (cond (visibility ;; JV (Note non-nil means visible in XEmacs) | 731 (cond ((eq visibility 't) |
733 (make-frame-visible (car (car iconification-data)))) | 732 (make-frame-visible (car (car iconification-data)))) |
734 ; (t ;; (eq visibility 'icon) ;; JV Not in XEmacs!!! | 733 ; (t ;; (eq visibility 'icon) |
735 ; (make-frame-visible (car (car iconification-data))) | 734 ; (make-frame-visible (car (car iconification-data))) |
736 ; (sleep-for 500 t) ; process X events; I really want to XSync() here | 735 ; (sleep-for 500 t) ; process X events; I really want to XSync() here |
737 ; (iconify-frame (car (car iconification-data)))) | 736 ; (iconify-frame (car (car iconification-data)))) |
738 ;; (t nil) | 737 ;; (t nil) |
739 )) | 738 )) |
740 (setq iconification-data (cdr iconification-data)))) | 739 (setq iconification-data (cdr iconification-data)))) |
741 | 740 |
742 (defun suspend-or-iconify-emacs () | 741 (defun suspend-or-iconify-emacs () |
743 "Calls iconify-emacs if frame is an X frame, otherwise calls suspend-emacs" | 742 "Calls iconify-emacs if frame is an X frame, otherwise calls suspend-emacs" |
744 (interactive) | 743 (interactive) |
745 (cond | 744 (if (eq (frame-type (selected-frame)) 'x) |
746 ((eq (frame-type (selected-frame)) 'x) (iconify-emacs)) | 745 (iconify-emacs) |
747 ((and (eq (frame-type (selected-frame)) 'tty) | 746 (suspend-emacs))) |
748 (console-tty-controlling-process (selected-console))) | |
749 (suspend-console (selected-console))) | |
750 (t | |
751 (suspend-emacs)))) | |
752 | 747 |
753 | 748 |
754 ;;; auto-raise and auto-lower | 749 ;;; auto-raise and auto-lower |
755 | 750 |
756 (defvar auto-raise-frame nil | 751 (defvar auto-raise-frame nil |
794 | 789 |
795 (and (boundp 'drag-and-drop-functions) | 790 (and (boundp 'drag-and-drop-functions) |
796 (or drag-and-drop-functions | 791 (or drag-and-drop-functions |
797 (add-hook 'drag-and-drop-functions 'default-drag-and-drop-functions))) | 792 (add-hook 'drag-and-drop-functions 'default-drag-and-drop-functions))) |
798 | 793 |
794 (defun cde-start-drag (begin end) | |
795 "Implements the CDE drag operation. | |
796 Calls the internal function cde-start-drag-internal to do the actual work." | |
797 (interactive "_r") | |
798 (if (featurep 'cde) | |
799 (cde-start-drag-internal (buffer-substring-no-properties begin end)) | |
800 (error "CDE functionality not compiled in."))) | |
801 | |
799 | 802 |
800 ;;; Application-specific frame-management | 803 ;;; Application-specific frame-management |
801 | 804 |
802 (defvar get-frame-for-buffer-default-frame-name nil | 805 (defvar get-frame-for-buffer-default-frame-name nil |
803 "The default frame to select; see doc of `get-frame-for-buffer'.") | 806 "The default frame to select; see doc of `get-frame-for-buffer'.") |
809 (save-excursion (set-buffer buffer) | 812 (save-excursion (set-buffer buffer) |
810 major-mode)))) | 813 major-mode)))) |
811 (or (get mode 'frame-name) | 814 (or (get mode 'frame-name) |
812 get-frame-for-buffer-default-frame-name))) | 815 get-frame-for-buffer-default-frame-name))) |
813 | 816 |
814 (defun get-frame-for-buffer-make-new-frame (buffer &optional frame-name plist) | 817 |
815 (let* ((fr (make-frame plist)) | 818 (defun get-frame-for-buffer-make-new-frame (buffer &optional frame-name) |
819 (let* ((fr (make-frame (and frame-name (list (cons 'name frame-name))))) | |
816 (w (frame-root-window fr))) | 820 (w (frame-root-window fr))) |
817 ;; | 821 ;; |
818 ;; Make the one buffer being displayed in this newly created | 822 ;; Make the one buffer being displayed in this newly created |
819 ;; frame be the buffer of interest, instead of something | 823 ;; frame be the buffer of interest, instead of something |
820 ;; random, so that it won't be shown in two-window mode. | 824 ;; random, so that it won't be shown in two-window mode. |
845 ;; | 849 ;; |
846 ;; This buffer's mode expressed a preference for a frame of a particular | 850 ;; This buffer's mode expressed a preference for a frame of a particular |
847 ;; name. That always takes priority. | 851 ;; name. That always takes priority. |
848 ;; | 852 ;; |
849 (let ((limit (get name 'instance-limit)) | 853 (let ((limit (get name 'instance-limit)) |
850 (defaults (get name 'frame-defaults)) | |
851 (matching-frames '()) | 854 (matching-frames '()) |
852 frames frame already-visible) | 855 frames frame already-visible) |
853 ;; Sort the list so that iconic frames will be found last. They | 856 ;; Sort the list so that iconic frames will be found last. They |
854 ;; will be used too, but mapped frames take precedence. And | 857 ;; will be used too, but mapped frames take precedence. And |
855 ;; fully visible frames come before occluded frames. | 858 ;; fully visible frames come before occluded frames. |
856 ;; Hidden frames come after really visible ones | |
857 (setq frames | 859 (setq frames |
858 (sort (frame-list) | 860 (sort (frame-list) |
859 #'(lambda (s1 s2) | 861 #'(lambda (s1 s2) |
860 (cond ((frame-totally-visible-p s2) | 862 (cond ((frame-totally-visible-p s2) |
861 nil) | 863 nil) |
862 ((not (frame-visible-p s2)) | 864 ((not (frame-visible-p s2)) |
863 (frame-visible-p s1)) | 865 (frame-visible-p s1)) |
864 ((eq (frame-visible-p s2) 'hidden) | |
865 (eq (frame-visible-p s1) t )) | |
866 ((not (frame-totally-visible-p s2)) | 866 ((not (frame-totally-visible-p s2)) |
867 (and (frame-visible-p s1) | 867 (and (frame-visible-p s1) |
868 (frame-totally-visible-p s1))))))) | 868 (frame-totally-visible-p s1))))))) |
869 ;; but the selected frame should come first, even if it's occluded, | 869 ;; but the selected frame should come first, even if it's occluded, |
870 ;; to minimize thrashing. | 870 ;; to minimize thrashing. |
883 (cond (already-visible | 883 (cond (already-visible |
884 already-visible) | 884 already-visible) |
885 ((or (null matching-frames) | 885 ((or (null matching-frames) |
886 (eq limit 0) ; means create with reckless abandon | 886 (eq limit 0) ; means create with reckless abandon |
887 (and limit (< (length matching-frames) limit))) | 887 (and limit (< (length matching-frames) limit))) |
888 (get-frame-for-buffer-make-new-frame | 888 (get-frame-for-buffer-make-new-frame buffer name)) |
889 buffer | |
890 name | |
891 (alist-to-plist (acons 'name name | |
892 (plist-to-alist defaults))))) | |
893 (t | 889 (t |
894 ;; do not switch any of the window/buffer associations in an | 890 ;; do not switch any of the window/buffer associations in an |
895 ;; existing frame; this function only picks a frame; the | 891 ;; existing frame; this function only picks a frame; the |
896 ;; determination of which windows on it get reused is up to | 892 ;; determination of which windows on it get reused is up to |
897 ;; display-buffer itself. | 893 ;; display-buffer itself. |
912 (or (frame-visible-p x) | 908 (or (frame-visible-p x) |
913 (frame-iconified-p x)))) | 909 (frame-iconified-p x)))) |
914 #'(lambda (s1 s2) | 910 #'(lambda (s1 s2) |
915 (cond ((and (frame-visible-p s1) | 911 (cond ((and (frame-visible-p s1) |
916 (not (frame-visible-p s2)))) | 912 (not (frame-visible-p s2)))) |
917 ((and (eq (frame-visible-p s1) t) | |
918 (eq (frame-visible-p s2) 'hidden))) | |
919 ((and (frame-visible-p s2) | 913 ((and (frame-visible-p s2) |
920 (not (frame-visible-p s1))) | 914 (not (frame-visible-p s1))) |
921 nil) | 915 nil) |
922 ((and (equal (frame-name s1) defname) | 916 ((and (equal (frame-name s1) defname) |
923 (not (equal (frame-name s2) defname)))) | 917 (not (equal (frame-name s2) defname)))) |
1014 nil | 1008 nil |
1015 (if (eq cur-frame next-frame) | 1009 (if (eq cur-frame next-frame) |
1016 (setq save-frame next-frame) | 1010 (setq save-frame next-frame) |
1017 (and | 1011 (and |
1018 (or (not visible-only) | 1012 (or (not visible-only) |
1019 (frame-visible-p next-frame)) | 1013 (eq t (frame-visible-p next-frame))) |
1020 (setq frames (append frames (list next-frame)))))) | 1014 (setq frames (append frames (list next-frame)))))) |
1021 (setq list (cdr list))) | 1015 (setq list (cdr list))) |
1022 | 1016 |
1023 (if save-frame | 1017 (if save-frame |
1024 (append (list save-frame) frames) | 1018 (append (list save-frame) frames) |
1025 frames))) | 1019 frames))) |
1026 | |
1027 (defvar temp-buffer-shrink-to-fit t | |
1028 "*When non-nil resize temporary output buffers to minimize blank lines.") | |
1029 | |
1030 (defvar temp-buffer-max-height .5 | |
1031 "*Proportion of frame to use for temp windows.") | |
1032 | 1020 |
1033 (defun show-temp-buffer-in-current-frame (buffer) | 1021 (defun show-temp-buffer-in-current-frame (buffer) |
1034 "For use as the value of temp-buffer-show-function: | 1022 "For use as the value of temp-buffer-show-function: |
1035 always displays the buffer in the current frame, regardless of the behavior | 1023 always displays the buffer in the current frame, regardless of the behavior |
1036 that would otherwise be introduced by the `pre-display-buffer-function', which | 1024 that would otherwise be introduced by the `pre-display-buffer-function', which |
1041 ;; only the pre-display-buffer-function should ever do this. | 1029 ;; only the pre-display-buffer-function should ever do this. |
1042 (error "display-buffer switched frames on its own!!")) | 1030 (error "display-buffer switched frames on its own!!")) |
1043 (setq minibuffer-scroll-window window) | 1031 (setq minibuffer-scroll-window window) |
1044 (set-window-start window 1) ; obeys narrowing | 1032 (set-window-start window 1) ; obeys narrowing |
1045 (set-window-point window 1) | 1033 (set-window-point window 1) |
1046 (when temp-buffer-shrink-to-fit | |
1047 (let* ((temp-window-size (round (* temp-buffer-max-height | |
1048 (frame-height (window-frame window))))) | |
1049 (size (window-displayed-height window))) | |
1050 (when (< size temp-window-size) | |
1051 (enlarge-window (- temp-window-size size) nil window))) | |
1052 (shrink-window-if-larger-than-buffer window)) | |
1053 nil))) | 1034 nil))) |
1054 | 1035 |
1055 (setq pre-display-buffer-function 'get-frame-for-buffer) | 1036 (setq pre-display-buffer-function 'get-frame-for-buffer) |
1056 (setq temp-buffer-show-function 'show-temp-buffer-in-current-frame) | 1037 (setq temp-buffer-show-function 'show-temp-buffer-in-current-frame) |
1057 | 1038 |
1200 "Set property PROP of FRAME to VAL. See `set-frame-properties'." | 1181 "Set property PROP of FRAME to VAL. See `set-frame-properties'." |
1201 (set-frame-properties frame (list prop val))) | 1182 (set-frame-properties frame (list prop val))) |
1202 | 1183 |
1203 (defun frame-height (&optional frame) | 1184 (defun frame-height (&optional frame) |
1204 "Return number of lines available for display on FRAME." | 1185 "Return number of lines available for display on FRAME." |
1205 (or frame (setq frame (selected-frame))) | |
1206 (frame-property frame 'height)) | 1186 (frame-property frame 'height)) |
1207 | 1187 |
1208 (defun frame-width (&optional frame) | 1188 (defun frame-width (&optional frame) |
1209 "Return number of columns available for display on FRAME." | 1189 "Return number of columns available for display on FRAME." |
1210 (or frame (setq frame (selected-frame))) | |
1211 (frame-property frame 'width)) | 1190 (frame-property frame 'width)) |
1212 | 1191 |
1213 (put 'cursor-color 'frame-property-alias [text-cursor background]) | 1192 (put 'cursor-color 'frame-property-alias [text-cursor background]) |
1214 (put 'modeline 'frame-property-alias 'has-modeline-p) | 1193 (put 'modeline 'frame-property-alias 'has-modeline-p) |
1215 | 1194 |