aboutsummaryrefslogtreecommitdiffstats
path: root/src/window.c
diff options
context:
space:
mode:
authorRichard M. Stallman1998-01-26 09:04:27 +0000
committerRichard M. Stallman1998-01-26 09:04:27 +0000
commitcbff28e8a0f78fb555b9a6ac35932dfe88f083ba (patch)
treef4787c53c248ffc52502041392a918677beb2218 /src/window.c
parented73fcc1fa527e03ba9049d766923027ebad91df (diff)
downloademacs-cbff28e8a0f78fb555b9a6ac35932dfe88f083ba.tar.gz
emacs-cbff28e8a0f78fb555b9a6ac35932dfe88f083ba.zip
(compare_window_configurations): New function.
Diffstat (limited to 'src/window.c')
-rw-r--r--src/window.c103
1 files changed, 99 insertions, 4 deletions
diff --git a/src/window.c b/src/window.c
index c3cda8e9289..51ac3fa23a5 100644
--- a/src/window.c
+++ b/src/window.c
@@ -3177,11 +3177,12 @@ struct save_window_data
3177 /* Record the values of window-min-width and window-min-height 3177 /* Record the values of window-min-width and window-min-height
3178 so that window sizes remain consistent with them. */ 3178 so that window sizes remain consistent with them. */
3179 Lisp_Object min_width, min_height; 3179 Lisp_Object min_width, min_height;
3180 /* A vector, interpreted as a struct saved_window */ 3180 /* A vector, each of whose elements is a struct saved_window
3181 for one window. */
3181 Lisp_Object saved_windows; 3182 Lisp_Object saved_windows;
3182 }; 3183 };
3183 3184
3184/* This is saved as a Lisp_Vector */ 3185/* This is saved as a Lisp_Vector */
3185struct saved_window 3186struct saved_window
3186 { 3187 {
3187 /* these first two must agree with struct Lisp_Vector in lisp.h */ 3188 /* these first two must agree with struct Lisp_Vector in lisp.h */
@@ -3201,7 +3202,7 @@ struct saved_window
3201 ((struct saved_window *) (XVECTOR ((swv)->contents[(n)]))) 3202 ((struct saved_window *) (XVECTOR ((swv)->contents[(n)])))
3202 3203
3203DEFUN ("window-configuration-p", Fwindow_configuration_p, Swindow_configuration_p, 1, 1, 0, 3204DEFUN ("window-configuration-p", Fwindow_configuration_p, Swindow_configuration_p, 1, 1, 0,
3204 "T if OBJECT is a window-configuration object.") 3205 "Return t if OBJECT is a window-configuration object.")
3205 (object) 3206 (object)
3206 Lisp_Object object; 3207 Lisp_Object object;
3207{ 3208{
@@ -3210,7 +3211,6 @@ DEFUN ("window-configuration-p", Fwindow_configuration_p, Swindow_configuration_
3210 return Qnil; 3211 return Qnil;
3211} 3212}
3212 3213
3213
3214DEFUN ("set-window-configuration", Fset_window_configuration, 3214DEFUN ("set-window-configuration", Fset_window_configuration,
3215 Sset_window_configuration, 1, 1, 0, 3215 Sset_window_configuration, 1, 1, 0,
3216 "Set the configuration of windows and buffers as specified by CONFIGURATION.\n\ 3216 "Set the configuration of windows and buffers as specified by CONFIGURATION.\n\
@@ -3242,6 +3242,7 @@ by `current-window-configuration' (which see).")
3242 { 3242 {
3243 if (XBUFFER (new_current_buffer) == current_buffer) 3243 if (XBUFFER (new_current_buffer) == current_buffer)
3244 old_point = PT; 3244 old_point = PT;
3245
3245 } 3246 }
3246 3247
3247 frame = XWINDOW (SAVED_WINDOW_N (saved_windows, 0)->window)->frame; 3248 frame = XWINDOW (SAVED_WINDOW_N (saved_windows, 0)->window)->frame;
@@ -3653,6 +3654,100 @@ Does not restore the value of point in current buffer.")
3653 return unbind_to (count, val); 3654 return unbind_to (count, val);
3654} 3655}
3655 3656
3657/* Return 1 if window configurations C1 and C2
3658 describe the same state of affairs. This is used by Fequal. */
3659
3660int
3661compare_window_configurations (c1, c2)
3662 Lisp_Object c1, c2;
3663{
3664 register struct save_window_data *d1, *d2;
3665 struct Lisp_Vector *sw1, *sw2;
3666 int i;
3667
3668 d1 = (struct save_window_data *) XVECTOR (c1);
3669 d2 = (struct save_window_data *) XVECTOR (c2);
3670 sw1 = XVECTOR (d1->saved_windows);
3671 sw2 = XVECTOR (d2->saved_windows);
3672
3673 if (! EQ (d1->frame_width, d2->frame_width))
3674 return 0;
3675 if (! EQ (d1->frame_height, d2->frame_height))
3676 return 0;
3677 if (! EQ (d1->frame_menu_bar_lines, d2->frame_menu_bar_lines))
3678 return 0;
3679 if (! EQ (d1->selected_frame, d2->selected_frame))
3680 return 0;
3681 /* Don't compare the current_window field directly.
3682 Instead see w1_is_current and w2_is_current, below. */
3683 if (! EQ (d1->current_buffer, d2->current_buffer))
3684 return 0;
3685 if (! EQ (d1->minibuf_scroll_window, d2->minibuf_scroll_window))
3686 return 0;
3687 /* Don't compare the root_window field.
3688 We don't require the two configurations
3689 to use the same window object,
3690 and the two root windows must be equivalent
3691 if everything else compares equal. */
3692 if (! EQ (d1->focus_frame, d2->focus_frame))
3693 return 0;
3694 if (! EQ (d1->min_width, d2->min_width))
3695 return 0;
3696 if (! EQ (d1->min_height, d2->min_height))
3697 return 0;
3698
3699 /* Verify that the two confis have the same number of windows. */
3700 if (sw1->size != sw2->size)
3701 return 0;
3702
3703 for (i = 0; i < sw1->size; i++)
3704 {
3705 struct saved_window *p1, *p2;
3706 int w1_is_current, w2_is_current;
3707
3708 p1 = SAVED_WINDOW_N (sw1, i);
3709 p2 = SAVED_WINDOW_N (sw2, i);
3710
3711 /* Verify that the current windows in the two
3712 configurations correspond to each other. */
3713 w1_is_current = EQ (d1->current_window, p1->window);
3714 w2_is_current = EQ (d2->current_window, p2->window);
3715
3716 if (w1_is_current != w2_is_current)
3717 return 0;
3718
3719 /* Verify that the corresponding windows do match. */
3720 if (! EQ (p1->buffer, p2->buffer))
3721 return 0;
3722 if (! EQ (p1->left, p2->left))
3723 return 0;
3724 if (! EQ (p1->top, p2->top))
3725 return 0;
3726 if (! EQ (p1->width, p2->width))
3727 return 0;
3728 if (! EQ (p1->height, p2->height))
3729 return 0;
3730 if (! EQ (p1->hscroll, p2->hscroll))
3731 return 0;
3732 if (! EQ (p1->start_at_line_beg, p2->start_at_line_beg))
3733 return 0;
3734 if (! EQ (p1->display_table, p2->display_table))
3735 return 0;
3736 if (! EQ (p1->parent, p2->parent))
3737 return 0;
3738 if (! EQ (p1->prev, p2->prev))
3739 return 0;
3740 if (NILP (Fequal (p1->start, p2->start)))
3741 return 0;
3742 if (NILP (Fequal (p1->pointm, p2->pointm)))
3743 return 0;
3744 if (NILP (Fequal (p1->mark, p2->mark)))
3745 return 0;
3746 }
3747
3748 return 1;
3749}
3750
3656init_window_once () 3751init_window_once ()
3657{ 3752{
3658 selected_frame = make_terminal_frame (); 3753 selected_frame = make_terminal_frame ();