diff options
| author | Gerd Moellmann | 2001-02-19 16:43:09 +0000 |
|---|---|---|
| committer | Gerd Moellmann | 2001-02-19 16:43:09 +0000 |
| commit | 8b6ea97f85693986b8222789d320d21754186f3e (patch) | |
| tree | 646c3e1fd8f37c0799c81fc69eee7525162f1b1e /src | |
| parent | 5be57d49654722c9c4886008506e35b808764b7c (diff) | |
| download | emacs-8b6ea97f85693986b8222789d320d21754186f3e.tar.gz emacs-8b6ea97f85693986b8222789d320d21754186f3e.zip | |
(line_bottom_y): New function extracted from
pos_visible_p.
(pos_visible_p): Use it.
Diffstat (limited to 'src')
| -rw-r--r-- | src/xdisp.c | 76 |
1 files changed, 46 insertions, 30 deletions
diff --git a/src/xdisp.c b/src/xdisp.c index b1270776eaf..4ff296d0959 100644 --- a/src/xdisp.c +++ b/src/xdisp.c | |||
| @@ -976,6 +976,46 @@ window_box_edges (w, area, top_left_x, top_left_y, | |||
| 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 |
| @@ -1021,40 +1061,16 @@ pos_visible_p (w, charpos, fully, exact_mode_line_heights_p) | |||
| 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) |