Mercurial > hg > xemacs-beta
comparison src/redisplay.c @ 361:7347b34c275b r21-1-10
Import from CVS: tag r21-1-10
author | cvs |
---|---|
date | Mon, 13 Aug 2007 10:58:40 +0200 |
parents | 8bec6624d99b |
children | a4f53d9b3154 |
comparison
equal
deleted
inserted
replaced
360:0f00b38cfccb | 361:7347b34c275b |
---|---|
1230 { | 1230 { |
1231 return add_octal_runes (data); | 1231 return add_octal_runes (data); |
1232 } | 1232 } |
1233 } | 1233 } |
1234 | 1234 |
1235 /* Given a display table entry, call the appropriate functions to | |
1236 display each element of the entry. */ | |
1237 | |
1238 static prop_block_dynarr * | 1235 static prop_block_dynarr * |
1239 add_disp_table_entry_runes (pos_data *data, Lisp_Object entry) | 1236 add_disp_table_entry_runes_1 (pos_data *data, Lisp_Object entry) |
1240 { | 1237 { |
1241 prop_block_dynarr *prop = NULL; | 1238 prop_block_dynarr *prop = NULL; |
1242 | 1239 |
1243 if (VECTORP (entry)) | 1240 if (STRINGP (entry)) |
1244 { | |
1245 struct Lisp_Vector *de = XVECTOR (entry); | |
1246 long len = vector_length (de); | |
1247 int elt; | |
1248 | |
1249 for (elt = 0; elt < len; elt++) | |
1250 { | |
1251 if (NILP (de->contents[elt])) | |
1252 continue; | |
1253 else if (STRINGP (de->contents[elt])) | |
1254 { | |
1255 prop = | |
1256 add_bufbyte_string_runes | |
1257 (data, | |
1258 XSTRING_DATA (de->contents[elt]), | |
1259 XSTRING_LENGTH (de->contents[elt]), | |
1260 0); | |
1261 } | |
1262 else if (GLYPHP (de->contents[elt])) | |
1263 { | |
1264 if (data->start_col) | |
1265 data->start_col--; | |
1266 | |
1267 if (!data->start_col && data->bi_start_col_enabled) | |
1268 { | |
1269 prop = add_hscroll_rune (data); | |
1270 } | |
1271 else | |
1272 { | |
1273 struct glyph_block gb; | |
1274 | |
1275 gb.glyph = de->contents[elt]; | |
1276 gb.extent = Qnil; | |
1277 prop = add_glyph_rune (data, &gb, BEGIN_GLYPHS, 0, 0); | |
1278 } | |
1279 } | |
1280 else if (CHAR_OR_CHAR_INTP (de->contents[elt])) | |
1281 { | |
1282 data->ch = XCHAR_OR_CHAR_INT (de->contents[elt]); | |
1283 prop = add_emchar_rune (data); | |
1284 } | |
1285 /* Else blow it off because someone added a bad entry and we | |
1286 don't have any safe way of signaling an error. */ | |
1287 | |
1288 /* #### Still need to add any remaining elements to the | |
1289 propagation information. */ | |
1290 if (prop) | |
1291 return prop; | |
1292 } | |
1293 } | |
1294 else if (STRINGP (entry)) | |
1295 { | 1241 { |
1296 prop = add_bufbyte_string_runes (data, | 1242 prop = add_bufbyte_string_runes (data, |
1297 XSTRING_DATA (entry), | 1243 XSTRING_DATA (entry), |
1298 XSTRING_LENGTH (entry), | 1244 XSTRING_LENGTH (entry), |
1299 0); | 1245 0); |
1319 else if (CHAR_OR_CHAR_INTP (entry)) | 1265 else if (CHAR_OR_CHAR_INTP (entry)) |
1320 { | 1266 { |
1321 data->ch = XCHAR_OR_CHAR_INT (entry); | 1267 data->ch = XCHAR_OR_CHAR_INT (entry); |
1322 prop = add_emchar_rune (data); | 1268 prop = add_emchar_rune (data); |
1323 } | 1269 } |
1270 else if (CONSP (entry)) | |
1271 { | |
1272 if (EQ (XCAR (entry), Qformat) | |
1273 && CONSP (XCDR (entry)) | |
1274 && STRINGP (XCAR (XCDR (entry)))) | |
1275 { | |
1276 Lisp_Object format = XCAR (XCDR (entry)); | |
1277 Bytind len = XSTRING_LENGTH (format); | |
1278 Bufbyte *src = XSTRING_DATA (format), *end = src + len; | |
1279 Bufbyte *result = alloca_array (Bufbyte, len); | |
1280 Bufbyte *dst = result; | |
1281 | |
1282 while (src < end) | |
1283 { | |
1284 Emchar c = charptr_emchar (src); | |
1285 INC_CHARPTR (src); | |
1286 if (c != '%' || src == end) | |
1287 dst += set_charptr_emchar (dst, c); | |
1288 else | |
1289 { | |
1290 c = charptr_emchar (src); | |
1291 INC_CHARPTR (src); | |
1292 switch (c) | |
1293 { | |
1294 /*case 'x': | |
1295 dst += long_to_string_base ((char *)dst, data->ch, 16); | |
1296 break;*/ | |
1297 case '%': | |
1298 dst += set_charptr_emchar (dst, '%'); | |
1299 break; | |
1300 } | |
1301 } | |
1302 } | |
1303 prop = add_bufbyte_string_runes (data, result, dst - result, 0); | |
1304 } | |
1305 } | |
1324 | 1306 |
1325 /* Else blow it off because someone added a bad entry and we don't | 1307 /* Else blow it off because someone added a bad entry and we don't |
1326 have any safe way of signaling an error. Hey, this comment | 1308 have any safe way of signaling an error. */ |
1327 sounds familiar. */ | 1309 return prop; |
1310 } | |
1311 | |
1312 /* Given a display table entry, call the appropriate functions to | |
1313 display each element of the entry. */ | |
1314 | |
1315 static prop_block_dynarr * | |
1316 add_disp_table_entry_runes (pos_data *data, Lisp_Object entry) | |
1317 { | |
1318 prop_block_dynarr *prop = NULL; | |
1319 if (VECTORP (entry)) | |
1320 { | |
1321 struct Lisp_Vector *de = XVECTOR (entry); | |
1322 EMACS_INT len = vector_length (de); | |
1323 int elt; | |
1324 | |
1325 for (elt = 0; elt < len; elt++) | |
1326 { | |
1327 if (NILP (vector_data (de)[elt])) | |
1328 continue; | |
1329 else | |
1330 prop = add_disp_table_entry_runes_1 (data, vector_data (de)[elt]); | |
1331 /* Else blow it off because someone added a bad entry and we | |
1332 don't have any safe way of signaling an error. Hey, this | |
1333 comment sounds familiar. */ | |
1334 | |
1335 /* #### Still need to add any remaining elements to the | |
1336 propagation information. */ | |
1337 if (prop) | |
1338 return prop; | |
1339 } | |
1340 } | |
1341 else | |
1342 prop = add_disp_table_entry_runes_1 (data, entry); | |
1328 return prop; | 1343 return prop; |
1329 } | 1344 } |
1330 | 1345 |
1331 /* Add runes which were propagated from the previous line. */ | 1346 /* Add runes which were propagated from the previous line. */ |
1332 | 1347 |
1748 struct frame *f = XFRAME (w->frame); | 1763 struct frame *f = XFRAME (w->frame); |
1749 struct buffer *b = XBUFFER (w->buffer); | 1764 struct buffer *b = XBUFFER (w->buffer); |
1750 struct device *d = XDEVICE (f->device); | 1765 struct device *d = XDEVICE (f->device); |
1751 | 1766 |
1752 pos_data data; | 1767 pos_data data; |
1753 struct Lisp_Vector *dt = 0; | |
1754 | 1768 |
1755 /* Don't display anything in the minibuffer if this window is not on | 1769 /* Don't display anything in the minibuffer if this window is not on |
1756 a selected frame. We consider all other windows to be active | 1770 a selected frame. We consider all other windows to be active |
1757 minibuffers as it simplifies the coding. */ | 1771 minibuffers as it simplifies the coding. */ |
1758 int active_minibuffer = (!MINI_WINDOW_P (w) || | 1772 int active_minibuffer = (!MINI_WINDOW_P (w) || |
1821 Emchar printable_min = (CHAR_OR_CHAR_INTP (b->ctl_arrow) | 1835 Emchar printable_min = (CHAR_OR_CHAR_INTP (b->ctl_arrow) |
1822 ? XCHAR_OR_CHAR_INT (b->ctl_arrow) | 1836 ? XCHAR_OR_CHAR_INT (b->ctl_arrow) |
1823 : ((EQ (b->ctl_arrow, Qt) || EQ (b->ctl_arrow, Qnil)) | 1837 : ((EQ (b->ctl_arrow, Qt) || EQ (b->ctl_arrow, Qnil)) |
1824 ? 255 : 160)); | 1838 ? 255 : 160)); |
1825 | 1839 |
1840 Lisp_Object face_dt, window_dt; | |
1841 | |
1826 /* The text display block for this display line. */ | 1842 /* The text display block for this display line. */ |
1827 struct display_block *db = get_display_block_from_line (dl, TEXT); | 1843 struct display_block *db = get_display_block_from_line (dl, TEXT); |
1828 | 1844 |
1829 /* The first time through the main loop we need to force the glyph | 1845 /* The first time through the main loop we need to force the glyph |
1830 data to be updated. */ | 1846 data to be updated. */ |
1959 /* Now compute the face and begin/end-glyph information. */ | 1975 /* Now compute the face and begin/end-glyph information. */ |
1960 data.findex = | 1976 data.findex = |
1961 /* Remember that the extent-fragment routines deal in Bytind's. */ | 1977 /* Remember that the extent-fragment routines deal in Bytind's. */ |
1962 extent_fragment_update (w, data.ef, data.bi_bufpos); | 1978 extent_fragment_update (w, data.ef, data.bi_bufpos); |
1963 | 1979 |
1980 get_display_tables (w, data.findex, &face_dt, &window_dt); | |
1981 | |
1964 if (data.bi_bufpos == data.ef->end) | 1982 if (data.bi_bufpos == data.ef->end) |
1965 no_more_frags = 1; | 1983 no_more_frags = 1; |
1966 | |
1967 dt = get_display_table (w, data.findex); | |
1968 } | 1984 } |
1969 initial = 0; | 1985 initial = 0; |
1970 | 1986 |
1971 /* Determine what is next to be displayed. We first handle any | 1987 /* Determine what is next to be displayed. We first handle any |
1972 glyphs returned by glyphs_at_bufpos. If there are no glyphs to | 1988 glyphs returned by glyphs_at_bufpos. If there are no glyphs to |
2074 else if (data.bi_bufpos == BI_BUF_ZV (b)) | 2090 else if (data.bi_bufpos == BI_BUF_ZV (b)) |
2075 goto done; | 2091 goto done; |
2076 | 2092 |
2077 else | 2093 else |
2078 { | 2094 { |
2095 Lisp_Object entry = Qnil; | |
2079 /* Get the character at the current buffer position. */ | 2096 /* Get the character at the current buffer position. */ |
2080 data.ch = BI_BUF_FETCH_CHAR (b, data.bi_bufpos); | 2097 data.ch = BI_BUF_FETCH_CHAR (b, data.bi_bufpos); |
2098 if (!NILP (face_dt) || !NILP (window_dt)) | |
2099 entry = display_table_entry (data.ch, face_dt, window_dt); | |
2081 | 2100 |
2082 /* If there is a display table entry for it, hand it off to | 2101 /* If there is a display table entry for it, hand it off to |
2083 add_disp_table_entry_runes and let it worry about it. */ | 2102 add_disp_table_entry_runes and let it worry about it. */ |
2084 if (dt && !NILP (DISP_CHAR_ENTRY (dt, data.ch))) | 2103 if (!NILP (entry) && !EQ (entry, make_char (data.ch))) |
2085 { | 2104 { |
2086 *prop = | 2105 *prop = add_disp_table_entry_runes (&data, entry); |
2087 add_disp_table_entry_runes (&data, | |
2088 DISP_CHAR_ENTRY (dt, data.ch)); | |
2089 | 2106 |
2090 if (*prop) | 2107 if (*prop) |
2091 goto done; | 2108 goto done; |
2092 } | 2109 } |
2093 | 2110 |
4228 Dynarr_add (prop, pb); | 4245 Dynarr_add (prop, pb); |
4229 } | 4246 } |
4230 else | 4247 else |
4231 prop = 0; | 4248 prop = 0; |
4232 | 4249 |
4250 /* Make sure this is set always */ | |
4251 /* Note the conversion at end */ | |
4252 w->window_end_pos[type] = start_pos; | |
4233 while (ypos < yend) | 4253 while (ypos < yend) |
4234 { | 4254 { |
4235 struct display_line dl; | 4255 struct display_line dl; |
4236 struct display_line *dlp; | 4256 struct display_line *dlp; |
4237 int local; | 4257 int local; |
4310 | 4330 |
4311 if (prop) | 4331 if (prop) |
4312 Dynarr_free (prop); | 4332 Dynarr_free (prop); |
4313 | 4333 |
4314 /* #### More not quite right, but close enough. */ | 4334 /* #### More not quite right, but close enough. */ |
4315 /* #### Ben sez: apparently window_end_pos[] is measured | 4335 /* Ben sez: apparently window_end_pos[] is measured |
4316 as the number of characters between the window end and the | 4336 as the number of characters between the window end and the |
4317 end of the buffer? This seems rather weirdo. What's | 4337 end of the buffer? This seems rather weirdo. What's |
4318 the justification for this? */ | 4338 the justification for this? |
4339 | |
4340 JV sez: Because BUF_Z (b) would be a good initial value, however | |
4341 that can change. This representation allows initalizing with 0. | |
4342 */ | |
4319 w->window_end_pos[type] = BUF_Z (b) - w->window_end_pos[type]; | 4343 w->window_end_pos[type] = BUF_Z (b) - w->window_end_pos[type]; |
4320 | 4344 |
4321 if (need_modeline) | 4345 if (need_modeline) |
4322 { | 4346 { |
4323 /* We know that this is the right thing to use because we put it | 4347 /* We know that this is the right thing to use because we put it |
6590 /* For the given window W, if display starts at STARTP, what will be | 6614 /* For the given window W, if display starts at STARTP, what will be |
6591 the buffer position at the beginning or end of the last line | 6615 the buffer position at the beginning or end of the last line |
6592 displayed. The end of the last line is also know as the window end | 6616 displayed. The end of the last line is also know as the window end |
6593 position. | 6617 position. |
6594 | 6618 |
6619 WARNING: Under some circumstances it is possible that rediplay failed | |
6620 to layout any lines for the windows. In that case this function returns | |
6621 0 as an error condition when may_error is non-zero and a normalized | |
6622 value of startp otherwise. | |
6623 Under normal circumstances this is rare. However it seems that it does | |
6624 occur in the following situation: A mouse event has come in and we need | |
6625 to compute its location in a window. That code (in | |
6626 pixel_to_glyph_translation) already can handle 0 as an error return | |
6627 value. | |
6628 | |
6595 #### With a little work this could probably be reworked as just a | 6629 #### With a little work this could probably be reworked as just a |
6596 call to start_with_line_at_pixpos. */ | 6630 call to start_with_line_at_pixpos. */ |
6597 | 6631 |
6598 static Bufpos | 6632 static Bufpos |
6599 start_end_of_last_line (struct window *w, Bufpos startp, int end) | 6633 start_end_of_last_line (struct window *w, Bufpos startp, int end, |
6634 int may_error) | |
6600 { | 6635 { |
6601 struct buffer *b = XBUFFER (w->buffer); | 6636 struct buffer *b = XBUFFER (w->buffer); |
6602 line_start_cache_dynarr *cache = w->line_start_cache; | 6637 line_start_cache_dynarr *cache = w->line_start_cache; |
6603 int pixpos = 0; | 6638 int pixpos = 0; |
6604 int bottom = WINDOW_TEXT_HEIGHT (w); | 6639 int bottom = WINDOW_TEXT_HEIGHT (w); |
6614 startp = BUF_ZV (b); | 6649 startp = BUF_ZV (b); |
6615 cur_start = startp; | 6650 cur_start = startp; |
6616 | 6651 |
6617 start_elt = point_in_line_start_cache (w, cur_start, 0); | 6652 start_elt = point_in_line_start_cache (w, cur_start, 0); |
6618 if (start_elt == -1) | 6653 if (start_elt == -1) |
6619 abort (); /* this had better never happen */ | 6654 return may_error ? 0 : startp; |
6620 | 6655 |
6621 while (1) | 6656 while (1) |
6622 { | 6657 { |
6623 int height = Dynarr_atp (cache, start_elt)->height; | 6658 int height = Dynarr_atp (cache, start_elt)->height; |
6624 | 6659 |
6625 cur_start = Dynarr_atp (cache, start_elt)->start; | 6660 cur_start = Dynarr_atp (cache, start_elt)->start; |
6678 the buffer position at the beginning of the last line displayed. */ | 6713 the buffer position at the beginning of the last line displayed. */ |
6679 | 6714 |
6680 Bufpos | 6715 Bufpos |
6681 start_of_last_line (struct window *w, Bufpos startp) | 6716 start_of_last_line (struct window *w, Bufpos startp) |
6682 { | 6717 { |
6683 return start_end_of_last_line (w, startp, 0); | 6718 return start_end_of_last_line (w, startp, 0 , 0); |
6684 } | 6719 } |
6685 | 6720 |
6686 /* For the given window W, if display starts at STARTP, what will be | 6721 /* For the given window W, if display starts at STARTP, what will be |
6687 the buffer position at the end of the last line displayed. This is | 6722 the buffer position at the end of the last line displayed. This is |
6688 also know as the window end position. */ | 6723 also know as the window end position. */ |
6689 | 6724 |
6690 Bufpos | 6725 Bufpos |
6691 end_of_last_line (struct window *w, Bufpos startp) | 6726 end_of_last_line (struct window *w, Bufpos startp) |
6692 { | 6727 { |
6693 return start_end_of_last_line (w, startp, 1); | 6728 return start_end_of_last_line (w, startp, 1, 0); |
6694 } | 6729 } |
6730 | |
6731 static Bufpos | |
6732 end_of_last_line_may_error (struct window *w, Bufpos startp) | |
6733 { | |
6734 return start_end_of_last_line (w, startp, 1, 1); | |
6735 } | |
6736 | |
6695 | 6737 |
6696 /* For window W, what does the starting position have to be so that | 6738 /* For window W, what does the starting position have to be so that |
6697 the line containing POINT will cover pixel position PIXPOS. */ | 6739 the line containing POINT will cover pixel position PIXPOS. */ |
6698 | 6740 |
6699 Bufpos | 6741 Bufpos |
7831 /* #### This should be checked out some more to determine what | 7873 /* #### This should be checked out some more to determine what |
7832 should really be going on. */ | 7874 should really be going on. */ |
7833 if (!MARKERP ((*w)->start[CURRENT_DISP])) | 7875 if (!MARKERP ((*w)->start[CURRENT_DISP])) |
7834 *closest = 0; | 7876 *closest = 0; |
7835 else | 7877 else |
7836 *closest = end_of_last_line (*w, | 7878 *closest = end_of_last_line_may_error (*w, |
7837 marker_position ((*w)->start[CURRENT_DISP])); | 7879 marker_position ((*w)->start[CURRENT_DISP])); |
7838 *col = 0; | 7880 *col = 0; |
7839 UPDATE_CACHE_RETURN; | 7881 UPDATE_CACHE_RETURN; |
7840 } | 7882 } |
7841 #undef UPDATE_CACHE_RETURN | 7883 #undef UPDATE_CACHE_RETURN |