From: Eli Zaretskii Date: Thu, 15 Aug 2013 15:28:53 +0000 (+0300) Subject: Fix bug #15099 with 'box' face attribute in display tables. X-Git-Tag: emacs-24.3.90~173^2^2~42^2~45^2~387^2~1686^2~233 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=0542623943803e346aec839369e399e4b0ff43ad;p=emacs.git Fix bug #15099 with 'box' face attribute in display tables. src/xdisp.c (next_element_from_display_vector): Support 'box' face attribute in the face definitions of a display vector. --- diff --git a/src/ChangeLog b/src/ChangeLog index 1a83531ad10..77c37864b00 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -6,6 +6,8 @@ visible character of the display line. This avoids funky horizontal shifting because the window start is not kept on the same position. (Bug#15090) + (next_element_from_display_vector): Support 'box' face attribute + in the face definitions of a display vector. (Bug#15099) 2013-08-15 Lars Magne Ingebrigtsen diff --git a/src/xdisp.c b/src/xdisp.c index 8b72c58cd07..25a2ed23a97 100644 --- a/src/xdisp.c +++ b/src/xdisp.c @@ -7461,6 +7461,8 @@ static int next_element_from_display_vector (struct it *it) { Lisp_Object gc; + int prev_face_id = it->face_id; + int next_face_id; /* Precondition. */ eassert (it->dpvec && it->current.dpvec_index >= 0); @@ -7473,6 +7475,8 @@ next_element_from_display_vector (struct it *it) if (GLYPH_CODE_P (gc)) { + struct face *this_face, *prev_face, *next_face; + it->c = GLYPH_CODE_CHAR (gc); it->len = CHAR_BYTES (it->c); @@ -7488,6 +7492,42 @@ next_element_from_display_vector (struct it *it) it->face_id = merge_faces (it->f, Qt, lface_id, it->saved_face_id); } + + /* Glyphs in the display vector could have the box face, so we + need to set the related flags in the iterator, as + appropriate. */ + this_face = FACE_FROM_ID (it->f, it->face_id); + prev_face = FACE_FROM_ID (it->f, prev_face_id); + + /* Is this character the first character of a box-face run? */ + it->start_of_box_run_p = (this_face && this_face->box != FACE_NO_BOX + && (!prev_face + || prev_face->box == FACE_NO_BOX)); + + /* For the last character of the box-face run, we need to look + either at the next glyph from the display vector, or at the + face we saw before the display vector. */ + if (it->current.dpvec_index < it->dpend - it->dpvec - 1) + { + if (it->dpvec_face_id >= 0) + next_face_id = it->dpvec_face_id; + else + { + int lface_id = + GLYPH_CODE_FACE (it->dpvec[it->current.dpvec_index + 1]); + + if (lface_id > 0) + next_face_id = merge_faces (it->f, Qt, lface_id, + it->saved_face_id); + } + } + else + next_face_id = it->saved_face_id; + next_face = FACE_FROM_ID (it->f, next_face_id); + it->end_of_box_run_p = (this_face && this_face->box != FACE_NO_BOX + && (!next_face + || next_face->box == FACE_NO_BOX)); + it->face_box_p = this_face && this_face->box != FACE_NO_BOX; } else /* Display table entry is invalid. Return a space. */