Mercurial > emacs
comparison src/xdisp.c @ 107617:c5f9e4613394
Merge from mainline.
author | Eli Zaretskii <eliz@gnu.org> |
---|---|
date | Sat, 16 Jan 2010 06:57:09 -0500 |
parents | 937f2da537a4 731b62c1f5cb |
children | d615810795cd |
comparison
equal
deleted
inserted
replaced
107616:fa5ad3eee9f5 | 107617:c5f9e4613394 |
---|---|
1 /* Display generation from window structure and buffer text. | 1 /* Display generation from window structure and buffer text. |
2 Copyright (C) 1985, 1986, 1987, 1988, 1993, 1994, 1995, | 2 Copyright (C) 1985, 1986, 1987, 1988, 1993, 1994, 1995, |
3 1997, 1998, 1999, 2000, 2001, 2002, 2003, | 3 1997, 1998, 1999, 2000, 2001, 2002, 2003, |
4 2004, 2005, 2006, 2007, 2008, 2009, 2010 | 4 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. |
5 Free Software Foundation, Inc. | |
6 | 5 |
7 This file is part of GNU Emacs. | 6 This file is part of GNU Emacs. |
8 | 7 |
9 GNU Emacs is free software: you can redistribute it and/or modify | 8 GNU Emacs is free software: you can redistribute it and/or modify |
10 it under the terms of the GNU General Public License as published by | 9 it under the terms of the GNU General Public License as published by |
954 static int display_line P_ ((struct it *)); | 953 static int display_line P_ ((struct it *)); |
955 static int display_mode_lines P_ ((struct window *)); | 954 static int display_mode_lines P_ ((struct window *)); |
956 static int display_mode_line P_ ((struct window *, enum face_id, Lisp_Object)); | 955 static int display_mode_line P_ ((struct window *, enum face_id, Lisp_Object)); |
957 static int display_mode_element P_ ((struct it *, int, int, int, Lisp_Object, Lisp_Object, int)); | 956 static int display_mode_element P_ ((struct it *, int, int, int, Lisp_Object, Lisp_Object, int)); |
958 static int store_mode_line_string P_ ((char *, Lisp_Object, int, int, int, Lisp_Object)); | 957 static int store_mode_line_string P_ ((char *, Lisp_Object, int, int, int, Lisp_Object)); |
959 static char *decode_mode_spec P_ ((struct window *, int, int, int, int *)); | 958 static char *decode_mode_spec P_ ((struct window *, int, int, int, |
959 Lisp_Object *)); | |
960 static void display_menu_bar P_ ((struct window *)); | 960 static void display_menu_bar P_ ((struct window *)); |
961 static int display_count_lines P_ ((int, int, int, int, int *)); | 961 static int display_count_lines P_ ((int, int, int, int, int *)); |
962 static int display_string P_ ((unsigned char *, Lisp_Object, Lisp_Object, | 962 static int display_string P_ ((unsigned char *, Lisp_Object, Lisp_Object, |
963 EMACS_INT, EMACS_INT, struct it *, int, int, int, int)); | 963 EMACS_INT, EMACS_INT, struct it *, int, int, int, int)); |
964 static void compute_line_metrics P_ ((struct it *)); | 964 static void compute_line_metrics P_ ((struct it *)); |
1364 after CHARPOS. (ii) If CHARPOS is in a display vector, | 1364 after CHARPOS. (ii) If CHARPOS is in a display vector, |
1365 move_it_to stops on its last glyph. */ | 1365 move_it_to stops on its last glyph. */ |
1366 int top_x = it.current_x; | 1366 int top_x = it.current_x; |
1367 int top_y = it.current_y; | 1367 int top_y = it.current_y; |
1368 enum it_method it_method = it.method; | 1368 enum it_method it_method = it.method; |
1369 /* Calling line_bottom_y may change it.method. */ | 1369 /* Calling line_bottom_y may change it.method, it.position, etc. */ |
1370 int bottom_y = (last_height = 0, line_bottom_y (&it)); | 1370 int bottom_y = (last_height = 0, line_bottom_y (&it)); |
1371 int window_top_y = WINDOW_HEADER_LINE_HEIGHT (w); | 1371 int window_top_y = WINDOW_HEADER_LINE_HEIGHT (w); |
1372 | 1372 |
1373 if (top_y < window_top_y) | 1373 if (top_y < window_top_y) |
1374 visible_p = bottom_y > window_top_y; | 1374 visible_p = bottom_y > window_top_y; |
1379 if (it_method == GET_FROM_BUFFER) | 1379 if (it_method == GET_FROM_BUFFER) |
1380 { | 1380 { |
1381 Lisp_Object window, prop; | 1381 Lisp_Object window, prop; |
1382 | 1382 |
1383 XSETWINDOW (window, w); | 1383 XSETWINDOW (window, w); |
1384 prop = Fget_char_property (make_number (it.position.charpos), | 1384 prop = Fget_char_property (make_number (charpos), |
1385 Qinvisible, window); | 1385 Qinvisible, window); |
1386 | 1386 |
1387 /* If charpos coincides with invisible text covered with an | 1387 /* If charpos coincides with invisible text covered with an |
1388 ellipsis, use the first glyph of the ellipsis to compute | 1388 ellipsis, use the first glyph of the ellipsis to compute |
1389 the pixel positions. */ | 1389 the pixel positions. */ |
5690 /* Use the standard display table for displaying strings. */ | 5690 /* Use the standard display table for displaying strings. */ |
5691 if (DISP_TABLE_P (Vstandard_display_table)) | 5691 if (DISP_TABLE_P (Vstandard_display_table)) |
5692 it->dp = XCHAR_TABLE (Vstandard_display_table); | 5692 it->dp = XCHAR_TABLE (Vstandard_display_table); |
5693 | 5693 |
5694 it->stop_charpos = charpos; | 5694 it->stop_charpos = charpos; |
5695 if (s == NULL && it->multibyte_p) | |
5696 composition_compute_stop_pos (&it->cmp_it, charpos, -1, it->end_charpos, | |
5697 it->string); | |
5695 CHECK_IT (it); | 5698 CHECK_IT (it); |
5696 } | 5699 } |
5697 | 5700 |
5698 | 5701 |
5699 | 5702 |
5717 | 5720 |
5718 | 5721 |
5719 /* Return 1 iff a character at CHARPOS (and BYTEPOS) is composed | 5722 /* Return 1 iff a character at CHARPOS (and BYTEPOS) is composed |
5720 (possibly with the following characters). */ | 5723 (possibly with the following characters). */ |
5721 | 5724 |
5722 #define CHAR_COMPOSED_P(IT,CHARPOS,BYTEPOS) \ | 5725 #define CHAR_COMPOSED_P(IT,CHARPOS,BYTEPOS,END_CHARPOS) \ |
5723 ((IT)->cmp_it.id >= 0 \ | 5726 ((IT)->cmp_it.id >= 0 \ |
5724 || ((IT)->cmp_it.stop_pos == (CHARPOS) \ | 5727 || ((IT)->cmp_it.stop_pos == (CHARPOS) \ |
5725 && composition_reseat_it (&(IT)->cmp_it, CHARPOS, BYTEPOS, \ | 5728 && composition_reseat_it (&(IT)->cmp_it, CHARPOS, BYTEPOS, \ |
5726 (IT)->end_charpos, (IT)->w, \ | 5729 END_CHARPOS, (IT)->w, \ |
5727 FACE_FROM_ID ((IT)->f, (IT)->face_id), \ | 5730 FACE_FROM_ID ((IT)->f, (IT)->face_id), \ |
5728 (IT)->string))) | 5731 (IT)->string))) |
5729 | 5732 |
5730 | 5733 |
5731 /* Load IT's display element fields with information about the next | 5734 /* Load IT's display element fields with information about the next |
6400 { | 6403 { |
6401 it->what = IT_EOB; | 6404 it->what = IT_EOB; |
6402 return 0; | 6405 return 0; |
6403 } | 6406 } |
6404 else if (CHAR_COMPOSED_P (it, IT_STRING_CHARPOS (*it), | 6407 else if (CHAR_COMPOSED_P (it, IT_STRING_CHARPOS (*it), |
6405 IT_STRING_BYTEPOS (*it)) | 6408 IT_STRING_BYTEPOS (*it), SCHARS (it->string)) |
6406 && next_element_from_composition (it)) | 6409 && next_element_from_composition (it)) |
6407 { | 6410 { |
6408 return 1; | 6411 return 1; |
6409 } | 6412 } |
6410 else if (STRING_MULTIBYTE (it->string)) | 6413 else if (STRING_MULTIBYTE (it->string)) |
6436 /* Pad with spaces. */ | 6439 /* Pad with spaces. */ |
6437 it->c = ' ', it->len = 1; | 6440 it->c = ' ', it->len = 1; |
6438 CHARPOS (position) = BYTEPOS (position) = -1; | 6441 CHARPOS (position) = BYTEPOS (position) = -1; |
6439 } | 6442 } |
6440 else if (CHAR_COMPOSED_P (it, IT_STRING_CHARPOS (*it), | 6443 else if (CHAR_COMPOSED_P (it, IT_STRING_CHARPOS (*it), |
6441 IT_STRING_BYTEPOS (*it)) | 6444 IT_STRING_BYTEPOS (*it), it->string_nchars) |
6442 && next_element_from_composition (it)) | 6445 && next_element_from_composition (it)) |
6443 { | 6446 { |
6444 return 1; | 6447 return 1; |
6445 } | 6448 } |
6446 else if (STRING_MULTIBYTE (it->string)) | 6449 else if (STRING_MULTIBYTE (it->string)) |
6752 if (it->redisplay_end_trigger_charpos | 6755 if (it->redisplay_end_trigger_charpos |
6753 && it->glyph_row | 6756 && it->glyph_row |
6754 && IT_CHARPOS (*it) >= it->redisplay_end_trigger_charpos) | 6757 && IT_CHARPOS (*it) >= it->redisplay_end_trigger_charpos) |
6755 run_redisplay_end_trigger_hook (it); | 6758 run_redisplay_end_trigger_hook (it); |
6756 | 6759 |
6757 if (CHAR_COMPOSED_P (it, IT_CHARPOS (*it), IT_BYTEPOS (*it)) | 6760 if (CHAR_COMPOSED_P (it, IT_CHARPOS (*it), IT_BYTEPOS (*it), |
6761 it->end_charpos) | |
6758 && next_element_from_composition (it)) | 6762 && next_element_from_composition (it)) |
6759 { | 6763 { |
6760 return 1; | 6764 return 1; |
6761 } | 6765 } |
6762 | 6766 |
18090 else if (c != 0) | 18094 else if (c != 0) |
18091 { | 18095 { |
18092 int multibyte; | 18096 int multibyte; |
18093 int bytepos, charpos; | 18097 int bytepos, charpos; |
18094 unsigned char *spec; | 18098 unsigned char *spec; |
18099 Lisp_Object string; | |
18095 | 18100 |
18096 bytepos = percent_position; | 18101 bytepos = percent_position; |
18097 charpos = (STRING_MULTIBYTE (elt) | 18102 charpos = (STRING_MULTIBYTE (elt) |
18098 ? string_byte_to_char (elt, bytepos) | 18103 ? string_byte_to_char (elt, bytepos) |
18099 : bytepos); | 18104 : bytepos); |
18100 spec | 18105 spec = decode_mode_spec (it->w, c, field, prec, &string); |
18101 = decode_mode_spec (it->w, c, field, prec, &multibyte); | 18106 multibyte = STRINGP (string) && STRING_MULTIBYTE (string); |
18102 | 18107 |
18103 switch (mode_line_target) | 18108 switch (mode_line_target) |
18104 { | 18109 { |
18105 case MODE_LINE_NOPROP: | 18110 case MODE_LINE_NOPROP: |
18106 case MODE_LINE_TITLE: | 18111 case MODE_LINE_TITLE: |
18118 case MODE_LINE_DISPLAY: | 18123 case MODE_LINE_DISPLAY: |
18119 { | 18124 { |
18120 int nglyphs_before, nwritten; | 18125 int nglyphs_before, nwritten; |
18121 | 18126 |
18122 nglyphs_before = it->glyph_row->used[TEXT_AREA]; | 18127 nglyphs_before = it->glyph_row->used[TEXT_AREA]; |
18123 nwritten = display_string (spec, Qnil, elt, | 18128 nwritten = display_string (spec, string, elt, |
18124 charpos, 0, it, | 18129 charpos, 0, it, |
18125 field, prec, 0, | 18130 field, prec, 0, |
18126 multibyte); | 18131 multibyte); |
18127 | 18132 |
18128 /* Assign to the glyphs written above the | 18133 /* Assign to the glyphs written above the |
18781 } | 18786 } |
18782 | 18787 |
18783 /* Return a string for the output of a mode line %-spec for window W, | 18788 /* Return a string for the output of a mode line %-spec for window W, |
18784 generated by character C. PRECISION >= 0 means don't return a | 18789 generated by character C. PRECISION >= 0 means don't return a |
18785 string longer than that value. FIELD_WIDTH > 0 means pad the | 18790 string longer than that value. FIELD_WIDTH > 0 means pad the |
18786 string returned with spaces to that value. Return 1 in *MULTIBYTE | 18791 string returned with spaces to that value. Return a Lisp string in |
18787 if the result is multibyte text. | 18792 *STRING if the resulting string is taken from that Lisp string. |
18788 | 18793 |
18789 Note we operate on the current buffer for most purposes, | 18794 Note we operate on the current buffer for most purposes, |
18790 the exception being w->base_line_pos. */ | 18795 the exception being w->base_line_pos. */ |
18791 | 18796 |
18792 static char lots_of_dashes[] = "--------------------------------------------------------------------------------------------------------------------------------------------"; | 18797 static char lots_of_dashes[] = "--------------------------------------------------------------------------------------------------------------------------------------------"; |
18793 | 18798 |
18794 static char * | 18799 static char * |
18795 decode_mode_spec (w, c, field_width, precision, multibyte) | 18800 decode_mode_spec (w, c, field_width, precision, string) |
18796 struct window *w; | 18801 struct window *w; |
18797 register int c; | 18802 register int c; |
18798 int field_width, precision; | 18803 int field_width, precision; |
18799 int *multibyte; | 18804 Lisp_Object *string; |
18800 { | 18805 { |
18801 Lisp_Object obj; | 18806 Lisp_Object obj; |
18802 struct frame *f = XFRAME (WINDOW_FRAME (w)); | 18807 struct frame *f = XFRAME (WINDOW_FRAME (w)); |
18803 char *decode_mode_spec_buf = f->decode_mode_spec_buffer; | 18808 char *decode_mode_spec_buf = f->decode_mode_spec_buffer; |
18804 struct buffer *b = current_buffer; | 18809 struct buffer *b = current_buffer; |
18805 | 18810 |
18806 obj = Qnil; | 18811 obj = Qnil; |
18807 *multibyte = 0; | 18812 *string = Qnil; |
18808 | 18813 |
18809 switch (c) | 18814 switch (c) |
18810 { | 18815 { |
18811 case '*': | 18816 case '*': |
18812 if (!NILP (b->read_only)) | 18817 if (!NILP (b->read_only)) |
19196 } | 19201 } |
19197 } | 19202 } |
19198 | 19203 |
19199 if (STRINGP (obj)) | 19204 if (STRINGP (obj)) |
19200 { | 19205 { |
19201 *multibyte = STRING_MULTIBYTE (obj); | 19206 *string = obj; |
19202 return (char *) SDATA (obj); | 19207 return (char *) SDATA (obj); |
19203 } | 19208 } |
19204 else | 19209 else |
19205 return ""; | 19210 return ""; |
19206 } | 19211 } |
19317 ***********************************************************************/ | 19322 ***********************************************************************/ |
19318 | 19323 |
19319 /* Display a NUL-terminated string, starting with index START. | 19324 /* Display a NUL-terminated string, starting with index START. |
19320 | 19325 |
19321 If STRING is non-null, display that C string. Otherwise, the Lisp | 19326 If STRING is non-null, display that C string. Otherwise, the Lisp |
19322 string LISP_STRING is displayed. | 19327 string LISP_STRING is displayed. There's a case that STRING is |
19328 non-null and LISP_STRING is not nil. It means STRING is a string | |
19329 data of LISP_STRING. In that case, we display LISP_STRING while | |
19330 ignoring its text properties. | |
19323 | 19331 |
19324 If FACE_STRING is not nil, FACE_STRING_POS is a position in | 19332 If FACE_STRING is not nil, FACE_STRING_POS is a position in |
19325 FACE_STRING. Display STRING or LISP_STRING with the face at | 19333 FACE_STRING. Display STRING or LISP_STRING with the face at |
19326 FACE_STRING_POS in FACE_STRING: | 19334 FACE_STRING_POS in FACE_STRING: |
19327 | 19335 |
19367 int saved_face_id = it->face_id; | 19375 int saved_face_id = it->face_id; |
19368 struct glyph_row *row = it->glyph_row; | 19376 struct glyph_row *row = it->glyph_row; |
19369 | 19377 |
19370 /* Initialize the iterator IT for iteration over STRING beginning | 19378 /* Initialize the iterator IT for iteration over STRING beginning |
19371 with index START. */ | 19379 with index START. */ |
19372 reseat_to_string (it, string, lisp_string, start, | 19380 reseat_to_string (it, NILP (lisp_string) ? string : NULL, lisp_string, start, |
19373 precision, field_width, multibyte); | 19381 precision, field_width, multibyte); |
19382 if (string && STRINGP (lisp_string)) | |
19383 /* LISP_STRING is the one returned by decode_mode_spec. We should | |
19384 ignore its text properties. */ | |
19385 it->stop_charpos = -1; | |
19374 | 19386 |
19375 /* If displaying STRING, set up the face of the iterator | 19387 /* If displaying STRING, set up the face of the iterator |
19376 from LISP_STRING, if that's given. */ | 19388 from LISP_STRING, if that's given. */ |
19377 if (STRINGP (face_string)) | 19389 if (STRINGP (face_string)) |
19378 { | 19390 { |