comparison src/xdisp.c @ 90519:138ce2701550

Merge from emacs--devo--0 Patches applied: * emacs--devo--0 (patch 320-342) - Update from CVS - Merge from gnus--rel--5.10 - lisp/play/cookie1.el (cookie): Work properly when there's only one entry - Add note about "link" button-class to etc/TODO * gnus--rel--5.10 (patch 108-112) - Merge from emacs--devo--0 - Clean up merge mistakes - Update from CVS - Update from CVS: texi/gnus.texi (Summary Buffer Lines): Fix typo. Revision: emacs@sv.gnu.org/emacs--unicode--0--patch-86
author Miles Bader <miles@gnu.org>
date Thu, 06 Jul 2006 08:59:39 +0000
parents 138027c8c982 0b31608be4a1
children 8a8e69664178
comparison
equal deleted inserted replaced
90518:64c755511769 90519:138ce2701550
3036 overlays even if the actual buffer text is replaced. */ 3036 overlays even if the actual buffer text is replaced. */
3037 if (!handle_overlay_change_p || it->sp > 1) 3037 if (!handle_overlay_change_p || it->sp > 1)
3038 return; 3038 return;
3039 if (!get_overlay_strings_1 (it, 0, 0)) 3039 if (!get_overlay_strings_1 (it, 0, 0))
3040 return; 3040 return;
3041 it->ignore_overlay_strings_at_pos_p = 1;
3041 it->string_from_display_prop_p = 0; 3042 it->string_from_display_prop_p = 0;
3042 handle_overlay_change_p = 0; 3043 handle_overlay_change_p = 0;
3043 handled = HANDLED_RECOMPUTE_PROPS; 3044 handled = HANDLED_RECOMPUTE_PROPS;
3044 break; 3045 break;
3045 } 3046 }
4586 IT_CHARPOS (*it) = end; 4587 IT_CHARPOS (*it) = end;
4587 IT_BYTEPOS (*it) = CHAR_TO_BYTE (end); 4588 IT_BYTEPOS (*it) = CHAR_TO_BYTE (end);
4588 } 4589 }
4589 return HANDLED_RECOMPUTE_PROPS; 4590 return HANDLED_RECOMPUTE_PROPS;
4590 } 4591 }
4592
4593 it->stop_charpos = end;
4594 push_it (it);
4595
4591 it->method = GET_FROM_COMPOSITION; 4596 it->method = GET_FROM_COMPOSITION;
4592 it->cmp_id = id; 4597 it->cmp_id = id;
4593 it->cmp_len = COMPOSITION_LENGTH (prop); 4598 it->cmp_len = COMPOSITION_LENGTH (prop);
4594 #ifdef USE_FONT_BACKEND 4599 #ifdef USE_FONT_BACKEND
4595 if (composition_table[id]->method == COMPOSITION_WITH_GLYPH_STRING) 4600 if (composition_table[id]->method == COMPOSITION_WITH_GLYPH_STRING)
4600 components. */ 4605 components. */
4601 it->c = COMPOSITION_GLYPH (composition_table[id], 0); 4606 it->c = COMPOSITION_GLYPH (composition_table[id], 0);
4602 it->len = (STRINGP (it->string) 4607 it->len = (STRINGP (it->string)
4603 ? string_char_to_byte (it->string, end) 4608 ? string_char_to_byte (it->string, end)
4604 : CHAR_TO_BYTE (end)) - pos_byte; 4609 : CHAR_TO_BYTE (end)) - pos_byte;
4605 it->stop_charpos = end;
4606 handled = HANDLED_RETURN; 4610 handled = HANDLED_RETURN;
4607 } 4611 }
4608 } 4612 }
4609 4613
4610 return handled; 4614 return handled;
5029 break; 5033 break;
5030 case GET_FROM_STRETCH: 5034 case GET_FROM_STRETCH:
5031 p->u.stretch.object = it->object; 5035 p->u.stretch.object = it->object;
5032 break; 5036 break;
5033 } 5037 }
5034 p->pos = it->current; 5038 p->position = it->position;
5039 p->current = it->current;
5035 p->end_charpos = it->end_charpos; 5040 p->end_charpos = it->end_charpos;
5036 p->string_nchars = it->string_nchars; 5041 p->string_nchars = it->string_nchars;
5037 p->area = it->area; 5042 p->area = it->area;
5038 p->multibyte_p = it->multibyte_p; 5043 p->multibyte_p = it->multibyte_p;
5039 p->space_width = it->space_width; 5044 p->space_width = it->space_width;
5060 xassert (it->sp > 0); 5065 xassert (it->sp > 0);
5061 --it->sp; 5066 --it->sp;
5062 p = it->stack + it->sp; 5067 p = it->stack + it->sp;
5063 it->stop_charpos = p->stop_charpos; 5068 it->stop_charpos = p->stop_charpos;
5064 it->face_id = p->face_id; 5069 it->face_id = p->face_id;
5065 it->current = p->pos; 5070 it->current = p->current;
5071 it->position = p->position;
5066 it->string = p->string; 5072 it->string = p->string;
5067 if (NILP (it->string)) 5073 if (NILP (it->string))
5068 SET_TEXT_POS (it->current.string_pos, -1, -1); 5074 SET_TEXT_POS (it->current.string_pos, -1, -1);
5069 it->method = p->method; 5075 it->method = p->method;
5070 switch (it->method) 5076 switch (it->method)
5218 struct it *it; 5224 struct it *it;
5219 { 5225 {
5220 while (IT_CHARPOS (*it) > BEGV) 5226 while (IT_CHARPOS (*it) > BEGV)
5221 { 5227 {
5222 back_to_previous_line_start (it); 5228 back_to_previous_line_start (it);
5229
5223 if (IT_CHARPOS (*it) <= BEGV) 5230 if (IT_CHARPOS (*it) <= BEGV)
5224 break; 5231 break;
5225 5232
5226 /* If selective > 0, then lines indented more than that values 5233 /* If selective > 0, then lines indented more than that values
5227 are invisible. */ 5234 are invisible. */
5890 } 5897 }
5891 break; 5898 break;
5892 5899
5893 case GET_FROM_COMPOSITION: 5900 case GET_FROM_COMPOSITION:
5894 xassert (it->cmp_id >= 0 && it->cmp_id < n_compositions); 5901 xassert (it->cmp_id >= 0 && it->cmp_id < n_compositions);
5895 if (STRINGP (it->string)) 5902 xassert (it->sp > 0);
5903 pop_it (it);
5904 if (it->method == GET_FROM_STRING)
5896 { 5905 {
5897 IT_STRING_BYTEPOS (*it) += it->len; 5906 IT_STRING_BYTEPOS (*it) += it->len;
5898 IT_STRING_CHARPOS (*it) += it->cmp_len; 5907 IT_STRING_CHARPOS (*it) += it->cmp_len;
5899 it->method = GET_FROM_STRING;
5900 it->object = it->string; 5908 it->object = it->string;
5901 goto consider_string_end; 5909 goto consider_string_end;
5902 } 5910 }
5903 else 5911 else if (it->method == GET_FROM_BUFFER)
5904 { 5912 {
5905 IT_BYTEPOS (*it) += it->len; 5913 IT_BYTEPOS (*it) += it->len;
5906 IT_CHARPOS (*it) += it->cmp_len; 5914 IT_CHARPOS (*it) += it->cmp_len;
5907 it->method = GET_FROM_BUFFER;
5908 it->object = it->w->buffer; 5915 it->object = it->w->buffer;
5909 } 5916 }
5910 break; 5917 break;
5911 5918
5912 case GET_FROM_C_STRING: 5919 case GET_FROM_C_STRING:
9716 if (x + glyph->pixel_width > max_x) 9723 if (x + glyph->pixel_width > max_x)
9717 { 9724 {
9718 /* Glyph doesn't fit on line. Backtrack. */ 9725 /* Glyph doesn't fit on line. Backtrack. */
9719 row->used[TEXT_AREA] = n_glyphs_before; 9726 row->used[TEXT_AREA] = n_glyphs_before;
9720 *it = it_before; 9727 *it = it_before;
9728 /* If this is the only glyph on this line, it will never fit on the
9729 toolbar, so skip it. But ensure there is at least one glyph,
9730 so we don't accidentally disable the tool-bar. */
9731 if (n_glyphs_before == 0
9732 && (it->vpos > 0 || IT_STRING_CHARPOS (*it) < it->end_charpos-1))
9733 break;
9721 goto out; 9734 goto out;
9722 } 9735 }
9723 9736
9724 ++it->hpos; 9737 ++it->hpos;
9725 x += glyph->pixel_width; 9738 x += glyph->pixel_width;
9774 ++it->vpos; 9787 ++it->vpos;
9775 ++it->glyph_row; 9788 ++it->glyph_row;
9776 } 9789 }
9777 9790
9778 9791
9792 /* Max tool-bar height. */
9793
9794 #define MAX_FRAME_TOOL_BAR_HEIGHT(f) \
9795 ((FRAME_LINE_HEIGHT (f) * FRAME_LINES (f)))
9796
9779 /* Value is the number of screen lines needed to make all tool-bar 9797 /* Value is the number of screen lines needed to make all tool-bar
9780 items of frame F visible. The number of actual rows needed is 9798 items of frame F visible. The number of actual rows needed is
9781 returned in *N_ROWS if non-NULL. */ 9799 returned in *N_ROWS if non-NULL. */
9782 9800
9783 static int 9801 static int
9785 struct frame *f; 9803 struct frame *f;
9786 int *n_rows; 9804 int *n_rows;
9787 { 9805 {
9788 struct window *w = XWINDOW (f->tool_bar_window); 9806 struct window *w = XWINDOW (f->tool_bar_window);
9789 struct it it; 9807 struct it it;
9790 struct glyph_row *temp_row = w->desired_matrix->rows; 9808 /* tool_bar_lines_needed is called from redisplay_tool_bar after building
9809 the desired matrix, so use (unused) mode-line row as temporary row to
9810 avoid destroying the first tool-bar row. */
9811 struct glyph_row *temp_row = MATRIX_MODE_LINE_ROW (w->desired_matrix);
9791 9812
9792 /* Initialize an iterator for iteration over 9813 /* Initialize an iterator for iteration over
9793 F->desired_tool_bar_string in the tool-bar window of frame F. */ 9814 F->desired_tool_bar_string in the tool-bar window of frame F. */
9794 init_iterator (&it, w, -1, -1, temp_row, TOOL_BAR_FACE_ID); 9815 init_iterator (&it, w, -1, -1, temp_row, TOOL_BAR_FACE_ID);
9795 it.first_visible_x = 0; 9816 it.first_visible_x = 0;
9891 extern Lisp_Object Qtool_bar_lines; 9912 extern Lisp_Object Qtool_bar_lines;
9892 Lisp_Object frame; 9913 Lisp_Object frame;
9893 int old_height = WINDOW_TOTAL_LINES (w); 9914 int old_height = WINDOW_TOTAL_LINES (w);
9894 9915
9895 XSETFRAME (frame, f); 9916 XSETFRAME (frame, f);
9896 clear_glyph_matrix (w->desired_matrix);
9897 Fmodify_frame_parameters (frame, 9917 Fmodify_frame_parameters (frame,
9898 Fcons (Fcons (Qtool_bar_lines, 9918 Fcons (Fcons (Qtool_bar_lines,
9899 make_number (nlines)), 9919 make_number (nlines)),
9900 Qnil)); 9920 Qnil));
9901 if (WINDOW_TOTAL_LINES (w) != old_height) 9921 if (WINDOW_TOTAL_LINES (w) != old_height)
9902 { 9922 {
9923 clear_glyph_matrix (w->desired_matrix);
9903 fonts_changed_p = 1; 9924 fonts_changed_p = 1;
9904 return 1; 9925 return 1;
9905 } 9926 }
9906 } 9927 }
9907 } 9928 }
9949 w->desired_matrix->no_scrolling_p = 1; 9970 w->desired_matrix->no_scrolling_p = 1;
9950 w->must_be_updated_p = 1; 9971 w->must_be_updated_p = 1;
9951 9972
9952 if (auto_resize_tool_bars_p) 9973 if (auto_resize_tool_bars_p)
9953 { 9974 {
9954 int nlines; 9975 int nlines, nrows;
9976 int max_tool_bar_height = MAX_FRAME_TOOL_BAR_HEIGHT (f);
9955 9977
9956 /* If we couldn't display everything, change the tool-bar's 9978 /* If we couldn't display everything, change the tool-bar's
9957 height. */ 9979 height if there is room for more. */
9958 if (IT_STRING_CHARPOS (it) < it.end_charpos) 9980 if (IT_STRING_CHARPOS (it) < it.end_charpos
9981 && it.current_y < max_tool_bar_height)
9959 change_height_p = 1; 9982 change_height_p = 1;
9983
9984 row = it.glyph_row - 1;
9960 9985
9961 /* If there are blank lines at the end, except for a partially 9986 /* If there are blank lines at the end, except for a partially
9962 visible blank line at the end that is smaller than 9987 visible blank line at the end that is smaller than
9963 FRAME_LINE_HEIGHT, change the tool-bar's height. */ 9988 FRAME_LINE_HEIGHT, change the tool-bar's height. */
9964 row = it.glyph_row - 1;
9965 if (!row->displays_text_p 9989 if (!row->displays_text_p
9966 && row->height >= FRAME_LINE_HEIGHT (f)) 9990 && row->height >= FRAME_LINE_HEIGHT (f))
9967 change_height_p = 1; 9991 change_height_p = 1;
9968 9992
9969 /* If row displays tool-bar items, but is partially visible, 9993 /* If row displays tool-bar items, but is partially visible,
9970 change the tool-bar's height. */ 9994 change the tool-bar's height. */
9971 if (row->displays_text_p 9995 if (row->displays_text_p
9972 && MATRIX_ROW_BOTTOM_Y (row) > it.last_visible_y) 9996 && MATRIX_ROW_BOTTOM_Y (row) > it.last_visible_y
9997 && MATRIX_ROW_BOTTOM_Y (row) < max_tool_bar_height)
9973 change_height_p = 1; 9998 change_height_p = 1;
9974 9999
9975 /* Resize windows as needed by changing the `tool-bar-lines' 10000 /* Resize windows as needed by changing the `tool-bar-lines'
9976 frame parameter. */ 10001 frame parameter. */
9977 if (change_height_p 10002 if (change_height_p
9978 && (nlines = tool_bar_lines_needed (f, &f->n_tool_bar_rows), 10003 && (nlines = tool_bar_lines_needed (f, &nrows),
9979 nlines != WINDOW_TOTAL_LINES (w))) 10004 nlines != WINDOW_TOTAL_LINES (w)))
9980 { 10005 {
9981 extern Lisp_Object Qtool_bar_lines; 10006 extern Lisp_Object Qtool_bar_lines;
9982 Lisp_Object frame; 10007 Lisp_Object frame;
9983 int old_height = WINDOW_TOTAL_LINES (w); 10008 int old_height = WINDOW_TOTAL_LINES (w);
9984 10009
9985 XSETFRAME (frame, f); 10010 XSETFRAME (frame, f);
9986 clear_glyph_matrix (w->desired_matrix);
9987 Fmodify_frame_parameters (frame, 10011 Fmodify_frame_parameters (frame,
9988 Fcons (Fcons (Qtool_bar_lines, 10012 Fcons (Fcons (Qtool_bar_lines,
9989 make_number (nlines)), 10013 make_number (nlines)),
9990 Qnil)); 10014 Qnil));
9991 if (WINDOW_TOTAL_LINES (w) != old_height) 10015 if (WINDOW_TOTAL_LINES (w) != old_height)
9992 fonts_changed_p = 1; 10016 {
10017 clear_glyph_matrix (w->desired_matrix);
10018 f->n_tool_bar_rows = nrows;
10019 fonts_changed_p = 1;
10020 }
9993 } 10021 }
9994 } 10022 }
9995 10023
9996 return change_height_p; 10024 return change_height_p;
9997 } 10025 }
11917 are from string. As there's no easy way to know the 11945 are from string. As there's no easy way to know the
11918 character position of the current glyph, find the correct 11946 character position of the current glyph, find the correct
11919 glyph on point by scanning from string_start again. */ 11947 glyph on point by scanning from string_start again. */
11920 Lisp_Object limit; 11948 Lisp_Object limit;
11921 Lisp_Object string; 11949 Lisp_Object string;
11950 struct glyph *stop = glyph;
11922 int pos; 11951 int pos;
11923 11952
11924 limit = make_number (pt_old + 1); 11953 limit = make_number (pt_old + 1);
11925 end = glyph;
11926 glyph = string_start; 11954 glyph = string_start;
11927 x = string_start_x; 11955 x = string_start_x;
11928 string = glyph->object; 11956 string = glyph->object;
11929 pos = string_buffer_position (w, string, string_before_pos); 11957 pos = string_buffer_position (w, string, string_before_pos);
11930 /* If STRING is from overlay, LAST_POS == 0. We skip such glyphs 11958 /* If STRING is from overlay, LAST_POS == 0. We skip such glyphs
11931 because we always put cursor after overlay strings. */ 11959 because we always put cursor after overlay strings. */
11932 while (pos == 0 && glyph < end) 11960 while (pos == 0 && glyph < stop)
11933 { 11961 {
11934 string = glyph->object; 11962 string = glyph->object;
11935 SKIP_GLYPHS (glyph, end, x, EQ (glyph->object, string)); 11963 SKIP_GLYPHS (glyph, stop, x, EQ (glyph->object, string));
11936 if (glyph < end) 11964 if (glyph < stop)
11937 pos = string_buffer_position (w, glyph->object, string_before_pos); 11965 pos = string_buffer_position (w, glyph->object, string_before_pos);
11938 } 11966 }
11939 11967
11940 while (glyph < end) 11968 while (glyph < stop)
11941 { 11969 {
11942 pos = XINT (Fnext_single_char_property_change 11970 pos = XINT (Fnext_single_char_property_change
11943 (make_number (pos), Qdisplay, Qnil, limit)); 11971 (make_number (pos), Qdisplay, Qnil, limit));
11944 if (pos > pt_old) 11972 if (pos > pt_old)
11945 break; 11973 break;
11946 /* Skip glyphs from the same string. */ 11974 /* Skip glyphs from the same string. */
11947 string = glyph->object; 11975 string = glyph->object;
11948 SKIP_GLYPHS (glyph, end, x, EQ (glyph->object, string)); 11976 SKIP_GLYPHS (glyph, stop, x, EQ (glyph->object, string));
11949 /* Skip glyphs from an overlay. */ 11977 /* Skip glyphs from an overlay. */
11950 while (glyph < end 11978 while (glyph < stop
11951 && ! string_buffer_position (w, glyph->object, pos)) 11979 && ! string_buffer_position (w, glyph->object, pos))
11952 { 11980 {
11953 string = glyph->object; 11981 string = glyph->object;
11954 SKIP_GLYPHS (glyph, end, x, EQ (glyph->object, string)); 11982 SKIP_GLYPHS (glyph, stop, x, EQ (glyph->object, string));
11955 } 11983 }
11956 } 11984 }
11957 11985
11958 /* If we reached the end of the line, and end was from a string, 11986 /* If we reached the end of the line, and end was from a string,
11959 cursor is not on this line. */ 11987 cursor is not on this line. */