comparison src/window.c @ 149:538048ae2ab8 r20-3b1

Import from CVS: tag r20-3b1
author cvs
date Mon, 13 Aug 2007 09:36:16 +0200
parents fe104dbd9147
children 8eaf7971accc
comparison
equal deleted inserted replaced
148:f659db2a1f73 149:538048ae2ab8
789 789
790 int 790 int
791 window_needs_vertical_divider (struct window *w) 791 window_needs_vertical_divider (struct window *w)
792 { 792 {
793 #ifdef HAVE_SCROLLBARS 793 #ifdef HAVE_SCROLLBARS
794 struct frame *f = XFRAME (w->frame); 794 return (!window_scrollbar_width (w) &&
795 795 ((XFRAME (w->frame)->scrollbar_on_left) ?
796 if (!window_scrollbar_width (w)) 796 !window_is_leftmost (w) :
797 { 797 !window_is_rightmost (w)));
798 if (f->scrollbar_on_left)
799 return (!window_is_leftmost (w));
800 else
801 return (!window_is_rightmost (w));
802 }
803 else
804 return 0;
805 #else 798 #else
806 return (!window_is_leftmost (w)); 799 return !window_is_leftmost (w);
807 #endif /* HAVE_SCROLLBARS */ 800 #endif /* HAVE_SCROLLBARS */
808 } 801 }
809 802
810 int 803 int
811 window_scrollbar_width (struct window *w) 804 window_scrollbar_width (struct window *w)
1395 return ncol; 1388 return ncol;
1396 } 1389 }
1397 1390
1398 #if 0 /* bogus RMS crock */ 1391 #if 0 /* bogus RMS crock */
1399 1392
1400 xxDEFUN ("window-redisplay-end-trigger", Fwindow_redisplay_end_trigger, 0, 1, 0 /* 1393 xxDEFUN ("window-redisplay-end-trigger",
1394 Fwindow_redisplay_end_trigger, 0, 1, 0, /*
1401 Return WINDOW's redisplay end trigger value. 1395 Return WINDOW's redisplay end trigger value.
1402 See `set-window-redisplay-end-trigger' for more information. 1396 See `set-window-redisplay-end-trigger' for more information.
1403 */ 1397 */
1404 (window)) 1398 (window))
1405 { 1399 {
1406 return decode_window (window)->redisplay_end_trigger; 1400 return decode_window (window)->redisplay_end_trigger;
1407 } 1401 }
1408 1402
1409 xxDEFUN ("set-window-redisplay-end-trigger", Fset_window_redisplay_end_trigger, 2, 2, 0 /* 1403 xxDEFUN ("set-window-redisplay-end-trigger",
1404 Fset_window_redisplay_end_trigger, 2, 2, 0, /*
1410 Set WINDOW's redisplay end trigger value to VALUE. 1405 Set WINDOW's redisplay end trigger value to VALUE.
1411 VALUE should be a buffer position (typically a marker) or nil. 1406 VALUE should be a buffer position (typically a marker) or nil.
1412 If it is a buffer position, then if redisplay in WINDOW reaches a position 1407 If it is a buffer position, then if redisplay in WINDOW reaches a position
1413 beyond VALUE, the functions in `redisplay-end-trigger-functions' are called 1408 beyond VALUE, the functions in `redisplay-end-trigger-functions' are called
1414 with two arguments: WINDOW, and the end trigger value. 1409 with two arguments: WINDOW, and the end trigger value.
1428 */ 1423 */
1429 (window)) 1424 (window))
1430 { 1425 {
1431 struct window *w = decode_window (window); 1426 struct window *w = decode_window (window);
1432 struct frame *f = XFRAME (w->frame); 1427 struct frame *f = XFRAME (w->frame);
1433 int left, top; 1428
1434 1429 int left = w->pixel_left - FRAME_LEFT_BORDER_END (f);
1435 left = w->pixel_left - FRAME_LEFT_BORDER_END (f); 1430 int top = w->pixel_top - FRAME_TOP_BORDER_END (f);
1436 top = w->pixel_top - FRAME_TOP_BORDER_END (f);
1437 1431
1438 return list4 (make_int (left), 1432 return list4 (make_int (left),
1439 make_int (top), 1433 make_int (top),
1440 make_int (left + w->pixel_width), 1434 make_int (left + w->pixel_width),
1441 make_int (top + w->pixel_height)); 1435 make_int (top + w->pixel_height));
1564 */ 1558 */
1565 (window, arg)) 1559 (window, arg))
1566 { 1560 {
1567 register struct window *w = decode_window (window); 1561 register struct window *w = decode_window (window);
1568 1562
1569 if (NILP (arg)) 1563 w->dedicated = NILP (arg) ? Qnil : Qt;
1570 w->dedicated = Qnil;
1571 else
1572 w->dedicated = Qt;
1573 1564
1574 return w->dedicated; 1565 return w->dedicated;
1575 } 1566 }
1576 1567
1577 /* FSFmacs has window-display-table here. We have display table as a 1568 /* FSFmacs has window-display-table here. We have display table as a
2724 Return the width in pixels of the left outside margin of window WINDOW. 2715 Return the width in pixels of the left outside margin of window WINDOW.
2725 If WINDOW is nil, the selected window is assumed. 2716 If WINDOW is nil, the selected window is assumed.
2726 */ 2717 */
2727 (window)) 2718 (window))
2728 { 2719 {
2729 struct window *w = decode_window (window); 2720 return make_int (window_left_margin_width (decode_window (window)));
2730
2731 return (make_int (window_left_margin_width (w)));
2732 } 2721 }
2733 2722
2734 DEFUN ("window-right-margin-pixel-width", 2723 DEFUN ("window-right-margin-pixel-width",
2735 Fwindow_right_margin_pixel_width, 0, 1, 0, /* 2724 Fwindow_right_margin_pixel_width, 0, 1, 0, /*
2736 Return the width in pixels of the right outside margin of window WINDOW. 2725 Return the width in pixels of the right outside margin of window WINDOW.
2737 If WINDOW is nil, the selected window is assumed. 2726 If WINDOW is nil, the selected window is assumed.
2738 */ 2727 */
2739 (window)) 2728 (window))
2740 { 2729 {
2741 struct window *w = decode_window (window); 2730 return make_int (window_right_margin_width (decode_window (window)));
2742
2743 return (make_int (window_right_margin_width (w)));
2744 } 2731 }
2745 2732
2746 DEFUN ("delete-other-windows", Fdelete_other_windows, 0, 1, "", /* 2733 DEFUN ("delete-other-windows", Fdelete_other_windows, 0, 1, "", /*
2747 Make WINDOW (or the selected window) fill its frame. 2734 Make WINDOW (or the selected window) fill its frame.
2748 Only the frame WINDOW is on is affected. 2735 Only the frame WINDOW is on is affected.
3044 3031
3045 #### This is a kludge. The correct approach is not to do this 3032 #### This is a kludge. The correct approach is not to do this
3046 but to fix set-window-configuration. */ 3033 but to fix set-window-configuration. */
3047 #if 0 3034 #if 0
3048 else if (EQ (tem, buffer)) 3035 else if (EQ (tem, buffer))
3049 return (Qnil); 3036 return Qnil;
3050 #endif 3037 #endif
3051 else if (! EQ (tem, Qt)) /* w->buffer is t when the window 3038 else if (! EQ (tem, Qt)) /* w->buffer is t when the window
3052 is first being set up. */ 3039 is first being set up. */
3053 { 3040 {
3054 if (!NILP (w->dedicated) && !EQ (tem, buffer)) 3041 if (!NILP (w->dedicated) && !EQ (tem, buffer))
3412 and optional third ARG specifies the window to change instead of the 3399 and optional third ARG specifies the window to change instead of the
3413 selected window. 3400 selected window.
3414 */ 3401 */
3415 (n, side, window)) 3402 (n, side, window))
3416 { 3403 {
3417 struct window *w = decode_window (window);
3418 CHECK_INT (n); 3404 CHECK_INT (n);
3419 change_window_height (w, -XINT (n), !NILP (side)); 3405 change_window_height (decode_window (window), -XINT (n), !NILP (side));
3420 return Qnil; 3406 return Qnil;
3421 } 3407 }
3422 3408
3423 static int 3409 static int
3424 window_pixel_height (Lisp_Object window) 3410 window_pixel_height (Lisp_Object window)
3425 { 3411 {
3426 struct window *w = XWINDOW (window); 3412 return WINDOW_HEIGHT (XWINDOW (window));
3427 return WINDOW_HEIGHT (w);
3428 } 3413 }
3429 3414
3430 static int 3415 static int
3431 window_pixel_height_to_char_height (struct window *w, int pixel_height, 3416 window_pixel_height_to_char_height (struct window *w, int pixel_height,
3432 int include_gutters_p) 3417 int include_gutters_p)
3545 /* If this line is clipped then we know that there is no 3530 /* If this line is clipped then we know that there is no
3546 blank room between eob and the modeline. If we are 3531 blank room between eob and the modeline. If we are
3547 scrolling on clipped lines just know off the clipped 3532 scrolling on clipped lines just know off the clipped
3548 line and return .*/ 3533 line and return .*/
3549 if (scroll_on_clipped_lines && dl->clip) 3534 if (scroll_on_clipped_lines && dl->clip)
3550 return (num_lines - 1); 3535 return num_lines - 1;
3551 ypos1 = dl->ypos + dl->descent - dl->clip; 3536 ypos1 = dl->ypos + dl->descent - dl->clip;
3552 } 3537 }
3553 } 3538 }
3554 3539
3555 default_face_height_and_width (window, &defheight, &defwidth); 3540 default_face_height_and_width (window, &defheight, &defwidth);
3571 } 3556 }
3572 3557
3573 static int 3558 static int
3574 window_pixel_width (Lisp_Object window) 3559 window_pixel_width (Lisp_Object window)
3575 { 3560 {
3576 struct window *w = XWINDOW (window); 3561 return WINDOW_WIDTH (XWINDOW (window));
3577 return WINDOW_WIDTH (w);
3578 } 3562 }
3579 3563
3580 static int 3564 static int
3581 window_pixel_width_to_char_width (struct window *w, int pixel_width, 3565 window_pixel_width_to_char_width (struct window *w, int pixel_width,
3582 int include_margins_p) 3566 int include_margins_p)
4132 if (NILP (arg)) 4116 if (NILP (arg))
4133 arg = make_int (window_char_width (w, 0) - 2); 4117 arg = make_int (window_char_width (w, 0) - 2);
4134 else 4118 else
4135 arg = Fprefix_numeric_value (arg); 4119 arg = Fprefix_numeric_value (arg);
4136 4120
4137 return 4121 return Fset_window_hscroll (window, make_int (w->hscroll + XINT (arg)));
4138 Fset_window_hscroll (window, make_int (w->hscroll + XINT (arg)));
4139 } 4122 }
4140 4123
4141 DEFUN ("scroll-right", Fscroll_right, 0, 1, "_P", /* 4124 DEFUN ("scroll-right", Fscroll_right, 0, 1, "_P", /*
4142 Scroll selected window display ARG columns right. 4125 Scroll selected window display ARG columns right.
4143 Default for ARG is window width minus 2. 4126 Default for ARG is window width minus 2.
4150 if (NILP (arg)) 4133 if (NILP (arg))
4151 arg = make_int (window_char_width (w, 0) - 2); 4134 arg = make_int (window_char_width (w, 0) - 2);
4152 else 4135 else
4153 arg = Fprefix_numeric_value (arg); 4136 arg = Fprefix_numeric_value (arg);
4154 4137
4155 return 4138 return Fset_window_hscroll (window, make_int (w->hscroll - XINT (arg)));
4156 Fset_window_hscroll (window, make_int (w->hscroll - XINT (arg)));
4157 } 4139 }
4158 4140
4159 DEFUN ("recenter", Frecenter, 0, 2, "_P", /* 4141 DEFUN ("recenter", Frecenter, 0, 2, "_P", /*
4160 Center point in WINDOW and redisplay frame. With ARG, put point on line ARG. 4142 Center point in WINDOW and redisplay frame. With ARG, put point on line ARG.
4161 The desired position of point is always relative to the window. 4143 The desired position of point is always relative to the window.
4270 Fset_window_point (window, make_int (new_point)); 4252 Fset_window_point (window, make_int (new_point));
4271 4253
4272 retval = line_at_center (w, CMOTION_DISP, start, BUF_PT (b)); 4254 retval = line_at_center (w, CMOTION_DISP, start, BUF_PT (b));
4273 } 4255 }
4274 4256
4275 return (make_int (retval)); 4257 return make_int (retval);
4276 } 4258 }
4277 else 4259 else
4278 { 4260 {
4279 /* #### Is this going to work right when at eob? */ 4261 /* #### Is this going to work right when at eob? */
4280 arg = Fprefix_numeric_value (arg); 4262 arg = Fprefix_numeric_value (arg);
4409 ovstats); 4391 ovstats);
4410 stats->scrollbar += 4392 stats->scrollbar +=
4411 compute_scrollbar_instance_usage (d, mir->scrollbar_horizontal_instance, 4393 compute_scrollbar_instance_usage (d, mir->scrollbar_horizontal_instance,
4412 ovstats); 4394 ovstats);
4413 } 4395 }
4414 #endif 4396 #endif /* HAVE_SCROLLBARS */
4415 stats->other_redisplay += 4397 stats->other_redisplay +=
4416 compute_display_line_dynarr_usage (mir->current_display_lines, ovstats); 4398 compute_display_line_dynarr_usage (mir->current_display_lines, ovstats);
4417 stats->other_redisplay += 4399 stats->other_redisplay +=
4418 compute_display_line_dynarr_usage (mir->desired_display_lines, ovstats); 4400 compute_display_line_dynarr_usage (mir->desired_display_lines, ovstats);
4419 } 4401 }
4579 ((markobj) (s->pointm)); 4561 ((markobj) (s->pointm));
4580 ((markobj) (s->sb_point)); 4562 ((markobj) (s->sb_point));
4581 ((markobj) (s->mark)); 4563 ((markobj) (s->mark));
4582 ((markobj) (s->dedicated)); 4564 ((markobj) (s->dedicated));
4583 } 4565 }
4584 return (Qnil); 4566 return Qnil;
4585 } 4567 }
4586 4568
4587 static int 4569 static int
4588 sizeof_window_config_for_n_windows (int n) 4570 sizeof_window_config_for_n_windows (int n)
4589 { 4571 {
4615 /* Returns a boolean indicating whether the two saved windows are 4597 /* Returns a boolean indicating whether the two saved windows are
4616 identical. */ 4598 identical. */
4617 static int 4599 static int
4618 saved_window_equal (struct saved_window *win1, struct saved_window *win2) 4600 saved_window_equal (struct saved_window *win1, struct saved_window *win2)
4619 { 4601 {
4620 if (!EQ (win1->window, win2->window)) 4602 return
4621 return 0; 4603 EQ (win1->window, win2->window) &&
4622 else if (!EQ (win1->buffer, win2->buffer)) 4604 EQ (win1->buffer, win2->buffer) &&
4623 return 0; 4605 !NILP (Fequal (win1->start, win2->start)) &&
4624 else if (NILP (Fequal (win1->start, win2->start))) 4606 !NILP (Fequal (win1->pointm, win2->pointm)) &&
4625 return 0; 4607 !NILP (Fequal (win1->sb_point, win2->sb_point)) &&
4626 else if (NILP (Fequal (win1->pointm, win2->pointm))) 4608 !NILP (Fequal (win1->mark, win2->mark)) &&
4627 return 0; 4609 win1->pixel_left == win2->pixel_left &&
4628 else if (NILP (Fequal (win1->sb_point, win2->sb_point))) 4610 win1->pixel_top == win2->pixel_top &&
4629 return 0; 4611 win1->pixel_width == win2->pixel_width &&
4630 else if (NILP (Fequal (win1->mark, win2->mark))) 4612 win1->pixel_height == win2->pixel_height &&
4631 return 0; 4613 win1->hscroll == win2->hscroll &&
4632 else if (win1->pixel_left != win2->pixel_left) 4614 win1->parent_index == win2->parent_index &&
4633 return 0; 4615 win1->prev_index == win2->prev_index &&
4634 else if (win1->pixel_top != win2->pixel_top) 4616 EQ (win1->dedicated, win2->dedicated) &&
4635 return 0; 4617 win1->start_at_line_beg == win2->start_at_line_beg;
4636 else if (win1->pixel_width != win2->pixel_width)
4637 return 0;
4638 else if (win1->pixel_height != win2->pixel_height)
4639 return 0;
4640 else if (win1->hscroll != win2->hscroll)
4641 return 0;
4642 else if (win1->parent_index != win2->parent_index)
4643 return 0;
4644 else if (win1->prev_index != win2->prev_index)
4645 return 0;
4646 else if (!EQ (win1->dedicated, win2->dedicated))
4647 return 0;
4648 else if (win1->start_at_line_beg != win2->start_at_line_beg)
4649 return 0;
4650
4651 return 1;
4652 } 4618 }
4653 4619
4654 /* Returns a boolean indicating whether the two given configurations 4620 /* Returns a boolean indicating whether the two given configurations
4655 are identical. */ 4621 are identical. */
4656 static int 4622 static int
4664 return 1; 4630 return 1;
4665 4631
4666 fig1 = XWINDOW_CONFIGURATION (conf1); 4632 fig1 = XWINDOW_CONFIGURATION (conf1);
4667 fig2 = XWINDOW_CONFIGURATION (conf2); 4633 fig2 = XWINDOW_CONFIGURATION (conf2);
4668 4634
4669 if (fig1->saved_windows_count != fig2->saved_windows_count) 4635 if (!((fig1->saved_windows_count == fig2->saved_windows_count) &&
4636 EQ (fig1->current_window, fig2->current_window) &&
4637 EQ (fig1->current_buffer, fig2->current_buffer) &&
4638 EQ (fig1->root_window, fig2->root_window) &&
4639 EQ (fig1->minibuf_scroll_window, fig2->minibuf_scroll_window) &&
4640 #ifdef ENERGIZE
4641 EQ (fig1->p_sheet_buffer, fig2->p_sheet_buffer) &&
4642 #endif
4643 fig1->frame_width == fig2->frame_width &&
4644 fig1->frame_height == fig2->frame_height))
4670 return 0; 4645 return 0;
4671 else if (!EQ (fig1->current_window, fig2->current_window))
4672 return 0;
4673 else if (!EQ (fig1->current_buffer, fig2->current_buffer))
4674 return 0;
4675 else if (!EQ (fig1->root_window, fig2->root_window))
4676 return 0;
4677 else if (!EQ (fig1->minibuf_scroll_window, fig2->minibuf_scroll_window))
4678 return 0;
4679 else if (fig1->frame_width != fig2->frame_width)
4680 return 0;
4681 else if (fig1->frame_height != fig2->frame_height)
4682 return 0;
4683 #ifdef ENERGIZE
4684 else if (!EQ (fig1->p_sheet_buffer, fig2->p_sheet_buffer))
4685 return 0;
4686 #endif
4687 4646
4688 for (i = 0; i < fig1->saved_windows_count; i++) 4647 for (i = 0; i < fig1->saved_windows_count; i++)
4689 { 4648 {
4690 if (!saved_window_equal (SAVED_WINDOW_N (fig1, i), 4649 if (!saved_window_equal (SAVED_WINDOW_N (fig1, i),
4691 SAVED_WINDOW_N (fig2, i))) 4650 SAVED_WINDOW_N (fig2, i)))
4698 DEFUN ("window-configuration-p", Fwindow_configuration_p, 1, 1, 0, /* 4657 DEFUN ("window-configuration-p", Fwindow_configuration_p, 1, 1, 0, /*
4699 T if OBJECT is a window-configuration object. 4658 T if OBJECT is a window-configuration object.
4700 */ 4659 */
4701 (obj)) 4660 (obj))
4702 { 4661 {
4703 return (WINDOW_CONFIGURATIONP (obj) ? Qt : Qnil); 4662 return WINDOW_CONFIGURATIONP (obj) ? Qt : Qnil;
4704 } 4663 }
4705 4664
4706 /* 4665 /*
4707 * There are getting to be a lot of functions which traverse the 4666 * There are getting to be a lot of functions which traverse the
4708 * window structure doing various things. It may be worth writing a 4667 * window structure doing various things. It may be worth writing a
5125 5084
5126 unbind_to (specpdl_count, Qnil); 5085 unbind_to (specpdl_count, Qnil);
5127 5086
5128 UNGCPRO; 5087 UNGCPRO;
5129 5088
5130 return (Qnil); 5089 return Qnil;
5131 } 5090 }
5132 5091
5133 /* Mark all subwindows of a window as deleted. The argument 5092 /* Mark all subwindows of a window as deleted. The argument
5134 W is actually the subwindow tree of the window in question. */ 5093 W is actually the subwindow tree of the window in question. */
5135 5094
5165 { 5124 {
5166 int j; 5125 int j;
5167 for (j = 0; j < lim; j++) 5126 for (j = 0; j < lim; j++)
5168 { 5127 {
5169 if (EQ (SAVED_WINDOW_N (config, j)->window, window)) 5128 if (EQ (SAVED_WINDOW_N (config, j)->window, window))
5170 { 5129 return j;
5171 return (j);
5172 } 5130 }
5173 }
5174 abort (); 5131 abort ();
5175 return 0; /* suppress compiler warning */ 5132 return 0; /* suppress compiler warning */
5176 } 5133 }
5177 5134
5178 static int 5135 static int
5300 if (ZEROP (config->p_sheet_buffer)) /* #### necessaryp? */ 5257 if (ZEROP (config->p_sheet_buffer)) /* #### necessaryp? */
5301 config->p_sheet_buffer = Qnil; 5258 config->p_sheet_buffer = Qnil;
5302 } 5259 }
5303 #endif 5260 #endif
5304 save_window_save (FRAME_ROOT_WINDOW (f), config, 0); 5261 save_window_save (FRAME_ROOT_WINDOW (f), config, 0);
5305 return (result); 5262 return result;
5306 } 5263 }
5307 5264
5308 Lisp_Object 5265 Lisp_Object
5309 save_window_excursion_unwind (Lisp_Object window_config) 5266 save_window_excursion_unwind (Lisp_Object window_config)
5310 { 5267 {