comparison src/xdisp.c @ 36201:32505f3d0441

(line_bottom_y): New function extracted from pos_visible_p. (pos_visible_p): Use it.
author Gerd Moellmann <gerd@gnu.org>
date Mon, 19 Feb 2001 16:43:09 +0000
parents be25f9e946fb
children aced2f7101b9
comparison
equal deleted inserted replaced
36200:ede1d6e9b322 36201:32505f3d0441
974 974
975 /*********************************************************************** 975 /***********************************************************************
976 Utilities 976 Utilities
977 ***********************************************************************/ 977 ***********************************************************************/
978 978
979 /* Return the bottom y-position of the line the iterator IT is in.
980 This can modify IT's settings. */
981
982 int
983 line_bottom_y (it)
984 struct it *it;
985 {
986 int line_height = it->max_ascent + it->max_descent;
987 int line_top_y = it->current_y;
988
989 if (line_height == 0)
990 {
991 if (last_height)
992 line_height = last_height;
993 else if (IT_CHARPOS (*it) < ZV)
994 {
995 move_it_by_lines (it, 1, 1);
996 line_height = (it->max_ascent || it->max_descent
997 ? it->max_ascent + it->max_descent
998 : last_height);
999 }
1000 else
1001 {
1002 struct glyph_row *row = it->glyph_row;
1003
1004 /* Use the default character height. */
1005 it->glyph_row = NULL;
1006 it->what = IT_CHARACTER;
1007 it->c = ' ';
1008 it->len = 1;
1009 PRODUCE_GLYPHS (it);
1010 line_height = it->ascent + it->descent;
1011 it->glyph_row = row;
1012 }
1013 }
1014
1015 return line_top_y + line_height;
1016 }
1017
1018
979 /* Return 1 if position CHARPOS is visible in window W. Set *FULLY to 1019 /* Return 1 if position CHARPOS is visible in window W. Set *FULLY to
980 1 if POS is visible and the line containing POS is fully visible. 1020 1 if POS is visible and the line containing POS is fully visible.
981 EXACT_MODE_LINE_HEIGHTS_P non-zero means compute exact mode-line 1021 EXACT_MODE_LINE_HEIGHTS_P non-zero means compute exact mode-line
982 and header-lines heights. */ 1022 and header-lines heights. */
983 1023
1019 MOVE_TO_POS | MOVE_TO_X | MOVE_TO_Y); 1059 MOVE_TO_POS | MOVE_TO_X | MOVE_TO_Y);
1020 1060
1021 /* Note that we may overshoot because of invisible text. */ 1061 /* Note that we may overshoot because of invisible text. */
1022 if (IT_CHARPOS (it) >= charpos) 1062 if (IT_CHARPOS (it) >= charpos)
1023 { 1063 {
1024 int line_height, line_bottom_y; 1064 int top_y = it.current_y;
1025 int line_top_y = it.current_y; 1065 int bottom_y = line_bottom_y (&it);
1026 int window_top_y = WINDOW_DISPLAY_HEADER_LINE_HEIGHT (w); 1066 int window_top_y = WINDOW_DISPLAY_HEADER_LINE_HEIGHT (w);
1027 1067
1028 line_height = it.max_ascent + it.max_descent; 1068 if (top_y < window_top_y)
1029 if (line_height == 0) 1069 visible_p = bottom_y > window_top_y;
1030 { 1070 else if (top_y < it.last_visible_y)
1031 if (last_height)
1032 line_height = last_height;
1033 else if (charpos < ZV)
1034 {
1035 move_it_by_lines (&it, 1, 1);
1036 line_height = (it.max_ascent || it.max_descent
1037 ? it.max_ascent + it.max_descent
1038 : last_height);
1039 }
1040 else
1041 {
1042 /* Use the default character height. */
1043 it.what = IT_CHARACTER;
1044 it.c = ' ';
1045 it.len = 1;
1046 PRODUCE_GLYPHS (&it);
1047 line_height = it.ascent + it.descent;
1048 }
1049 }
1050 line_bottom_y = line_top_y + line_height;
1051
1052 if (line_top_y < window_top_y)
1053 visible_p = line_bottom_y > window_top_y;
1054 else if (line_top_y < it.last_visible_y)
1055 { 1071 {
1056 visible_p = 1; 1072 visible_p = 1;
1057 *fully = line_bottom_y <= it.last_visible_y; 1073 *fully = bottom_y <= it.last_visible_y;
1058 } 1074 }
1059 } 1075 }
1060 else if (it.current_y + it.max_ascent + it.max_descent > it.last_visible_y) 1076 else if (it.current_y + it.max_ascent + it.max_descent > it.last_visible_y)
1061 { 1077 {
1062 move_it_by_lines (&it, 1, 0); 1078 move_it_by_lines (&it, 1, 0);