comparison src/window.c @ 442:abe6d1db359e r21-2-36

Import from CVS: tag r21-2-36
author cvs
date Mon, 13 Aug 2007 11:35:02 +0200
parents 8de8e3f6228a
children 576fb035e263
comparison
equal deleted inserted replaced
441:72a7cfa4a488 442:abe6d1db359e
80 Lisp_Object Vvertical_divider_shadow_thickness; 80 Lisp_Object Vvertical_divider_shadow_thickness;
81 81
82 /* Divider surface width (not counting 3-d borders) */ 82 /* Divider surface width (not counting 3-d borders) */
83 Lisp_Object Vvertical_divider_line_width; 83 Lisp_Object Vvertical_divider_line_width;
84 84
85 /* Spacing between outer egde of divider border and window edge */ 85 /* Spacing between outer edge of divider border and window edge */
86 Lisp_Object Vvertical_divider_spacing; 86 Lisp_Object Vvertical_divider_spacing;
87 87
88 /* How much to scroll by per-line. */ 88 /* How much to scroll by per-line. */
89 Lisp_Object Vwindow_pixel_scroll_increment; 89 Lisp_Object Vwindow_pixel_scroll_increment;
90 90
279 INIT_DISP_VARIABLE (last_start, Fmake_marker ()); 279 INIT_DISP_VARIABLE (last_start, Fmake_marker ());
280 INIT_DISP_VARIABLE (last_facechange, Qzero); 280 INIT_DISP_VARIABLE (last_facechange, Qzero);
281 p->face_cachels = Dynarr_new (face_cachel); 281 p->face_cachels = Dynarr_new (face_cachel);
282 p->glyph_cachels = Dynarr_new (glyph_cachel); 282 p->glyph_cachels = Dynarr_new (glyph_cachel);
283 p->line_start_cache = Dynarr_new (line_start_cache); 283 p->line_start_cache = Dynarr_new (line_start_cache);
284 p->subwindow_instance_cache = make_lisp_hash_table (10, 284 p->subwindow_instance_cache = make_lisp_hash_table (30,
285 HASH_TABLE_KEY_WEAK, 285 HASH_TABLE_KEY_VALUE_WEAK,
286 HASH_TABLE_EQ); 286 HASH_TABLE_EQ);
287 p->line_cache_last_updated = Qzero; 287 p->line_cache_last_updated = Qzero;
288 INIT_DISP_VARIABLE (last_point_x, 0); 288 INIT_DISP_VARIABLE (last_point_x, 0);
289 INIT_DISP_VARIABLE (last_point_y, 0); 289 INIT_DISP_VARIABLE (last_point_y, 0);
290 INIT_DISP_VARIABLE (window_end_pos, 0); 290 INIT_DISP_VARIABLE (window_end_pos, 0);
291 p->redisplay_end_trigger = Qnil; 291 p->redisplay_end_trigger = Qnil;
292
293 p->gutter_extent_modiff[0] = 0;
294 p->gutter_extent_modiff[1] = 0;
295 p->gutter_extent_modiff[2] = 0;
296 p->gutter_extent_modiff[3] = 0;
292 297
293 #define WINDOW_SLOT(slot, compare) p->slot = Qnil 298 #define WINDOW_SLOT(slot, compare) p->slot = Qnil
294 #include "winslots.h" 299 #include "winslots.h"
295 300
296 p->windows_changed = 1; 301 p->windows_changed = 1;
731 736
732 return 0; 737 return 0;
733 } 738 }
734 739
735 DEFUN ("window-truncated-p", Fwindow_truncated_p, 0, 1, 0, /* 740 DEFUN ("window-truncated-p", Fwindow_truncated_p, 0, 1, 0, /*
736 Returns Non-Nil iff the window is truncated. 741 Returns non-nil if text in the window is truncated.
737 */ 742 */
738 (window)) 743 (window))
739 { 744 {
740 struct window *w = decode_window (window); 745 struct window *w = decode_window (window);
741 746
1008 functions refer to the Y coord for bottom and top gutters and the X 1013 functions refer to the Y coord for bottom and top gutters and the X
1009 coord for left and right gutters. All starting positions are 1014 coord for left and right gutters. All starting positions are
1010 relative to the frame, not the window. 1015 relative to the frame, not the window.
1011 ****************************************************************************/ 1016 ****************************************************************************/
1012 1017
1018 static int
1019 window_top_window_gutter_height (struct window *w)
1020 {
1021 if (!NILP (w->hchild) || !NILP (w->vchild))
1022 return 0;
1023
1024 #ifdef HAVE_SCROLLBARS
1025 if (!NILP (w->scrollbar_on_top_p))
1026 return window_scrollbar_height (w);
1027 else
1028 #endif
1029 return 0;
1030 }
1031
1013 int 1032 int
1014 window_top_gutter_height (struct window *w) 1033 window_top_gutter_height (struct window *w)
1015 { 1034 {
1016 int gutter = WINDOW_REAL_TOP_GUTTER_BOUNDS (w); 1035 return window_top_window_gutter_height (w);
1036 }
1037
1038 static int
1039 window_bottom_window_gutter_height (struct window *w)
1040 {
1041 int gutter;
1017 1042
1018 if (!NILP (w->hchild) || !NILP (w->vchild)) 1043 if (!NILP (w->hchild) || !NILP (w->vchild))
1019 return 0; 1044 return 0;
1020 1045
1021 #ifdef HAVE_SCROLLBARS 1046 gutter = window_modeline_height (w);
1022 if (!NILP (w->scrollbar_on_top_p))
1023 return window_scrollbar_height (w) + gutter;
1024 else
1025 #endif
1026 return gutter;
1027 }
1028
1029 int
1030 window_bottom_gutter_height (struct window *w)
1031 {
1032 int gutter = WINDOW_REAL_BOTTOM_GUTTER_BOUNDS (w);
1033
1034 if (!NILP (w->hchild) || !NILP (w->vchild))
1035 return 0;
1036
1037 gutter += window_modeline_height (w);
1038 1047
1039 #ifdef HAVE_SCROLLBARS 1048 #ifdef HAVE_SCROLLBARS
1040 if (NILP (w->scrollbar_on_top_p)) 1049 if (NILP (w->scrollbar_on_top_p))
1041 return window_scrollbar_height (w) + gutter; 1050 return window_scrollbar_height (w) + gutter;
1042 else 1051 else
1043 #endif 1052 #endif
1044 return gutter; 1053 return gutter;
1045 } 1054 }
1046 1055
1047 int 1056 int
1048 window_left_gutter_width (struct window *w, int modeline) 1057 window_bottom_gutter_height (struct window *w)
1049 { 1058 {
1050 int gutter = WINDOW_REAL_LEFT_GUTTER_BOUNDS (w); 1059 return window_bottom_window_gutter_height (w);
1051 1060 }
1061
1062 static int
1063 window_left_window_gutter_width (struct window *w, int modeline)
1064 {
1052 if (!NILP (w->hchild) || !NILP (w->vchild)) 1065 if (!NILP (w->hchild) || !NILP (w->vchild))
1053 return 0; 1066 return 0;
1054 1067
1055 #ifdef HAVE_SCROLLBARS 1068 #ifdef HAVE_SCROLLBARS
1056 if (!modeline && !NILP (w->scrollbar_on_left_p)) 1069 if (!modeline && !NILP (w->scrollbar_on_left_p))
1057 gutter += window_scrollbar_width (w); 1070 return window_scrollbar_width (w);
1058 #endif 1071 #endif
1059 1072
1060 return gutter; 1073 return 0;
1061 } 1074 }
1062 1075
1063 int 1076 int
1064 window_right_gutter_width (struct window *w, int modeline) 1077 window_left_gutter_width (struct window *w, int modeline)
1065 { 1078 {
1066 int gutter = WINDOW_REAL_RIGHT_GUTTER_BOUNDS (w); 1079 return window_left_window_gutter_width (w, modeline);
1080 }
1081
1082 static int
1083 window_right_window_gutter_width (struct window *w, int modeline)
1084 {
1085 int gutter = 0;
1067 1086
1068 if (!NILP (w->hchild) || !NILP (w->vchild)) 1087 if (!NILP (w->hchild) || !NILP (w->vchild))
1069 return 0; 1088 return 0;
1070 1089
1071 #ifdef HAVE_SCROLLBARS 1090 #ifdef HAVE_SCROLLBARS
1075 1094
1076 if (window_needs_vertical_divider (w)) 1095 if (window_needs_vertical_divider (w))
1077 gutter += window_divider_width (w); 1096 gutter += window_divider_width (w);
1078 1097
1079 return gutter; 1098 return gutter;
1099 }
1100
1101 int
1102 window_right_gutter_width (struct window *w, int modeline)
1103 {
1104 return window_right_window_gutter_width (w, modeline);
1105 }
1106
1107 static int
1108 window_pixel_height (struct window* w)
1109 {
1110 return WINDOW_HEIGHT (w);
1080 } 1111 }
1081 1112
1082 1113
1083 DEFUN ("windowp", Fwindowp, 1, 1, 0, /* 1114 DEFUN ("windowp", Fwindowp, 1, 1, 0, /*
1084 Return t if OBJ is a window. 1115 Return t if OBJ is a window.
1292 default font; therefore, the number of displayed lines will probably 1323 default font; therefore, the number of displayed lines will probably
1293 be different. 1324 be different.
1294 Use `window-height' to get consistent results in geometry calculations. 1325 Use `window-height' to get consistent results in geometry calculations.
1295 Use `window-displayed-height' to get the actual number of lines 1326 Use `window-displayed-height' to get the actual number of lines
1296 currently displayed in a window. 1327 currently displayed in a window.
1328
1329 The names are somewhat confusing; here's a table to help out:
1330
1331 width height
1332 -------------------------------------------------------------------------
1333 w/o gutters
1334 (rows/columns) window-width window-text-area-height
1335 (pixels) window-text-area-pixel-width window-text-area-pixel-height
1336
1337 with gutters
1338 (rows/columns) window-full-width window-height
1339 (pixels) window-pixel-width window-pixel-height
1340
1341 actually displayed
1342 (rows/columns) ---- window-displayed-height
1343 (pixels) ---- window-displayed-text-pixel-height
1297 */ 1344 */
1298 (window)) 1345 (window))
1299 { 1346 {
1300 return make_int (window_char_height (decode_window (window), 1)); 1347 return make_int (window_char_height (decode_window (window), 1));
1301 } 1348 }
1318 Return the height of WINDOW in pixels. Defaults to current window. 1365 Return the height of WINDOW in pixels. Defaults to current window.
1319 This includes the window's modeline and horizontal scrollbar (if any). 1366 This includes the window's modeline and horizontal scrollbar (if any).
1320 */ 1367 */
1321 (window)) 1368 (window))
1322 { 1369 {
1323 return make_int (decode_window (window)->pixel_height); 1370 return make_int (window_pixel_height (decode_window (window)));
1371 }
1372
1373 DEFUN ("window-text-area-height", Fwindow_text_area_height, 0, 1, 0, /*
1374 Return the number of default lines in the text area of WINDOW.
1375 This actually works by dividing the window's text area pixel height (i.e.
1376 excluding the modeline and horizontal scrollbar, if any) by the height of the
1377 default font; therefore, the number of displayed lines will probably
1378 be different.
1379 See also `window-height' and `window-displayed-height'.
1380 */
1381 (window))
1382 {
1383 return make_int (window_char_height (decode_window (window), 0));
1324 } 1384 }
1325 1385
1326 DEFUN ("window-text-area-pixel-height", 1386 DEFUN ("window-text-area-pixel-height",
1327 Fwindow_text_area_pixel_height, 0, 1, 0, /* 1387 Fwindow_text_area_pixel_height, 0, 1, 0, /*
1328 Return the height in pixels of the text-displaying portion of WINDOW. 1388 Return the height in pixels of the text-displaying portion of WINDOW.
1399 RETURN_NOT_REACHED(make_int (0)) /* shut up compiler */ 1459 RETURN_NOT_REACHED(make_int (0)) /* shut up compiler */
1400 } 1460 }
1401 1461
1402 DEFUN ("window-width", Fwindow_width, 0, 1, 0, /* 1462 DEFUN ("window-width", Fwindow_width, 0, 1, 0, /*
1403 Return the number of display columns in WINDOW. 1463 Return the number of display columns in WINDOW.
1404 This is the width that is usable columns available for text in WINDOW. 1464 This is the width that is usable columns available for text in WINDOW,
1465 and does not include vertical scrollbars, dividers, or the like. See also
1466 `window-full-width' and `window-height'.
1405 */ 1467 */
1406 (window)) 1468 (window))
1407 { 1469 {
1408 return make_int (window_char_width (decode_window (window), 0)); 1470 return make_int (window_char_width (decode_window (window), 0));
1471 }
1472
1473 DEFUN ("window-full-width", Fwindow_full_width, 0, 1, 0, /*
1474 Return the total number of columns in WINDOW.
1475 This is like `window-width' but includes vertical scrollbars, dividers,
1476 etc.
1477 */
1478 (window))
1479 {
1480 return make_int (window_char_width (decode_window (window), 1));
1409 } 1481 }
1410 1482
1411 DEFUN ("window-pixel-width", Fwindow_pixel_width, 0, 1, 0, /* 1483 DEFUN ("window-pixel-width", Fwindow_pixel_width, 0, 1, 0, /*
1412 Return the width of WINDOW in pixels. Defaults to current window. 1484 Return the width of WINDOW in pixels. Defaults to current window.
1413 */ 1485 */
1436 { 1508 {
1437 return make_int (decode_window (window)->hscroll); 1509 return make_int (decode_window (window)->hscroll);
1438 } 1510 }
1439 1511
1440 DEFUN ("modeline-hscroll", Fmodeline_hscroll, 0, 1, 0, /* 1512 DEFUN ("modeline-hscroll", Fmodeline_hscroll, 0, 1, 0, /*
1441 Return the horizontal scrolling ammount of WINDOW's modeline. 1513 Return the horizontal scrolling amount of WINDOW's modeline.
1442 If the window has no modeline, return nil. 1514 If the window has no modeline, return nil.
1443 */ 1515 */
1444 (window)) 1516 (window))
1445 { 1517 {
1446 struct window *w = decode_window (window); 1518 struct window *w = decode_window (window);
1448 return (WINDOW_HAS_MODELINE_P (w)) ? make_int ((int) w->modeline_hscroll) : 1520 return (WINDOW_HAS_MODELINE_P (w)) ? make_int ((int) w->modeline_hscroll) :
1449 Qnil; 1521 Qnil;
1450 } 1522 }
1451 1523
1452 DEFUN ("set-modeline-hscroll", Fset_modeline_hscroll, 2, 2, 0, /* 1524 DEFUN ("set-modeline-hscroll", Fset_modeline_hscroll, 2, 2, 0, /*
1453 Set the horizontal scrolling ammount of WINDOW's modeline to NCOL. 1525 Set the horizontal scrolling amount of WINDOW's modeline to NCOL.
1454 If NCOL is negative, it will silently be forced to 0. 1526 If NCOL is negative, it will silently be forced to 0.
1455 If the window has no modeline, return nil. Otherwise, return the actual 1527 If the window has no modeline, return nil. Otherwise, return the actual
1456 value that was set. 1528 value that was set.
1457 */ 1529 */
1458 (window, ncol)) 1530 (window, ncol))
1524 #endif /* 0 */ 1596 #endif /* 0 */
1525 1597
1526 DEFUN ("window-pixel-edges", Fwindow_pixel_edges, 0, 1, 0, /* 1598 DEFUN ("window-pixel-edges", Fwindow_pixel_edges, 0, 1, 0, /*
1527 Return a list of the pixel edge coordinates of WINDOW. 1599 Return a list of the pixel edge coordinates of WINDOW.
1528 \(LEFT TOP RIGHT BOTTOM), all relative to 0, 0 at top left corner of frame. 1600 \(LEFT TOP RIGHT BOTTOM), all relative to 0, 0 at top left corner of frame.
1529 The frame toolbars and menubars are considered to be outside of this area. 1601 The frame toolbars, menubars and gutters are considered to be outside of this area.
1530 */ 1602 */
1531 (window)) 1603 (window))
1532 { 1604 {
1533 struct window *w = decode_window (window); 1605 struct window *w = decode_window (window);
1534 struct frame *f = XFRAME (w->frame); 1606 struct frame *f = XFRAME (w->frame);
1535 1607
1536 int left = w->pixel_left - FRAME_LEFT_BORDER_END (f); 1608 int left =
1537 int top = w->pixel_top - FRAME_TOP_BORDER_END (f); 1609 w->pixel_left - FRAME_LEFT_BORDER_END (f) - FRAME_LEFT_GUTTER_BOUNDS (f);
1610 int top =
1611 w->pixel_top - FRAME_TOP_BORDER_END (f) - FRAME_TOP_GUTTER_BOUNDS (f);
1538 1612
1539 return list4 (make_int (left), 1613 return list4 (make_int (left),
1540 make_int (top), 1614 make_int (top),
1541 make_int (left + w->pixel_width), 1615 make_int (left + w->pixel_width),
1542 make_int (top + w->pixel_height)); 1616 make_int (top + w->pixel_height));
1563 make_int (bottom)); 1637 make_int (bottom));
1564 } 1638 }
1565 1639
1566 DEFUN ("window-point", Fwindow_point, 0, 1, 0, /* 1640 DEFUN ("window-point", Fwindow_point, 0, 1, 0, /*
1567 Return current value of point in WINDOW. 1641 Return current value of point in WINDOW.
1568 For a nonselected window, this is the value point would have 1642 For a non-selected window, this is the value point would have
1569 if that window were selected. 1643 if that window were selected.
1570 1644
1571 Note that, when WINDOW is the selected window and its buffer 1645 Note that, when WINDOW is the selected window and its buffer
1572 is also currently selected, the value returned is the same as (point). 1646 is also currently selected, the value returned is the same as (point).
1573 It would be more strictly correct to return the `top-level' value 1647 It would be more strictly correct to return the `top-level' value
1619 else 1693 else
1620 { 1694 {
1621 Bufpos startp = marker_position (w->start[CURRENT_DISP]); 1695 Bufpos startp = marker_position (w->start[CURRENT_DISP]);
1622 return make_int (end_of_last_line (w, startp)); 1696 return make_int (end_of_last_line (w, startp));
1623 } 1697 }
1698 }
1699
1700 DEFUN ("window-last-line-visible-height", Fwindow_last_line_visible_height, 0, 1, 0, /*
1701 Return pixel height of visible part of last window line if it is clipped.
1702 If the last line is not clipped, return nil.
1703 */
1704 (window))
1705 {
1706 struct window *w = decode_window (window);
1707 display_line_dynarr *dla = window_display_lines (w, CURRENT_DISP);
1708 int num_lines = Dynarr_length (dla);
1709 struct display_line *dl;
1710
1711 /* No lines - no clipped lines */
1712 if (num_lines == 0 || (num_lines == 1 && Dynarr_atp (dla, 0)->modeline))
1713 return Qnil;
1714
1715 dl = Dynarr_atp (dla, num_lines - 1);
1716 if (dl->clip == 0)
1717 return Qnil;
1718
1719 return make_int (dl->ascent + dl->descent - dl->clip);
1624 } 1720 }
1625 1721
1626 DEFUN ("set-window-point", Fset_window_point, 2, 2, 0, /* 1722 DEFUN ("set-window-point", Fset_window_point, 2, 2, 0, /*
1627 Make point value in WINDOW be at position POS in WINDOW's buffer. 1723 Make point value in WINDOW be at position POS in WINDOW's buffer.
1628 */ 1724 */
1772 } 1868 }
1773 1869
1774 /* #### Here, if replacement is a vertical combination 1870 /* #### Here, if replacement is a vertical combination
1775 and so is its new parent, we should make replacement's 1871 and so is its new parent, we should make replacement's
1776 children be children of that parent instead. */ 1872 children be children of that parent instead. */
1873
1874 ERROR_CHECK_SUBWINDOW_CACHE (p);
1875 }
1876
1877 static void
1878 window_unmap_subwindows (struct window* w)
1879 {
1880 assert (!NILP (w->subwindow_instance_cache));
1881 elisp_maphash (unmap_subwindow_instance_cache_mapper,
1882 w->subwindow_instance_cache, (void*)1);
1777 } 1883 }
1778 1884
1779 /* we're deleting W; set the structure of W to indicate this. */ 1885 /* we're deleting W; set the structure of W to indicate this. */
1780 1886
1781 static void 1887 static void
1782 mark_window_as_deleted (struct window *w) 1888 mark_window_as_deleted (struct window *w)
1783 { 1889 {
1890 /* The window instance cache is going away now, so need to get the
1891 cachels reset by redisplay. */
1892 MARK_FRAME_SUBWINDOWS_CHANGED (XFRAME (WINDOW_FRAME (w)));
1893
1894 /* The cache is going away. If we leave unmapping to
1895 reset_subwindow_cachels then we get in a situation where the
1896 domain (the window) has been deleted but we still need access to
1897 its attributes in order to unmap windows properly. Since the
1898 subwindows are going to get GC'd anyway as a result of the domain
1899 going away, it is safer to just unmap them all while we know the
1900 domain is still valid. */
1901 ERROR_CHECK_SUBWINDOW_CACHE (w);
1902 window_unmap_subwindows (w);
1903
1784 /* In the loop 1904 /* In the loop
1785 (while t (split-window) (delete-window)) 1905 (while t (split-window) (delete-window))
1786 we end up with a tree of deleted windows which are all connected 1906 we end up with a tree of deleted windows which are all connected
1787 through the `next' slot. This might not seem so bad, as they're 1907 through the `next' slot. This might not seem so bad, as they're
1788 deleted, and will presumably be GCed - but if even *one* of those 1908 deleted, and will presumably be GCed - but if even *one* of those
1790 configuration, then *all* of those windows stick around. 1910 configuration, then *all* of those windows stick around.
1791 1911
1792 Since the window-configuration code doesn't need any of the 1912 Since the window-configuration code doesn't need any of the
1793 pointers to other windows (they are all recreated from the 1913 pointers to other windows (they are all recreated from the
1794 window-config data), we set them all to nil so that we 1914 window-config data), we set them all to nil so that we
1795 are able to collect more actual garbage. 1915 are able to collect more actual garbage. */
1796 */
1797 w->next = Qnil; 1916 w->next = Qnil;
1798 w->prev = Qnil; 1917 w->prev = Qnil;
1799 w->hchild = Qnil; 1918 w->hchild = Qnil;
1800 w->vchild = Qnil; 1919 w->vchild = Qnil;
1801 w->parent = Qnil; 1920 w->parent = Qnil;
1921 w->subwindow_instance_cache = Qnil;
1802 1922
1803 w->dead = 1; 1923 w->dead = 1;
1804 1924
1805 /* Free the extra data structures attached to windows immediately so 1925 /* Free the extra data structures attached to windows immediately so
1806 they don't sit around consuming excess space. They will be 1926 they don't sit around consuming excess space. They will be
1833 deleted window; it's OK to delete an already-deleted window. */ 1953 deleted window; it's OK to delete an already-deleted window. */
1834 if (NILP (window)) 1954 if (NILP (window))
1835 window = Fselected_window (Qnil); 1955 window = Fselected_window (Qnil);
1836 else 1956 else
1837 CHECK_WINDOW (window); 1957 CHECK_WINDOW (window);
1958
1838 w = XWINDOW (window); 1959 w = XWINDOW (window);
1839 1960
1840 /* It's okay to delete an already-deleted window. */ 1961 /* It's okay to delete an already-deleted window. */
1841 if (! WINDOW_LIVE_P (w)) 1962 if (! WINDOW_LIVE_P (w))
1842 return Qnil; 1963 return Qnil;
1987 return Qnil; 2108 return Qnil;
1988 } 2109 }
1989 2110
1990 2111
1991 DEFUN ("next-window", Fnext_window, 0, 4, 0, /* 2112 DEFUN ("next-window", Fnext_window, 0, 4, 0, /*
1992 Return next window after WINDOW in canonical ordering of windows. 2113 Return the next window after WINDOW in the canonical ordering of windows.
1993 If omitted, WINDOW defaults to the selected window. 2114 If omitted, WINDOW defaults to the selected window.
1994 2115
1995 Optional second arg MINIBUF t means count the minibuffer window even 2116 Optional second arg MINIBUF t means count the minibuffer window even
1996 if not active. MINIBUF nil or omitted means count the minibuffer iff 2117 if not active. MINIBUF nil or omitted means count the minibuffer iff
1997 it is active. MINIBUF neither t nor nil means not to count the 2118 it is active. MINIBUF neither t nor nil means not to count the
2008 above. ALL-FRAMES = `visible' means include windows on all visible frames. 2129 above. ALL-FRAMES = `visible' means include windows on all visible frames.
2009 ALL-FRAMES = 0 means include windows on all visible and iconified frames. 2130 ALL-FRAMES = 0 means include windows on all visible and iconified frames.
2010 If ALL-FRAMES is a frame, restrict search to windows on that frame. 2131 If ALL-FRAMES is a frame, restrict search to windows on that frame.
2011 Anything else means restrict to WINDOW's frame. 2132 Anything else means restrict to WINDOW's frame.
2012 2133
2013 Optional fourth argument CONSOLE controls which consoles or devices the 2134 Optional fourth arg CONSOLE controls which consoles or devices the
2014 returned window may be on. If CONSOLE is a console, return windows only 2135 returned window may be on. If CONSOLE is a console, return windows only
2015 on that console. If CONSOLE is a device, return windows only on that 2136 on that console. If CONSOLE is a device, return windows only on that
2016 device. If CONSOLE is a console type, return windows only on consoles 2137 device. If CONSOLE is a console type, return windows only on consoles
2017 of that type. If CONSOLE is 'window-system, return any windows on any 2138 of that type. If CONSOLE is 'window-system, return any windows on any
2018 window-system consoles. If CONSOLE is nil or omitted, return windows only 2139 window-system consoles. If CONSOLE is nil or omitted, return windows only
2039 Decide if it does. */ 2160 Decide if it does. */
2040 if (NILP (minibuf)) 2161 if (NILP (minibuf))
2041 minibuf = (minibuf_level ? minibuf_window : Qlambda); 2162 minibuf = (minibuf_level ? minibuf_window : Qlambda);
2042 else if (! EQ (minibuf, Qt)) 2163 else if (! EQ (minibuf, Qt))
2043 minibuf = Qlambda; 2164 minibuf = Qlambda;
2044 /* Now minibuf can be t => count all minibuffer windows, 2165 /* Now `minibuf' is one of:
2045 lambda => count none of them, 2166 t => count all minibuffer windows
2167 lambda => count none of them
2046 or a specific minibuffer window (the active one) to count. */ 2168 or a specific minibuffer window (the active one) to count. */
2047 2169
2048 /* all_frames == nil doesn't specify which frames to include. */ 2170 /* all_frames == nil doesn't specify which frames to include. */
2049 if (NILP (all_frames)) 2171 if (NILP (all_frames))
2050 all_frames = (! EQ (minibuf, Qlambda) 2172 all_frames = (! EQ (minibuf, Qlambda)
2061 /* If all_frames is a frame and window arg isn't on that frame, just 2183 /* If all_frames is a frame and window arg isn't on that frame, just
2062 return the first window on the frame. */ 2184 return the first window on the frame. */
2063 return frame_first_window (XFRAME (all_frames)); 2185 return frame_first_window (XFRAME (all_frames));
2064 else if (! EQ (all_frames, Qt)) 2186 else if (! EQ (all_frames, Qt))
2065 all_frames = Qnil; 2187 all_frames = Qnil;
2066 /* Now all_frames is t meaning search all frames, 2188 /* Now `all_frames' is one of:
2067 nil meaning search just current frame, 2189 t => search all frames
2068 visible meaning search just visible frames, 2190 nil => search just the current frame
2069 0 meaning search visible and iconified frames, 2191 visible => search just visible frames
2070 or a window, meaning search the frame that window belongs to. */ 2192 0 => search visible and iconified frames
2193 a window => search the frame that window belongs to. */
2071 2194
2072 /* Do this loop at least once, to get the next window, and perhaps 2195 /* Do this loop at least once, to get the next window, and perhaps
2073 again, if we hit the minibuffer and that is not acceptable. */ 2196 again, if we hit the minibuffer and that is not acceptable. */
2074 do 2197 do
2075 { 2198 {
2084 Which other frames are acceptable? */ 2207 Which other frames are acceptable? */
2085 tem = WINDOW_FRAME (XWINDOW (window)); 2208 tem = WINDOW_FRAME (XWINDOW (window));
2086 2209
2087 if (! NILP (all_frames)) 2210 if (! NILP (all_frames))
2088 { 2211 {
2089 Lisp_Object tem1; 2212 Lisp_Object tem1 = tem;
2090
2091 tem1 = tem;
2092 tem = next_frame (tem, all_frames, console); 2213 tem = next_frame (tem, all_frames, console);
2214
2093 /* In the case where the minibuffer is active, 2215 /* In the case where the minibuffer is active,
2094 and we include its frame as well as the selected one, 2216 and we include its frame as well as the selected one,
2095 next_frame may get stuck in that frame. 2217 next_frame may get stuck in that frame.
2096 If that happens, go back to the selected frame 2218 If that happens, go back to the selected frame
2097 so we can complete the cycle. */ 2219 so we can complete the cycle. */
2114 else if (!NILP (XWINDOW (window)->vchild)) 2236 else if (!NILP (XWINDOW (window)->vchild))
2115 window = XWINDOW (window)->vchild; 2237 window = XWINDOW (window)->vchild;
2116 else break; 2238 else break;
2117 } 2239 }
2118 } 2240 }
2119 /* "acceptable" is the correct spelling. */
2120 /* Which windows are acceptable? 2241 /* Which windows are acceptable?
2121 Exit the loop and accept this window if 2242 Exit the loop and accept this window if
2122 this isn't a minibuffer window, 2243 this isn't a minibuffer window,
2123 or we're accepting all minibuffer windows, 2244 or we're accepting all minibuffer windows,
2124 or this is the active minibuffer and we are accepting that one, or 2245 or this is the active minibuffer and we are accepting that one, or
2130 2251
2131 return window; 2252 return window;
2132 } 2253 }
2133 2254
2134 DEFUN ("previous-window", Fprevious_window, 0, 4, 0, /* 2255 DEFUN ("previous-window", Fprevious_window, 0, 4, 0, /*
2135 Return the window preceding WINDOW in canonical ordering of windows. 2256 Return the window preceding WINDOW in the canonical ordering of windows.
2136 If omitted, WINDOW defaults to the selected window. 2257 If omitted, WINDOW defaults to the selected window.
2137 2258
2138 Optional second arg MINIBUF t means count the minibuffer window even 2259 Optional second arg MINIBUF t means count the minibuffer window even
2139 if not active. MINIBUF nil or omitted means count the minibuffer iff 2260 if not active. MINIBUF nil or omitted means count the minibuffer iff
2140 it is active. MINIBUF neither t nor nil means not to count the 2261 it is active. MINIBUF neither t nor nil means not to count the
2142 2263
2143 Several frames may share a single minibuffer; if the minibuffer 2264 Several frames may share a single minibuffer; if the minibuffer
2144 counts, all windows on all frames that share that minibuffer count 2265 counts, all windows on all frames that share that minibuffer count
2145 too. Therefore, `previous-window' can be used to iterate through 2266 too. Therefore, `previous-window' can be used to iterate through
2146 the set of windows even when the minibuffer is on another frame. If 2267 the set of windows even when the minibuffer is on another frame. If
2147 the minibuffer does not count, only windows from WINDOW's frame count 2268 the minibuffer does not count, only windows from WINDOW's frame count.
2148 2269
2149 If optional third arg ALL-FRAMES t means include windows on all frames. 2270 Optional third arg ALL-FRAMES t means include windows on all frames.
2150 ALL-FRAMES nil or omitted means cycle within the frames as specified 2271 ALL-FRAMES nil or omitted means cycle within the frames as specified
2151 above. ALL-FRAMES = `visible' means include windows on all visible frames. 2272 above. ALL-FRAMES = `visible' means include windows on all visible frames.
2152 ALL-FRAMES = 0 means include windows on all visible and iconified frames. 2273 ALL-FRAMES = 0 means include windows on all visible and iconified frames.
2153 If ALL-FRAMES is a frame, restrict search to windows on that frame. 2274 If ALL-FRAMES is a frame, restrict search to windows on that frame.
2154 Anything else means restrict to WINDOW's frame. 2275 Anything else means restrict to WINDOW's frame.
2155 2276
2156 Optional fourth argument CONSOLE controls which consoles or devices the 2277 Optional fourth arg CONSOLE controls which consoles or devices the
2157 returned window may be on. If CONSOLE is a console, return windows only 2278 returned window may be on. If CONSOLE is a console, return windows only
2158 on that console. If CONSOLE is a device, return windows only on that 2279 on that console. If CONSOLE is a device, return windows only on that
2159 device. If CONSOLE is a console type, return windows only on consoles 2280 device. If CONSOLE is a console type, return windows only on consoles
2160 of that type. If CONSOLE is 'window-system, return any windows on any 2281 of that type. If CONSOLE is 'window-system, return any windows on any
2161 window-system consoles. If CONSOLE is nil or omitted, return windows only 2282 window-system consoles. If CONSOLE is nil or omitted, return windows only
2182 Decide if it does. */ 2303 Decide if it does. */
2183 if (NILP (minibuf)) 2304 if (NILP (minibuf))
2184 minibuf = (minibuf_level ? minibuf_window : Qlambda); 2305 minibuf = (minibuf_level ? minibuf_window : Qlambda);
2185 else if (! EQ (minibuf, Qt)) 2306 else if (! EQ (minibuf, Qt))
2186 minibuf = Qlambda; 2307 minibuf = Qlambda;
2187 /* Now minibuf can be t => count all minibuffer windows, 2308 /* Now `minibuf' is one of:
2188 lambda => count none of them, 2309 t => count all minibuffer windows
2310 lambda => count none of them
2189 or a specific minibuffer window (the active one) to count. */ 2311 or a specific minibuffer window (the active one) to count. */
2190 2312
2191 /* all_frames == nil doesn't specify which frames to include. 2313 /* all_frames == nil doesn't specify which frames to include.
2192 Decide which frames it includes. */ 2314 Decide which frames it includes. */
2193 if (NILP (all_frames)) 2315 if (NILP (all_frames))
2205 /* If all_frames is a frame and window arg isn't on that frame, just 2327 /* If all_frames is a frame and window arg isn't on that frame, just
2206 return the first window on the frame. */ 2328 return the first window on the frame. */
2207 return frame_first_window (XFRAME (all_frames)); 2329 return frame_first_window (XFRAME (all_frames));
2208 else if (! EQ (all_frames, Qt)) 2330 else if (! EQ (all_frames, Qt))
2209 all_frames = Qnil; 2331 all_frames = Qnil;
2210 /* Now all_frames is t meaning search all frames, 2332 /* Now `all_frames' is one of:
2211 nil meaning search just current frame, 2333 t => search all frames
2212 visible meaning search just visible frames, 2334 nil => search just the current frame
2213 0 meaning search visible and iconified frames, 2335 visible => search just visible frames
2214 or a window, meaning search the frame that window belongs to. */ 2336 0 => search visible and iconified frames
2337 a window => search the frame that window belongs to. */
2215 2338
2216 /* Do this loop at least once, to get the next window, and perhaps 2339 /* Do this loop at least once, to get the next window, and perhaps
2217 again, if we hit the minibuffer and that is not acceptable. */ 2340 again, if we hit the minibuffer and that is not acceptable. */
2218 do 2341 do
2219 { 2342 {
2227 /* We have found the top window on the frame. 2350 /* We have found the top window on the frame.
2228 Which frames are acceptable? */ 2351 Which frames are acceptable? */
2229 tem = WINDOW_FRAME (XWINDOW (window)); 2352 tem = WINDOW_FRAME (XWINDOW (window));
2230 2353
2231 if (! NILP (all_frames)) 2354 if (! NILP (all_frames))
2232 /* It's actually important that we use prev_frame here, 2355 /* It's actually important that we use previous_frame here,
2233 rather than next_frame. All the windows acceptable 2356 rather than next_frame. All the windows acceptable
2234 according to the given parameters should form a ring; 2357 according to the given parameters should form a ring;
2235 Fnext_window and Fprevious_window should go back and 2358 Fnext_window and Fprevious_window should go back and
2236 forth around the ring. If we use next_frame here, 2359 forth around the ring. If we use next_frame here,
2237 then Fnext_window and Fprevious_window take different 2360 then Fnext_window and Fprevious_window take different
2238 paths through the set of acceptable windows. 2361 paths through the set of acceptable windows.
2239 window_loop assumes that these `ring' requirement are 2362 window_loop assumes that these `ring' requirement are
2240 met. */ 2363 met. */
2241 { 2364 {
2242 Lisp_Object tem1; 2365 Lisp_Object tem1 = tem;
2243 2366 tem = previous_frame (tem, all_frames, console);
2244 tem1 = tem;
2245 tem = prev_frame (tem, all_frames, console);
2246 /* In the case where the minibuffer is active, 2367 /* In the case where the minibuffer is active,
2247 and we include its frame as well as the selected one, 2368 and we include its frame as well as the selected one,
2248 next_frame may get stuck in that frame. 2369 next_frame may get stuck in that frame.
2249 If that happens, go back to the selected frame 2370 If that happens, go back to the selected frame
2250 so we can complete the cycle. */ 2371 so we can complete the cycle. */
2426 * #### catch the lossage this is meant(?) to punt on... 2547 * #### catch the lossage this is meant(?) to punt on...
2427 */ 2548 */
2428 int lose_lose = 0; 2549 int lose_lose = 0;
2429 Lisp_Object devcons, concons; 2550 Lisp_Object devcons, concons;
2430 2551
2431 /* FRAME_ARG is Qlambda to stick to one frame,
2432 Qvisible to consider all visible frames,
2433 or Qt otherwise. */
2434
2435 /* If we're only looping through windows on a particular frame, 2552 /* If we're only looping through windows on a particular frame,
2436 FRAME points to that frame. If we're looping through windows 2553 FRAME points to that frame. If we're looping through windows
2437 on all frames, FRAME is 0. */ 2554 on all frames, FRAME is 0. */
2438
2439 if (FRAMEP (frames)) 2555 if (FRAMEP (frames))
2440 frame = XFRAME (frames); 2556 frame = XFRAME (frames);
2441 else if (NILP (frames)) 2557 else if (NILP (frames))
2442 frame = selected_frame (); 2558 frame = selected_frame ();
2443 else 2559 else
2444 frame = 0; 2560 frame = 0;
2561
2562 /* FRAME_ARG is Qlambda to stick to one frame,
2563 Qvisible to consider all visible frames,
2564 or Qt otherwise. */
2445 if (frame) 2565 if (frame)
2446 frame_arg = Qlambda; 2566 frame_arg = Qlambda;
2447 else if (ZEROP (frames)) 2567 else if (ZEROP (frames))
2448 frame_arg = frames; 2568 frame_arg = frames;
2449 else if (EQ (frames, Qvisible)) 2569 else if (EQ (frames, Qvisible))
2460 the_frame = DEVICE_SELECTED_FRAME (XDEVICE (device)); 2580 the_frame = DEVICE_SELECTED_FRAME (XDEVICE (device));
2461 2581
2462 if (NILP (the_frame)) 2582 if (NILP (the_frame))
2463 continue; 2583 continue;
2464 2584
2465 if (!device_matches_console_spec (the_frame, device, console)) 2585 if (!device_matches_console_spec (device,
2586 NILP (console) ?
2587 FRAME_CONSOLE (XFRAME (the_frame)) :
2588 console))
2466 continue; 2589 continue;
2467 2590
2468 /* Pick a window to start with. */ 2591 /* Pick a window to start with. */
2469 if (WINDOWP (obj)) 2592 if (WINDOWP (obj))
2470 w = obj; 2593 w = obj;
2486 struct window *p = XWINDOW (w); 2609 struct window *p = XWINDOW (w);
2487 struct frame *w_frame = XFRAME (WINDOW_FRAME (p)); 2610 struct frame *w_frame = XFRAME (WINDOW_FRAME (p));
2488 2611
2489 /* Pick the next window now, since some operations will delete 2612 /* Pick the next window now, since some operations will delete
2490 the current window. */ 2613 the current window. */
2491 next_window = Fnext_window (w, mini ? Qt : Qnil, frame_arg, Qt); 2614 next_window = Fnext_window (w, mini ? Qt : Qnil, frame_arg, device);
2492 2615
2493 /* #### Still needed ?? */ 2616 /* #### Still needed ?? */
2494 /* Given the outstanding quality of the rest of this code, 2617 /* Given the outstanding quality of the rest of this code,
2495 I feel no shame about putting this piece of shit in. */ 2618 I feel no shame about putting this piece of shit in. */
2496 if (++lose_lose >= 500) 2619 if (++lose_lose >= 500)
3164 3287
3165 DEFUN ("set-window-buffer", Fset_window_buffer, 2, 3, 0, /* 3288 DEFUN ("set-window-buffer", Fset_window_buffer, 2, 3, 0, /*
3166 Make WINDOW display BUFFER as its contents. 3289 Make WINDOW display BUFFER as its contents.
3167 BUFFER can be a buffer or buffer name. 3290 BUFFER can be a buffer or buffer name.
3168 3291
3169 With non-nil optional argument `norecord', do not modify the 3292 With non-nil optional argument NORECORD, do not modify the
3170 global or per-frame buffer ordering. 3293 global or per-frame buffer ordering.
3171 */ 3294 */
3172 (window, buffer, norecord)) 3295 (window, buffer, norecord))
3173 { 3296 {
3174 Lisp_Object tem; 3297 Lisp_Object tem;
3239 DEFUN ("select-window", Fselect_window, 1, 2, 0, /* 3362 DEFUN ("select-window", Fselect_window, 1, 2, 0, /*
3240 Select WINDOW. Most editing will apply to WINDOW's buffer. 3363 Select WINDOW. Most editing will apply to WINDOW's buffer.
3241 The main editor command loop selects the buffer of the selected window 3364 The main editor command loop selects the buffer of the selected window
3242 before each command. 3365 before each command.
3243 3366
3244 With non-nil optional argument `norecord', do not modify the 3367 With non-nil optional argument NORECORD, do not modify the
3245 global or per-frame buffer ordering. 3368 global or per-frame buffer ordering.
3246 */ 3369 */
3247 (window, norecord)) 3370 (window, norecord))
3248 { 3371 {
3249 struct window *w; 3372 struct window *w;
3255 /* we have already caught dead-window errors */ 3378 /* we have already caught dead-window errors */
3256 if (!NILP (w->hchild) || !NILP (w->vchild)) 3379 if (!NILP (w->hchild) || !NILP (w->vchild))
3257 error ("Trying to select non-leaf window"); 3380 error ("Trying to select non-leaf window");
3258 3381
3259 w->use_time = make_int (++window_select_count); 3382 w->use_time = make_int (++window_select_count);
3383
3260 if (EQ (window, old_selected_window)) 3384 if (EQ (window, old_selected_window))
3261 return window; 3385 return window;
3262 3386
3263 /* deselect the old window, if it exists (it might not exist if 3387 /* deselect the old window, if it exists (it might not exist if
3264 the selected device has no frames, which occurs at startup) */ 3388 the selected device has no frames, which occurs at startup) */
3378 /* Don't copy the pointers to the line start cache or the face 3502 /* Don't copy the pointers to the line start cache or the face
3379 instances. */ 3503 instances. */
3380 p->line_start_cache = Dynarr_new (line_start_cache); 3504 p->line_start_cache = Dynarr_new (line_start_cache);
3381 p->face_cachels = Dynarr_new (face_cachel); 3505 p->face_cachels = Dynarr_new (face_cachel);
3382 p->glyph_cachels = Dynarr_new (glyph_cachel); 3506 p->glyph_cachels = Dynarr_new (glyph_cachel);
3507 p->subwindow_instance_cache =
3508 make_lisp_hash_table (30,
3509 HASH_TABLE_KEY_VALUE_WEAK,
3510 HASH_TABLE_EQ);
3383 3511
3384 /* Put new into window structure in place of window */ 3512 /* Put new into window structure in place of window */
3385 replace_window (window, new); 3513 replace_window (window, new);
3386 3514
3387 o->next = Qnil; 3515 o->next = Qnil;
3401 } 3529 }
3402 3530
3403 DEFUN ("split-window", Fsplit_window, 0, 3, "", /* 3531 DEFUN ("split-window", Fsplit_window, 0, 3, "", /*
3404 Split WINDOW, putting SIZE lines in the first of the pair. 3532 Split WINDOW, putting SIZE lines in the first of the pair.
3405 WINDOW defaults to selected one and SIZE to half its size. 3533 WINDOW defaults to selected one and SIZE to half its size.
3406 If optional third arg HOR-FLAG is non-nil, split side by side 3534 If optional third arg HORFLAG is non-nil, split side by side
3407 and put SIZE columns in the first of the pair. 3535 and put SIZE columns in the first of the pair.
3408 */ 3536 */
3409 (window, chsize, horflag)) 3537 (window, chsize, horflag))
3410 { 3538 {
3411 Lisp_Object new; 3539 Lisp_Object new;
3593 /* inpixels */ 1); 3721 /* inpixels */ 1);
3594 return Qnil; 3722 return Qnil;
3595 } 3723 }
3596 3724
3597 static int 3725 static int
3598 window_pixel_height (Lisp_Object window)
3599 {
3600 return WINDOW_HEIGHT (XWINDOW (window));
3601 }
3602
3603 static int
3604 window_pixel_height_to_char_height (struct window *w, int pixel_height, 3726 window_pixel_height_to_char_height (struct window *w, int pixel_height,
3605 int include_gutters_p) 3727 int include_gutters_p)
3606 { 3728 {
3607 int avail_height; 3729 int avail_height;
3608 int defheight, defwidth; 3730 int defheight, defwidth;
3611 3733
3612 XSETWINDOW (window, w); 3734 XSETWINDOW (window, w);
3613 3735
3614 avail_height = (pixel_height - 3736 avail_height = (pixel_height -
3615 (include_gutters_p ? 0 : 3737 (include_gutters_p ? 0 :
3616 window_top_gutter_height (w) + 3738 window_top_window_gutter_height (w) +
3617 window_bottom_gutter_height (w))); 3739 window_bottom_window_gutter_height (w)));
3618 3740
3619 default_face_height_and_width (window, &defheight, &defwidth); 3741 default_face_height_and_width (window, &defheight, &defwidth);
3620 3742
3621 char_height = avail_height / defheight; 3743 char_height = avail_height / defheight;
3622 3744
3643 default_face_height_and_width (window, &defheight, &defwidth); 3765 default_face_height_and_width (window, &defheight, &defwidth);
3644 3766
3645 avail_height = char_height * defheight; 3767 avail_height = char_height * defheight;
3646 pixel_height = (avail_height + 3768 pixel_height = (avail_height +
3647 (include_gutters_p ? 0 : 3769 (include_gutters_p ? 0 :
3648 window_top_gutter_height (w) + 3770 window_top_window_gutter_height (w) +
3649 window_bottom_gutter_height (w))); 3771 window_bottom_window_gutter_height (w)));
3650 3772
3651 /* It's the calling function's responsibility to check these values 3773 /* It's the calling function's responsibility to check these values
3652 and make sure they're not out of range. 3774 and make sure they're not out of range.
3653 3775
3654 #### We need to go through the calling functions and actually 3776 #### We need to go through the calling functions and actually
3657 } 3779 }
3658 3780
3659 /* Return number of default lines of text can fit in the window W. 3781 /* Return number of default lines of text can fit in the window W.
3660 If INCLUDE_GUTTERS_P is 1, include "gutter" space (modeline plus 3782 If INCLUDE_GUTTERS_P is 1, include "gutter" space (modeline plus
3661 horizontal scrollbar) in the space that is used for the calculation. 3783 horizontal scrollbar) in the space that is used for the calculation.
3784 This doesn't include space used by the frame gutters.
3662 */ 3785 */
3663 int 3786 int
3664 window_char_height (struct window *w, int include_gutters_p) 3787 window_char_height (struct window *w, int include_gutters_p)
3665 { 3788 {
3666 return window_pixel_height_to_char_height (w, WINDOW_HEIGHT (w), 3789 return window_pixel_height_to_char_height (w, window_pixel_height (w),
3667 include_gutters_p); 3790 include_gutters_p);
3668 } 3791 }
3669 3792
3670 /* 3793 /*
3671 * Return number of lines currently displayed in window w. If 3794 * Return number of lines currently displayed in window w. If
3741 window_pixel_width (Lisp_Object window) 3864 window_pixel_width (Lisp_Object window)
3742 { 3865 {
3743 return WINDOW_WIDTH (XWINDOW (window)); 3866 return WINDOW_WIDTH (XWINDOW (window));
3744 } 3867 }
3745 3868
3869 /* Calculate the pixel of a window, optionally including margin space
3870 but no vertical gutters. */
3746 static int 3871 static int
3747 window_pixel_width_to_char_width (struct window *w, int pixel_width, 3872 window_pixel_width_to_char_width (struct window *w, int pixel_width,
3748 int include_margins_p) 3873 int include_margins_p)
3749 { 3874 {
3750 int avail_width; 3875 int avail_width;
3785 3910
3786 default_face_height_and_width (window, &defheight, &defwidth); 3911 default_face_height_and_width (window, &defheight, &defwidth);
3787 3912
3788 avail_width = char_width * defwidth; 3913 avail_width = char_width * defwidth;
3789 pixel_width = (avail_width + 3914 pixel_width = (avail_width +
3790 window_left_gutter_width (w, 0) + 3915 window_left_window_gutter_width (w, 0) +
3791 window_right_gutter_width (w, 0) + 3916 window_right_window_gutter_width (w, 0) +
3792 (include_margins_p ? 0 : window_left_margin_width (w)) + 3917 (include_margins_p ? 0 : window_left_margin_width (w)) +
3793 (include_margins_p ? 0 : window_right_margin_width (w))); 3918 (include_margins_p ? 0 : window_right_margin_width (w)));
3794 3919
3795 /* It's the calling function's responsibility to check these values 3920 /* It's the calling function's responsibility to check these values
3796 and make sure they're not out of range. 3921 and make sure they're not out of range.
3824 (widthflag ? window_char_width (w, 0) : window_char_height (w, 1)) 3949 (widthflag ? window_char_width (w, 0) : window_char_height (w, 1))
3825 3950
3826 #define MINCHARSIZE(window) \ 3951 #define MINCHARSIZE(window) \
3827 (widthflag ? window_min_width : MINI_WINDOW_P (XWINDOW (window)) \ 3952 (widthflag ? window_min_width : MINI_WINDOW_P (XWINDOW (window)) \
3828 ? 1 : window_min_height) 3953 ? 1 : window_min_height)
3954
3955 static int
3956 window_pixheight (Lisp_Object w)
3957 {
3958 return window_pixel_height (XWINDOW (w));
3959 }
3829 3960
3830 /* Unlike set_window_pixheight, this function 3961 /* Unlike set_window_pixheight, this function
3831 also changes the heights of the siblings so as to 3962 also changes the heights of the siblings so as to
3832 keep everything consistent. */ 3963 keep everything consistent. */
3833 3964
3840 struct window *w; 3971 struct window *w;
3841 struct frame *f; 3972 struct frame *f;
3842 int *sizep; 3973 int *sizep;
3843 int (*sizefun) (Lisp_Object) = (widthflag 3974 int (*sizefun) (Lisp_Object) = (widthflag
3844 ? window_pixel_width 3975 ? window_pixel_width
3845 : window_pixel_height); 3976 : window_pixheight);
3846 void (*setsizefun) (Lisp_Object, int, int) = (widthflag 3977 void (*setsizefun) (Lisp_Object, int, int) = (widthflag
3847 ? set_window_pixwidth 3978 ? set_window_pixwidth
3848 : set_window_pixheight); 3979 : set_window_pixheight);
3849 int dim; 3980 int dim;
3850 int defheight, defwidth; 3981 int defheight, defwidth;
4824 /* n - 1 because zero-sized arrays aren't ANSI C */ 4955 /* n - 1 because zero-sized arrays aren't ANSI C */
4825 (n - 1) *sizeof (struct saved_window)); 4956 (n - 1) *sizeof (struct saved_window));
4826 } 4957 }
4827 4958
4828 static size_t 4959 static size_t
4829 sizeof_window_config (CONST void *h) 4960 sizeof_window_config (const void *h)
4830 { 4961 {
4831 CONST struct window_config *c = (CONST struct window_config *) h; 4962 const struct window_config *c = (const struct window_config *) h;
4832 return sizeof_window_config_for_n_windows (c->saved_windows_count); 4963 return sizeof_window_config_for_n_windows (c->saved_windows_count);
4833 } 4964 }
4834 4965
4835 static void 4966 static void
4836 print_window_config (Lisp_Object obj, Lisp_Object printcharfun, int escapeflag) 4967 print_window_config (Lisp_Object obj, Lisp_Object printcharfun, int escapeflag)
5069 in an inconsistent state. */ 5200 in an inconsistent state. */
5070 begin_dont_check_for_quit (); 5201 begin_dont_check_for_quit ();
5071 record_unwind_protect (free_window_configuration, old_window_config); 5202 record_unwind_protect (free_window_configuration, old_window_config);
5072 5203
5073 mark_windows_in_use (f, 1); 5204 mark_windows_in_use (f, 1);
5074 5205 #ifdef BROKEN_SUBWINDOW_REDISPLAY
5206 /* Force subwindows to be remapped. This is overkill but saves
5207 us having to rely on the redisplay code to unmap any extant
5208 subwindows.
5209
5210 #### It does cause some extra flashing though which we could
5211 possibly avoid. So consider trying to get redisplay to work
5212 correctly.
5213
5214 Removing the instances from the frame cache is wrong because
5215 an instance is only put in the frame cache when it is
5216 instantiated. So if we do this there is a chance that stuff
5217 will never get put back in the frame cache. */
5218 reset_frame_subwindow_instance_cache (f);
5219 #endif
5075 #if 0 5220 #if 0
5076 /* JV: This is bogus, 5221 /* JV: This is bogus,
5077 First of all, the units are inconsistent. The frame sizes are measured 5222 First of all, the units are inconsistent. The frame sizes are measured
5078 in characters but the window sizes are stored in pixels. So if a 5223 in characters but the window sizes are stored in pixels. So if a
5079 font size change happened between saving and restoring, the 5224 font size change happened between saving and restoring, the
5080 frame "sizes" maybe equal but the windows still should be 5225 frame "sizes" maybe equal but the windows still should be
5081 resized. This is tickled alot by the new "character size 5226 resized. This is tickled a lot by the new "character size
5082 stays constant" policy in 21.0. It leads to very wierd 5227 stays constant" policy in 21.0. It leads to very weird
5083 glitches (and possibly craches when asserts are tickled). 5228 glitches (and possibly crashes when asserts are tickled).
5084 5229
5085 Just changing the units doens't help because changing the 5230 Just changing the units doesn't help because changing the
5086 toolbar configuration can also change the pixel positions. 5231 toolbar configuration can also change the pixel positions.
5087 Luckily there is a much simpler way of doing this, see below. 5232 Luckily there is a much simpler way of doing this, see below.
5088 */ 5233 */
5089 previous_frame_width = FRAME_WIDTH (f); 5234 previous_frame_width = FRAME_WIDTH (f);
5090 previous_frame_height = FRAME_HEIGHT (f); 5235 previous_frame_height = FRAME_HEIGHT (f);
5151 } 5296 }
5152 if (!w->glyph_cachels) 5297 if (!w->glyph_cachels)
5153 w->glyph_cachels = Dynarr_new (glyph_cachel); 5298 w->glyph_cachels = Dynarr_new (glyph_cachel);
5154 if (!w->line_start_cache) 5299 if (!w->line_start_cache)
5155 w->line_start_cache = Dynarr_new (line_start_cache); 5300 w->line_start_cache = Dynarr_new (line_start_cache);
5301 w->gutter_extent_modiff[0] = 0;
5302 w->gutter_extent_modiff[1] = 0;
5303 w->gutter_extent_modiff[2] = 0;
5304 w->gutter_extent_modiff[3] = 0;
5156 w->dead = 0; 5305 w->dead = 0;
5157 5306
5158 if (p->parent_index >= 0) 5307 if (p->parent_index >= 0)
5159 w->parent = SAVED_WINDOW_N (config, p->parent_index)->window; 5308 w->parent = SAVED_WINDOW_N (config, p->parent_index)->window;
5160 else 5309 else
5208 WINDOW_WIDTH (w) = WINDOW_WIDTH (p); 5357 WINDOW_WIDTH (w) = WINDOW_WIDTH (p);
5209 WINDOW_HEIGHT (w) = WINDOW_HEIGHT (p); 5358 WINDOW_HEIGHT (w) = WINDOW_HEIGHT (p);
5210 w->hscroll = p->hscroll; 5359 w->hscroll = p->hscroll;
5211 w->modeline_hscroll = p->modeline_hscroll; 5360 w->modeline_hscroll = p->modeline_hscroll;
5212 w->line_cache_last_updated = Qzero; 5361 w->line_cache_last_updated = Qzero;
5362 /* When we restore a window's configuration, the identity of
5363 the window hasn't actually changed - so there is no
5364 reason why we shouldn't preserve the instance cache for
5365 it - unless it was originally deleted. This will often
5366 buy us something as we will not have to re-instantiate
5367 all the instances. This is because this is an instance
5368 cache - not a display cache. Preserving the display cache
5369 would definitely be wrong.
5370
5371 We specifically want to do this for tabs, since for some
5372 reason finding a file will cause the configuration to be
5373 set. */
5374 if (NILP (w->subwindow_instance_cache))
5375 w->subwindow_instance_cache =
5376 make_lisp_hash_table (30,
5377 HASH_TABLE_KEY_VALUE_WEAK,
5378 HASH_TABLE_EQ);
5213 SET_LAST_MODIFIED (w, 1); 5379 SET_LAST_MODIFIED (w, 1);
5214 SET_LAST_FACECHANGE (w); 5380 SET_LAST_FACECHANGE (w);
5215 w->config_mark = 0; 5381 w->config_mark = 0;
5216 5382
5383 /* #### Consider making the instance cache a winslot. */
5217 #define WINDOW_SLOT(slot, compare) w->slot = p->slot 5384 #define WINDOW_SLOT(slot, compare) w->slot = p->slot
5218 #include "winslots.h" 5385 #include "winslots.h"
5219 5386
5220 /* Reinstall the saved buffer and pointers into it. */ 5387 /* Reinstall the saved buffer and pointers into it. */
5221 if (NILP (p->buffer)) 5388 if (NILP (p->buffer))
5350 /* If restoring in the current frame make the window current, 5517 /* If restoring in the current frame make the window current,
5351 otherwise just update the frame selected_window slot to be 5518 otherwise just update the frame selected_window slot to be
5352 the restored current_window. */ 5519 the restored current_window. */
5353 if (f == selected_frame ()) 5520 if (f == selected_frame ())
5354 { 5521 {
5522 #if 0
5355 /* When using `pop-window-configuration', often the minibuffer 5523 /* When using `pop-window-configuration', often the minibuffer
5356 ends up as the selected window even though it's not active ... 5524 ends up as the selected window even though it's not active ...
5357 I really don't know the cause of this, but it should never 5525 I really don't know the cause of this, but it should never
5358 happen. This kludge should fix it. 5526 happen. This kludge should fix it.
5359 5527
5360 #### Find out why this is really going wrong. */ 5528 #### Find out why this is really going wrong. */
5361 if (!minibuf_level && 5529 if (!minibuf_level &&
5362 MINI_WINDOW_P (XWINDOW (config->current_window))) 5530 MINI_WINDOW_P (XWINDOW (config->current_window)))
5363 Fselect_window (Fnext_window (config->current_window, 5531 window_to_select = Fnext_window (config->current_window,
5364 Qnil, Qnil, Qnil), 5532 Qnil, Qnil, Qnil);
5365 Qnil);
5366 else 5533 else
5367 Fselect_window (config->current_window, Qnil); 5534 window_to_select = config->current_window;
5535 #endif
5536 /* Do this last so that buffer stacking is calculated
5537 correctly. */
5538 Fselect_window (config->current_window, Qnil);
5539
5368 if (!NILP (new_current_buffer)) 5540 if (!NILP (new_current_buffer))
5369 Fset_buffer (new_current_buffer); 5541 {
5542 Fset_buffer (new_current_buffer);
5543 Frecord_buffer (new_current_buffer);
5544 }
5370 else 5545 else
5371 Fset_buffer (XWINDOW (Fselected_window (Qnil))->buffer); 5546 {
5547 Fset_buffer (XWINDOW (config->current_window)->buffer);
5548 Frecord_buffer (XWINDOW (config->current_window)->buffer);
5549 }
5372 } 5550 }
5373 else 5551 else
5374 set_frame_selected_window (f, config->current_window); 5552 set_frame_selected_window (f, config->current_window);
5375 } 5553 }
5376 else 5554 else
5575 &lrecord_window_configuration); 5753 &lrecord_window_configuration);
5576 XSETWINDOW_CONFIGURATION (result, config); 5754 XSETWINDOW_CONFIGURATION (result, config);
5577 /* 5755 /*
5578 config->frame_width = FRAME_WIDTH (f); 5756 config->frame_width = FRAME_WIDTH (f);
5579 config->frame_height = FRAME_HEIGHT (f); */ 5757 config->frame_height = FRAME_HEIGHT (f); */
5580 config->current_window = FRAME_SELECTED_WINDOW (f); 5758 /* When using `push-window-configuration', often the minibuffer ends
5759 up as the selected window because functions run as the result of
5760 user interaction e.g. hyper-apropos. It seems to me the sensible
5761 thing to do is not record the minibuffer here. */
5762 if (FRAME_MINIBUF_ONLY_P (f) || minibuf_level)
5763 config->current_window = FRAME_SELECTED_WINDOW (f);
5764 else
5765 config->current_window = FRAME_LAST_NONMINIBUF_WINDOW (f);
5581 XSETBUFFER (config->current_buffer, current_buffer); 5766 XSETBUFFER (config->current_buffer, current_buffer);
5582 config->minibuffer_scroll_window = Vminibuffer_scroll_window; 5767 config->minibuffer_scroll_window = Vminibuffer_scroll_window;
5583 config->root_window = FRAME_ROOT_WINDOW (f); 5768 config->root_window = FRAME_ROOT_WINDOW (f);
5584 config->min_height = window_min_height; 5769 config->min_height = window_min_height;
5585 config->min_width = window_min_width; 5770 config->min_width = window_min_width;
5687 found_bufpos: 5872 found_bufpos:
5688 ; 5873 ;
5689 } 5874 }
5690 else 5875 else
5691 { 5876 {
5692 /* optimised case */ 5877 /* optimized case */
5693 dl = Dynarr_atp (dla, y); 5878 dl = Dynarr_atp (dla, y);
5694 db = get_display_block_from_line (dl, TEXT); 5879 db = get_display_block_from_line (dl, TEXT);
5695 5880
5696 if (x >= Dynarr_length (db->runes)) 5881 if (x >= Dynarr_length (db->runes))
5697 return Qnil; 5882 return Qnil;
5715 5900
5716 if (NILP (child)) 5901 if (NILP (child))
5717 child = Fwindow_first_hchild (window); 5902 child = Fwindow_first_hchild (window);
5718 5903
5719 for (i = level; i > 0; i--) 5904 for (i = level; i > 0; i--)
5720 putc ('\t', stderr); 5905 stderr_out ("\t");
5721 5906
5722 fputs ("#<window", stderr); 5907 stderr_out ("#<window");
5723 { 5908 {
5724 Lisp_Object buffer = XWINDOW (window)->buffer; 5909 Lisp_Object buffer = XWINDOW (window)->buffer;
5725 if (!NILP (buffer) && BUFFERP (buffer)) 5910 if (!NILP (buffer) && BUFFERP (buffer))
5726 fprintf (stderr, " on %s", XSTRING_DATA (XBUFFER (buffer)->name)); 5911 stderr_out (" on %s", XSTRING_DATA (XBUFFER (buffer)->name));
5727 } 5912 }
5728 fprintf (stderr, " 0x%x>", XWINDOW (window)->header.uid); 5913 stderr_out (" 0x%x>", XWINDOW (window)->header.uid);
5729 5914
5730 while (!NILP (child)) 5915 while (!NILP (child))
5731 { 5916 {
5732 debug_print_window (child, level + 1); 5917 debug_print_window (child, level + 1);
5733 child = Fwindow_next_child (child); 5918 child = Fwindow_next_child (child);
5749 /************************************************************************/ 5934 /************************************************************************/
5750 5935
5751 void 5936 void
5752 syms_of_window (void) 5937 syms_of_window (void)
5753 { 5938 {
5939 INIT_LRECORD_IMPLEMENTATION (window);
5940 INIT_LRECORD_IMPLEMENTATION (window_configuration);
5941
5754 defsymbol (&Qwindowp, "windowp"); 5942 defsymbol (&Qwindowp, "windowp");
5755 defsymbol (&Qwindow_live_p, "window-live-p"); 5943 defsymbol (&Qwindow_live_p, "window-live-p");
5756 defsymbol (&Qwindow_configurationp, "window-configuration-p"); 5944 defsymbol (&Qwindow_configurationp, "window-configuration-p");
5757 defsymbol (&Qtemp_buffer_show_hook, "temp-buffer-show-hook"); 5945 defsymbol (&Qtemp_buffer_show_hook, "temp-buffer-show-hook");
5758 defsymbol (&Qdisplay_buffer, "display-buffer"); 5946 defsymbol (&Qdisplay_buffer, "display-buffer");
5788 DEFSUBR (Fwindow_buffer); 5976 DEFSUBR (Fwindow_buffer);
5789 DEFSUBR (Fwindow_frame); 5977 DEFSUBR (Fwindow_frame);
5790 DEFSUBR (Fwindow_height); 5978 DEFSUBR (Fwindow_height);
5791 DEFSUBR (Fwindow_displayed_height); 5979 DEFSUBR (Fwindow_displayed_height);
5792 DEFSUBR (Fwindow_width); 5980 DEFSUBR (Fwindow_width);
5981 DEFSUBR (Fwindow_full_width);
5793 DEFSUBR (Fwindow_pixel_height); 5982 DEFSUBR (Fwindow_pixel_height);
5794 DEFSUBR (Fwindow_pixel_width); 5983 DEFSUBR (Fwindow_pixel_width);
5984 DEFSUBR (Fwindow_text_area_height);
5795 DEFSUBR (Fwindow_text_area_pixel_height); 5985 DEFSUBR (Fwindow_text_area_pixel_height);
5796 DEFSUBR (Fwindow_displayed_text_pixel_height); 5986 DEFSUBR (Fwindow_displayed_text_pixel_height);
5797 DEFSUBR (Fwindow_text_area_pixel_width); 5987 DEFSUBR (Fwindow_text_area_pixel_width);
5798 DEFSUBR (Fwindow_hscroll); 5988 DEFSUBR (Fwindow_hscroll);
5799 DEFSUBR (Fset_window_hscroll); 5989 DEFSUBR (Fset_window_hscroll);
5806 DEFSUBR (Fwindow_pixel_edges); 5996 DEFSUBR (Fwindow_pixel_edges);
5807 DEFSUBR (Fwindow_text_area_pixel_edges); 5997 DEFSUBR (Fwindow_text_area_pixel_edges);
5808 DEFSUBR (Fwindow_point); 5998 DEFSUBR (Fwindow_point);
5809 DEFSUBR (Fwindow_start); 5999 DEFSUBR (Fwindow_start);
5810 DEFSUBR (Fwindow_end); 6000 DEFSUBR (Fwindow_end);
6001 DEFSUBR (Fwindow_last_line_visible_height);
5811 DEFSUBR (Fset_window_point); 6002 DEFSUBR (Fset_window_point);
5812 DEFSUBR (Fset_window_start); 6003 DEFSUBR (Fset_window_start);
5813 DEFSUBR (Fwindow_dedicated_p); 6004 DEFSUBR (Fwindow_dedicated_p);
5814 DEFSUBR (Fset_window_dedicated_p); 6005 DEFSUBR (Fset_window_dedicated_p);
5815 DEFSUBR (Fnext_window); 6006 DEFSUBR (Fnext_window);
5886 Non-nil means call as function to display a help buffer. 6077 Non-nil means call as function to display a help buffer.
5887 The function is called with one argument, the buffer to be displayed. 6078 The function is called with one argument, the buffer to be displayed.
5888 Used by `with-output-to-temp-buffer'. 6079 Used by `with-output-to-temp-buffer'.
5889 If this function is used, then it must do the entire job of showing 6080 If this function is used, then it must do the entire job of showing
5890 the buffer; `temp-buffer-show-hook' is not run unless this function runs it. 6081 the buffer; `temp-buffer-show-hook' is not run unless this function runs it.
6082 \(`temp-buffer-show-hook' is obsolete. Do not use in new code.)
5891 */ ); 6083 */ );
5892 Vtemp_buffer_show_function = Qnil; 6084 Vtemp_buffer_show_function = Qnil;
5893 6085
5894 DEFVAR_LISP ("minibuffer-scroll-window", &Vminibuffer_scroll_window /* 6086 DEFVAR_LISP ("minibuffer-scroll-window", &Vminibuffer_scroll_window /*
5895 Non-nil means it is the window that \\<minibuffer-local-map>\\[scroll-other-window] in minibuffer should scroll. 6087 Non-nil means it is the window that \\<minibuffer-local-map>\\[scroll-other-window] in minibuffer should scroll.