aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJimmy Aguilar Mena2019-09-14 21:15:17 +0200
committerJimmy Aguilar Mena2019-10-14 14:18:40 +0200
commit95d1c3b23e5188f10b7552a0c90613eb66cd2d94 (patch)
tree0c457e0f9d184f57b2450e99273405191b10b35d /src
parenteb259473db50e5083296b9dd1468e378c94ce7f1 (diff)
downloademacs-95d1c3b23e5188f10b7552a0c90613eb66cd2d94.tar.gz
emacs-95d1c3b23e5188f10b7552a0c90613eb66cd2d94.zip
Add space for cursor to work also in terminal.
* src/xdisp.c (append_space_for_newline): Modified to add the space with the last face also in terminal interface. (fill_column_indicator_column): Modified to group more conditions. (extend_face_to_end_of_line): Simplified code in fill_column_indicator to use the new function.
Diffstat (limited to 'src')
-rw-r--r--src/xdisp.c255
1 files changed, 126 insertions, 129 deletions
diff --git a/src/xdisp.c b/src/xdisp.c
index ad4d69938c8..8e87e8c0ac5 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -431,7 +431,7 @@ static Lisp_Object list_of_error;
431 met, return the (nonnegative) column number, else return a negative 431 met, return the (nonnegative) column number, else return a negative
432 value. */ 432 value. */
433static int 433static int
434fill_column_indicator_column (struct it *it) 434fill_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->continuation_lines_width == 0 437 && it->continuation_lines_width == 0
@@ -440,8 +440,16 @@ fill_column_indicator_column (struct it *it)
440 Lisp_Object col = (EQ (Vdisplay_fill_column_indicator_column, Qt) 440 Lisp_Object col = (EQ (Vdisplay_fill_column_indicator_column, Qt)
441 ? BVAR (current_buffer, fill_column) 441 ? BVAR (current_buffer, fill_column)
442 : Vdisplay_fill_column_indicator_column); 442 : Vdisplay_fill_column_indicator_column);
443
444 /* The stretch width needs to considet the latter
445 added glyph in append_space_for_newline. */
443 if (RANGED_FIXNUMP (0, col, INT_MAX)) 446 if (RANGED_FIXNUMP (0, col, INT_MAX))
444 return XFIXNUM (col); 447 {
448 int icol = XFIXNUM (col);
449 if (!INT_MULTIPLY_WRAPV (char_width, icol, &icol)
450 && !INT_ADD_WRAPV (it->lnum_pixel_width, icol, &icol))
451 return icol;
452 }
445 } 453 }
446 return -1; 454 return -1;
447} 455}
@@ -4244,7 +4252,7 @@ handle_face_prop_general (struct it *it, int initial_face_id,
4244 bufpos, 4252 bufpos,
4245 &next_stop, 4253 &next_stop,
4246 base_face_id, false); 4254 base_face_id, false);
4247 } 4255 } /* !is_string. */
4248 4256
4249 /* Is this a start of a run of characters with box face? 4257 /* Is this a start of a run of characters with box face?
4250 Caveat: this can be called for a freshly initialized 4258 Caveat: this can be called for a freshly initialized
@@ -21357,97 +21365,94 @@ compute_line_metrics (struct it *it)
21357static bool 21365static bool
21358append_space_for_newline (struct it *it, bool default_face_p) 21366append_space_for_newline (struct it *it, bool default_face_p)
21359{ 21367{
21360#ifdef HAVE_WINDOW_SYSTEM 21368 int n = it->glyph_row->used[TEXT_AREA];
21361 if (FRAME_WINDOW_P (it->f)) 21369
21370 if (it->glyph_row->glyphs[TEXT_AREA] + n
21371 < it->glyph_row->glyphs[1 + TEXT_AREA])
21362 { 21372 {
21363 int n = it->glyph_row->used[TEXT_AREA]; 21373 /* Save some values that must not be changed.
21364 21374 Must save IT->c and IT->len because otherwise
21365 if (it->glyph_row->glyphs[TEXT_AREA] + n 21375 ITERATOR_AT_END_P wouldn't work anymore after
21366 < it->glyph_row->glyphs[1 + TEXT_AREA]) 21376 append_space_for_newline has been called. */
21367 { 21377 enum display_element_type saved_what = it->what;
21368 /* Save some values that must not be changed. 21378 int saved_c = it->c, saved_len = it->len;
21369 Must save IT->c and IT->len because otherwise 21379 int saved_char_to_display = it->char_to_display;
21370 ITERATOR_AT_END_P wouldn't work anymore after 21380 int saved_x = it->current_x;
21371 append_space_for_newline has been called. */ 21381 int saved_face_id = it->face_id;
21372 enum display_element_type saved_what = it->what; 21382 bool saved_box_end = it->end_of_box_run_p;
21373 int saved_c = it->c, saved_len = it->len; 21383 struct text_pos saved_pos = it->position;
21374 int saved_char_to_display = it->char_to_display; 21384 Lisp_Object saved_object = it->object;
21375 int saved_x = it->current_x; 21385 struct face *face;
21376 int saved_face_id = it->face_id; 21386
21377 bool saved_box_end = it->end_of_box_run_p; 21387 it->what = IT_CHARACTER;
21378 struct text_pos saved_pos; 21388 memset (&it->position, 0, sizeof it->position);
21379 Lisp_Object saved_object; 21389 it->object = Qnil;
21380 struct face *face; 21390 it->len = 1;
21381 21391
21382 saved_object = it->object; 21392 int local_default_face_id =
21383 saved_pos = it->position; 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);
21384 21396
21385 it->what = IT_CHARACTER; 21397 /* Corner case for when display-fill-column-indicator-mode
21386 memset (&it->position, 0, sizeof it->position); 21398 is active and the extra character should be added in the
21387 it->object = Qnil; 21399 same place than the line. */
21388 it->len = 1;
21389 21400
21390 int local_default_face_id = 21401 int char_width = 1;
21391 lookup_basic_face (it->w, it->f, DEFAULT_FACE_ID);
21392 struct face* default_face =
21393 FACE_FROM_ID_OR_NULL (it->f, local_default_face_id);
21394
21395 /* Corner case for when display-fill-column-indicator-mode
21396 is active and the extra character should be added in the
21397 same place than the line. */
21398 int indicator_column = (it->w->pseudo_window_p == 0
21399 ? fill_column_indicator_column (it)
21400 : -1);
21401 if (indicator_column >= 0)
21402 {
21403 struct font *font = (default_face->font
21404 ? default_face->font
21405 : FRAME_FONT (it->f));
21406 const int char_width = (font->average_width
21407 ? font->average_width
21408 : font->space_width);
21409 int column_x;
21410
21411 if (!INT_MULTIPLY_WRAPV (indicator_column, char_width,
21412 &column_x)
21413 && !INT_ADD_WRAPV (it->lnum_pixel_width, column_x,
21414 &column_x)
21415 && it->current_x == column_x)
21416 {
21417 it->c = it->char_to_display
21418 = XFIXNAT (Vdisplay_fill_column_indicator_character);
21419 it->face_id
21420 = merge_faces (it->w, Qfill_column_indicator,
21421 0, saved_face_id);
21422 face = FACE_FROM_ID (it->f, it->face_id);
21423 goto produce_glyphs;
21424 }
21425 }
21426
21427 it->c = it->char_to_display = ' ';
21428 /* If the default face was remapped, be sure to use the
21429 remapped face for the appended newline. */
21430 if (default_face_p)
21431 it->face_id = local_default_face_id;
21432 else if (it->face_before_selective_p)
21433 it->face_id = it->saved_face_id;
21434 21402
21403#ifdef HAVE_WINDOW_SYSTEM
21404 if (FRAME_WINDOW_P (it->f))
21405 {
21406 struct font *font = (default_face->font
21407 ? default_face->font
21408 : FRAME_FONT (it->f));
21409 char_width = (font->average_width
21410 ? font->average_width
21411 : font->space_width);
21412 }
21413#endif
21414 const int indicator_column =
21415 (it->w->pseudo_window_p == 0
21416 ? fill_column_indicator_column (it, char_width)
21417 : -1);
21418
21419 if (it->current_x == indicator_column)
21420 {
21421 it->c = it->char_to_display
21422 = XFIXNAT (Vdisplay_fill_column_indicator_character);
21423 it->face_id
21424 = merge_faces (it->w, Qfill_column_indicator,
21425 0, saved_face_id);
21435 face = FACE_FROM_ID (it->f, it->face_id); 21426 face = FACE_FROM_ID (it->f, it->face_id);
21436 it->face_id = FACE_FOR_CHAR (it->f, face, 0, -1, Qnil); 21427 goto produce_glyphs;
21437 /* In R2L rows, we will prepend a stretch glyph that will 21428 }
21438 have the end_of_box_run_p flag set for it, so there's no
21439 need for the appended newline glyph to have that flag
21440 set. */
21441 if (it->glyph_row->reversed_p
21442 /* But if the appended newline glyph goes all the way to
21443 the end of the row, there will be no stretch glyph,
21444 so leave the box flag set. */
21445 && saved_x + FRAME_COLUMN_WIDTH (it->f) < it->last_visible_x)
21446 it->end_of_box_run_p = false;
21447
21448 produce_glyphs:
21449 PRODUCE_GLYPHS (it);
21450 21429
21430 it->c = it->char_to_display = ' ';
21431 /* If the default face was remapped, be sure to use the
21432 remapped face for the appended newline. */
21433 it->face_id = default_face_p
21434 ? local_default_face_id
21435 : it->saved_face_id;
21436
21437
21438 face = FACE_FROM_ID (it->f, it->face_id);
21439 it->face_id = FACE_FOR_CHAR (it->f, face, 0, -1, Qnil);
21440 /* In R2L rows, we will prepend a stretch glyph that will
21441 have the end_of_box_run_p flag set for it, so there's no
21442 need for the appended newline glyph to have that flag
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);
21453#ifdef HAVE_WINDOW_SYSTEM
21454 if (FRAME_WINDOW_P (it->f))
21455 {
21451 /* Make sure this space glyph has the right ascent and 21456 /* Make sure this space glyph has the right ascent and
21452 descent values, or else cursor at end of line will look 21457 descent values, or else cursor at end of line will look
21453 funny, and height of empty lines will be incorrect. */ 21458 funny, and height of empty lines will be incorrect. */
@@ -21468,8 +21473,8 @@ append_space_for_newline (struct it *it, bool default_face_p)
21468 gui_produce_glyph for newline characters. */ 21473 gui_produce_glyph for newline characters. */
21469 height = get_it_property (it, Qline_height); 21474 height = get_it_property (it, Qline_height);
21470 if (CONSP (height) 21475 if (CONSP (height)
21471 && CONSP (XCDR (height)) 21476 && CONSP (XCDR (height))
21472 && NILP (XCDR (XCDR (height)))) 21477 && NILP (XCDR (XCDR (height))))
21473 { 21478 {
21474 total_height = XCAR (XCDR (height)); 21479 total_height = XCAR (XCDR (height));
21475 height = XCAR (height); 21480 height = XCAR (height);
@@ -21498,12 +21503,12 @@ append_space_for_newline (struct it *it, bool default_face_p)
21498 21503
21499 if (!NILP (total_height)) 21504 if (!NILP (total_height))
21500 spacing = calc_line_height_property (it, total_height, font, 21505 spacing = calc_line_height_property (it, total_height, font,
21501 boff, false); 21506 boff, false);
21502 else 21507 else
21503 { 21508 {
21504 spacing = get_it_property (it, Qline_spacing); 21509 spacing = get_it_property (it, Qline_spacing);
21505 spacing = calc_line_height_property (it, spacing, font, 21510 spacing = calc_line_height_property (it, spacing, font,
21506 boff, false); 21511 boff, false);
21507 } 21512 }
21508 if (FIXNUMP (spacing)) 21513 if (FIXNUMP (spacing))
21509 { 21514 {
@@ -21526,22 +21531,21 @@ append_space_for_newline (struct it *it, bool default_face_p)
21526 21531
21527 g->ascent = it->max_ascent; 21532 g->ascent = it->max_ascent;
21528 g->descent = it->max_descent; 21533 g->descent = it->max_descent;
21529
21530 it->override_ascent = -1;
21531 it->constrain_row_ascent_descent_p = false;
21532 it->current_x = saved_x;
21533 it->object = saved_object;
21534 it->position = saved_pos;
21535 it->what = saved_what;
21536 it->face_id = saved_face_id;
21537 it->len = saved_len;
21538 it->c = saved_c;
21539 it->char_to_display = saved_char_to_display;
21540 it->end_of_box_run_p = saved_box_end;
21541 return true;
21542 } 21534 }
21535#endif // HAVE_WINDOW_SYSTEM
21536 it->override_ascent = -1;
21537 it->constrain_row_ascent_descent_p = false;
21538 it->current_x = saved_x;
21539 it->object = saved_object;
21540 it->position = saved_pos;
21541 it->what = saved_what;
21542 it->face_id = saved_face_id;
21543 it->len = saved_len;
21544 it->c = saved_c;
21545 it->char_to_display = saved_char_to_display;
21546 it->end_of_box_run_p = saved_box_end;
21547 return true;
21543 } 21548 }
21544#endif
21545 21549
21546 return false; 21550 return false;
21547} 21551}
@@ -21657,9 +21661,6 @@ extend_face_to_end_of_line (struct it *it)
21657 /* Display fill column indicator if not in modeline or 21661 /* Display fill column indicator if not in modeline or
21658 toolbar and display fill column indicator mode is 21662 toolbar and display fill column indicator mode is
21659 active. */ 21663 active. */
21660 const int indicator_column = (it->w->pseudo_window_p == 0
21661 ? fill_column_indicator_column (it)
21662 : -1);
21663 21664
21664 struct font *font = (default_face->font 21665 struct font *font = (default_face->font
21665 ? default_face->font 21666 ? default_face->font
@@ -21668,7 +21669,11 @@ extend_face_to_end_of_line (struct it *it)
21668 const int char_width = (font->average_width 21669 const int char_width = (font->average_width
21669 ? font->average_width 21670 ? font->average_width
21670 : font->space_width); 21671 : font->space_width);
21671 int column_x; 21672
21673 const int indicator_column =
21674 (it->w->pseudo_window_p == 0
21675 ? fill_column_indicator_column (it, char_width)
21676 : -1);
21672 21677
21673 const char saved_char = it->char_to_display; 21678 const char saved_char = it->char_to_display;
21674 const struct text_pos saved_pos = it->position; 21679 const struct text_pos saved_pos = it->position;
@@ -21678,22 +21683,18 @@ extend_face_to_end_of_line (struct it *it)
21678 const int saved_face_id = it->face_id; 21683 const int saved_face_id = it->face_id;
21679 21684
21680 it->face_id = it->extend_face_id; 21685 it->face_id = it->extend_face_id;
21686 it->avoid_cursor_p = true;
21687 it->object = Qnil;
21681 21688
21682 if (indicator_column >= 0 21689 if (indicator_column >= 0
21683 && !INT_MULTIPLY_WRAPV (indicator_column, char_width, &column_x) 21690 && indicator_column > it->current_x
21684 && !INT_ADD_WRAPV (it->lnum_pixel_width, column_x, &column_x) 21691 && indicator_column < it->last_visible_x)
21685 && column_x >= it->current_x
21686 && column_x <= it->last_visible_x)
21687 { 21692 {
21688 21693
21689 /* The stretch width needs to considet the latter 21694 const int stretch_width =
21690 added glyph. */ 21695 indicator_column - it->current_x - char_width;
21691 const int stretch_width
21692 = column_x - it->current_x - char_width;
21693 21696
21694 memset (&it->position, 0, sizeof it->position); 21697 memset (&it->position, 0, sizeof it->position);
21695 it->avoid_cursor_p = true;
21696 it->object = Qnil;
21697 21698
21698 /* Only generate a stretch glyph if there is distance 21699 /* Only generate a stretch glyph if there is distance
21699 between current_x and and the indicator position. */ 21700 between current_x and and the indicator position. */
@@ -21708,7 +21709,7 @@ extend_face_to_end_of_line (struct it *it)
21708 21709
21709 /* Generate the glyph indicator only if 21710 /* Generate the glyph indicator only if
21710 append_space_for_newline didn't already. */ 21711 append_space_for_newline didn't already. */
21711 if (it->current_x < column_x) 21712 if (it->current_x < indicator_column)
21712 { 21713 {
21713 const int save_face_id = it->face_id; 21714 const int save_face_id = it->face_id;
21714 it->char_to_display 21715 it->char_to_display
@@ -21718,7 +21719,6 @@ extend_face_to_end_of_line (struct it *it)
21718 0, it->extend_face_id); 21719 0, it->extend_face_id);
21719 PRODUCE_GLYPHS (it); 21720 PRODUCE_GLYPHS (it);
21720 it->face_id = save_face_id; 21721 it->face_id = save_face_id;
21721
21722 } 21722 }
21723 } 21723 }
21724 21724
@@ -21853,14 +21853,13 @@ extend_face_to_end_of_line (struct it *it)
21853 default_face->id : face->id); 21853 default_face->id : face->id);
21854 21854
21855 /* Display fill-column indicator if needed. */ 21855 /* Display fill-column indicator if needed. */
21856 int indicator_column = fill_column_indicator_column (it); 21856 const int indicator_column =
21857 if (indicator_column >= 0 21857 fill_column_indicator_column (it, 1) - 1;
21858 && INT_ADD_WRAPV (it->lnum_pixel_width, indicator_column,
21859 &indicator_column))
21860 indicator_column = -1;
21861 do 21858 do
21862 { 21859 {
21863 if (it->current_x == indicator_column) 21860 if (it->current_x != indicator_column)
21861 PRODUCE_GLYPHS (it);
21862 else
21864 { 21863 {
21865 int saved_face_id = it->face_id; 21864 int saved_face_id = it->face_id;
21866 it->face_id 21865 it->face_id
@@ -21873,8 +21872,6 @@ extend_face_to_end_of_line (struct it *it)
21873 it->face_id = saved_face_id; 21872 it->face_id = saved_face_id;
21874 it->c = it->char_to_display = ' '; 21873 it->c = it->char_to_display = ' ';
21875 } 21874 }
21876 else
21877 PRODUCE_GLYPHS (it);
21878 } 21875 }
21879 while (it->current_x <= it->last_visible_x); 21876 while (it->current_x <= it->last_visible_x);
21880 21877