Mercurial > emacs
comparison src/window.c @ 90602:b5c13d1564a9
Merge from emacs--devo--0
Patches applied:
* emacs--devo--0 (patch 437-446)
- Update from CVS
- lisp/url/url-methods.el: Fix format error when http_proxy is empty string
- Merge from gnus--rel--5.10
* gnus--rel--5.10 (patch 137-140)
- Update from CVS
Revision: emacs@sv.gnu.org/emacs--unicode--0--patch-111
author | Miles Bader <miles@gnu.org> |
---|---|
date | Wed, 20 Sep 2006 06:04:23 +0000 |
parents | 84dd84b43e1b 79ada95d4018 |
children | bb0e318b7c53 |
comparison
equal
deleted
inserted
replaced
90601:a1a25ac6c88a | 90602:b5c13d1564a9 |
---|---|
338 If POS is visible, return t if PARTIALLY is nil; if PARTIALLY is non-nil, | 338 If POS is visible, return t if PARTIALLY is nil; if PARTIALLY is non-nil, |
339 return value is a list of 2 or 6 elements (X Y [RTOP RBOT ROWH VPOS]), | 339 return value is a list of 2 or 6 elements (X Y [RTOP RBOT ROWH VPOS]), |
340 where X and Y are the pixel coordinates relative to the top left corner | 340 where X and Y are the pixel coordinates relative to the top left corner |
341 of the window. The remaining elements are omitted if the character after | 341 of the window. The remaining elements are omitted if the character after |
342 POS is fully visible; otherwise, RTOP and RBOT are the number of pixels | 342 POS is fully visible; otherwise, RTOP and RBOT are the number of pixels |
343 invisible at the top and bottom of the row, ROWH is the height of the display | 343 off-screen at the top and bottom of the row, ROWH is the height of the |
344 row, and VPOS is the row number (0-based) containing POS. */) | 344 display row, and VPOS is the row number (0-based) containing POS. */) |
345 (pos, window, partially) | 345 (pos, window, partially) |
346 Lisp_Object pos, window, partially; | 346 Lisp_Object pos, window, partially; |
347 { | 347 { |
348 register struct window *w; | 348 register struct window *w; |
349 register int posint; | 349 register int posint; |
388 } | 388 } |
389 | 389 |
390 return in_window; | 390 return in_window; |
391 } | 391 } |
392 | 392 |
393 DEFUN ("window-line-height", Fwindow_line_height, | |
394 Swindow_line_height, 0, 2, 0, | |
395 doc: /* Return height in pixels of text line LINE in window WINDOW. | |
396 If WINDOW is nil or omitted, use selected window. | |
397 | |
398 Return height of current line if LINE is omitted or nil. Return height of | |
399 header or mode line if LINE is `header-line' and `mode-line'. | |
400 Otherwise, LINE is a text line number starting from 0. A negative number | |
401 counts from the end of the window. | |
402 | |
403 Value is a list (HEIGHT VPOS YPOS OFFBOT), where HEIGHT is the height | |
404 in pixels of the visible part of the line, VPOS and YPOS are the | |
405 vertical position in lines and pixels of the row, relative to the top | |
406 of the first text line, and OFFBOT is the number of off-screen pixels at | |
407 the bottom of the text row. If there are off-screen pixels at the top | |
408 of the (first) text row, YPOS is negative. | |
409 | |
410 Return nil if window display is not up-to-date. In that case, use | |
411 `pos-visible-in-window-p' to obtain the information. */) | |
412 (line, window) | |
413 Lisp_Object line, window; | |
414 { | |
415 register struct window *w; | |
416 register struct buffer *b; | |
417 struct glyph_row *row, *end_row; | |
418 int max_y, crop, i, n; | |
419 | |
420 w = decode_window (window); | |
421 | |
422 if (noninteractive | |
423 || w->pseudo_window_p) | |
424 return Qnil; | |
425 | |
426 CHECK_BUFFER (w->buffer); | |
427 b = XBUFFER (w->buffer); | |
428 | |
429 /* Fail if current matrix is not up-to-date. */ | |
430 if (NILP (w->window_end_valid) | |
431 || current_buffer->clip_changed | |
432 || current_buffer->prevent_redisplay_optimizations_p | |
433 || XFASTINT (w->last_modified) < BUF_MODIFF (b) | |
434 || XFASTINT (w->last_overlay_modified) < BUF_OVERLAY_MODIFF (b)) | |
435 return Qnil; | |
436 | |
437 if (NILP (line)) | |
438 { | |
439 i = w->cursor.vpos; | |
440 if (i < 0 || i >= w->current_matrix->nrows | |
441 || (row = MATRIX_ROW (w->current_matrix, i), !row->enabled_p)) | |
442 return Qnil; | |
443 max_y = window_text_bottom_y (w); | |
444 goto found_row; | |
445 } | |
446 | |
447 if (EQ (line, Qheader_line)) | |
448 { | |
449 if (!WINDOW_WANTS_HEADER_LINE_P (w)) | |
450 return Qnil; | |
451 row = MATRIX_HEADER_LINE_ROW (w->current_matrix); | |
452 if (!row->enabled_p) | |
453 return Qnil; | |
454 return list4 (make_number (row->height), | |
455 make_number (0), make_number (0), | |
456 make_number (0)); | |
457 } | |
458 | |
459 if (EQ (line, Qmode_line)) | |
460 { | |
461 row = MATRIX_MODE_LINE_ROW (w->current_matrix); | |
462 if (!row->enabled_p) | |
463 return Qnil; | |
464 return list4 (make_number (row->height), | |
465 make_number (0), /* not accurate */ | |
466 make_number (WINDOW_HEADER_LINE_HEIGHT (w) | |
467 + window_text_bottom_y (w)), | |
468 make_number (0)); | |
469 } | |
470 | |
471 CHECK_NUMBER (line); | |
472 n = XINT (line); | |
473 | |
474 row = MATRIX_FIRST_TEXT_ROW (w->current_matrix); | |
475 end_row = MATRIX_BOTTOM_TEXT_ROW (w->current_matrix, w); | |
476 max_y = window_text_bottom_y (w); | |
477 i = 0; | |
478 | |
479 while ((n < 0 || i < n) | |
480 && row <= end_row && row->enabled_p | |
481 && row->y + row->height < max_y) | |
482 row++, i++; | |
483 | |
484 if (row > end_row || !row->enabled_p) | |
485 return Qnil; | |
486 | |
487 if (++n < 0) | |
488 { | |
489 if (-n > i) | |
490 return Qnil; | |
491 row += n; | |
492 i += n; | |
493 } | |
494 | |
495 found_row: | |
496 crop = max (0, (row->y + row->height) - max_y); | |
497 return list4 (make_number (row->height + min (0, row->y) - crop), | |
498 make_number (i), | |
499 make_number (row->y), | |
500 make_number (crop)); | |
501 } | |
502 | |
503 | |
393 | 504 |
394 static struct window * | 505 static struct window * |
395 decode_window (window) | 506 decode_window (window) |
396 register Lisp_Object window; | 507 register Lisp_Object window; |
397 { | 508 { |
452 DEFUN ("set-window-hscroll", Fset_window_hscroll, Sset_window_hscroll, 2, 2, 0, | 563 DEFUN ("set-window-hscroll", Fset_window_hscroll, Sset_window_hscroll, 2, 2, 0, |
453 doc: /* Set number of columns WINDOW is scrolled from left margin to NCOL. | 564 doc: /* Set number of columns WINDOW is scrolled from left margin to NCOL. |
454 Return NCOL. NCOL should be zero or positive. | 565 Return NCOL. NCOL should be zero or positive. |
455 | 566 |
456 Note that if `automatic-hscrolling' is non-nil, you cannot scroll the | 567 Note that if `automatic-hscrolling' is non-nil, you cannot scroll the |
457 window so that the location of point becomes invisible. */) | 568 window so that the location of point moves off-screen. */) |
458 (window, ncol) | 569 (window, ncol) |
459 Lisp_Object window, ncol; | 570 Lisp_Object window, ncol; |
460 { | 571 { |
461 struct window *w = decode_window (window); | 572 struct window *w = decode_window (window); |
462 int hscroll; | 573 int hscroll; |
1049 Lisp_Object window, update; | 1160 Lisp_Object window, update; |
1050 { | 1161 { |
1051 Lisp_Object value; | 1162 Lisp_Object value; |
1052 struct window *w = decode_window (window); | 1163 struct window *w = decode_window (window); |
1053 Lisp_Object buf; | 1164 Lisp_Object buf; |
1165 struct buffer *b; | |
1054 | 1166 |
1055 buf = w->buffer; | 1167 buf = w->buffer; |
1056 CHECK_BUFFER (buf); | 1168 CHECK_BUFFER (buf); |
1169 b = XBUFFER (buf); | |
1057 | 1170 |
1058 #if 0 /* This change broke some things. We should make it later. */ | 1171 #if 0 /* This change broke some things. We should make it later. */ |
1059 /* If we don't know the end position, return nil. | 1172 /* If we don't know the end position, return nil. |
1060 The user can compute it with vertical-motion if he wants to. | 1173 The user can compute it with vertical-motion if he wants to. |
1061 It would be nicer to do it automatically, | 1174 It would be nicer to do it automatically, |
1064 return Qnil; | 1177 return Qnil; |
1065 #endif | 1178 #endif |
1066 | 1179 |
1067 if (! NILP (update) | 1180 if (! NILP (update) |
1068 && ! (! NILP (w->window_end_valid) | 1181 && ! (! NILP (w->window_end_valid) |
1069 && XFASTINT (w->last_modified) >= MODIFF) | 1182 && XFASTINT (w->last_modified) >= BUF_MODIFF (b)) |
1070 && !noninteractive) | 1183 && !noninteractive) |
1071 { | 1184 { |
1072 struct text_pos startp; | 1185 struct text_pos startp; |
1073 struct it it; | 1186 struct it it; |
1074 struct buffer *old_buffer = NULL, *b = XBUFFER (buf); | 1187 struct buffer *old_buffer = NULL; |
1188 | |
1189 /* Cannot use Fvertical_motion because that function doesn't | |
1190 cope with variable-height lines. */ | |
1191 if (b != current_buffer) | |
1192 { | |
1193 old_buffer = current_buffer; | |
1194 set_buffer_internal (b); | |
1195 } | |
1075 | 1196 |
1076 /* In case W->start is out of the range, use something | 1197 /* In case W->start is out of the range, use something |
1077 reasonable. This situation occurred when loading a file with | 1198 reasonable. This situation occurred when loading a file with |
1078 `-l' containing a call to `rmail' with subsequent other | 1199 `-l' containing a call to `rmail' with subsequent other |
1079 commands. At the end, W->start happened to be BEG, while | 1200 commands. At the end, W->start happened to be BEG, while |
1083 else if (XMARKER (w->start)->charpos > ZV) | 1204 else if (XMARKER (w->start)->charpos > ZV) |
1084 SET_TEXT_POS (startp, ZV, ZV_BYTE); | 1205 SET_TEXT_POS (startp, ZV, ZV_BYTE); |
1085 else | 1206 else |
1086 SET_TEXT_POS_FROM_MARKER (startp, w->start); | 1207 SET_TEXT_POS_FROM_MARKER (startp, w->start); |
1087 | 1208 |
1088 /* Cannot use Fvertical_motion because that function doesn't | |
1089 cope with variable-height lines. */ | |
1090 if (b != current_buffer) | |
1091 { | |
1092 old_buffer = current_buffer; | |
1093 set_buffer_internal (b); | |
1094 } | |
1095 | |
1096 start_display (&it, w, startp); | 1209 start_display (&it, w, startp); |
1097 move_it_vertically (&it, window_box_height (w)); | 1210 move_it_vertically (&it, window_box_height (w)); |
1098 if (it.current_y < it.last_visible_y) | 1211 if (it.current_y < it.last_visible_y) |
1099 move_it_past_eol (&it); | 1212 move_it_past_eol (&it); |
1100 value = make_number (IT_CHARPOS (it)); | 1213 value = make_number (IT_CHARPOS (it)); |
1101 | 1214 |
1102 if (old_buffer) | 1215 if (old_buffer) |
1103 set_buffer_internal (old_buffer); | 1216 set_buffer_internal (old_buffer); |
1104 } | 1217 } |
1105 else | 1218 else |
1106 XSETINT (value, BUF_Z (XBUFFER (buf)) - XFASTINT (w->window_end_pos)); | 1219 XSETINT (value, BUF_Z (b) - XFASTINT (w->window_end_pos)); |
1107 | 1220 |
1108 return value; | 1221 return value; |
1109 } | 1222 } |
1110 | 1223 |
1111 DEFUN ("set-window-point", Fset_window_point, Sset_window_point, 2, 2, 0, | 1224 DEFUN ("set-window-point", Fset_window_point, Sset_window_point, 2, 2, 0, |
7363 defsubr (&Sminibuffer_window); | 7476 defsubr (&Sminibuffer_window); |
7364 defsubr (&Swindow_minibuffer_p); | 7477 defsubr (&Swindow_minibuffer_p); |
7365 defsubr (&Swindowp); | 7478 defsubr (&Swindowp); |
7366 defsubr (&Swindow_live_p); | 7479 defsubr (&Swindow_live_p); |
7367 defsubr (&Spos_visible_in_window_p); | 7480 defsubr (&Spos_visible_in_window_p); |
7481 defsubr (&Swindow_line_height); | |
7368 defsubr (&Swindow_buffer); | 7482 defsubr (&Swindow_buffer); |
7369 defsubr (&Swindow_height); | 7483 defsubr (&Swindow_height); |
7370 defsubr (&Swindow_width); | 7484 defsubr (&Swindow_width); |
7371 defsubr (&Swindow_hscroll); | 7485 defsubr (&Swindow_hscroll); |
7372 defsubr (&Sset_window_hscroll); | 7486 defsubr (&Sset_window_hscroll); |