From 77394d40d90fe4ba150444c0160654c608ef227d Mon Sep 17 00:00:00 2001 From: Dmitry Antipov Date: Fri, 6 Sep 2013 20:40:12 +0400 Subject: [PATCH] * lisp.h (last_glyphless_glyph_frame, last_glyphless_glyph_face_id) (last_glyphless_glyph_merged_face_id): Remove declarations. * dispextern.h (merge_glyphless_glyph_face): Add prototype. * xdisp.c (last_glyphless_glyph_frame, last_glyphless_glyph_face_id) (last_glyphless_glyph_merged_face_id): Now static. (merge_escape_glyph_face): New function, refactored from... (get_next_display_element): ...here. (merge_glyphless_glyph_face): New function, refactored from... (produce_glyphless_glyph): ...here... * term.c (produce_glyphless_glyph): ...and here. --- src/ChangeLog | 13 ++++++ src/dispextern.h | 1 + src/lisp.h | 3 -- src/term.c | 19 +------- src/xdisp.c | 117 +++++++++++++++++++++++------------------------ 5 files changed, 72 insertions(+), 81 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index 526b05fbd9f..7f41abc46bb 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,16 @@ +2013-09-06 Dmitry Antipov + + * lisp.h (last_glyphless_glyph_frame, last_glyphless_glyph_face_id) + (last_glyphless_glyph_merged_face_id): Remove declarations. + * dispextern.h (merge_glyphless_glyph_face): Add prototype. + * xdisp.c (last_glyphless_glyph_frame, last_glyphless_glyph_face_id) + (last_glyphless_glyph_merged_face_id): Now static. + (merge_escape_glyph_face): New function, refactored from... + (get_next_display_element): ...here. + (merge_glyphless_glyph_face): New function, refactored from... + (produce_glyphless_glyph): ...here... + * term.c (produce_glyphless_glyph): ...and here. + 2013-09-06 Stefan Monnier * eval.c (eval_sub): Only call Ffunction if necessary. diff --git a/src/dispextern.h b/src/dispextern.h index 864229e1d04..f15da1e6564 100644 --- a/src/dispextern.h +++ b/src/dispextern.h @@ -3208,6 +3208,7 @@ extern ptrdiff_t compute_display_string_pos (struct text_pos *, extern ptrdiff_t compute_display_string_end (ptrdiff_t, struct bidi_string_data *); extern void produce_stretch_glyph (struct it *); +extern int merge_glyphless_glyph_face (struct it *); #ifdef HAVE_WINDOW_SYSTEM diff --git a/src/lisp.h b/src/lisp.h index 27359ffeb3f..38b538d9bc2 100644 --- a/src/lisp.h +++ b/src/lisp.h @@ -3359,9 +3359,6 @@ extern Lisp_Object Qglyphless_char; extern Lisp_Object QCdata, QCfile; extern Lisp_Object QCmap; extern Lisp_Object Qrisky_local_variable; -extern struct frame *last_glyphless_glyph_frame; -extern int last_glyphless_glyph_face_id; -extern int last_glyphless_glyph_merged_face_id; extern int noninteractive_need_newline; extern Lisp_Object echo_area_buffer[2]; extern void add_to_log (const char *, Lisp_Object, Lisp_Object); diff --git a/src/term.c b/src/term.c index aa61fde06ee..0270c1eefa6 100644 --- a/src/term.c +++ b/src/term.c @@ -1800,27 +1800,10 @@ append_glyphless_glyph (struct it *it, int face_id, const char *str) static void produce_glyphless_glyph (struct it *it, Lisp_Object acronym) { - int face_id; - int len; + int len, face_id = merge_glyphless_glyph_face (it); char buf[sizeof "\\x" + max (6, (sizeof it->c * CHAR_BIT + 3) / 4)]; char const *str = " "; - /* Get a face ID for the glyph by utilizing a cache (the same way as - done for `escape-glyph' in get_next_display_element). */ - if (it->f == last_glyphless_glyph_frame - && it->face_id == last_glyphless_glyph_face_id) - { - face_id = last_glyphless_glyph_merged_face_id; - } - else - { - /* Merge the `glyphless-char' face into the current face. */ - face_id = merge_faces (it->f, Qglyphless_char, 0, it->face_id); - last_glyphless_glyph_frame = it->f; - last_glyphless_glyph_face_id = it->face_id; - last_glyphless_glyph_merged_face_id = face_id; - } - if (it->glyphless_method == GLYPHLESS_DISPLAY_THIN_SPACE) { /* As there's no way to produce a thin space, we produce a space diff --git a/src/xdisp.c b/src/xdisp.c index a7f7fc88198..d5def065936 100644 --- a/src/xdisp.c +++ b/src/xdisp.c @@ -6666,17 +6666,59 @@ lookup_glyphless_char_display (int c, struct it *it) return glyphless_method; } -/* Load IT's display element fields with information about the next - display element from the current position of IT. Value is zero if - end of buffer (or C string) is reached. */ +/* Merge escape glyph face and cache the result. */ static struct frame *last_escape_glyph_frame = NULL; static int last_escape_glyph_face_id = (1 << FACE_ID_BITS); static int last_escape_glyph_merged_face_id = 0; -struct frame *last_glyphless_glyph_frame = NULL; -int last_glyphless_glyph_face_id = (1 << FACE_ID_BITS); -int last_glyphless_glyph_merged_face_id = 0; +static int +merge_escape_glyph_face (struct it *it) +{ + int face_id; + + if (it->f == last_escape_glyph_frame + && it->face_id == last_escape_glyph_face_id) + face_id = last_escape_glyph_merged_face_id; + else + { + /* Merge the `escape-glyph' face into the current face. */ + face_id = merge_faces (it->f, Qescape_glyph, 0, it->face_id); + last_escape_glyph_frame = it->f; + last_escape_glyph_face_id = it->face_id; + last_escape_glyph_merged_face_id = face_id; + } + return face_id; +} + +/* Likewise for glyphless glyph face. */ + +static struct frame *last_glyphless_glyph_frame = NULL; +static int last_glyphless_glyph_face_id = (1 << FACE_ID_BITS); +static int last_glyphless_glyph_merged_face_id = 0; + +int +merge_glyphless_glyph_face (struct it *it) +{ + int face_id; + + if (it->f == last_glyphless_glyph_frame + && it->face_id == last_glyphless_glyph_face_id) + face_id = last_glyphless_glyph_merged_face_id; + else + { + /* Merge the `glyphless-char' face into the current face. */ + face_id = merge_faces (it->f, Qglyphless_char, 0, it->face_id); + last_glyphless_glyph_frame = it->f; + last_glyphless_glyph_face_id = it->face_id; + last_glyphless_glyph_merged_face_id = face_id; + } + return face_id; +} + +/* Load IT's display element fields with information about the next + display element from the current position of IT. Value is zero if + end of buffer (or C string) is reached. */ static int get_next_display_element (struct it *it) @@ -6824,24 +6866,10 @@ get_next_display_element (struct it *it) g = GLYPH_CODE_CHAR (gc); lface_id = GLYPH_CODE_FACE (gc); } - if (lface_id) - { - face_id = merge_faces (it->f, Qt, lface_id, it->face_id); - } - else if (it->f == last_escape_glyph_frame - && it->face_id == last_escape_glyph_face_id) - { - face_id = last_escape_glyph_merged_face_id; - } - else - { - /* Merge the escape-glyph face into the current face. */ - face_id = merge_faces (it->f, Qescape_glyph, 0, - it->face_id); - last_escape_glyph_frame = it->f; - last_escape_glyph_face_id = it->face_id; - last_escape_glyph_merged_face_id = face_id; - } + + face_id = (lface_id + ? merge_faces (it->f, Qt, lface_id, it->face_id) + : merge_escape_glyph_face (it)); XSETINT (it->ctl_chars[0], g); XSETINT (it->ctl_chars[1], c ^ 0100); @@ -6873,27 +6901,10 @@ get_next_display_element (struct it *it) escape_glyph = GLYPH_CODE_CHAR (gc); lface_id = GLYPH_CODE_FACE (gc); } - if (lface_id) - { - /* The display table specified a face. - Merge it into face_id and also into escape_glyph. */ - face_id = merge_faces (it->f, Qt, lface_id, - it->face_id); - } - else if (it->f == last_escape_glyph_frame - && it->face_id == last_escape_glyph_face_id) - { - face_id = last_escape_glyph_merged_face_id; - } - else - { - /* Merge the escape-glyph face into the current face. */ - face_id = merge_faces (it->f, Qescape_glyph, 0, - it->face_id); - last_escape_glyph_frame = it->f; - last_escape_glyph_face_id = it->face_id; - last_escape_glyph_merged_face_id = face_id; - } + + face_id = (lface_id + ? merge_faces (it->f, Qt, lface_id, it->face_id) + : merge_escape_glyph_face (it)); /* Draw non-ASCII hyphen with just highlighting: */ @@ -24895,21 +24906,7 @@ produce_glyphless_glyph (struct it *it, int for_no_font, Lisp_Object acronym) base_height = it->ascent + it->descent; base_width = font->average_width; - /* Get a face ID for the glyph by utilizing a cache (the same way as - done for `escape-glyph' in get_next_display_element). */ - if (it->f == last_glyphless_glyph_frame - && it->face_id == last_glyphless_glyph_face_id) - { - face_id = last_glyphless_glyph_merged_face_id; - } - else - { - /* Merge the `glyphless-char' face into the current face. */ - face_id = merge_faces (it->f, Qglyphless_char, 0, it->face_id); - last_glyphless_glyph_frame = it->f; - last_glyphless_glyph_face_id = it->face_id; - last_glyphless_glyph_merged_face_id = face_id; - } + face_id = merge_glyphless_glyph_face (it); if (it->glyphless_method == GLYPHLESS_DISPLAY_THIN_SPACE) { -- 2.39.2