diff options
| author | Jimmy Aguilar Mena | 2019-09-14 23:43:32 +0200 |
|---|---|---|
| committer | Jimmy Aguilar Mena | 2019-10-14 14:18:41 +0200 |
| commit | ab22720651cd792d2ca5c0c3ec20a5249c1ce1f0 (patch) | |
| tree | e3602c5695a44e70b869a3da62a77d47898f4d25 /src | |
| parent | 95d1c3b23e5188f10b7552a0c90613eb66cd2d94 (diff) | |
| download | emacs-ab22720651cd792d2ca5c0c3ec20a5249c1ce1f0.tar.gz emacs-ab22720651cd792d2ca5c0c3ec20a5249c1ce1f0.zip | |
Fix last change in append_space_for_newline.
* src/xdisp.c (append_space_for_newline): Code refactor and
simplification.
Diffstat (limited to 'src')
| -rw-r--r-- | src/xdisp.c | 95 |
1 files changed, 48 insertions, 47 deletions
diff --git a/src/xdisp.c b/src/xdisp.c index 8e87e8c0ac5..d77fe5d40a8 100644 --- a/src/xdisp.c +++ b/src/xdisp.c | |||
| @@ -434,6 +434,7 @@ static int | |||
| 434 | fill_column_indicator_column (struct it *it, int char_width) | 434 | fill_column_indicator_column (struct it *it, int char_width) |
| 435 | { | 435 | { |
| 436 | if (Vdisplay_fill_column_indicator | 436 | if (Vdisplay_fill_column_indicator |
| 437 | && it->w->pseudo_window_p == 0 | ||
| 437 | && it->continuation_lines_width == 0 | 438 | && it->continuation_lines_width == 0 |
| 438 | && CHARACTERP (Vdisplay_fill_column_indicator_character)) | 439 | && CHARACTERP (Vdisplay_fill_column_indicator_character)) |
| 439 | { | 440 | { |
| @@ -21378,7 +21379,7 @@ append_space_for_newline (struct it *it, bool default_face_p) | |||
| 21378 | int saved_c = it->c, saved_len = it->len; | 21379 | int saved_c = it->c, saved_len = it->len; |
| 21379 | int saved_char_to_display = it->char_to_display; | 21380 | int saved_char_to_display = it->char_to_display; |
| 21380 | int saved_x = it->current_x; | 21381 | int saved_x = it->current_x; |
| 21381 | int saved_face_id = it->face_id; | 21382 | const int saved_face_id = it->face_id; |
| 21382 | bool saved_box_end = it->end_of_box_run_p; | 21383 | bool saved_box_end = it->end_of_box_run_p; |
| 21383 | struct text_pos saved_pos = it->position; | 21384 | struct text_pos saved_pos = it->position; |
| 21384 | Lisp_Object saved_object = it->object; | 21385 | Lisp_Object saved_object = it->object; |
| @@ -21389,32 +21390,39 @@ append_space_for_newline (struct it *it, bool default_face_p) | |||
| 21389 | it->object = Qnil; | 21390 | it->object = Qnil; |
| 21390 | it->len = 1; | 21391 | it->len = 1; |
| 21391 | 21392 | ||
| 21392 | int local_default_face_id = | ||
| 21393 | lookup_basic_face (it->w, it->f, DEFAULT_FACE_ID); | ||
| 21394 | struct face* default_face = | ||
| 21395 | FACE_FROM_ID (it->f, local_default_face_id); | ||
| 21396 | |||
| 21397 | /* Corner case for when display-fill-column-indicator-mode | ||
| 21398 | is active and the extra character should be added in the | ||
| 21399 | same place than the line. */ | ||
| 21400 | |||
| 21401 | int char_width = 1; | 21393 | int char_width = 1; |
| 21402 | 21394 | ||
| 21395 | if (default_face_p | ||
| 21403 | #ifdef HAVE_WINDOW_SYSTEM | 21396 | #ifdef HAVE_WINDOW_SYSTEM |
| 21404 | if (FRAME_WINDOW_P (it->f)) | 21397 | || FRAME_WINDOW_P (it->f) |
| 21398 | #endif | ||
| 21399 | ) | ||
| 21405 | { | 21400 | { |
| 21406 | struct font *font = (default_face->font | 21401 | const int local_default_face_id = |
| 21407 | ? default_face->font | 21402 | lookup_basic_face (it->w, it->f, DEFAULT_FACE_ID); |
| 21408 | : FRAME_FONT (it->f)); | 21403 | struct face* default_face = |
| 21409 | char_width = (font->average_width | 21404 | FACE_FROM_ID (it->f, local_default_face_id); |
| 21410 | ? font->average_width | 21405 | |
| 21411 | : font->space_width); | 21406 | #ifdef HAVE_WINDOW_SYSTEM |
| 21412 | } | 21407 | if (FRAME_WINDOW_P (it->f)) |
| 21408 | { | ||
| 21409 | struct font *font = (default_face->font | ||
| 21410 | ? default_face->font | ||
| 21411 | : FRAME_FONT (it->f)); | ||
| 21412 | char_width = (font->average_width | ||
| 21413 | ? font->average_width | ||
| 21414 | : font->space_width); | ||
| 21415 | } | ||
| 21413 | #endif | 21416 | #endif |
| 21417 | if (default_face_p) | ||
| 21418 | it->face_id = local_default_face_id; | ||
| 21419 | } | ||
| 21420 | /* Corner case for when display-fill-column-indicator-mode | ||
| 21421 | is active and the extra character should be added in the | ||
| 21422 | same place than the line. */ | ||
| 21423 | |||
| 21414 | const int indicator_column = | 21424 | const int indicator_column = |
| 21415 | (it->w->pseudo_window_p == 0 | 21425 | fill_column_indicator_column (it, char_width); |
| 21416 | ? fill_column_indicator_column (it, char_width) | ||
| 21417 | : -1); | ||
| 21418 | 21426 | ||
| 21419 | if (it->current_x == indicator_column) | 21427 | if (it->current_x == indicator_column) |
| 21420 | { | 21428 | { |
| @@ -21424,31 +21432,26 @@ append_space_for_newline (struct it *it, bool default_face_p) | |||
| 21424 | = merge_faces (it->w, Qfill_column_indicator, | 21432 | = merge_faces (it->w, Qfill_column_indicator, |
| 21425 | 0, saved_face_id); | 21433 | 0, saved_face_id); |
| 21426 | face = FACE_FROM_ID (it->f, it->face_id); | 21434 | face = FACE_FROM_ID (it->f, it->face_id); |
| 21427 | goto produce_glyphs; | ||
| 21428 | } | 21435 | } |
| 21436 | else | ||
| 21437 | { | ||
| 21438 | it->c = it->char_to_display = ' '; | ||
| 21439 | /* If the default face was remapped, be sure to use the | ||
| 21440 | remapped face for the appended newline. */ | ||
| 21429 | 21441 | ||
| 21430 | it->c = it->char_to_display = ' '; | 21442 | face = FACE_FROM_ID (it->f, it->face_id); |
| 21431 | /* If the default face was remapped, be sure to use the | 21443 | it->face_id = FACE_FOR_CHAR (it->f, face, 0, -1, Qnil); |
| 21432 | remapped face for the appended newline. */ | 21444 | /* In R2L rows, we will prepend a stretch glyph that will |
| 21433 | it->face_id = default_face_p | 21445 | have the end_of_box_run_p flag set for it, so there's no |
| 21434 | ? local_default_face_id | 21446 | need for the appended newline glyph to have that flag |
| 21435 | : it->saved_face_id; | 21447 | set. */ |
| 21436 | 21448 | if (it->glyph_row->reversed_p | |
| 21437 | 21449 | /* But if the appended newline glyph goes all the way to | |
| 21438 | face = FACE_FROM_ID (it->f, it->face_id); | 21450 | the end of the row, there will be no stretch glyph, |
| 21439 | it->face_id = FACE_FOR_CHAR (it->f, face, 0, -1, Qnil); | 21451 | so leave the box flag set. */ |
| 21440 | /* In R2L rows, we will prepend a stretch glyph that will | 21452 | && saved_x + FRAME_COLUMN_WIDTH (it->f) < it->last_visible_x) |
| 21441 | have the end_of_box_run_p flag set for it, so there's no | 21453 | it->end_of_box_run_p = false; |
| 21442 | need for the appended newline glyph to have that flag | 21454 | } |
| 21443 | set. */ | ||
| 21444 | if (it->glyph_row->reversed_p | ||
| 21445 | /* But if the appended newline glyph goes all the way to | ||
| 21446 | the end of the row, there will be no stretch glyph, | ||
| 21447 | so leave the box flag set. */ | ||
| 21448 | && saved_x + FRAME_COLUMN_WIDTH (it->f) < it->last_visible_x) | ||
| 21449 | it->end_of_box_run_p = false; | ||
| 21450 | |||
| 21451 | produce_glyphs: | ||
| 21452 | PRODUCE_GLYPHS (it); | 21455 | PRODUCE_GLYPHS (it); |
| 21453 | #ifdef HAVE_WINDOW_SYSTEM | 21456 | #ifdef HAVE_WINDOW_SYSTEM |
| 21454 | if (FRAME_WINDOW_P (it->f)) | 21457 | if (FRAME_WINDOW_P (it->f)) |
| @@ -21671,9 +21674,7 @@ extend_face_to_end_of_line (struct it *it) | |||
| 21671 | : font->space_width); | 21674 | : font->space_width); |
| 21672 | 21675 | ||
| 21673 | const int indicator_column = | 21676 | const int indicator_column = |
| 21674 | (it->w->pseudo_window_p == 0 | 21677 | fill_column_indicator_column (it, char_width); |
| 21675 | ? fill_column_indicator_column (it, char_width) | ||
| 21676 | : -1); | ||
| 21677 | 21678 | ||
| 21678 | const char saved_char = it->char_to_display; | 21679 | const char saved_char = it->char_to_display; |
| 21679 | const struct text_pos saved_pos = it->position; | 21680 | const struct text_pos saved_pos = it->position; |