comparison src/window.c @ 288:e11d67e05968 r21-0b42

Import from CVS: tag r21-0b42
author cvs
date Mon, 13 Aug 2007 10:35:54 +0200
parents 57709be46d1b
children 70ad99077275
comparison
equal deleted inserted replaced
287:13a0bd77a29d 288:e11d67e05968
1305 (window)) 1305 (window))
1306 { 1306 {
1307 return make_int (decode_window (window)->pixel_height); 1307 return make_int (decode_window (window)->pixel_height);
1308 } 1308 }
1309 1309
1310 DEFUN ("window-text-pixel-height", Fwindow_text_pixel_height, 0, 1, 0, /* 1310 DEFUN ("window-text-area-pixel-height",
1311 Fwindow_text_area_pixel_height, 0, 1, 0, /*
1311 Return the height in pixels of the text-displaying portion of WINDOW. 1312 Return the height in pixels of the text-displaying portion of WINDOW.
1312 Unlike `window-pixel-height', the space occupied by the modeline and 1313 Unlike `window-pixel-height', the space occupied by the modeline and
1313 horizontal scrollbar, if any, is not counted. 1314 horizontal scrollbar, if any, is not counted.
1314 */ 1315 */
1315 (window)) 1316 (window))
1317 struct window *w = decode_window (window); 1318 struct window *w = decode_window (window);
1318 1319
1319 return make_int (WINDOW_TEXT_HEIGHT (w)); 1320 return make_int (WINDOW_TEXT_HEIGHT (w));
1320 } 1321 }
1321 1322
1323 DEFUN ("window-displayed-text-pixel-height",
1324 Fwindow_displayed_text_pixel_height, 0, 2, 0, /*
1325 Return the height in pixels of the text displayed in WINDOW.
1326 Unlike `window-text-area-pixel-height', any blank space below the
1327 end of the buffer is not included. If optional argument NOCLIPPED
1328 is non-nil, do not include space occupied by clipped lines.
1329 */
1330 (window, noclipped))
1331 {
1332 struct window *w;
1333 Bufpos start, eobuf;
1334 int defheight;
1335 int hlimit, height, prev_height = -1;
1336 int line;
1337 int elt, nelt, i;
1338 int needed;
1339 line_start_cache_dynarr *cache;
1340
1341 if (NILP (window))
1342 window = Fselected_window (Qnil);
1343
1344 CHECK_WINDOW (window);
1345 w = XWINDOW (window);
1346
1347 start = marker_position (w->start[CURRENT_DISP]);
1348 hlimit = WINDOW_TEXT_HEIGHT (w);
1349 eobuf = BUF_ZV (XBUFFER (w->buffer));
1350
1351 default_face_height_and_width (window, &defheight, NULL);
1352
1353 /* guess lines needed in line start cache + a few extra */
1354 needed = (hlimit + defheight-1) / defheight + 3;
1355
1356 while (1) {
1357 elt = point_in_line_start_cache (w, start, needed);
1358 assert (elt >= 0); /* in the cache */
1359
1360 cache = w->line_start_cache;
1361 nelt = Dynarr_length (cache);
1362
1363 height = 0;
1364 for (i = elt; i < nelt; i++) {
1365 line = Dynarr_atp (cache, i)->height;
1366
1367 if (height + line > hlimit)
1368 return make_int (!NILP (noclipped) ? height : hlimit);
1369
1370 height += line;
1371
1372 if (height == hlimit || Dynarr_atp (cache, i)->end >= eobuf)
1373 return make_int (height);
1374 }
1375
1376 /* get here => need more cache lines. try again. */
1377 assert(height > prev_height); /* progress? */
1378 prev_height = height;
1379
1380 needed += ((hlimit - height)*(nelt - elt) + height-1)/height + 3;
1381 }
1382
1383 RETURN_NOT_REACHED(make_int (0)) /* shut up compiler */
1384 }
1385
1322 DEFUN ("window-width", Fwindow_width, 0, 1, 0, /* 1386 DEFUN ("window-width", Fwindow_width, 0, 1, 0, /*
1323 Return the number of display columns in WINDOW. 1387 Return the number of display columns in WINDOW.
1324 This is the width that is usable columns available for text in WINDOW. 1388 This is the width that is usable columns available for text in WINDOW.
1325 */ 1389 */
1326 (window)) 1390 (window))
1334 (window)) 1398 (window))
1335 { 1399 {
1336 return make_int (decode_window (window)->pixel_width); 1400 return make_int (decode_window (window)->pixel_width);
1337 } 1401 }
1338 1402
1339 DEFUN ("window-text-pixel-width", Fwindow_text_pixel_width, 0, 1, 0, /* 1403 DEFUN ("window-text-area-pixel-width",
1404 Fwindow_text_area_pixel_width, 0, 1, 0, /*
1340 Return the width in pixels of the text-displaying portion of WINDOW. 1405 Return the width in pixels of the text-displaying portion of WINDOW.
1341 Unlike `window-pixel-width', the space occupied by the vertical 1406 Unlike `window-pixel-width', the space occupied by the vertical
1342 scrollbar or divider, if any, is not counted. 1407 scrollbar or divider, if any, is not counted.
1343 */ 1408 */
1344 (window)) 1409 (window))
1456 make_int (top), 1521 make_int (top),
1457 make_int (left + w->pixel_width), 1522 make_int (left + w->pixel_width),
1458 make_int (top + w->pixel_height)); 1523 make_int (top + w->pixel_height));
1459 } 1524 }
1460 1525
1461 DEFUN ("window-text-pixel-edges", Fwindow_text_pixel_edges, 0, 1, 0, /* 1526 DEFUN ("window-text-area-pixel-edges",
1527 Fwindow_text_area_pixel_edges, 0, 1, 0, /*
1462 Return a list of the pixel edge coordinates of the text area of WINDOW. 1528 Return a list of the pixel edge coordinates of the text area of WINDOW.
1463 Returns the list \(LEFT TOP RIGHT BOTTOM), all relative to 0, 0 at the 1529 Returns the list \(LEFT TOP RIGHT BOTTOM), all relative to 0, 0 at the
1464 top left corner of the window. 1530 top left corner of the window.
1465 */ 1531 */
1466 (window)) 1532 (window))
3893 completely documented the behavior of the scrolling functions under 3959 completely documented the behavior of the scrolling functions under
3894 all circumstances. */ 3960 all circumstances. */
3895 tem = Fpos_visible_in_window_p (point, window); 3961 tem = Fpos_visible_in_window_p (point, window);
3896 if (NILP (tem)) 3962 if (NILP (tem))
3897 { 3963 {
3898 Fvertical_motion (make_int (-window_char_height (w, 0) / 2), window); 3964 Fvertical_motion (make_int (-window_char_height (w, 0) / 2),
3965 window, Qnil);
3899 Fset_marker (w->start[CURRENT_DISP], point, w->buffer); 3966 Fset_marker (w->start[CURRENT_DISP], point, w->buffer);
3900 w->start_at_line_beg = beginning_of_line_p (b, XINT (point)); 3967 w->start_at_line_beg = beginning_of_line_p (b, XINT (point));
3901 MARK_WINDOWS_CHANGED (w); 3968 MARK_WINDOWS_CHANGED (w);
3902 } 3969 }
3903 3970
4315 else 4382 else
4316 Fset_window_point (window, make_int (start)); 4383 Fset_window_point (window, make_int (start));
4317 } 4384 }
4318 4385
4319 if (selected) 4386 if (selected)
4320 return Fvertical_motion (arg, window); 4387 return Fvertical_motion (arg, window, Qnil);
4321 else 4388 else
4322 { 4389 {
4323 int vpos; 4390 int vpos;
4324 new_point = vmotion (XWINDOW (window), 4391 new_point = vmotion (XWINDOW (window),
4325 marker_position (w->pointm[CURRENT_DISP]), 4392 marker_position (w->pointm[CURRENT_DISP]),
5386 DEFSUBR (Fwindow_height); 5453 DEFSUBR (Fwindow_height);
5387 DEFSUBR (Fwindow_displayed_height); 5454 DEFSUBR (Fwindow_displayed_height);
5388 DEFSUBR (Fwindow_width); 5455 DEFSUBR (Fwindow_width);
5389 DEFSUBR (Fwindow_pixel_height); 5456 DEFSUBR (Fwindow_pixel_height);
5390 DEFSUBR (Fwindow_pixel_width); 5457 DEFSUBR (Fwindow_pixel_width);
5391 DEFSUBR (Fwindow_text_pixel_height); 5458 DEFSUBR (Fwindow_text_area_pixel_height);
5392 DEFSUBR (Fwindow_text_pixel_width); 5459 DEFSUBR (Fwindow_displayed_text_pixel_height);
5460 DEFSUBR (Fwindow_text_area_pixel_width);
5393 DEFSUBR (Fwindow_hscroll); 5461 DEFSUBR (Fwindow_hscroll);
5394 #ifdef MODELINE_IS_SCROLLABLE 5462 #ifdef MODELINE_IS_SCROLLABLE
5395 DEFSUBR (Fmodeline_hscroll); 5463 DEFSUBR (Fmodeline_hscroll);
5396 DEFSUBR (Fset_modeline_hscroll); 5464 DEFSUBR (Fset_modeline_hscroll);
5397 #endif /* MODELINE_IS_SCROLLABLE */ 5465 #endif /* MODELINE_IS_SCROLLABLE */
5399 DEFSUBR (Fwindow_redisplay_end_trigger); 5467 DEFSUBR (Fwindow_redisplay_end_trigger);
5400 DEFSUBR (Fset_window_redisplay_end_trigger); 5468 DEFSUBR (Fset_window_redisplay_end_trigger);
5401 #endif 5469 #endif
5402 DEFSUBR (Fset_window_hscroll); 5470 DEFSUBR (Fset_window_hscroll);
5403 DEFSUBR (Fwindow_pixel_edges); 5471 DEFSUBR (Fwindow_pixel_edges);
5404 DEFSUBR (Fwindow_text_pixel_edges); 5472 DEFSUBR (Fwindow_text_area_pixel_edges);
5405 DEFSUBR (Fwindow_point); 5473 DEFSUBR (Fwindow_point);
5406 DEFSUBR (Fwindow_start); 5474 DEFSUBR (Fwindow_start);
5407 DEFSUBR (Fwindow_end); 5475 DEFSUBR (Fwindow_end);
5408 DEFSUBR (Fset_window_point); 5476 DEFSUBR (Fset_window_point);
5409 DEFSUBR (Fset_window_start); 5477 DEFSUBR (Fset_window_start);