comparison src/xdisp.c @ 55124:ff3536099b37

(append_space_for_newline): Rename from append_space. Remove DEFAULT_FACE_P arg; always use current face. Callers changed. (x_produce_glyphs): Handle line-spacing property on newline char. If value is t, adjust ascent and descent to fit current row height. If value is an integer or float, set extra_line_spacing to integer value, or to float value x current line height.
author Kim F. Storm <storm@cua.dk>
date Sat, 24 Apr 2004 23:28:10 +0000
parents 01ecdd56871c
children 491a6ea7f8c4
comparison
equal deleted inserted replaced
55123:a27729919ff1 55124:ff3536099b37
848 static Lisp_Object safe_eval_handler P_ ((Lisp_Object)); 848 static Lisp_Object safe_eval_handler P_ ((Lisp_Object));
849 static void insert_left_trunc_glyphs P_ ((struct it *)); 849 static void insert_left_trunc_glyphs P_ ((struct it *));
850 static struct glyph_row *get_overlay_arrow_glyph_row P_ ((struct window *, 850 static struct glyph_row *get_overlay_arrow_glyph_row P_ ((struct window *,
851 Lisp_Object)); 851 Lisp_Object));
852 static void extend_face_to_end_of_line P_ ((struct it *)); 852 static void extend_face_to_end_of_line P_ ((struct it *));
853 static int append_space P_ ((struct it *, int)); 853 static int append_space_for_newline P_ ((struct it *));
854 static int make_cursor_line_fully_visible P_ ((struct window *, int)); 854 static int make_cursor_line_fully_visible P_ ((struct window *, int));
855 static int try_scrolling P_ ((Lisp_Object, int, EMACS_INT, EMACS_INT, int, int)); 855 static int try_scrolling P_ ((Lisp_Object, int, EMACS_INT, EMACS_INT, int, int));
856 static int try_cursor_movement P_ ((Lisp_Object, struct text_pos, int *)); 856 static int try_cursor_movement P_ ((Lisp_Object, struct text_pos, int *));
857 static int trailing_whitespace_p P_ ((int)); 857 static int trailing_whitespace_p P_ ((int));
858 static int message_log_check_duplicate P_ ((int, int, int, int)); 858 static int message_log_check_duplicate P_ ((int, int, int, int));
14143 it->max_phys_ascent = it->max_phys_descent = 0; 14143 it->max_phys_ascent = it->max_phys_descent = 0;
14144 } 14144 }
14145 14145
14146 14146
14147 /* Append one space to the glyph row of iterator IT if doing a 14147 /* Append one space to the glyph row of iterator IT if doing a
14148 window-based redisplay. DEFAULT_FACE_P non-zero means let the 14148 window-based redisplay. The space has the same face as
14149 space have the default face, otherwise let it have the same face as
14150 IT->face_id. Value is non-zero if a space was added. 14149 IT->face_id. Value is non-zero if a space was added.
14151 14150
14152 This function is called to make sure that there is always one glyph 14151 This function is called to make sure that there is always one glyph
14153 at the end of a glyph row that the cursor can be set on under 14152 at the end of a glyph row that the cursor can be set on under
14154 window-systems. (If there weren't such a glyph we would not know 14153 window-systems. (If there weren't such a glyph we would not know
14156 14155
14157 At the same time this space let's a nicely handle clearing to the 14156 At the same time this space let's a nicely handle clearing to the
14158 end of the line if the row ends in italic text. */ 14157 end of the line if the row ends in italic text. */
14159 14158
14160 static int 14159 static int
14161 append_space (it, default_face_p) 14160 append_space_for_newline (it)
14162 struct it *it; 14161 struct it *it;
14163 int default_face_p;
14164 { 14162 {
14165 if (FRAME_WINDOW_P (it->f)) 14163 if (FRAME_WINDOW_P (it->f))
14166 { 14164 {
14167 int n = it->glyph_row->used[TEXT_AREA]; 14165 int n = it->glyph_row->used[TEXT_AREA];
14168 14166
14170 < it->glyph_row->glyphs[1 + TEXT_AREA]) 14168 < it->glyph_row->glyphs[1 + TEXT_AREA])
14171 { 14169 {
14172 /* Save some values that must not be changed. 14170 /* Save some values that must not be changed.
14173 Must save IT->c and IT->len because otherwise 14171 Must save IT->c and IT->len because otherwise
14174 ITERATOR_AT_END_P wouldn't work anymore after 14172 ITERATOR_AT_END_P wouldn't work anymore after
14175 append_space has been called. */ 14173 append_space_for_newline has been called. */
14176 enum display_element_type saved_what = it->what; 14174 enum display_element_type saved_what = it->what;
14177 int saved_c = it->c, saved_len = it->len; 14175 int saved_c = it->c, saved_len = it->len;
14178 int saved_x = it->current_x; 14176 int saved_x = it->current_x;
14179 int saved_face_id = it->face_id; 14177 int saved_face_id = it->face_id;
14180 struct text_pos saved_pos; 14178 struct text_pos saved_pos;
14188 bzero (&it->position, sizeof it->position); 14186 bzero (&it->position, sizeof it->position);
14189 it->object = make_number (0); 14187 it->object = make_number (0);
14190 it->c = ' '; 14188 it->c = ' ';
14191 it->len = 1; 14189 it->len = 1;
14192 14190
14193 if (default_face_p) 14191 if (it->face_before_selective_p)
14194 it->face_id = DEFAULT_FACE_ID;
14195 else if (it->face_before_selective_p)
14196 it->face_id = it->saved_face_id; 14192 it->face_id = it->saved_face_id;
14197 face = FACE_FROM_ID (it->f, it->face_id); 14193 face = FACE_FROM_ID (it->f, it->face_id);
14198 it->face_id = FACE_FOR_CHAR (it->f, face, 0); 14194 it->face_id = FACE_FOR_CHAR (it->f, face, 0);
14199 14195
14200 if (it->max_ascent > 0 || it->max_descent > 0) 14196 if (it->max_ascent > 0 || it->max_descent > 0)
14482 #ifdef HAVE_WINDOW_SYSTEM 14478 #ifdef HAVE_WINDOW_SYSTEM
14483 if (IT_OVERFLOW_NEWLINE_INTO_FRINGE (it)) 14479 if (IT_OVERFLOW_NEWLINE_INTO_FRINGE (it))
14484 row->exact_window_width_line_p = 1; 14480 row->exact_window_width_line_p = 1;
14485 else 14481 else
14486 #endif /* HAVE_WINDOW_SYSTEM */ 14482 #endif /* HAVE_WINDOW_SYSTEM */
14487 if ((append_space (it, 1) && row->used[TEXT_AREA] == 1) 14483 if ((append_space_for_newline (it) && row->used[TEXT_AREA] == 1)
14488 || row->used[TEXT_AREA] == 0) 14484 || row->used[TEXT_AREA] == 0)
14489 { 14485 {
14490 row->glyphs[TEXT_AREA]->charpos = -1; 14486 row->glyphs[TEXT_AREA]->charpos = -1;
14491 row->displays_text_p = 0; 14487 row->displays_text_p = 0;
14492 14488
14724 14720
14725 #ifdef HAVE_WINDOW_SYSTEM 14721 #ifdef HAVE_WINDOW_SYSTEM
14726 /* Add a space at the end of the line that is used to 14722 /* Add a space at the end of the line that is used to
14727 display the cursor there. */ 14723 display the cursor there. */
14728 if (!IT_OVERFLOW_NEWLINE_INTO_FRINGE (it)) 14724 if (!IT_OVERFLOW_NEWLINE_INTO_FRINGE (it))
14729 append_space (it, 0); 14725 append_space_for_newline (it);
14730 #endif /* HAVE_WINDOW_SYSTEM */ 14726 #endif /* HAVE_WINDOW_SYSTEM */
14731 14727
14732 /* Extend the face to the end of the line. */ 14728 /* Extend the face to the end of the line. */
14733 extend_face_to_end_of_line (it); 14729 extend_face_to_end_of_line (it);
14734 14730
18513 18509
18514 void 18510 void
18515 x_produce_glyphs (it) 18511 x_produce_glyphs (it)
18516 struct it *it; 18512 struct it *it;
18517 { 18513 {
18514 int extra_line_spacing = it->extra_line_spacing;
18515
18518 it->glyph_not_available_p = 0; 18516 it->glyph_not_available_p = 0;
18519 18517
18520 if (it->what == IT_CHARACTER) 18518 if (it->what == IT_CHARACTER)
18521 { 18519 {
18522 XChar2b char2b; 18520 XChar2b char2b;
18622 it->descent = min (it->max_descent, it->descent + it->ascent - it->max_ascent); 18620 it->descent = min (it->max_descent, it->descent + it->ascent - it->max_ascent);
18623 it->ascent = it->max_ascent; 18621 it->ascent = it->max_ascent;
18624 } 18622 }
18625 it->phys_ascent = min (it->phys_ascent, it->ascent); 18623 it->phys_ascent = min (it->phys_ascent, it->ascent);
18626 it->phys_descent = min (it->phys_descent, it->descent); 18624 it->phys_descent = min (it->phys_descent, it->descent);
18625 extra_line_spacing = 0;
18627 } 18626 }
18628 18627
18629 /* If this is a space inside a region of text with 18628 /* If this is a space inside a region of text with
18630 `space-width' property, change its width. */ 18629 `space-width' property, change its width. */
18631 stretched_p = it->char_to_display == ' ' && !NILP (it->space_width); 18630 stretched_p = it->char_to_display == ' ' && !NILP (it->space_width);
18694 { 18693 {
18695 /* A newline has no width but we need the height of the line. 18694 /* A newline has no width but we need the height of the line.
18696 But if previous part of the line set a height, don't 18695 But if previous part of the line set a height, don't
18697 increase that height */ 18696 increase that height */
18698 18697
18698 Lisp_Object lsp;
18699
18699 it->pixel_width = 0; 18700 it->pixel_width = 0;
18700 it->nglyphs = 0; 18701 it->nglyphs = 0;
18701 18702
18703 lsp = Fget_text_property (IT_CHARPOS (*it), Qline_spacing, it->w->buffer);
18704
18702 it->ascent = FONT_BASE (font) + boff; 18705 it->ascent = FONT_BASE (font) + boff;
18703 it->descent = FONT_DESCENT (font) - boff; 18706 it->descent = FONT_DESCENT (font) - boff;
18704 18707
18705 if (it->max_ascent > 0 || it->max_descent > 0) 18708 if (EQ (lsp, Qt))
18706 { 18709 {
18707 it->ascent = it->descent = 0; 18710 if (it->descent > it->max_descent)
18711 {
18712 it->ascent += it->descent - it->max_descent;
18713 it->descent = it->max_descent;
18714 }
18715 if (it->ascent> it->max_ascent)
18716 {
18717 it->descent = min (it->max_descent, it->descent + it->ascent - it->max_ascent);
18718 it->ascent = it->max_ascent;
18719 }
18720 it->phys_ascent = min (it->phys_ascent, it->ascent);
18721 it->phys_descent = min (it->phys_descent, it->descent);
18722 extra_line_spacing = 0;
18708 } 18723 }
18709 else 18724 else
18710 { 18725 {
18711 it->ascent = FONT_BASE (font) + boff; 18726 it->phys_ascent = it->ascent;
18712 it->descent = FONT_DESCENT (font) - boff; 18727 it->phys_descent = it->descent;
18713 } 18728
18714 18729 if ((it->max_ascent > 0 || it->max_descent > 0)
18715 it->phys_ascent = it->ascent; 18730 && face->box != FACE_NO_BOX
18716 it->phys_descent = it->descent; 18731 && face->box_line_width > 0)
18717 18732 {
18718 if ((it->max_ascent > 0 || it->max_descent > 0) 18733 it->ascent += face->box_line_width;
18719 && face->box != FACE_NO_BOX 18734 it->descent += face->box_line_width;
18720 && face->box_line_width > 0) 18735 }
18721 { 18736 if (INTEGERP (lsp))
18722 it->ascent += face->box_line_width; 18737 extra_line_spacing = XINT (lsp);
18723 it->descent += face->box_line_width; 18738 else if (FLOATP (lsp))
18739 extra_line_spacing = (it->phys_ascent + it->phys_descent) * XFLOAT_DATA (lsp);
18724 } 18740 }
18725 } 18741 }
18726 else if (it->char_to_display == '\t') 18742 else if (it->char_to_display == '\t')
18727 { 18743 {
18728 int tab_width = it->tab_width * FRAME_COLUMN_WIDTH (it->f); 18744 int tab_width = it->tab_width * FRAME_COLUMN_WIDTH (it->f);
19096 because this isn't true for images with `:ascent 100'. */ 19112 because this isn't true for images with `:ascent 100'. */
19097 xassert (it->ascent >= 0 && it->descent >= 0); 19113 xassert (it->ascent >= 0 && it->descent >= 0);
19098 if (it->area == TEXT_AREA) 19114 if (it->area == TEXT_AREA)
19099 it->current_x += it->pixel_width; 19115 it->current_x += it->pixel_width;
19100 19116
19101 it->descent += it->extra_line_spacing; 19117 it->descent += extra_line_spacing;
19102 19118
19103 it->max_ascent = max (it->max_ascent, it->ascent); 19119 it->max_ascent = max (it->max_ascent, it->ascent);
19104 it->max_descent = max (it->max_descent, it->descent); 19120 it->max_descent = max (it->max_descent, it->descent);
19105 it->max_phys_ascent = max (it->max_phys_ascent, it->phys_ascent); 19121 it->max_phys_ascent = max (it->max_phys_ascent, it->phys_ascent);
19106 it->max_phys_descent = max (it->max_phys_descent, it->phys_descent); 19122 it->max_phys_descent = max (it->max_phys_descent, it->phys_descent);