comparison src/window.c @ 51207:7e176ef34c10

Make (many) trivial substitutions for renamed and new macros in dispextern.h, frame.h and window.h. (make_window): Initialize new members left_margin_cols, right_margin_cols, left_fringe_width, right_fringe_width, fringes_outside_margins, scroll_bar_width, and vertical_scroll_bar_type. (coordinates_in_window): Adapted to new fringe/margin positions and per-window fringes and scroll-bars. Fix bug related to incorrectly adjusting coordinates by frame's internal_border_width (the effect normally negible since the internal_border_width is typically 0 or 1 pixel, but very noticeable for an internal_border_width of e.g. 25 pixels). Upon successful return (other than ON_NOTHING), the coordinates are now always properly converted to window relative for the given display element. (window_from_coordinates): Add new parameters wx and wy to return the window relative x and y position in the returned window and part. A null arg means, don't return the position. All callers changed. (adjust_window_margins): New function which may reduce the width of the display margins if a window's text area is too small after resizing or splitting windows. (size_window): Fix bug that did not account for display margin widths when checking the minimum width of a window; use adjust_window_margins. (set_window_buffer): Call Fset_window_fringes and Fset_window_scroll_bars to setup per-window elements. Add new arg KEEP_MARGINS_P. Non-nil means to keep window's existing display margin, fringe widths, and scroll bar settings (e.g. after splitting a window or resizing the frame). All callers changed. (Fset_window_buffer): New arg KEEP_MARGINS. All callers changed. (Fsplit_window): Duplicate original window's display margin, fringe, and scroll-bar settings; then call Fset_window_buffer with KEEP_MARGINS non-nil. This fixes a bug which caused a split window to only preserve the display margins in one of the windows. When splitting horisontally, call adjust_window_margins on both windows to ensure that the text area of the new windows is non too narrow. This fixes a bug which could cause emacs to trap if the width of the split window was less than the width of the display margins. (window_box_text_cols): Renamed from window_internal_width. All uses changed. Adapt to per-window fringes and scroll bars. Fix bug that caused vertical separator to be subtracted also on window frames. Fix another bug that did not reduce the returned value by the columns used for display margins. (window_scroll_line_based): Fix bug related to scrolling too much when display margins are present (implicitly fixed by the fix to window_box_text_cols). (scroll_left, scroll_right): Fix bug related to scrolling too far by default when display margins are present (implicitly fixed by the fix to window_box_text_cols). (struct saved_window): Rename members left to left_col, top to top_line, width to total_cols, height to total_lines, orig_top to orig_top_line, orig_height to orig_total_lines. All uses changed. New members left_margin_cols, right_margin_cols, left_fringe_width, right_fringe_width, fringes_outside_margins, scroll_bar_width, and vertical_scroll_bar_type for saving per-window display elements. (Fset_window_configuration): Restore display margins, fringes, and scroll bar settings. This fixes a bug which caused display margins to be discarded when saving and restoring a window configuration. (save_window_save): Save display margins, fringes, and scroll bar settings. This fixes a bug which caused display margins to be discarded when saving and restoring a window configuration. (Fset_window_margins): Do nothing if display margins are not really changed. Otherwise, call adjust_window_margins to ensure the text area doesn't get too narrow. This fixes a bug which could cause emacs to trap if setting display margins wider than the width of the window. (Fset_window_fringes): New defun to allow user to specifically set this window's fringe widths and position vs. display margins. (Fwindow_fringes): New defun to return window's actual fringe settings. (Fset_window_scroll_bars): New defun to allow user to specifically set this window's scroll bar width and position. (Fwindow_scroll_bars): New defun to return window's actual scroll bar settings. (compare_window_configurations): Also compare display margins, fringes, and scroll bar settings. (syms_of_window): Defsubr new defuns for fringe and scroll bars.
author Kim F. Storm <storm@cua.dk>
date Sat, 24 May 2003 22:07:51 +0000
parents 12bbef36ecf1
children c1daf1c22f97
comparison
equal deleted inserted replaced
51206:22a5614b558f 51207:7e176ef34c10
240 Lisp_Object val; 240 Lisp_Object val;
241 register struct window *p; 241 register struct window *p;
242 242
243 p = allocate_window (); 243 p = allocate_window ();
244 XSETFASTINT (p->sequence_number, ++sequence_number); 244 XSETFASTINT (p->sequence_number, ++sequence_number);
245 XSETFASTINT (p->left, 0); 245 XSETFASTINT (p->left_col, 0);
246 XSETFASTINT (p->top, 0); 246 XSETFASTINT (p->top_line, 0);
247 XSETFASTINT (p->height, 0); 247 XSETFASTINT (p->total_lines, 0);
248 XSETFASTINT (p->width, 0); 248 XSETFASTINT (p->total_cols, 0);
249 XSETFASTINT (p->hscroll, 0); 249 XSETFASTINT (p->hscroll, 0);
250 XSETFASTINT (p->min_hscroll, 0); 250 XSETFASTINT (p->min_hscroll, 0);
251 p->orig_top = p->orig_height = Qnil; 251 p->orig_top_line = p->orig_total_lines = Qnil;
252 p->start = Fmake_marker (); 252 p->start = Fmake_marker ();
253 p->pointm = Fmake_marker (); 253 p->pointm = Fmake_marker ();
254 XSETFASTINT (p->use_time, 0); 254 XSETFASTINT (p->use_time, 0);
255 p->frame = Qnil; 255 p->frame = Qnil;
256 p->display_table = Qnil; 256 p->display_table = Qnil;
270 XSETWINDOW (val, p); 270 XSETWINDOW (val, p);
271 XSETFASTINT (p->last_point, 0); 271 XSETFASTINT (p->last_point, 0);
272 p->frozen_window_start_p = 0; 272 p->frozen_window_start_p = 0;
273 p->height_fixed_p = 0; 273 p->height_fixed_p = 0;
274 p->last_cursor_off_p = p->cursor_off_p = 0; 274 p->last_cursor_off_p = p->cursor_off_p = 0;
275 p->left_margin_cols = Qnil;
276 p->right_margin_cols = Qnil;
277 p->left_fringe_width = Qnil;
278 p->right_fringe_width = Qnil;
279 p->fringes_outside_margins = Qnil;
280 p->scroll_bar_width = Qnil;
281 p->vertical_scroll_bar_type = Qt;
275 282
276 Vwindow_list = Qnil; 283 Vwindow_list = Qnil;
277 return val; 284 return val;
278 } 285 }
279 286
396 DEFUN ("window-height", Fwindow_height, Swindow_height, 0, 1, 0, 403 DEFUN ("window-height", Fwindow_height, Swindow_height, 0, 1, 0,
397 doc: /* Return the number of lines in WINDOW (including its mode line). */) 404 doc: /* Return the number of lines in WINDOW (including its mode line). */)
398 (window) 405 (window)
399 Lisp_Object window; 406 Lisp_Object window;
400 { 407 {
401 return decode_window (window)->height; 408 return decode_window (window)->total_lines;
402 } 409 }
403 410
404 DEFUN ("window-width", Fwindow_width, Swindow_width, 0, 1, 0, 411 DEFUN ("window-width", Fwindow_width, Swindow_width, 0, 1, 0,
405 doc: /* Return the number of display columns in WINDOW. 412 doc: /* Return the number of display columns in WINDOW.
406 This is the width that is usable columns available for text in WINDOW. 413 This is the width that is usable columns available for text in WINDOW.
407 If you want to find out how many columns WINDOW takes up, 414 If you want to find out how many columns WINDOW takes up,
408 use (let ((edges (window-edges))) (- (nth 2 edges) (nth 0 edges))). */) 415 use (let ((edges (window-edges))) (- (nth 2 edges) (nth 0 edges))). */)
409 (window) 416 (window)
410 Lisp_Object window; 417 Lisp_Object window;
411 { 418 {
412 return make_number (window_internal_width (decode_window (window))); 419 return make_number (window_box_text_cols (decode_window (window)));
413 } 420 }
414 421
415 DEFUN ("window-hscroll", Fwindow_hscroll, Swindow_hscroll, 0, 1, 0, 422 DEFUN ("window-hscroll", Fwindow_hscroll, Swindow_hscroll, 0, 1, 0,
416 doc: /* Return the number of columns by which WINDOW is scrolled from left margin. */) 423 doc: /* Return the number of columns by which WINDOW is scrolled from left margin. */)
417 (window) 424 (window)
480 (window) 487 (window)
481 Lisp_Object window; 488 Lisp_Object window;
482 { 489 {
483 register struct window *w = decode_window (window); 490 register struct window *w = decode_window (window);
484 491
485 return Fcons (w->left, Fcons (w->top, 492 return Fcons (make_number (WINDOW_LEFT_EDGE_COL (w)),
486 Fcons (make_number (WINDOW_RIGHT_EDGE (w)), 493 Fcons (make_number (WINDOW_TOP_EDGE_LINE (w)),
487 Fcons (make_number (XFASTINT (w->top) 494 Fcons (make_number (WINDOW_RIGHT_EDGE_COL (w)),
488 + XFASTINT (w->height)), 495 Fcons (make_number (WINDOW_BOTTOM_EDGE_LINE (w)),
489 Qnil)))); 496 Qnil))));
490 } 497 }
491 498
492 /* Test if the character at column *X, row *Y is within window W. 499 /* Test if the character at column *X, row *Y is within window W.
493 If it is not, return ON_NOTHING; 500 If it is not, return ON_NOTHING;
494 if it is in the window's text area, 501 if it is in the window's text area,
511 static enum window_part 518 static enum window_part
512 coordinates_in_window (w, x, y) 519 coordinates_in_window (w, x, y)
513 register struct window *w; 520 register struct window *w;
514 register int *x, *y; 521 register int *x, *y;
515 { 522 {
516 /* Let's make this a global enum later, instead of using numbers
517 everywhere. */
518 struct frame *f = XFRAME (WINDOW_FRAME (w)); 523 struct frame *f = XFRAME (WINDOW_FRAME (w));
519 int left_x, right_x, top_y, bottom_y; 524 int left_x, right_x, top_y, bottom_y;
520 enum window_part part; 525 enum window_part part;
521 int ux = CANON_X_UNIT (f); 526 int ux = FRAME_COLUMN_WIDTH (f);
522 int x0 = XFASTINT (w->left) * ux; 527 int x0 = WINDOW_LEFT_EDGE_X (w);
523 int x1 = x0 + XFASTINT (w->width) * ux; 528 int x1 = WINDOW_RIGHT_EDGE_X (w);
524 /* The width of the area where the vertical line can be dragged. 529 /* The width of the area where the vertical line can be dragged.
525 (Between mode lines for instance. */ 530 (Between mode lines for instance. */
526 int grabbable_width = ux; 531 int grabbable_width = ux;
527 int lmargin_width = 0, rmargin_width = 0; 532 int lmargin_width, rmargin_width, text_left, text_right;
528 533
529 if (*x < x0 || *x >= x1) 534 if (*x < x0 || *x >= x1)
530 return ON_NOTHING; 535 return ON_NOTHING;
531 536
532 /* In what's below, we subtract 1 when computing right_x because we 537 /* In what's below, we subtract 1 when computing right_x because we
533 want the rightmost pixel, which is given by left_pixel+width-1. */ 538 want the rightmost pixel, which is given by left_pixel+width-1. */
534 if (w->pseudo_window_p) 539 if (w->pseudo_window_p)
535 { 540 {
536 left_x = 0; 541 left_x = 0;
537 right_x = XFASTINT (w->width) * CANON_X_UNIT (f) - 1; 542 right_x = WINDOW_TOTAL_WIDTH (w) - 1;
538 top_y = WINDOW_DISPLAY_TOP_EDGE_PIXEL_Y (w); 543 top_y = WINDOW_TOP_EDGE_Y (w);
539 bottom_y = WINDOW_DISPLAY_BOTTOM_EDGE_PIXEL_Y (w); 544 bottom_y = WINDOW_BOTTOM_EDGE_Y (w);
540 } 545 }
541 else 546 else
542 { 547 {
543 left_x = (WINDOW_DISPLAY_LEFT_EDGE_PIXEL_X (w) 548 left_x = WINDOW_BOX_LEFT_EDGE_X (w);
544 - FRAME_INTERNAL_BORDER_WIDTH_SAFE (f)); 549 right_x = WINDOW_BOX_RIGHT_EDGE_X (w) - 1;
545 right_x = WINDOW_DISPLAY_RIGHT_EDGE_PIXEL_X (w) - 1; 550 top_y = WINDOW_TOP_EDGE_Y (w);
546 top_y = (WINDOW_DISPLAY_TOP_EDGE_PIXEL_Y (w) 551 bottom_y = WINDOW_BOTTOM_EDGE_Y (w);
547 - FRAME_INTERNAL_BORDER_WIDTH_SAFE (f)); 552 }
548 bottom_y = WINDOW_DISPLAY_BOTTOM_EDGE_PIXEL_Y (w); 553
549 } 554 /* Outside any interesting row? */
555 if (*y < top_y || *y >= bottom_y)
556 return ON_NOTHING;
550 557
551 /* On the mode line or header line? If it's near the start of 558 /* On the mode line or header line? If it's near the start of
552 the mode or header line of window that's has a horizontal 559 the mode or header line of window that's has a horizontal
553 sibling, say it's on the vertical line. That's to be able 560 sibling, say it's on the vertical line. That's to be able
554 to resize windows horizontally in case we're using toolkit 561 to resize windows horizontally in case we're using toolkit
556 563
557 if (WINDOW_WANTS_MODELINE_P (w) 564 if (WINDOW_WANTS_MODELINE_P (w)
558 && *y >= bottom_y - CURRENT_MODE_LINE_HEIGHT (w) 565 && *y >= bottom_y - CURRENT_MODE_LINE_HEIGHT (w)
559 && *y < bottom_y) 566 && *y < bottom_y)
560 { 567 {
568 part = ON_MODE_LINE;
569
570 header_vertical_border_check:
561 /* We're somewhere on the mode line. We consider the place 571 /* We're somewhere on the mode line. We consider the place
562 between mode lines of horizontally adjacent mode lines 572 between mode lines of horizontally adjacent mode lines
563 as the vertical border. If scroll bars on the left, 573 as the vertical border. If scroll bars on the left,
564 return the right window. */ 574 return the right window. */
565 part = ON_MODE_LINE; 575 if (WINDOW_HAS_VERTICAL_SCROLL_BAR_ON_LEFT (w)
566 576 || WINDOW_RIGHTMOST_P (w))
567 if (FRAME_HAS_VERTICAL_SCROLL_BARS_ON_LEFT (f))
568 { 577 {
569 if (abs (*x - x0) < grabbable_width) 578 if (!WINDOW_LEFTMOST_P (w) && abs (*x - x0) < grabbable_width)
570 part = ON_VERTICAL_BORDER; 579 return ON_VERTICAL_BORDER;
571 } 580 }
572 else if (!WINDOW_RIGHTMOST_P (w) && abs (*x - x1) < grabbable_width) 581 else
573 part = ON_VERTICAL_BORDER; 582 {
574 } 583 if (abs (*x - x1) < grabbable_width)
575 else if (WINDOW_WANTS_HEADER_LINE_P (w) 584 return ON_VERTICAL_BORDER;
576 && *y < top_y + CURRENT_HEADER_LINE_HEIGHT (w) 585 }
577 && *y >= top_y) 586
587 return part;
588 }
589
590 if (WINDOW_WANTS_HEADER_LINE_P (w)
591 && *y >= top_y
592 && *y < top_y + CURRENT_HEADER_LINE_HEIGHT (w))
578 { 593 {
579 part = ON_HEADER_LINE; 594 part = ON_HEADER_LINE;
580 595 goto header_vertical_border_check;
581 if (FRAME_HAS_VERTICAL_SCROLL_BARS_ON_LEFT (f)) 596 }
582 { 597
583 if (abs (*x - x0) < grabbable_width) 598 /* Outside any interesting column? */
584 part = ON_VERTICAL_BORDER; 599 if (*x < left_x || *x > right_x)
585 } 600 return ON_NOTHING;
586 else if (!WINDOW_RIGHTMOST_P (w) && abs (*x - x1) < grabbable_width) 601
587 part = ON_VERTICAL_BORDER; 602 lmargin_width = window_box_width (w, LEFT_MARGIN_AREA);
588 } 603 rmargin_width = window_box_width (w, RIGHT_MARGIN_AREA);
589 /* Outside anything interesting? */ 604
590 else if (*y < top_y 605 text_left = window_box_left (w, TEXT_AREA);
591 || *y >= bottom_y 606 text_right = text_left + window_box_width (w, TEXT_AREA);
592 || *x < (left_x 607
593 - FRAME_LEFT_FRINGE_WIDTH (f) 608 if (FRAME_WINDOW_P (f))
594 - FRAME_LEFT_SCROLL_BAR_WIDTH (f) * ux)
595 || *x > (right_x
596 + FRAME_RIGHT_FRINGE_WIDTH (f)
597 + FRAME_RIGHT_SCROLL_BAR_WIDTH (f) * ux))
598 {
599 part = ON_NOTHING;
600 }
601 else if (FRAME_WINDOW_P (f))
602 { 609 {
603 if (!w->pseudo_window_p 610 if (!w->pseudo_window_p
604 && !FRAME_HAS_VERTICAL_SCROLL_BARS (f) 611 && !WINDOW_HAS_VERTICAL_SCROLL_BAR (w)
605 && !WINDOW_RIGHTMOST_P (w) 612 && !WINDOW_RIGHTMOST_P (w)
606 && (abs (*x - right_x - FRAME_RIGHT_FRINGE_WIDTH (f)) < grabbable_width)) 613 && (abs (*x - right_x) < grabbable_width))
607 { 614 return ON_VERTICAL_BORDER;
608 part = ON_VERTICAL_BORDER;
609 }
610 else if (*x < left_x || *x > right_x)
611 {
612 /* Other lines than the mode line don't include fringes and
613 scroll bars on the left. */
614
615 /* Convert X and Y to window-relative pixel coordinates. */
616 *x -= left_x;
617 *y -= top_y;
618 part = *x < left_x ? ON_LEFT_FRINGE : ON_RIGHT_FRINGE;
619 }
620 else
621 {
622 lmargin_width = window_box_width (w, LEFT_MARGIN_AREA);
623 rmargin_width = window_box_width (w, RIGHT_MARGIN_AREA);
624 /* You can never be on a margin area if its width is zero. */
625 if (lmargin_width
626 && *x <= window_box_right (w, LEFT_MARGIN_AREA))
627 part = ON_LEFT_MARGIN;
628 else if (rmargin_width
629 && *x >= window_box_left (w, RIGHT_MARGIN_AREA))
630 part = ON_RIGHT_MARGIN;
631 else
632 {
633 part = ON_TEXT;
634 *x -= left_x;
635 *y -= top_y;
636 }
637 }
638 } 615 }
639 else 616 else
640 { 617 {
641 /* Need to say "*x > right_x" rather than >=, since on character 618 /* Need to say "*x > right_x" rather than >=, since on character
642 terminals, the vertical line's x coordinate is right_x. */ 619 terminals, the vertical line's x coordinate is right_x. */
643 if (*x < left_x || *x > right_x) 620 if (!w->pseudo_window_p
644 { 621 && !WINDOW_RIGHTMOST_P (w)
645 /* Other lines than the mode line don't include fringes and 622 && *x > right_x - ux)
646 scroll bars on the left. */
647
648 /* Convert X and Y to window-relative pixel coordinates. */
649 *x -= left_x;
650 *y -= top_y;
651 part = *x < left_x ? ON_LEFT_FRINGE : ON_RIGHT_FRINGE;
652 }
653 /* Here, too, "*x > right_x" is because of character terminals. */
654 else if (!w->pseudo_window_p
655 && !WINDOW_RIGHTMOST_P (w)
656 && *x > right_x - ux)
657 { 623 {
658 /* On the border on the right side of the window? Assume that 624 /* On the border on the right side of the window? Assume that
659 this area begins at RIGHT_X minus a canonical char width. */ 625 this area begins at RIGHT_X minus a canonical char width. */
660 part = ON_VERTICAL_BORDER; 626 return ON_VERTICAL_BORDER;
661 } 627 }
662 else 628 }
663 { 629
664 lmargin_width = window_box_width (w, LEFT_MARGIN_AREA); 630 if (*x < text_left)
665 rmargin_width = window_box_width (w, RIGHT_MARGIN_AREA); 631 {
666 /* You can never be on a margin area if its width is zero. 632 if (lmargin_width > 0
667 This is especially important for character terminals. */ 633 && (WINDOW_HAS_FRINGES_OUTSIDE_MARGINS (w)
668 if (lmargin_width 634 ? (*x >= left_x + WINDOW_LEFT_FRINGE_WIDTH (w))
669 && *x <= window_box_right (w, LEFT_MARGIN_AREA)) 635 : (*x < left_x + lmargin_width)))
670 part = ON_LEFT_MARGIN; 636 return ON_LEFT_MARGIN;
671 else if (rmargin_width 637
672 && *x >= window_box_left (w, RIGHT_MARGIN_AREA)) 638 /* Convert X and Y to window-relative pixel coordinates. */
673 part = ON_RIGHT_MARGIN; 639 *x -= left_x;
674 else 640 *y -= top_y;
675 { 641 return ON_LEFT_FRINGE;
676 part = ON_TEXT; 642 }
677 /* Convert X and Y to window-relative pixel coordinates. */ 643
678 *x -= left_x; 644 if (*x >= text_right)
679 *y -= top_y; 645 {
680 } 646 if (rmargin_width > 0
681 } 647 && (WINDOW_HAS_FRINGES_OUTSIDE_MARGINS (w)
682 } 648 ? (*x < right_x - WINDOW_RIGHT_FRINGE_WIDTH (w))
683 649 : (*x >= right_x - rmargin_width)))
684 return part; 650 return ON_RIGHT_MARGIN;
651
652 /* Convert X and Y to window-relative pixel coordinates. */
653 *x -= left_x + WINDOW_LEFT_FRINGE_WIDTH (w);
654 *y -= top_y;
655 return ON_RIGHT_FRINGE;
656 }
657
658 /* Everything special ruled out - must be on text area */
659 *x -= left_x + WINDOW_LEFT_FRINGE_WIDTH (w);
660 *y -= top_y;
661 return ON_TEXT;
685 } 662 }
686 663
687 664
688 DEFUN ("coordinates-in-window-p", Fcoordinates_in_window_p, 665 DEFUN ("coordinates-in-window-p", Fcoordinates_in_window_p,
689 Scoordinates_in_window_p, 2, 2, 0, 666 Scoordinates_in_window_p, 2, 2, 0,
716 CHECK_CONS (coordinates); 693 CHECK_CONS (coordinates);
717 lx = Fcar (coordinates); 694 lx = Fcar (coordinates);
718 ly = Fcdr (coordinates); 695 ly = Fcdr (coordinates);
719 CHECK_NUMBER_OR_FLOAT (lx); 696 CHECK_NUMBER_OR_FLOAT (lx);
720 CHECK_NUMBER_OR_FLOAT (ly); 697 CHECK_NUMBER_OR_FLOAT (ly);
721 x = PIXEL_X_FROM_CANON_X (f, lx); 698 x = FRAME_PIXEL_X_FROM_CANON_X (f, lx);
722 y = PIXEL_Y_FROM_CANON_Y (f, ly); 699 y = FRAME_PIXEL_Y_FROM_CANON_Y (f, ly);
723 700
724 switch (coordinates_in_window (w, &x, &y)) 701 switch (coordinates_in_window (w, &x, &y))
725 { 702 {
726 case ON_NOTHING: 703 case ON_NOTHING:
727 return Qnil; 704 return Qnil;
728 705
729 case ON_TEXT: 706 case ON_TEXT:
730 /* X and Y are now window relative pixel coordinates. Convert 707 /* X and Y are now window relative pixel coordinates. Convert
731 them to canonical char units before returning them. */ 708 them to canonical char units before returning them. */
732 return Fcons (CANON_X_FROM_PIXEL_X (f, x), 709 return Fcons (FRAME_CANON_X_FROM_PIXEL_X (f, x),
733 CANON_Y_FROM_PIXEL_Y (f, y)); 710 FRAME_CANON_Y_FROM_PIXEL_Y (f, y));
734 711
735 case ON_MODE_LINE: 712 case ON_MODE_LINE:
736 return Qmode_line; 713 return Qmode_line;
737 714
738 case ON_VERTICAL_BORDER: 715 case ON_VERTICAL_BORDER:
795 return continue_p; 772 return continue_p;
796 } 773 }
797 774
798 775
799 /* Find the window containing frame-relative pixel position X/Y and 776 /* Find the window containing frame-relative pixel position X/Y and
800 return it as a Lisp_Object. If X, Y is on one of the window's 777 return it as a Lisp_Object.
801 special `window_part' elements, set *PART to the id of that element. 778
779 If X, Y is on one of the window's special `window_part' elements,
780 set *PART to the id of that element, and return X and Y converted
781 to window relative coordinates in WX and WY.
782
802 If there is no window under X, Y return nil and leave *PART 783 If there is no window under X, Y return nil and leave *PART
803 unmodified. TOOL_BAR_P non-zero means detect tool-bar windows. 784 unmodified. TOOL_BAR_P non-zero means detect tool-bar windows.
804 785
805 This function was previously implemented with a loop cycling over 786 This function was previously implemented with a loop cycling over
806 windows with Fnext_window, and starting with the frame's selected 787 windows with Fnext_window, and starting with the frame's selected
810 tree of F when this function is called asynchronously from 791 tree of F when this function is called asynchronously from
811 note_mouse_highlight. The original loop didn't terminate in this 792 note_mouse_highlight. The original loop didn't terminate in this
812 case. */ 793 case. */
813 794
814 Lisp_Object 795 Lisp_Object
815 window_from_coordinates (f, x, y, part, tool_bar_p) 796 window_from_coordinates (f, x, y, part, wx, wy, tool_bar_p)
816 struct frame *f; 797 struct frame *f;
817 int x, y; 798 int x, y;
818 enum window_part *part; 799 enum window_part *part;
800 int *wx, *wy;
819 int tool_bar_p; 801 int tool_bar_p;
820 { 802 {
821 Lisp_Object window; 803 Lisp_Object window;
822 struct check_window_data cw; 804 struct check_window_data cw;
823 enum window_part dummy; 805 enum window_part dummy;
832 /* If not found above, see if it's in the tool bar window, if a tool 814 /* If not found above, see if it's in the tool bar window, if a tool
833 bar exists. */ 815 bar exists. */
834 if (NILP (window) 816 if (NILP (window)
835 && tool_bar_p 817 && tool_bar_p
836 && WINDOWP (f->tool_bar_window) 818 && WINDOWP (f->tool_bar_window)
837 && XINT (XWINDOW (f->tool_bar_window)->height) > 0 819 && WINDOW_TOTAL_LINES (XWINDOW (f->tool_bar_window)) > 0
838 && (coordinates_in_window (XWINDOW (f->tool_bar_window), &x, &y) 820 && (coordinates_in_window (XWINDOW (f->tool_bar_window), &x, &y)
839 != ON_NOTHING)) 821 != ON_NOTHING))
840 { 822 {
841 *part = ON_TEXT; 823 *part = ON_TEXT;
842 window = f->tool_bar_window; 824 window = f->tool_bar_window;
843 } 825 }
826
827 if (wx) *wx = x;
828 if (wy) *wy = y;
844 829
845 return window; 830 return window;
846 } 831 }
847 832
848 DEFUN ("window-at", Fwindow_at, Swindow_at, 2, 3, 0, 833 DEFUN ("window-at", Fwindow_at, Swindow_at, 2, 3, 0,
863 /* Check that arguments are integers or floats. */ 848 /* Check that arguments are integers or floats. */
864 CHECK_NUMBER_OR_FLOAT (x); 849 CHECK_NUMBER_OR_FLOAT (x);
865 CHECK_NUMBER_OR_FLOAT (y); 850 CHECK_NUMBER_OR_FLOAT (y);
866 851
867 return window_from_coordinates (f, 852 return window_from_coordinates (f,
868 PIXEL_X_FROM_CANON_X (f, x), 853 FRAME_PIXEL_X_FROM_CANON_X (f, x),
869 PIXEL_Y_FROM_CANON_Y (f, y), 854 FRAME_PIXEL_Y_FROM_CANON_Y (f, y),
870 0, 0); 855 0, 0, 0, 0);
871 } 856 }
872 857
873 DEFUN ("window-point", Fwindow_point, Swindow_point, 0, 1, 0, 858 DEFUN ("window-point", Fwindow_point, Swindow_point, 0, 1, 0,
874 doc: /* Return current value of point in WINDOW. 859 doc: /* Return current value of point in WINDOW.
875 For a nonselected window, this is the value point would have 860 For a nonselected window, this is the value point would have
1165 root_window for that frame. */ 1150 root_window for that frame. */
1166 1151
1167 if (EQ (old, FRAME_ROOT_WINDOW (XFRAME (o->frame)))) 1152 if (EQ (old, FRAME_ROOT_WINDOW (XFRAME (o->frame))))
1168 FRAME_ROOT_WINDOW (XFRAME (o->frame)) = replacement; 1153 FRAME_ROOT_WINDOW (XFRAME (o->frame)) = replacement;
1169 1154
1170 p->left = o->left; 1155 p->left_col = o->left_col;
1171 p->top = o->top; 1156 p->top_line = o->top_line;
1172 p->width = o->width; 1157 p->total_cols = o->total_cols;
1173 p->height = o->height; 1158 p->total_lines = o->total_lines;
1174 p->desired_matrix = p->current_matrix = 0; 1159 p->desired_matrix = p->current_matrix = 0;
1175 p->vscroll = 0; 1160 p->vscroll = 0;
1176 bzero (&p->cursor, sizeof (p->cursor)); 1161 bzero (&p->cursor, sizeof (p->cursor));
1177 bzero (&p->last_cursor, sizeof (p->last_cursor)); 1162 bzero (&p->last_cursor, sizeof (p->last_cursor));
1178 bzero (&p->phys_cursor, sizeof (p->phys_cursor)); 1163 bzero (&p->phys_cursor, sizeof (p->phys_cursor));
1182 p->pseudo_window_p = 0; 1167 p->pseudo_window_p = 0;
1183 XSETFASTINT (p->window_end_vpos, 0); 1168 XSETFASTINT (p->window_end_vpos, 0);
1184 XSETFASTINT (p->window_end_pos, 0); 1169 XSETFASTINT (p->window_end_pos, 0);
1185 p->window_end_valid = Qnil; 1170 p->window_end_valid = Qnil;
1186 p->frozen_window_start_p = 0; 1171 p->frozen_window_start_p = 0;
1187 p->orig_top = p->orig_height = Qnil; 1172 p->orig_top_line = p->orig_total_lines = Qnil;
1188 1173
1189 p->next = tem = o->next; 1174 p->next = tem = o->next;
1190 if (!NILP (tem)) 1175 if (!NILP (tem))
1191 XWINDOW (tem)->prev = replacement; 1176 XWINDOW (tem)->prev = replacement;
1192 1177
1341 /* If p gives its space to its next sibling, that sibling needs 1326 /* If p gives its space to its next sibling, that sibling needs
1342 to have its top/left side pulled back to where p's is. 1327 to have its top/left side pulled back to where p's is.
1343 set_window_{height,width} will re-position the sibling's 1328 set_window_{height,width} will re-position the sibling's
1344 children. */ 1329 children. */
1345 sib = p->next; 1330 sib = p->next;
1346 XWINDOW (sib)->top = p->top; 1331 XWINDOW (sib)->top_line = p->top_line;
1347 XWINDOW (sib)->left = p->left; 1332 XWINDOW (sib)->left_col = p->left_col;
1348 } 1333 }
1349 1334
1350 /* Stretch that sibling. */ 1335 /* Stretch that sibling. */
1351 if (!NILP (par->vchild)) 1336 if (!NILP (par->vchild))
1352 set_window_height (sib, 1337 set_window_height (sib,
1353 XFASTINT (XWINDOW (sib)->height) + XFASTINT (p->height), 1338 XFASTINT (XWINDOW (sib)->total_lines) + XFASTINT (p->total_lines),
1354 1); 1339 1);
1355 if (!NILP (par->hchild)) 1340 if (!NILP (par->hchild))
1356 set_window_width (sib, 1341 set_window_width (sib,
1357 XFASTINT (XWINDOW (sib)->width) + XFASTINT (p->width), 1342 XFASTINT (XWINDOW (sib)->total_cols) + XFASTINT (p->total_cols),
1358 1); 1343 1);
1359 1344
1360 /* If parent now has only one child, 1345 /* If parent now has only one child,
1361 put the child into the parent's place. */ 1346 put the child into the parent's place. */
1362 tem = par->hchild; 1347 tem = par->hchild;
1888 /* If we're deleting the buffer displayed in the 1873 /* If we're deleting the buffer displayed in the
1889 only window on the frame, find a new buffer to 1874 only window on the frame, find a new buffer to
1890 display there. */ 1875 display there. */
1891 Lisp_Object buffer; 1876 Lisp_Object buffer;
1892 buffer = Fother_buffer (obj, Qnil, w->frame); 1877 buffer = Fother_buffer (obj, Qnil, w->frame);
1893 Fset_window_buffer (window, buffer); 1878 Fset_window_buffer (window, buffer, Qnil);
1894 if (EQ (window, selected_window)) 1879 if (EQ (window, selected_window))
1895 Fset_buffer (w->buffer); 1880 Fset_buffer (w->buffer);
1896 } 1881 }
1897 else 1882 else
1898 Fdelete_window (window); 1883 Fdelete_window (window);
1908 if (NILP (best_window)) 1893 if (NILP (best_window))
1909 best_window = window; 1894 best_window = window;
1910 else 1895 else
1911 { 1896 {
1912 struct window *b = XWINDOW (best_window); 1897 struct window *b = XWINDOW (best_window);
1913 if (XFASTINT (w->height) * XFASTINT (w->width) 1898 if (XFASTINT (w->total_lines) * XFASTINT (w->total_cols)
1914 > XFASTINT (b->height) * XFASTINT (b->width)) 1899 > XFASTINT (b->total_lines) * XFASTINT (b->total_cols))
1915 best_window = window; 1900 best_window = window;
1916 } 1901 }
1917 } 1902 }
1918 break; 1903 break;
1919 1904
1952 } 1937 }
1953 else 1938 else
1954 { 1939 {
1955 /* Otherwise show a different buffer in the window. */ 1940 /* Otherwise show a different buffer in the window. */
1956 w->dedicated = Qnil; 1941 w->dedicated = Qnil;
1957 Fset_window_buffer (window, buffer); 1942 Fset_window_buffer (window, buffer, Qnil);
1958 if (EQ (window, selected_window)) 1943 if (EQ (window, selected_window))
1959 Fset_buffer (w->buffer); 1944 Fset_buffer (w->buffer);
1960 } 1945 }
1961 } 1946 }
1962 break; 1947 break;
2057 else 2042 else
2058 CHECK_LIVE_WINDOW (window); 2043 CHECK_LIVE_WINDOW (window);
2059 w = XWINDOW (window); 2044 w = XWINDOW (window);
2060 2045
2061 startpos = marker_position (w->start); 2046 startpos = marker_position (w->start);
2062 top = XFASTINT (w->top) - FRAME_TOP_MARGIN (XFRAME (WINDOW_FRAME (w))); 2047 top = WINDOW_TOP_EDGE_LINE (w) - FRAME_TOP_MARGIN (XFRAME (WINDOW_FRAME (w)));
2063 2048
2064 if (MINI_WINDOW_P (w) && top > 0) 2049 if (MINI_WINDOW_P (w) && top > 0)
2065 error ("Can't expand minibuffer to full frame"); 2050 error ("Can't expand minibuffer to full frame");
2066 2051
2067 window_loop (DELETE_OTHER_WINDOWS, window, 0, WINDOW_FRAME (w)); 2052 window_loop (DELETE_OTHER_WINDOWS, window, 0, WINDOW_FRAME (w));
2069 /* Try to minimize scrolling, by setting the window start to the point 2054 /* Try to minimize scrolling, by setting the window start to the point
2070 will cause the text at the old window start to be at the same place 2055 will cause the text at the old window start to be at the same place
2071 on the frame. But don't try to do this if the window start is 2056 on the frame. But don't try to do this if the window start is
2072 outside the visible portion (as might happen when the display is 2057 outside the visible portion (as might happen when the display is
2073 not current, due to typeahead). */ 2058 not current, due to typeahead). */
2074 new_top = XFASTINT (w->top) - FRAME_TOP_MARGIN (XFRAME (WINDOW_FRAME (w))); 2059 new_top = WINDOW_TOP_EDGE_LINE (w) - FRAME_TOP_MARGIN (XFRAME (WINDOW_FRAME (w)));
2075 if (new_top != top 2060 if (new_top != top
2076 && startpos >= BUF_BEGV (XBUFFER (w->buffer)) 2061 && startpos >= BUF_BEGV (XBUFFER (w->buffer))
2077 && startpos <= BUF_ZV (XBUFFER (w->buffer))) 2062 && startpos <= BUF_ZV (XBUFFER (w->buffer)))
2078 { 2063 {
2079 struct position pos; 2064 struct position pos;
2424 2409
2425 if (fixed) 2410 if (fixed)
2426 *fixed = fixed_p; 2411 *fixed = fixed_p;
2427 2412
2428 if (fixed_p) 2413 if (fixed_p)
2429 size = width_p ? XFASTINT (w->width) : XFASTINT (w->height); 2414 size = width_p ? XFASTINT (w->total_cols) : XFASTINT (w->total_lines);
2430 else 2415 else
2431 size = window_min_size_1 (w, width_p); 2416 size = window_min_size_1 (w, width_p);
2432 2417
2433 return size; 2418 return size;
2419 }
2420
2421
2422 /* Adjust the margins of window W if text area is too small.
2423 Return 1 if window width is ok after adjustment; 0 if window
2424 is still too narrow. */
2425
2426 static int
2427 adjust_window_margins (w)
2428 struct window *w;
2429 {
2430 int box_cols = (WINDOW_TOTAL_COLS (w)
2431 - WINDOW_FRINGE_COLS (w)
2432 - WINDOW_SCROLL_BAR_COLS (w));
2433 int margin_cols = (WINDOW_LEFT_MARGIN_COLS (w)
2434 + WINDOW_RIGHT_MARGIN_COLS (w));
2435
2436 if (box_cols - margin_cols >= MIN_SAFE_WINDOW_WIDTH)
2437 return 1;
2438
2439 if (margin_cols < 0 || box_cols < MIN_SAFE_WINDOW_WIDTH)
2440 return 0;
2441
2442 /* Window's text area is too narrow, but reducing the window
2443 margins will fix that. */
2444 margin_cols = box_cols - MIN_SAFE_WINDOW_WIDTH;
2445 if (WINDOW_RIGHT_MARGIN_COLS (w) > 0)
2446 {
2447 if (WINDOW_LEFT_MARGIN_COLS (w) > 0)
2448 w->left_margin_cols = w->right_margin_cols
2449 = make_number (margin_cols/2);
2450 else
2451 w->right_margin_cols = make_number (margin_cols);
2452 }
2453 else
2454 w->left_margin_cols = make_number (margin_cols);
2455 return 1;
2434 } 2456 }
2435 2457
2436 2458
2437 /* Set WINDOW's height or width to SIZE. WIDTH_P non-zero means set 2459 /* Set WINDOW's height or width to SIZE. WIDTH_P non-zero means set
2438 WINDOW's width. Resize WINDOW's children, if any, so that they 2460 WINDOW's width. Resize WINDOW's children, if any, so that they
2449 int size, width_p, nodelete_p; 2471 int size, width_p, nodelete_p;
2450 { 2472 {
2451 struct window *w = XWINDOW (window); 2473 struct window *w = XWINDOW (window);
2452 struct window *c; 2474 struct window *c;
2453 Lisp_Object child, *forward, *sideward; 2475 Lisp_Object child, *forward, *sideward;
2454 int old_size, min_size; 2476 int old_size, min_size, safe_min_size;
2455 2477
2478 /* We test nodelete_p != 2 and nodelete_p != 1 below, so it
2479 seems like it's too soon to do this here. ++KFS. */
2456 if (nodelete_p == 2) 2480 if (nodelete_p == 2)
2457 nodelete_p = 0; 2481 nodelete_p = 0;
2458 2482
2459 check_min_window_sizes (); 2483 check_min_window_sizes ();
2460 size = max (0, size); 2484 size = max (0, size);
2462 /* If the window has been "too small" at one point, 2486 /* If the window has been "too small" at one point,
2463 don't delete it for being "too small" in the future. 2487 don't delete it for being "too small" in the future.
2464 Preserve it as long as that is at all possible. */ 2488 Preserve it as long as that is at all possible. */
2465 if (width_p) 2489 if (width_p)
2466 { 2490 {
2467 old_size = XINT (w->width); 2491 old_size = WINDOW_TOTAL_COLS (w);
2468 min_size = window_min_width; 2492 min_size = window_min_width;
2493 /* Ensure that there is room for the scroll bar and fringes!
2494 We may reduce display margins though. */
2495 safe_min_size = (MIN_SAFE_WINDOW_WIDTH
2496 + WINDOW_FRINGE_COLS (w)
2497 + WINDOW_SCROLL_BAR_COLS (w));
2469 } 2498 }
2470 else 2499 else
2471 { 2500 {
2472 old_size = XINT (w->height); 2501 old_size = XINT (w->total_lines);
2473 min_size = window_min_height; 2502 min_size = window_min_height;
2503 safe_min_size = MIN_SAFE_WINDOW_HEIGHT;
2474 } 2504 }
2475 2505
2476 if (old_size < min_size && nodelete_p != 2) 2506 if (old_size < min_size && nodelete_p != 2)
2477 w->too_small_ok = Qt; 2507 w->too_small_ok = Qt;
2478 2508
2479 /* Maybe delete WINDOW if it's too small. */ 2509 /* Maybe delete WINDOW if it's too small. */
2480 if (nodelete_p != 1 && !NILP (w->parent)) 2510 if (nodelete_p != 1 && !NILP (w->parent))
2481 { 2511 {
2482 if (!MINI_WINDOW_P (w) && !NILP (w->too_small_ok)) 2512 if (!MINI_WINDOW_P (w) && !NILP (w->too_small_ok))
2483 min_size = width_p ? MIN_SAFE_WINDOW_WIDTH : MIN_SAFE_WINDOW_HEIGHT; 2513 min_size = width_p ? MIN_SAFE_WINDOW_WIDTH : MIN_SAFE_WINDOW_HEIGHT;
2484 else 2514 if (min_size < safe_min_size)
2485 min_size = width_p ? window_min_width : window_min_height; 2515 min_size = safe_min_size;
2486
2487 if (size < min_size) 2516 if (size < min_size)
2488 { 2517 {
2489 delete_window (window); 2518 delete_window (window);
2490 return; 2519 return;
2491 } 2520 }
2499 2528
2500 if (width_p) 2529 if (width_p)
2501 { 2530 {
2502 sideward = &w->vchild; 2531 sideward = &w->vchild;
2503 forward = &w->hchild; 2532 forward = &w->hchild;
2504 w->width = make_number (size); 2533 w->total_cols = make_number (size);
2534 adjust_window_margins (w);
2505 } 2535 }
2506 else 2536 else
2507 { 2537 {
2508 sideward = &w->hchild; 2538 sideward = &w->hchild;
2509 forward = &w->vchild; 2539 forward = &w->vchild;
2510 w->height = make_number (size); 2540 w->total_lines = make_number (size);
2511 w->orig_height = Qnil; 2541 w->orig_total_lines = Qnil;
2512 } 2542 }
2513 2543
2514 if (!NILP (*sideward)) 2544 if (!NILP (*sideward))
2515 { 2545 {
2516 for (child = *sideward; !NILP (child); child = c->next) 2546 for (child = *sideward; !NILP (child); child = c->next)
2517 { 2547 {
2518 c = XWINDOW (child); 2548 c = XWINDOW (child);
2519 if (width_p) 2549 if (width_p)
2520 c->left = w->left; 2550 c->left_col = w->left_col;
2521 else 2551 else
2522 c->top = w->top; 2552 c->top_line = w->top_line;
2523 size_window (child, size, width_p, nodelete_p); 2553 size_window (child, size, width_p, nodelete_p);
2524 } 2554 }
2525 } 2555 }
2526 else if (!NILP (*forward)) 2556 else if (!NILP (*forward))
2527 { 2557 {
2535 for (child = *forward; !NILP (child); child = c->next, ++nchildren) 2565 for (child = *forward; !NILP (child); child = c->next, ++nchildren)
2536 { 2566 {
2537 int child_size; 2567 int child_size;
2538 2568
2539 c = XWINDOW (child); 2569 c = XWINDOW (child);
2540 child_size = width_p ? XINT (c->width) : XINT (c->height); 2570 child_size = width_p ? XINT (c->total_cols) : XINT (c->total_lines);
2541 total += child_size; 2571 total += child_size;
2542 2572
2543 if (window_fixed_size_p (c, width_p, 0)) 2573 if (window_fixed_size_p (c, width_p, 0))
2544 { 2574 {
2545 fixed_size += child_size; 2575 fixed_size += child_size;
2557 n = resize_fixed_p ? nchildren : nchildren - nfixed; 2587 n = resize_fixed_p ? nchildren : nchildren - nfixed;
2558 each = (size - total) / n; 2588 each = (size - total) / n;
2559 extra = (size - total) - n * each; 2589 extra = (size - total) - n * each;
2560 2590
2561 /* Compute new children heights and edge positions. */ 2591 /* Compute new children heights and edge positions. */
2562 first_pos = width_p ? XINT (w->left) : XINT (w->top); 2592 first_pos = width_p ? XINT (w->left_col) : XINT (w->top_line);
2563 last_pos = first_pos; 2593 last_pos = first_pos;
2564 for (child = *forward; !NILP (child); child = c->next) 2594 for (child = *forward; !NILP (child); child = c->next)
2565 { 2595 {
2566 int new_size, old_size; 2596 int new_size, old_size;
2567 2597
2568 c = XWINDOW (child); 2598 c = XWINDOW (child);
2569 old_size = width_p ? XFASTINT (c->width) : XFASTINT (c->height); 2599 old_size = width_p ? XFASTINT (c->total_cols) : XFASTINT (c->total_lines);
2570 new_size = old_size; 2600 new_size = old_size;
2571 2601
2572 /* The top or left edge position of this child equals the 2602 /* The top or left edge position of this child equals the
2573 bottom or right edge of its predecessor. */ 2603 bottom or right edge of its predecessor. */
2574 if (width_p) 2604 if (width_p)
2575 c->left = make_number (last_pos); 2605 c->left_col = make_number (last_pos);
2576 else 2606 else
2577 c->top = make_number (last_pos); 2607 c->top_line = make_number (last_pos);
2578 2608
2579 /* If this child can be resized, do it. */ 2609 /* If this child can be resized, do it. */
2580 if (resize_fixed_p || !window_fixed_size_p (c, width_p, 0)) 2610 if (resize_fixed_p || !window_fixed_size_p (c, width_p, 0))
2581 { 2611 {
2582 new_size = old_size + each + extra; 2612 new_size = old_size + each + extra;
2600 if (!nodelete_p) 2630 if (!nodelete_p)
2601 for (child = *forward; !NILP (child); child = c->next) 2631 for (child = *forward; !NILP (child); child = c->next)
2602 { 2632 {
2603 int child_size; 2633 int child_size;
2604 c = XWINDOW (child); 2634 c = XWINDOW (child);
2605 child_size = width_p ? XINT (c->width) : XINT (c->height); 2635 child_size = width_p ? XINT (c->total_cols) : XINT (c->total_lines);
2606 size_window (child, child_size, width_p, 2); 2636 size_window (child, child_size, width_p, 2);
2607 } 2637 }
2608 } 2638 }
2609 } 2639 }
2610 2640
2644 Lisp_Object window; 2674 Lisp_Object window;
2645 int n; 2675 int n;
2646 { 2676 {
2647 struct window *w = XWINDOW (window); 2677 struct window *w = XWINDOW (window);
2648 2678
2649 XSETFASTINT (w->top, XFASTINT (w->top) + n); 2679 XSETFASTINT (w->top_line, XFASTINT (w->top_line) + n);
2650 XSETFASTINT (w->height, XFASTINT (w->height) - n); 2680 XSETFASTINT (w->total_lines, XFASTINT (w->total_lines) - n);
2651 2681
2652 if (INTEGERP (w->orig_top)) 2682 if (INTEGERP (w->orig_top_line))
2653 XSETFASTINT (w->orig_top, XFASTINT (w->orig_top) + n); 2683 XSETFASTINT (w->orig_top_line, XFASTINT (w->orig_top_line) + n);
2654 if (INTEGERP (w->orig_height)) 2684 if (INTEGERP (w->orig_total_lines))
2655 XSETFASTINT (w->orig_height, XFASTINT (w->orig_height) - n); 2685 XSETFASTINT (w->orig_total_lines, XFASTINT (w->orig_total_lines) - n);
2656 2686
2657 /* Handle just the top child in a vertical split. */ 2687 /* Handle just the top child in a vertical split. */
2658 if (!NILP (w->vchild)) 2688 if (!NILP (w->vchild))
2659 change_window_heights (w->vchild, n); 2689 change_window_heights (w->vchild, n);
2660 2690
2678 } 2708 }
2679 2709
2680 2710
2681 /* Make WINDOW display BUFFER as its contents. RUN_HOOKS_P non-zero 2711 /* Make WINDOW display BUFFER as its contents. RUN_HOOKS_P non-zero
2682 means it's allowed to run hooks. See make_frame for a case where 2712 means it's allowed to run hooks. See make_frame for a case where
2683 it's not allowed. */ 2713 it's not allowed. KEEP_MARGINS_P non-zero means that the current
2714 margins, fringes, and scroll-bar settings of the window are not
2715 reset from the buffer's local settings. */
2684 2716
2685 void 2717 void
2686 set_window_buffer (window, buffer, run_hooks_p) 2718 set_window_buffer (window, buffer, run_hooks_p, keep_margins_p)
2687 Lisp_Object window, buffer; 2719 Lisp_Object window, buffer;
2688 int run_hooks_p; 2720 int run_hooks_p, keep_margins_p;
2689 { 2721 {
2690 struct window *w = XWINDOW (window); 2722 struct window *w = XWINDOW (window);
2691 struct buffer *b = XBUFFER (buffer); 2723 struct buffer *b = XBUFFER (buffer);
2692 int count = SPECPDL_INDEX (); 2724 int count = SPECPDL_INDEX ();
2693 2725
2728 { 2760 {
2729 record_unwind_protect (Fset_window_buffer_unwind, Fcurrent_buffer ()); 2761 record_unwind_protect (Fset_window_buffer_unwind, Fcurrent_buffer ());
2730 Fset_buffer (buffer); 2762 Fset_buffer (buffer);
2731 } 2763 }
2732 2764
2733 /* Set left and right marginal area width from buffer. */ 2765 if (!keep_margins_p)
2734 Fset_window_margins (window, b->left_margin_width, b->right_margin_width); 2766 {
2767 /* Set left and right marginal area width etc. from buffer. */
2768
2769 /* This may call adjust_window_margins three times, so
2770 temporarily disable window margins. */
2771 w->left_margin_cols = w->right_margin_cols = Qnil;
2772
2773 Fset_window_fringes (window,
2774 b->left_fringe_width, b->right_fringe_width,
2775 b->fringes_outside_margins);
2776
2777 Fset_window_scroll_bars (window,
2778 b->scroll_bar_width,
2779 b->vertical_scroll_bar_type, Qnil);
2780
2781 Fset_window_margins (window,
2782 b->left_margin_cols, b->right_margin_cols);
2783 }
2735 2784
2736 if (run_hooks_p) 2785 if (run_hooks_p)
2737 { 2786 {
2738 if (! NILP (Vwindow_scroll_functions)) 2787 if (! NILP (Vwindow_scroll_functions))
2739 run_hook_with_args_2 (Qwindow_scroll_functions, window, 2788 run_hook_with_args_2 (Qwindow_scroll_functions, window,
2746 2795
2747 unbind_to (count, Qnil); 2796 unbind_to (count, Qnil);
2748 } 2797 }
2749 2798
2750 2799
2751 DEFUN ("set-window-buffer", Fset_window_buffer, Sset_window_buffer, 2, 2, 0, 2800 DEFUN ("set-window-buffer", Fset_window_buffer, Sset_window_buffer, 2, 3, 0,
2752 doc: /* Make WINDOW display BUFFER as its contents. 2801 doc: /* Make WINDOW display BUFFER as its contents.
2753 BUFFER can be a buffer or buffer name. */) 2802 BUFFER can be a buffer or buffer name.
2754 (window, buffer) 2803 Optional third arg KEEP_MARGINS non-nil means that WINDOW's current
2804 display margins, fringe widths, and scroll bar settings are maintained;
2805 the default is to reset these from BUFFER's local settings or the frame
2806 defaults. */)
2807 (window, buffer, keep_margins)
2755 register Lisp_Object window, buffer; 2808 register Lisp_Object window, buffer;
2756 { 2809 {
2757 register Lisp_Object tem; 2810 register Lisp_Object tem;
2758 register struct window *w = decode_window (window); 2811 register struct window *w = decode_window (window);
2759 2812
2775 SDATA (XBUFFER (tem)->name)); 2828 SDATA (XBUFFER (tem)->name));
2776 2829
2777 unshow_buffer (w); 2830 unshow_buffer (w);
2778 } 2831 }
2779 2832
2780 set_window_buffer (window, buffer, 1); 2833 set_window_buffer (window, buffer, 1, !NILP (keep_margins));
2781 return Qnil; 2834 return Qnil;
2782 } 2835 }
2783 2836
2784 DEFUN ("select-window", Fselect_window, Sselect_window, 1, 2, 0, 2837 DEFUN ("select-window", Fselect_window, Sselect_window, 1, 2, 0,
2785 doc: /* Select WINDOW. Most editing will apply to WINDOW's buffer. 2838 doc: /* Select WINDOW. Most editing will apply to WINDOW's buffer.
3045 /* If there are no frames open that have more than a minibuffer, 3098 /* If there are no frames open that have more than a minibuffer,
3046 we need to create a new frame. */ 3099 we need to create a new frame. */
3047 if (pop_up_frames || last_nonminibuf_frame == 0) 3100 if (pop_up_frames || last_nonminibuf_frame == 0)
3048 { 3101 {
3049 window = Fframe_selected_window (call0 (Vpop_up_frame_function)); 3102 window = Fframe_selected_window (call0 (Vpop_up_frame_function));
3050 Fset_window_buffer (window, buffer); 3103 Fset_window_buffer (window, buffer, Qnil);
3051 return display_buffer_1 (window); 3104 return display_buffer_1 (window);
3052 } 3105 }
3053 3106
3054 f = SELECTED_FRAME (); 3107 f = SELECTED_FRAME ();
3055 if (pop_up_windows 3108 if (pop_up_windows
3134 if (!NILP (XWINDOW (window)->next)) 3187 if (!NILP (XWINDOW (window)->next))
3135 other = lower = XWINDOW (window)->next, upper = window; 3188 other = lower = XWINDOW (window)->next, upper = window;
3136 if (!NILP (other) 3189 if (!NILP (other)
3137 && !NILP (Veven_window_heights) 3190 && !NILP (Veven_window_heights)
3138 /* Check that OTHER and WINDOW are vertically arrayed. */ 3191 /* Check that OTHER and WINDOW are vertically arrayed. */
3139 && !EQ (XWINDOW (other)->top, XWINDOW (window)->top) 3192 && !EQ (XWINDOW (other)->top_line, XWINDOW (window)->top_line)
3140 && (XFASTINT (XWINDOW (other)->height) 3193 && (XFASTINT (XWINDOW (other)->total_lines)
3141 > XFASTINT (XWINDOW (window)->height))) 3194 > XFASTINT (XWINDOW (window)->total_lines)))
3142 { 3195 {
3143 int total = (XFASTINT (XWINDOW (other)->height) 3196 int total = (XFASTINT (XWINDOW (other)->total_lines)
3144 + XFASTINT (XWINDOW (window)->height)); 3197 + XFASTINT (XWINDOW (window)->total_lines));
3145 enlarge_window (upper, 3198 enlarge_window (upper,
3146 total / 2 - XFASTINT (XWINDOW (upper)->height), 3199 total / 2 - XFASTINT (XWINDOW (upper)->total_lines),
3147 0, 0); 3200 0, 0);
3148 } 3201 }
3149 } 3202 }
3150 } 3203 }
3151 else 3204 else
3152 window = Fget_lru_window (Qnil); 3205 window = Fget_lru_window (Qnil);
3153 3206
3154 Fset_window_buffer (window, buffer); 3207 Fset_window_buffer (window, buffer, Qnil);
3155 return display_buffer_1 (window); 3208 return display_buffer_1 (window);
3156 } 3209 }
3157 3210
3158 void 3211 void
3159 temp_output_buffer_show (buf) 3212 temp_output_buffer_show (buf)
3280 if (!NILP (horflag)) 3333 if (!NILP (horflag))
3281 /* Calculate the size of the left-hand window, by dividing 3334 /* Calculate the size of the left-hand window, by dividing
3282 the usable space in columns by two. 3335 the usable space in columns by two.
3283 We round up, since the left-hand window may include 3336 We round up, since the left-hand window may include
3284 a dividing line, while the right-hand may not. */ 3337 a dividing line, while the right-hand may not. */
3285 size_int = (XFASTINT (o->width) + 1) >> 1; 3338 size_int = (XFASTINT (o->total_cols) + 1) >> 1;
3286 else 3339 else
3287 size_int = XFASTINT (o->height) >> 1; 3340 size_int = XFASTINT (o->total_lines) >> 1;
3288 } 3341 }
3289 else 3342 else
3290 { 3343 {
3291 CHECK_NUMBER (size); 3344 CHECK_NUMBER (size);
3292 size_int = XINT (size); 3345 size_int = XINT (size);
3301 3354
3302 if (NILP (horflag)) 3355 if (NILP (horflag))
3303 { 3356 {
3304 if (size_int < window_min_height) 3357 if (size_int < window_min_height)
3305 error ("Window height %d too small (after splitting)", size_int); 3358 error ("Window height %d too small (after splitting)", size_int);
3306 if (size_int + window_min_height > XFASTINT (o->height)) 3359 if (size_int + window_min_height > XFASTINT (o->total_lines))
3307 error ("Window height %d too small (after splitting)", 3360 error ("Window height %d too small (after splitting)",
3308 XFASTINT (o->height) - size_int); 3361 XFASTINT (o->total_lines) - size_int);
3309 if (NILP (o->parent) 3362 if (NILP (o->parent)
3310 || NILP (XWINDOW (o->parent)->vchild)) 3363 || NILP (XWINDOW (o->parent)->vchild))
3311 { 3364 {
3312 make_dummy_parent (window); 3365 make_dummy_parent (window);
3313 new = o->parent; 3366 new = o->parent;
3317 else 3370 else
3318 { 3371 {
3319 if (size_int < window_min_width) 3372 if (size_int < window_min_width)
3320 error ("Window width %d too small (after splitting)", size_int); 3373 error ("Window width %d too small (after splitting)", size_int);
3321 3374
3322 if (size_int + window_min_width > XFASTINT (o->width)) 3375 if (size_int + window_min_width > XFASTINT (o->total_cols))
3323 error ("Window width %d too small (after splitting)", 3376 error ("Window width %d too small (after splitting)",
3324 XFASTINT (o->width) - size_int); 3377 XFASTINT (o->total_cols) - size_int);
3325 if (NILP (o->parent) 3378 if (NILP (o->parent)
3326 || NILP (XWINDOW (o->parent)->hchild)) 3379 || NILP (XWINDOW (o->parent)->hchild))
3327 { 3380 {
3328 make_dummy_parent (window); 3381 make_dummy_parent (window);
3329 new = o->parent; 3382 new = o->parent;
3349 p->parent = o->parent; 3402 p->parent = o->parent;
3350 p->buffer = Qt; 3403 p->buffer = Qt;
3351 p->window_end_valid = Qnil; 3404 p->window_end_valid = Qnil;
3352 bzero (&p->last_cursor, sizeof p->last_cursor); 3405 bzero (&p->last_cursor, sizeof p->last_cursor);
3353 3406
3407 /* Duplicate special geometry settings. */
3408
3409 p->left_margin_cols = o->left_margin_cols;
3410 p->right_margin_cols = o->right_margin_cols;
3411 p->left_fringe_width = o->left_fringe_width;
3412 p->right_fringe_width = o->right_fringe_width;
3413 p->fringes_outside_margins = o->fringes_outside_margins;
3414 p->scroll_bar_width = o->scroll_bar_width;
3415 p->vertical_scroll_bar_type = o->vertical_scroll_bar_type;
3416
3354 /* Apportion the available frame space among the two new windows */ 3417 /* Apportion the available frame space among the two new windows */
3355 3418
3356 if (!NILP (horflag)) 3419 if (!NILP (horflag))
3357 { 3420 {
3358 p->height = o->height; 3421 p->total_lines = o->total_lines;
3359 p->top = o->top; 3422 p->top_line = o->top_line;
3360 XSETFASTINT (p->width, XFASTINT (o->width) - size_int); 3423 XSETFASTINT (p->total_cols, XFASTINT (o->total_cols) - size_int);
3361 XSETFASTINT (o->width, size_int); 3424 XSETFASTINT (o->total_cols, size_int);
3362 XSETFASTINT (p->left, XFASTINT (o->left) + size_int); 3425 XSETFASTINT (p->left_col, XFASTINT (o->left_col) + size_int);
3426 adjust_window_margins (p);
3427 adjust_window_margins (o);
3363 } 3428 }
3364 else 3429 else
3365 { 3430 {
3366 p->left = o->left; 3431 p->left_col = o->left_col;
3367 p->width = o->width; 3432 p->total_cols = o->total_cols;
3368 XSETFASTINT (p->height, XFASTINT (o->height) - size_int); 3433 XSETFASTINT (p->total_lines, XFASTINT (o->total_lines) - size_int);
3369 XSETFASTINT (o->height, size_int); 3434 XSETFASTINT (o->total_lines, size_int);
3370 XSETFASTINT (p->top, XFASTINT (o->top) + size_int); 3435 XSETFASTINT (p->top_line, XFASTINT (o->top_line) + size_int);
3371 } 3436 }
3372 3437
3373 /* Adjust glyph matrices. */ 3438 /* Adjust glyph matrices. */
3374 adjust_glyphs (fo); 3439 adjust_glyphs (fo);
3375 Fset_window_buffer (new, o->buffer); 3440
3441 Fset_window_buffer (new, o->buffer, Qt);
3376 return new; 3442 return new;
3377 } 3443 }
3378 3444
3379 DEFUN ("enlarge-window", Fenlarge_window, Senlarge_window, 1, 3, "p", 3445 DEFUN ("enlarge-window", Fenlarge_window, Senlarge_window, 1, 3, "p",
3380 doc: /* Make current window ARG lines bigger. 3446 doc: /* Make current window ARG lines bigger.
3421 int 3487 int
3422 window_height (window) 3488 window_height (window)
3423 Lisp_Object window; 3489 Lisp_Object window;
3424 { 3490 {
3425 register struct window *p = XWINDOW (window); 3491 register struct window *p = XWINDOW (window);
3426 return XFASTINT (p->height); 3492 return WINDOW_TOTAL_LINES (p);
3427 } 3493 }
3428 3494
3429 int 3495 int
3430 window_width (window) 3496 window_width (window)
3431 Lisp_Object window; 3497 Lisp_Object window;
3432 { 3498 {
3433 register struct window *p = XWINDOW (window); 3499 register struct window *p = XWINDOW (window);
3434 return XFASTINT (p->width); 3500 return WINDOW_TOTAL_COLS (p);
3435 } 3501 }
3436 3502
3437 3503
3438 #define CURBEG(w) \ 3504 #define CURBEG(w) \
3439 *(widthflag ? &(XWINDOW (w)->left) : &(XWINDOW (w)->top)) 3505 *(widthflag ? &(XWINDOW (w)->left_col) : &(XWINDOW (w)->top_line))
3440 3506
3441 #define CURSIZE(w) \ 3507 #define CURSIZE(w) \
3442 *(widthflag ? &(XWINDOW (w)->width) : &(XWINDOW (w)->height)) 3508 *(widthflag ? &(XWINDOW (w)->total_cols) : &(XWINDOW (w)->total_lines))
3443 3509
3444 3510
3445 /* Enlarge WINDOW by DELTA. WIDTHFLAG non-zero means 3511 /* Enlarge WINDOW by DELTA. WIDTHFLAG non-zero means
3446 increase its width. Siblings of the selected window are resized to 3512 increase its width. Siblings of the selected window are resized to
3447 fulfill the size request. If they become too small in the process, 3513 fulfill the size request. If they become too small in the process,
3768 XSETFASTINT (w->last_modified, 0); 3834 XSETFASTINT (w->last_modified, 0);
3769 XSETFASTINT (w->last_overlay_modified, 0); 3835 XSETFASTINT (w->last_overlay_modified, 0);
3770 windows_or_buffers_changed++; 3836 windows_or_buffers_changed++;
3771 FRAME_WINDOW_SIZES_CHANGED (XFRAME (WINDOW_FRAME (w))) = 1; 3837 FRAME_WINDOW_SIZES_CHANGED (XFRAME (WINDOW_FRAME (w))) = 1;
3772 3838
3773 old_height = XFASTINT (w->height); 3839 old_height = XFASTINT (w->total_lines);
3774 XSETFASTINT (w->height, height); 3840 XSETFASTINT (w->total_lines, height);
3775 3841
3776 if (!NILP (w->hchild)) 3842 if (!NILP (w->hchild))
3777 { 3843 {
3778 for (child = w->hchild; !NILP (child); child = c->next) 3844 for (child = w->hchild; !NILP (child); child = c->next)
3779 { 3845 {
3780 c = XWINDOW (child); 3846 c = XWINDOW (child);
3781 c->top = w->top; 3847 c->top_line = w->top_line;
3782 shrink_window_lowest_first (c, height); 3848 shrink_window_lowest_first (c, height);
3783 } 3849 }
3784 } 3850 }
3785 else if (!NILP (w->vchild)) 3851 else if (!NILP (w->vchild))
3786 { 3852 {
3800 for (child = last_child; delta && !NILP (child); child = c->prev) 3866 for (child = last_child; delta && !NILP (child); child = c->prev)
3801 { 3867 {
3802 int this_one; 3868 int this_one;
3803 3869
3804 c = XWINDOW (child); 3870 c = XWINDOW (child);
3805 this_one = XFASTINT (c->height) - MIN_SAFE_WINDOW_HEIGHT; 3871 this_one = XFASTINT (c->total_lines) - MIN_SAFE_WINDOW_HEIGHT;
3806 3872
3807 if (this_one > delta) 3873 if (this_one > delta)
3808 this_one = delta; 3874 this_one = delta;
3809 3875
3810 shrink_window_lowest_first (c, XFASTINT (c->height) - this_one); 3876 shrink_window_lowest_first (c, XFASTINT (c->total_lines) - this_one);
3811 delta -= this_one; 3877 delta -= this_one;
3812 } 3878 }
3813 3879
3814 /* Compute new positions. */ 3880 /* Compute new positions. */
3815 last_top = XINT (w->top); 3881 last_top = XINT (w->top_line);
3816 for (child = w->vchild; !NILP (child); child = c->next) 3882 for (child = w->vchild; !NILP (child); child = c->next)
3817 { 3883 {
3818 c = XWINDOW (child); 3884 c = XWINDOW (child);
3819 c->top = make_number (last_top); 3885 c->top_line = make_number (last_top);
3820 shrink_window_lowest_first (c, XFASTINT (c->height)); 3886 shrink_window_lowest_first (c, XFASTINT (c->total_lines));
3821 last_top += XFASTINT (c->height); 3887 last_top += XFASTINT (c->total_lines);
3822 } 3888 }
3823 } 3889 }
3824 } 3890 }
3825 3891
3826 3892
3827 /* Save, restore, or check positions and sizes in the window tree 3893 /* Save, restore, or check positions and sizes in the window tree
3828 rooted at W. ACTION says what to do. 3894 rooted at W. ACTION says what to do.
3829 3895
3830 If ACTION is CHECK_ORIG_SIZES, check if orig_top and orig_height 3896 If ACTION is CHECK_ORIG_SIZES, check if orig_top_line and
3831 members are valid for all windows in the window tree. Value is 3897 orig_total_lines members are valid for all windows in the window
3832 non-zero if they are valid. 3898 tree. Value is non-zero if they are valid.
3833 3899
3834 If ACTION is SAVE_ORIG_SIZES, save members top and height in 3900 If ACTION is SAVE_ORIG_SIZES, save members top and height in
3835 orig_top and orig_height for all windows in the tree. 3901 orig_top_line and orig_total_lines for all windows in the tree.
3836 3902
3837 If ACTION is RESTORE_ORIG_SIZES, restore top and height from 3903 If ACTION is RESTORE_ORIG_SIZES, restore top and height from values
3838 values stored in orig_top and orig_height for all windows. */ 3904 stored in orig_top_line and orig_total_lines for all windows. */
3839 3905
3840 static int 3906 static int
3841 save_restore_orig_size (w, action) 3907 save_restore_orig_size (w, action)
3842 struct window *w; 3908 struct window *w;
3843 enum save_restore_action action; 3909 enum save_restore_action action;
3858 } 3924 }
3859 3925
3860 switch (action) 3926 switch (action)
3861 { 3927 {
3862 case CHECK_ORIG_SIZES: 3928 case CHECK_ORIG_SIZES:
3863 if (!INTEGERP (w->orig_top) || !INTEGERP (w->orig_height)) 3929 if (!INTEGERP (w->orig_top_line) || !INTEGERP (w->orig_total_lines))
3864 return 0; 3930 return 0;
3865 break; 3931 break;
3866 3932
3867 case SAVE_ORIG_SIZES: 3933 case SAVE_ORIG_SIZES:
3868 w->orig_top = w->top; 3934 w->orig_top_line = w->top_line;
3869 w->orig_height = w->height; 3935 w->orig_total_lines = w->total_lines;
3870 XSETFASTINT (w->last_modified, 0); 3936 XSETFASTINT (w->last_modified, 0);
3871 XSETFASTINT (w->last_overlay_modified, 0); 3937 XSETFASTINT (w->last_overlay_modified, 0);
3872 break; 3938 break;
3873 3939
3874 case RESTORE_ORIG_SIZES: 3940 case RESTORE_ORIG_SIZES:
3875 xassert (INTEGERP (w->orig_top) && INTEGERP (w->orig_height)); 3941 xassert (INTEGERP (w->orig_top_line) && INTEGERP (w->orig_total_lines));
3876 w->top = w->orig_top; 3942 w->top_line = w->orig_top_line;
3877 w->height = w->orig_height; 3943 w->total_lines = w->orig_total_lines;
3878 w->orig_height = w->orig_top = Qnil; 3944 w->orig_total_lines = w->orig_top_line = Qnil;
3879 XSETFASTINT (w->last_modified, 0); 3945 XSETFASTINT (w->last_modified, 0);
3880 XSETFASTINT (w->last_overlay_modified, 0); 3946 XSETFASTINT (w->last_overlay_modified, 0);
3881 break; 3947 break;
3882 3948
3883 default: 3949 default:
3913 other windows. */ 3979 other windows. */
3914 root = XWINDOW (FRAME_ROOT_WINDOW (f)); 3980 root = XWINDOW (FRAME_ROOT_WINDOW (f));
3915 if (delta) 3981 if (delta)
3916 { 3982 {
3917 int min_height = window_min_size (root, 0, 0, 0); 3983 int min_height = window_min_size (root, 0, 0, 0);
3918 if (XFASTINT (root->height) - delta < min_height) 3984 if (XFASTINT (root->total_lines) - delta < min_height)
3919 /* Note that the root window may already be smaller than 3985 /* Note that the root window may already be smaller than
3920 min_height. */ 3986 min_height. */
3921 delta = max (0, XFASTINT (root->height) - min_height); 3987 delta = max (0, XFASTINT (root->total_lines) - min_height);
3922 } 3988 }
3923 3989
3924 if (delta) 3990 if (delta)
3925 { 3991 {
3926 /* Save original window sizes and positions, if not already done. */ 3992 /* Save original window sizes and positions, if not already done. */
3927 if (!save_restore_orig_size (root, CHECK_ORIG_SIZES)) 3993 if (!save_restore_orig_size (root, CHECK_ORIG_SIZES))
3928 save_restore_orig_size (root, SAVE_ORIG_SIZES); 3994 save_restore_orig_size (root, SAVE_ORIG_SIZES);
3929 3995
3930 /* Shrink other windows. */ 3996 /* Shrink other windows. */
3931 shrink_window_lowest_first (root, XFASTINT (root->height) - delta); 3997 shrink_window_lowest_first (root, XFASTINT (root->total_lines) - delta);
3932 3998
3933 /* Grow the mini-window. */ 3999 /* Grow the mini-window. */
3934 w->top = make_number (XFASTINT (root->top) + XFASTINT (root->height)); 4000 w->top_line = make_number (XFASTINT (root->top_line) + XFASTINT (root->total_lines));
3935 w->height = make_number (XFASTINT (w->height) + delta); 4001 w->total_lines = make_number (XFASTINT (w->total_lines) + delta);
3936 XSETFASTINT (w->last_modified, 0); 4002 XSETFASTINT (w->last_modified, 0);
3937 XSETFASTINT (w->last_overlay_modified, 0); 4003 XSETFASTINT (w->last_overlay_modified, 0);
3938 4004
3939 adjust_glyphs (f); 4005 adjust_glyphs (f);
3940 } 4006 }
3958 save_restore_orig_size (root, RESTORE_ORIG_SIZES); 4024 save_restore_orig_size (root, RESTORE_ORIG_SIZES);
3959 adjust_glyphs (f); 4025 adjust_glyphs (f);
3960 FRAME_WINDOW_SIZES_CHANGED (f) = 1; 4026 FRAME_WINDOW_SIZES_CHANGED (f) = 1;
3961 windows_or_buffers_changed = 1; 4027 windows_or_buffers_changed = 1;
3962 } 4028 }
3963 else if (XFASTINT (w->height) > 1) 4029 else if (XFASTINT (w->total_lines) > 1)
3964 { 4030 {
3965 /* Distribute the additional lines of the mini-window 4031 /* Distribute the additional lines of the mini-window
3966 among the other windows. */ 4032 among the other windows. */
3967 Lisp_Object window; 4033 Lisp_Object window;
3968 XSETWINDOW (window, w); 4034 XSETWINDOW (window, w);
3969 enlarge_window (window, 1 - XFASTINT (w->height), 0, 0); 4035 enlarge_window (window, 1 - XFASTINT (w->total_lines), 0, 0);
3970 } 4036 }
3971 } 4037 }
3972 4038
3973 4039
3974 4040
3999 4065
4000 int 4066 int
4001 window_internal_height (w) 4067 window_internal_height (w)
4002 struct window *w; 4068 struct window *w;
4003 { 4069 {
4004 int ht = XFASTINT (w->height); 4070 int ht = XFASTINT (w->total_lines);
4005 4071
4006 if (!MINI_WINDOW_P (w)) 4072 if (!MINI_WINDOW_P (w))
4007 { 4073 {
4008 if (!NILP (w->parent) 4074 if (!NILP (w->parent)
4009 || !NILP (w->vchild) 4075 || !NILP (w->vchild)
4024 /* Return the number of columns in W. 4090 /* Return the number of columns in W.
4025 Don't count columns occupied by scroll bars or the vertical bar 4091 Don't count columns occupied by scroll bars or the vertical bar
4026 separating W from the sibling to its right. */ 4092 separating W from the sibling to its right. */
4027 4093
4028 int 4094 int
4029 window_internal_width (w) 4095 window_box_text_cols (w)
4030 struct window *w; 4096 struct window *w;
4031 { 4097 {
4032 struct frame *f = XFRAME (WINDOW_FRAME (w)); 4098 struct frame *f = XFRAME (WINDOW_FRAME (w));
4033 int width = XINT (w->width); 4099 int width = XINT (w->total_cols);
4034 4100
4035 if (FRAME_HAS_VERTICAL_SCROLL_BARS (f)) 4101 if (WINDOW_HAS_VERTICAL_SCROLL_BAR (w))
4036 /* Scroll bars occupy a few columns. */ 4102 /* Scroll bars occupy a few columns. */
4037 width -= FRAME_SCROLL_BAR_COLS (f); 4103 width -= WINDOW_CONFIG_SCROLL_BAR_COLS (w);
4038 else if (!WINDOW_RIGHTMOST_P (w) && !WINDOW_FULL_WIDTH_P (w)) 4104 else if (!FRAME_WINDOW_P (f)
4105 && !WINDOW_RIGHTMOST_P (w) && !WINDOW_FULL_WIDTH_P (w))
4039 /* The column of `|' characters separating side-by-side windows 4106 /* The column of `|' characters separating side-by-side windows
4040 occupies one column only. */ 4107 occupies one column only. */
4041 width -= 1; 4108 width -= 1;
4042 4109
4043 /* On window-systems, areas to the left and right of the window
4044 are used as fringes. */
4045 if (FRAME_WINDOW_P (f)) 4110 if (FRAME_WINDOW_P (f))
4046 width -= FRAME_FRINGE_COLS (f); 4111 /* On window-systems, fringes and display margins cannot be
4112 used for normal text. */
4113 width -= (WINDOW_FRINGE_COLS (w)
4114 + WINDOW_LEFT_MARGIN_COLS (w)
4115 + WINDOW_RIGHT_MARGIN_COLS (w));
4047 4116
4048 return width; 4117 return width;
4049 } 4118 }
4050 4119
4051 4120
4146 backward. The result is the new window start. */ 4215 backward. The result is the new window start. */
4147 start_display (&it, w, start); 4216 start_display (&it, w, start);
4148 if (whole) 4217 if (whole)
4149 { 4218 {
4150 int screen_full = (window_box_height (w) 4219 int screen_full = (window_box_height (w)
4151 - next_screen_context_lines * CANON_Y_UNIT (it.f)); 4220 - next_screen_context_lines * FRAME_LINE_HEIGHT (it.f));
4152 int dy = n * screen_full; 4221 int dy = n * screen_full;
4153 4222
4154 /* Note that move_it_vertically always moves the iterator to the 4223 /* Note that move_it_vertically always moves the iterator to the
4155 start of a line. So, if the last line doesn't have a newline, 4224 start of a line. So, if the last line doesn't have a newline,
4156 we would end up at the start of the line ending at ZV. */ 4225 we would end up at the start of the line ending at ZV. */
4243 } 4312 }
4244 else 4313 else
4245 { 4314 {
4246 /* Move PT out of scroll margins. */ 4315 /* Move PT out of scroll margins. */
4247 this_scroll_margin = max (0, scroll_margin); 4316 this_scroll_margin = max (0, scroll_margin);
4248 this_scroll_margin = min (this_scroll_margin, XFASTINT (w->height) / 4); 4317 this_scroll_margin = min (this_scroll_margin, XFASTINT (w->total_lines) / 4);
4249 this_scroll_margin *= CANON_Y_UNIT (it.f); 4318 this_scroll_margin *= FRAME_LINE_HEIGHT (it.f);
4250 4319
4251 if (n > 0) 4320 if (n > 0)
4252 { 4321 {
4253 /* We moved the window start towards ZV, so PT may be now 4322 /* We moved the window start towards ZV, so PT may be now
4254 in the scroll margin at the top. */ 4323 in the scroll margin at the top. */
4321 4390
4322 startpos = marker_position (w->start); 4391 startpos = marker_position (w->start);
4323 4392
4324 posit = *compute_motion (startpos, 0, 0, 0, 4393 posit = *compute_motion (startpos, 0, 0, 0,
4325 PT, ht, 0, 4394 PT, ht, 0,
4326 window_internal_width (w), XINT (w->hscroll), 4395 window_box_text_cols (w), XINT (w->hscroll),
4327 0, w); 4396 0, w);
4328 original_vpos = posit.vpos; 4397 original_vpos = posit.vpos;
4329 4398
4330 XSETFASTINT (tem, PT); 4399 XSETFASTINT (tem, PT);
4331 tem = Fpos_visible_in_window_p (tem, window, Qnil); 4400 tem = Fpos_visible_in_window_p (tem, window, Qnil);
4358 4427
4359 /* Don't use a scroll margin that is negative or too large. */ 4428 /* Don't use a scroll margin that is negative or too large. */
4360 if (this_scroll_margin < 0) 4429 if (this_scroll_margin < 0)
4361 this_scroll_margin = 0; 4430 this_scroll_margin = 0;
4362 4431
4363 if (XINT (w->height) < 4 * scroll_margin) 4432 if (XINT (w->total_lines) < 4 * scroll_margin)
4364 this_scroll_margin = XINT (w->height) / 4; 4433 this_scroll_margin = XINT (w->total_lines) / 4;
4365 4434
4366 set_marker_restricted_both (w->start, w->buffer, pos, pos_byte); 4435 set_marker_restricted_both (w->start, w->buffer, pos, pos_byte);
4367 w->start_at_line_beg = bolp; 4436 w->start_at_line_beg = bolp;
4368 w->update_mode_line = Qt; 4437 w->update_mode_line = Qt;
4369 XSETFASTINT (w->last_modified, 0); 4438 XSETFASTINT (w->last_modified, 0);
4609 Lisp_Object result; 4678 Lisp_Object result;
4610 int hscroll; 4679 int hscroll;
4611 struct window *w = XWINDOW (selected_window); 4680 struct window *w = XWINDOW (selected_window);
4612 4681
4613 if (NILP (arg)) 4682 if (NILP (arg))
4614 XSETFASTINT (arg, window_internal_width (w) - 2); 4683 XSETFASTINT (arg, window_box_text_cols (w) - 2);
4615 else 4684 else
4616 arg = Fprefix_numeric_value (arg); 4685 arg = Fprefix_numeric_value (arg);
4617 4686
4618 hscroll = XINT (w->hscroll) + XINT (arg); 4687 hscroll = XINT (w->hscroll) + XINT (arg);
4619 result = Fset_window_hscroll (selected_window, make_number (hscroll)); 4688 result = Fset_window_hscroll (selected_window, make_number (hscroll));
4639 Lisp_Object result; 4708 Lisp_Object result;
4640 int hscroll; 4709 int hscroll;
4641 struct window *w = XWINDOW (selected_window); 4710 struct window *w = XWINDOW (selected_window);
4642 4711
4643 if (NILP (arg)) 4712 if (NILP (arg))
4644 XSETFASTINT (arg, window_internal_width (w) - 2); 4713 XSETFASTINT (arg, window_box_text_cols (w) - 2);
4645 else 4714 else
4646 arg = Fprefix_numeric_value (arg); 4715 arg = Fprefix_numeric_value (arg);
4647 4716
4648 hscroll = XINT (w->hscroll) - XINT (arg); 4717 hscroll = XINT (w->hscroll) - XINT (arg);
4649 result = Fset_window_hscroll (selected_window, make_number (hscroll)); 4718 result = Fset_window_hscroll (selected_window, make_number (hscroll));
4713 height++; 4782 height++;
4714 4783
4715 /* Add in empty lines at the bottom of the window. */ 4784 /* Add in empty lines at the bottom of the window. */
4716 if (bottom_y < height) 4785 if (bottom_y < height)
4717 { 4786 {
4718 int uy = CANON_Y_UNIT (it.f); 4787 int uy = FRAME_LINE_HEIGHT (it.f);
4719 it.vpos += (height - bottom_y + uy - 1) / uy; 4788 it.vpos += (height - bottom_y + uy - 1) / uy;
4720 } 4789 }
4721 4790
4722 if (old_buffer) 4791 if (old_buffer)
4723 set_buffer_internal (old_buffer); 4792 set_buffer_internal (old_buffer);
4805 y1 = line_bottom_y (&it); 4874 y1 = line_bottom_y (&it);
4806 4875
4807 /* If we can't move down NLINES lines because we hit 4876 /* If we can't move down NLINES lines because we hit
4808 the end of the buffer, count in some empty lines. */ 4877 the end of the buffer, count in some empty lines. */
4809 if (it.vpos < nlines) 4878 if (it.vpos < nlines)
4810 y1 += (nlines - it.vpos) * CANON_Y_UNIT (it.f); 4879 y1 += (nlines - it.vpos) * FRAME_LINE_HEIGHT (it.f);
4811 4880
4812 h = window_box_height (w) - (y1 - y0); 4881 h = window_box_height (w) - (y1 - y0);
4813 4882
4814 start_display (&it, w, pt); 4883 start_display (&it, w, pt);
4815 move_it_vertically (&it, - h); 4884 move_it_vertically (&it, - h);
4863 (window) 4932 (window)
4864 Lisp_Object window; 4933 Lisp_Object window;
4865 { 4934 {
4866 struct window *w = decode_window (window); 4935 struct window *w = decode_window (window);
4867 int pixel_height = window_box_height (w); 4936 int pixel_height = window_box_height (w);
4868 int line_height = pixel_height / CANON_Y_UNIT (XFRAME (w->frame)); 4937 int line_height = pixel_height / FRAME_LINE_HEIGHT (XFRAME (w->frame));
4869 return make_number (line_height); 4938 return make_number (line_height);
4870 } 4939 }
4871 4940
4872 4941
4873 4942
4922 4991
4923 struct save_window_data 4992 struct save_window_data
4924 { 4993 {
4925 EMACS_INT size_from_Lisp_Vector_struct; 4994 EMACS_INT size_from_Lisp_Vector_struct;
4926 struct Lisp_Vector *next_from_Lisp_Vector_struct; 4995 struct Lisp_Vector *next_from_Lisp_Vector_struct;
4927 Lisp_Object frame_width, frame_height, frame_menu_bar_lines; 4996 Lisp_Object frame_cols, frame_lines, frame_menu_bar_lines;
4928 Lisp_Object frame_tool_bar_lines; 4997 Lisp_Object frame_tool_bar_lines;
4929 Lisp_Object selected_frame; 4998 Lisp_Object selected_frame;
4930 Lisp_Object current_window; 4999 Lisp_Object current_window;
4931 Lisp_Object current_buffer; 5000 Lisp_Object current_buffer;
4932 Lisp_Object minibuf_scroll_window; 5001 Lisp_Object minibuf_scroll_window;
4948 EMACS_INT size_from_Lisp_Vector_struct; 5017 EMACS_INT size_from_Lisp_Vector_struct;
4949 struct Lisp_Vector *next_from_Lisp_Vector_struct; 5018 struct Lisp_Vector *next_from_Lisp_Vector_struct;
4950 5019
4951 Lisp_Object window; 5020 Lisp_Object window;
4952 Lisp_Object buffer, start, pointm, mark; 5021 Lisp_Object buffer, start, pointm, mark;
4953 Lisp_Object left, top, width, height, hscroll, min_hscroll; 5022 Lisp_Object left_col, top_line, total_cols, total_lines;
5023 Lisp_Object hscroll, min_hscroll;
4954 Lisp_Object parent, prev; 5024 Lisp_Object parent, prev;
4955 Lisp_Object start_at_line_beg; 5025 Lisp_Object start_at_line_beg;
4956 Lisp_Object display_table; 5026 Lisp_Object display_table;
4957 Lisp_Object orig_top, orig_height; 5027 Lisp_Object orig_top_line, orig_total_lines;
5028 Lisp_Object left_margin_cols, right_margin_cols;
5029 Lisp_Object left_fringe_width, right_fringe_width, fringes_outside_margins;
5030 Lisp_Object scroll_bar_width, vertical_scroll_bar_type;
4958 }; 5031 };
4959 5032
4960 #define SAVED_WINDOW_VECTOR_SIZE 17 /* Arg to Fmake_vector */ 5033 #define SAVED_WINDOW_VECTOR_SIZE 24 /* Arg to Fmake_vector */
4961 5034
4962 #define SAVED_WINDOW_N(swv,n) \ 5035 #define SAVED_WINDOW_N(swv,n) \
4963 ((struct saved_window *) (XVECTOR ((swv)->contents[(n)]))) 5036 ((struct saved_window *) (XVECTOR ((swv)->contents[(n)])))
4964 5037
4965 DEFUN ("window-configuration-p", Fwindow_configuration_p, Swindow_configuration_p, 1, 1, 0, 5038 DEFUN ("window-configuration-p", Fwindow_configuration_p, Swindow_configuration_p, 1, 1, 0,
5039 5112
5040 /* If the frame has been resized since this window configuration was 5113 /* If the frame has been resized since this window configuration was
5041 made, we change the frame to the size specified in the 5114 made, we change the frame to the size specified in the
5042 configuration, restore the configuration, and then resize it 5115 configuration, restore the configuration, and then resize it
5043 back. We keep track of the prevailing height in these variables. */ 5116 back. We keep track of the prevailing height in these variables. */
5044 int previous_frame_height = FRAME_HEIGHT (f); 5117 int previous_frame_lines = FRAME_LINES (f);
5045 int previous_frame_width = FRAME_WIDTH (f); 5118 int previous_frame_cols = FRAME_COLS (f);
5046 int previous_frame_menu_bar_lines = FRAME_MENU_BAR_LINES (f); 5119 int previous_frame_menu_bar_lines = FRAME_MENU_BAR_LINES (f);
5047 int previous_frame_tool_bar_lines = FRAME_TOOL_BAR_LINES (f); 5120 int previous_frame_tool_bar_lines = FRAME_TOOL_BAR_LINES (f);
5048 5121
5049 /* The mouse highlighting code could get screwed up 5122 /* The mouse highlighting code could get screwed up
5050 if it runs during this. */ 5123 if it runs during this. */
5051 BLOCK_INPUT; 5124 BLOCK_INPUT;
5052 5125
5053 if (XFASTINT (data->frame_height) != previous_frame_height 5126 if (XFASTINT (data->frame_lines) != previous_frame_lines
5054 || XFASTINT (data->frame_width) != previous_frame_width) 5127 || XFASTINT (data->frame_cols) != previous_frame_cols)
5055 change_frame_size (f, XFASTINT (data->frame_height), 5128 change_frame_size (f, XFASTINT (data->frame_lines),
5056 XFASTINT (data->frame_width), 0, 0, 0); 5129 XFASTINT (data->frame_cols), 0, 0, 0);
5057 #if defined (HAVE_WINDOW_SYSTEM) || defined (MSDOS) 5130 #if defined (HAVE_WINDOW_SYSTEM) || defined (MSDOS)
5058 if (XFASTINT (data->frame_menu_bar_lines) 5131 if (XFASTINT (data->frame_menu_bar_lines)
5059 != previous_frame_menu_bar_lines) 5132 != previous_frame_menu_bar_lines)
5060 x_set_menu_bar_lines (f, data->frame_menu_bar_lines, make_number (0)); 5133 x_set_menu_bar_lines (f, data->frame_menu_bar_lines, make_number (0));
5061 #ifdef HAVE_WINDOW_SYSTEM 5134 #ifdef HAVE_WINDOW_SYSTEM
5126 else 5199 else
5127 { 5200 {
5128 w->prev = Qnil; 5201 w->prev = Qnil;
5129 if (!NILP (w->parent)) 5202 if (!NILP (w->parent))
5130 { 5203 {
5131 if (EQ (p->width, XWINDOW (w->parent)->width)) 5204 if (EQ (p->total_cols, XWINDOW (w->parent)->total_cols))
5132 { 5205 {
5133 XWINDOW (w->parent)->vchild = p->window; 5206 XWINDOW (w->parent)->vchild = p->window;
5134 XWINDOW (w->parent)->hchild = Qnil; 5207 XWINDOW (w->parent)->hchild = Qnil;
5135 } 5208 }
5136 else 5209 else
5141 } 5214 }
5142 } 5215 }
5143 5216
5144 /* If we squirreled away the buffer in the window's height, 5217 /* If we squirreled away the buffer in the window's height,
5145 restore it now. */ 5218 restore it now. */
5146 if (BUFFERP (w->height)) 5219 if (BUFFERP (w->total_lines))
5147 w->buffer = w->height; 5220 w->buffer = w->total_lines;
5148 w->left = p->left; 5221 w->left_col = p->left_col;
5149 w->top = p->top; 5222 w->top_line = p->top_line;
5150 w->width = p->width; 5223 w->total_cols = p->total_cols;
5151 w->height = p->height; 5224 w->total_lines = p->total_lines;
5152 w->hscroll = p->hscroll; 5225 w->hscroll = p->hscroll;
5153 w->min_hscroll = p->min_hscroll; 5226 w->min_hscroll = p->min_hscroll;
5154 w->display_table = p->display_table; 5227 w->display_table = p->display_table;
5155 w->orig_top = p->orig_top; 5228 w->orig_top_line = p->orig_top_line;
5156 w->orig_height = p->orig_height; 5229 w->orig_total_lines = p->orig_total_lines;
5230 w->left_margin_cols = p->left_margin_cols;
5231 w->right_margin_cols = p->right_margin_cols;
5232 w->left_fringe_width = p->left_fringe_width;
5233 w->right_fringe_width = p->right_fringe_width;
5234 w->fringes_outside_margins = p->fringes_outside_margins;
5235 w->scroll_bar_width = p->scroll_bar_width;
5236 w->vertical_scroll_bar_type = p->vertical_scroll_bar_type;
5157 XSETFASTINT (w->last_modified, 0); 5237 XSETFASTINT (w->last_modified, 0);
5158 XSETFASTINT (w->last_overlay_modified, 0); 5238 XSETFASTINT (w->last_overlay_modified, 0);
5159 5239
5160 /* Reinstall the saved buffer and pointers into it. */ 5240 /* Reinstall the saved buffer and pointers into it. */
5161 if (NILP (p->buffer)) 5241 if (NILP (p->buffer))
5233 do_switch_frame (WINDOW_FRAME (XWINDOW (data->root_window)), 5313 do_switch_frame (WINDOW_FRAME (XWINDOW (data->root_window)),
5234 0, 0); 5314 0, 0);
5235 #endif 5315 #endif
5236 5316
5237 /* Set the screen height to the value it had before this function. */ 5317 /* Set the screen height to the value it had before this function. */
5238 if (previous_frame_height != FRAME_HEIGHT (f) 5318 if (previous_frame_lines != FRAME_LINES (f)
5239 || previous_frame_width != FRAME_WIDTH (f)) 5319 || previous_frame_cols != FRAME_COLS (f))
5240 change_frame_size (f, previous_frame_height, previous_frame_width, 5320 change_frame_size (f, previous_frame_lines, previous_frame_cols,
5241 0, 0, 0); 5321 0, 0, 0);
5242 #if defined (HAVE_WINDOW_SYSTEM) || defined (MSDOS) 5322 #if defined (HAVE_WINDOW_SYSTEM) || defined (MSDOS)
5243 if (previous_frame_menu_bar_lines != FRAME_MENU_BAR_LINES (f)) 5323 if (previous_frame_menu_bar_lines != FRAME_MENU_BAR_LINES (f))
5244 x_set_menu_bar_lines (f, make_number (previous_frame_menu_bar_lines), 5324 x_set_menu_bar_lines (f, make_number (previous_frame_menu_bar_lines),
5245 make_number (0)); 5325 make_number (0));
5306 if (!NILP (w->vchild)) 5386 if (!NILP (w->vchild))
5307 delete_all_subwindows (XWINDOW (w->vchild)); 5387 delete_all_subwindows (XWINDOW (w->vchild));
5308 if (!NILP (w->hchild)) 5388 if (!NILP (w->hchild))
5309 delete_all_subwindows (XWINDOW (w->hchild)); 5389 delete_all_subwindows (XWINDOW (w->hchild));
5310 5390
5311 w->height = w->buffer; /* See Fset_window_configuration for excuse. */ 5391 w->total_lines = w->buffer; /* See Fset_window_configuration for excuse. */
5312 5392
5313 if (!NILP (w->buffer)) 5393 if (!NILP (w->buffer))
5314 unshow_buffer (w); 5394 unshow_buffer (w);
5315 5395
5316 /* We set all three of these fields to nil, to make sure that we can 5396 /* We set all three of these fields to nil, to make sure that we can
5404 w = XWINDOW (window); 5484 w = XWINDOW (window);
5405 5485
5406 XSETFASTINT (w->temslot, i++); 5486 XSETFASTINT (w->temslot, i++);
5407 p->window = window; 5487 p->window = window;
5408 p->buffer = w->buffer; 5488 p->buffer = w->buffer;
5409 p->left = w->left; 5489 p->left_col = w->left_col;
5410 p->top = w->top; 5490 p->top_line = w->top_line;
5411 p->width = w->width; 5491 p->total_cols = w->total_cols;
5412 p->height = w->height; 5492 p->total_lines = w->total_lines;
5413 p->hscroll = w->hscroll; 5493 p->hscroll = w->hscroll;
5414 p->min_hscroll = w->min_hscroll; 5494 p->min_hscroll = w->min_hscroll;
5415 p->display_table = w->display_table; 5495 p->display_table = w->display_table;
5416 p->orig_top = w->orig_top; 5496 p->orig_top_line = w->orig_top_line;
5417 p->orig_height = w->orig_height; 5497 p->orig_total_lines = w->orig_total_lines;
5498 p->left_margin_cols = w->left_margin_cols;
5499 p->right_margin_cols = w->right_margin_cols;
5500 p->left_fringe_width = w->left_fringe_width;
5501 p->right_fringe_width = w->right_fringe_width;
5502 p->fringes_outside_margins = w->fringes_outside_margins;
5503 p->scroll_bar_width = w->scroll_bar_width;
5504 p->vertical_scroll_bar_type = w->vertical_scroll_bar_type;
5418 if (!NILP (w->buffer)) 5505 if (!NILP (w->buffer))
5419 { 5506 {
5420 /* Save w's value of point in the window configuration. 5507 /* Save w's value of point in the window configuration.
5421 If w is the selected window, then get the value of point 5508 If w is the selected window, then get the value of point
5422 from the buffer; pointm is garbage in the selected window. */ 5509 from the buffer; pointm is garbage in the selected window. */
5490 5577
5491 n_windows = count_windows (XWINDOW (FRAME_ROOT_WINDOW (f))); 5578 n_windows = count_windows (XWINDOW (FRAME_ROOT_WINDOW (f)));
5492 vec = allocate_other_vector (VECSIZE (struct save_window_data)); 5579 vec = allocate_other_vector (VECSIZE (struct save_window_data));
5493 data = (struct save_window_data *)vec; 5580 data = (struct save_window_data *)vec;
5494 5581
5495 XSETFASTINT (data->frame_width, FRAME_WIDTH (f)); 5582 XSETFASTINT (data->frame_cols, FRAME_COLS (f));
5496 XSETFASTINT (data->frame_height, FRAME_HEIGHT (f)); 5583 XSETFASTINT (data->frame_lines, FRAME_LINES (f));
5497 XSETFASTINT (data->frame_menu_bar_lines, FRAME_MENU_BAR_LINES (f)); 5584 XSETFASTINT (data->frame_menu_bar_lines, FRAME_MENU_BAR_LINES (f));
5498 XSETFASTINT (data->frame_tool_bar_lines, FRAME_TOOL_BAR_LINES (f)); 5585 XSETFASTINT (data->frame_tool_bar_lines, FRAME_TOOL_BAR_LINES (f));
5499 data->selected_frame = selected_frame; 5586 data->selected_frame = selected_frame;
5500 data->current_window = FRAME_SELECTED_WINDOW (f); 5587 data->current_window = FRAME_SELECTED_WINDOW (f);
5501 XSETBUFFER (data->current_buffer, current_buffer); 5588 XSETBUFFER (data->current_buffer, current_buffer);
5552 (window, left, right) 5639 (window, left, right)
5553 Lisp_Object window, left, right; 5640 Lisp_Object window, left, right;
5554 { 5641 {
5555 struct window *w = decode_window (window); 5642 struct window *w = decode_window (window);
5556 5643
5644 /* TODO: It doesn't make sense to use FLOATs here, since
5645 the rest of the code assumes they are integers.
5646 So don't allow floats! ++KFS */
5647
5557 if (!NILP (left)) 5648 if (!NILP (left))
5558 CHECK_NUMBER_OR_FLOAT (left); 5649 CHECK_NUMBER_OR_FLOAT (left);
5559 if (!NILP (right)) 5650 if (!NILP (right))
5560 CHECK_NUMBER_OR_FLOAT (right); 5651 CHECK_NUMBER_OR_FLOAT (right);
5561 5652
5571 || (FLOATP (right) && XFLOAT_DATA (right) <= 0)) 5662 || (FLOATP (right) && XFLOAT_DATA (right) <= 0))
5572 XSETFASTINT (right, 0); 5663 XSETFASTINT (right, 0);
5573 if (INTEGERP (right) && XFASTINT (right) == 0) 5664 if (INTEGERP (right) && XFASTINT (right) == 0)
5574 right = Qnil; 5665 right = Qnil;
5575 5666
5576 w->left_margin_width = left; 5667 if (!EQ (w->left_margin_cols, left)
5577 w->right_margin_width = right; 5668 || !EQ (w->right_margin_cols, right))
5578 5669 {
5579 ++windows_or_buffers_changed; 5670 w->left_margin_cols = left;
5580 adjust_glyphs (XFRAME (WINDOW_FRAME (w))); 5671 w->right_margin_cols = right;
5672
5673 adjust_window_margins (w);
5674
5675 ++windows_or_buffers_changed;
5676 adjust_glyphs (XFRAME (WINDOW_FRAME (w)));
5677 }
5678
5581 return Qnil; 5679 return Qnil;
5582 } 5680 }
5583 5681
5584 5682
5585 DEFUN ("window-margins", Fwindow_margins, Swindow_margins, 5683 DEFUN ("window-margins", Fwindow_margins, Swindow_margins,
5591 as nil. */) 5689 as nil. */)
5592 (window) 5690 (window)
5593 Lisp_Object window; 5691 Lisp_Object window;
5594 { 5692 {
5595 struct window *w = decode_window (window); 5693 struct window *w = decode_window (window);
5596 return Fcons (w->left_margin_width, w->right_margin_width); 5694 return Fcons (w->left_margin_cols, w->right_margin_cols);
5695 }
5696
5697
5698
5699 /***********************************************************************
5700 Fringes
5701 ***********************************************************************/
5702
5703 DEFUN ("set-window-fringes", Fset_window_fringes, Sset_window_fringes,
5704 2, 4, 0,
5705 doc: /* Set width of fringes of window WINDOW.
5706
5707 If window is nil, set fringes of the currently selected window.
5708 Second parameter LEFT-WIDTH specifies the number of pixels to reserve
5709 for the left fringe. Third parameter RIGHT-WIDTH does the same for
5710 the right fringe. Fourth parameter OUTSIDE-MARGINS non-nil specifies
5711 that fringes are drawn outside of the display margins; by default, fringes
5712 are drawn between display marginal areas and the text area.
5713 A nil width parameter means to use the frame's corresponding fringe width. */)
5714 (window, left, right, outside_margins)
5715 Lisp_Object window, left, right, outside_margins;
5716 {
5717 struct window *w = decode_window (window);
5718
5719 if (!NILP (left))
5720 CHECK_NUMBER (left);
5721 if (!NILP (right))
5722 CHECK_NUMBER (right);
5723
5724 if (!EQ (w->left_fringe_width, left)
5725 || !EQ (w->right_fringe_width, right)
5726 || !EQ (w->fringes_outside_margins, outside_margins))
5727 {
5728 w->left_fringe_width = left;
5729 w->right_fringe_width = right;
5730 w->fringes_outside_margins = outside_margins;
5731
5732 adjust_window_margins (w);
5733
5734 clear_glyph_matrix (w->current_matrix);
5735 w->window_end_valid = Qnil;
5736
5737 ++windows_or_buffers_changed;
5738 adjust_glyphs (XFRAME (WINDOW_FRAME (w)));
5739 }
5740
5741 return Qnil;
5742 }
5743
5744
5745 DEFUN ("window-fringes", Fwindow_fringes, Swindow_fringes,
5746 0, 1, 0,
5747 doc: /* Get width of fringes of window WINDOW.
5748 If WINDOW is omitted or nil, use the currently selected window.
5749 Value is a list of the form (LEFT-WIDTH RIGHT-WIDTH OUTSIDE-MARGINS).
5750 If a window specific fringe width is not set, its width will be returned
5751 as nil. */)
5752 (window)
5753 Lisp_Object window;
5754 {
5755 struct window *w = decode_window (window);
5756 return Fcons (make_number (WINDOW_LEFT_FRINGE_WIDTH (w)),
5757 Fcons (make_number (WINDOW_RIGHT_FRINGE_WIDTH (w)),
5758 Fcons ((WINDOW_HAS_FRINGES_OUTSIDE_MARGINS (w) ?
5759 Qt : Qnil), Qnil)));
5760 }
5761
5762
5763
5764 /***********************************************************************
5765 Scroll bars
5766 ***********************************************************************/
5767
5768 DEFUN ("set-window-scroll-bars", Fset_window_scroll_bars, Sset_window_scroll_bars,
5769 2, 4, 0,
5770 doc: /* Set width and type of scroll bars of window WINDOW.
5771 If window is nil, set scroll bars of the currently selected window.
5772 Second parameter WIDTH specifies the pixel width for the scroll bar;
5773 this is automatically adjusted to a multiple of the frame column width.
5774 Third parameter VERTICAL-TYPE specifies the type of the vertical scroll
5775 bar: left, right, or nil.
5776 A width of nil and type of t means to use the frame's corresponding value. */)
5777 (window, width, vertical_type, horisontal_type)
5778 Lisp_Object window, width, vertical_type, horisontal_type;
5779 {
5780 struct window *w = decode_window (window);
5781
5782 if (!NILP (width))
5783 CHECK_NUMBER (width);
5784
5785 if (XINT (width) == 0)
5786 vertical_type = Qnil;
5787
5788 if (!EQ (w->scroll_bar_width, width)
5789 || !EQ (w->vertical_scroll_bar_type, vertical_type))
5790 {
5791 w->scroll_bar_width = width;
5792 w->vertical_scroll_bar_type = vertical_type;
5793
5794 adjust_window_margins (w);
5795
5796 clear_glyph_matrix (w->current_matrix);
5797 w->window_end_valid = Qnil;
5798
5799 ++windows_or_buffers_changed;
5800 adjust_glyphs (XFRAME (WINDOW_FRAME (w)));
5801 }
5802
5803 return Qnil;
5804 }
5805
5806
5807 DEFUN ("window-scroll-bars", Fwindow_scroll_bars, Swindow_scroll_bars,
5808 0, 1, 0,
5809 doc: /* Get width and type of scroll bars of window WINDOW.
5810 If WINDOW is omitted or nil, use the currently selected window.
5811 Value is a list of the form (WIDTH COLS VERTICAL-TYPE HORISONTAL-TYPE). */)
5812 (window)
5813 Lisp_Object window;
5814 {
5815 struct window *w = decode_window (window);
5816 return Fcons (make_number ((WINDOW_CONFIG_SCROLL_BAR_WIDTH (w)
5817 ? WINDOW_CONFIG_SCROLL_BAR_WIDTH (w)
5818 : WINDOW_SCROLL_BAR_AREA_WIDTH (w))),
5819 Fcons (make_number (WINDOW_SCROLL_BAR_COLS (w)),
5820 Fcons (w->vertical_scroll_bar_type,
5821 Fcons (Qnil, Qnil))));
5597 } 5822 }
5598 5823
5599 5824
5600 5825
5601 /*********************************************************************** 5826 /***********************************************************************
5619 CHECK_WINDOW (window); 5844 CHECK_WINDOW (window);
5620 w = XWINDOW (window); 5845 w = XWINDOW (window);
5621 f = XFRAME (w->frame); 5846 f = XFRAME (w->frame);
5622 5847
5623 if (FRAME_WINDOW_P (f)) 5848 if (FRAME_WINDOW_P (f))
5624 result = CANON_Y_FROM_PIXEL_Y (f, -w->vscroll); 5849 result = FRAME_CANON_Y_FROM_PIXEL_Y (f, -w->vscroll);
5625 else 5850 else
5626 result = make_number (0); 5851 result = make_number (0);
5627 return result; 5852 return result;
5628 } 5853 }
5629 5854
5650 5875
5651 if (FRAME_WINDOW_P (f)) 5876 if (FRAME_WINDOW_P (f))
5652 { 5877 {
5653 int old_dy = w->vscroll; 5878 int old_dy = w->vscroll;
5654 5879
5655 w->vscroll = - CANON_Y_UNIT (f) * XFLOATINT (vscroll); 5880 w->vscroll = - FRAME_LINE_HEIGHT (f) * XFLOATINT (vscroll);
5656 w->vscroll = min (w->vscroll, 0); 5881 w->vscroll = min (w->vscroll, 0);
5657 5882
5658 /* Adjust glyph matrix of the frame if the virtual display 5883 /* Adjust glyph matrix of the frame if the virtual display
5659 area becomes larger than before. */ 5884 area becomes larger than before. */
5660 if (w->vscroll < 0 && w->vscroll < old_dy) 5885 if (w->vscroll < 0 && w->vscroll < old_dy)
5769 d1 = (struct save_window_data *) XVECTOR (c1); 5994 d1 = (struct save_window_data *) XVECTOR (c1);
5770 d2 = (struct save_window_data *) XVECTOR (c2); 5995 d2 = (struct save_window_data *) XVECTOR (c2);
5771 sw1 = XVECTOR (d1->saved_windows); 5996 sw1 = XVECTOR (d1->saved_windows);
5772 sw2 = XVECTOR (d2->saved_windows); 5997 sw2 = XVECTOR (d2->saved_windows);
5773 5998
5774 if (! EQ (d1->frame_width, d2->frame_width)) 5999 if (! EQ (d1->frame_cols, d2->frame_cols))
5775 return 0; 6000 return 0;
5776 if (! EQ (d1->frame_height, d2->frame_height)) 6001 if (! EQ (d1->frame_lines, d2->frame_lines))
5777 return 0; 6002 return 0;
5778 if (! EQ (d1->frame_menu_bar_lines, d2->frame_menu_bar_lines)) 6003 if (! EQ (d1->frame_menu_bar_lines, d2->frame_menu_bar_lines))
5779 return 0; 6004 return 0;
5780 if (! EQ (d1->selected_frame, d2->selected_frame)) 6005 if (! EQ (d1->selected_frame, d2->selected_frame))
5781 return 0; 6006 return 0;
5823 return 0; 6048 return 0;
5824 6049
5825 /* Verify that the corresponding windows do match. */ 6050 /* Verify that the corresponding windows do match. */
5826 if (! EQ (p1->buffer, p2->buffer)) 6051 if (! EQ (p1->buffer, p2->buffer))
5827 return 0; 6052 return 0;
5828 if (! EQ (p1->left, p2->left)) 6053 if (! EQ (p1->left_col, p2->left_col))
5829 return 0; 6054 return 0;
5830 if (! EQ (p1->top, p2->top)) 6055 if (! EQ (p1->top_line, p2->top_line))
5831 return 0; 6056 return 0;
5832 if (! EQ (p1->width, p2->width)) 6057 if (! EQ (p1->total_cols, p2->total_cols))
5833 return 0; 6058 return 0;
5834 if (! EQ (p1->height, p2->height)) 6059 if (! EQ (p1->total_lines, p2->total_lines))
5835 return 0; 6060 return 0;
5836 if (! EQ (p1->display_table, p2->display_table)) 6061 if (! EQ (p1->display_table, p2->display_table))
5837 return 0; 6062 return 0;
5838 if (! EQ (p1->parent, p2->parent)) 6063 if (! EQ (p1->parent, p2->parent))
5839 return 0; 6064 return 0;
5852 if (NILP (Fequal (p1->pointm, p2->pointm))) 6077 if (NILP (Fequal (p1->pointm, p2->pointm)))
5853 return 0; 6078 return 0;
5854 if (NILP (Fequal (p1->mark, p2->mark))) 6079 if (NILP (Fequal (p1->mark, p2->mark)))
5855 return 0; 6080 return 0;
5856 } 6081 }
6082 if (! EQ (p1->left_margin_cols, p2->left_margin_cols))
6083 return 0;
6084 if (! EQ (p1->right_margin_cols, p2->right_margin_cols))
6085 return 0;
6086 if (! EQ (p1->left_fringe_width, p2->left_fringe_width))
6087 return 0;
6088 if (! EQ (p1->right_fringe_width, p2->right_fringe_width))
6089 return 0;
6090 if (! EQ (p1->fringes_outside_margins, p2->fringes_outside_margins))
6091 return 0;
6092 if (! EQ (p1->scroll_bar_width, p2->scroll_bar_width))
6093 return 0;
6094 if (! EQ (p1->vertical_scroll_bar_type, p2->vertical_scroll_bar_type))
6095 return 0;
5857 } 6096 }
5858 6097
5859 return 1; 6098 return 1;
5860 } 6099 }
5861 6100
6150 defsubr (&Sset_window_configuration); 6389 defsubr (&Sset_window_configuration);
6151 defsubr (&Scurrent_window_configuration); 6390 defsubr (&Scurrent_window_configuration);
6152 defsubr (&Ssave_window_excursion); 6391 defsubr (&Ssave_window_excursion);
6153 defsubr (&Sset_window_margins); 6392 defsubr (&Sset_window_margins);
6154 defsubr (&Swindow_margins); 6393 defsubr (&Swindow_margins);
6394 defsubr (&Sset_window_fringes);
6395 defsubr (&Swindow_fringes);
6396 defsubr (&Sset_window_scroll_bars);
6397 defsubr (&Swindow_scroll_bars);
6155 defsubr (&Swindow_vscroll); 6398 defsubr (&Swindow_vscroll);
6156 defsubr (&Sset_window_vscroll); 6399 defsubr (&Sset_window_vscroll);
6157 defsubr (&Scompare_window_configurations); 6400 defsubr (&Scompare_window_configurations);
6158 defsubr (&Swindow_list); 6401 defsubr (&Swindow_list);
6159 } 6402 }