diff options
| author | Gerd Möllmann | 2024-10-27 12:05:58 +0100 |
|---|---|---|
| committer | Gerd Möllmann | 2024-10-28 05:52:21 +0100 |
| commit | d3f8ed730fa10d7283c6638dc4cc20cabbe4f4bf (patch) | |
| tree | b97eadf7843b58cc648c203fdf5959e5c9a26bd1 /src/term.c | |
| parent | d7bf2cfd5d5713c9a9014807567e3f7e723280cf (diff) | |
| download | emacs-d3f8ed730fa10d7283c6638dc4cc20cabbe4f4bf.tar.gz emacs-d3f8ed730fa10d7283c6638dc4cc20cabbe4f4bf.zip | |
Don't work around a corner case once observed
* src/term.c (tty_write_glyphs): Refactor a bit. Don't check for null
glyph frame.
Diffstat (limited to 'src/term.c')
| -rw-r--r-- | src/term.c | 25 |
1 files changed, 8 insertions, 17 deletions
diff --git a/src/term.c b/src/term.c index 69abbc23d92..bd48e1f3e55 100644 --- a/src/term.c +++ b/src/term.c | |||
| @@ -751,18 +751,12 @@ encode_terminal_code (struct glyph *src, int src_len, | |||
| 751 | static void | 751 | static void |
| 752 | tty_write_glyphs (struct frame *f, struct glyph *string, int len) | 752 | tty_write_glyphs (struct frame *f, struct glyph *string, int len) |
| 753 | { | 753 | { |
| 754 | unsigned char *conversion_buffer; | ||
| 755 | struct coding_system *coding; | ||
| 756 | int n, stringlen; | ||
| 757 | |||
| 758 | struct tty_display_info *tty = FRAME_TTY (f); | 754 | struct tty_display_info *tty = FRAME_TTY (f); |
| 759 | |||
| 760 | tty_turn_off_insert (tty); | 755 | tty_turn_off_insert (tty); |
| 761 | tty_hide_cursor (tty); | 756 | tty_hide_cursor (tty); |
| 762 | 757 | ||
| 763 | /* Don't dare write in last column of bottom line, if Auto-Wrap, | 758 | /* Don't dare write in last column of bottom line, if Auto-Wrap, |
| 764 | since that would scroll the whole frame on some terminals. */ | 759 | since that would scroll the whole frame on some terminals. */ |
| 765 | |||
| 766 | if (AutoWrap (tty) | 760 | if (AutoWrap (tty) |
| 767 | && curY (tty) + 1 == FRAME_TOTAL_LINES (f) | 761 | && curY (tty) + 1 == FRAME_TOTAL_LINES (f) |
| 768 | && (curX (tty) + len) == FRAME_COLS (f)) | 762 | && (curX (tty) + len) == FRAME_COLS (f)) |
| @@ -775,22 +769,19 @@ tty_write_glyphs (struct frame *f, struct glyph *string, int len) | |||
| 775 | /* If terminal_coding does any conversion, use it, otherwise use | 769 | /* If terminal_coding does any conversion, use it, otherwise use |
| 776 | safe_terminal_coding. We can't use CODING_REQUIRE_ENCODING here | 770 | safe_terminal_coding. We can't use CODING_REQUIRE_ENCODING here |
| 777 | because it always return 1 if the member src_multibyte is 1. */ | 771 | because it always return 1 if the member src_multibyte is 1. */ |
| 778 | coding = (FRAME_TERMINAL_CODING (f)->common_flags & CODING_REQUIRE_ENCODING_MASK | 772 | struct coding_system *coding |
| 779 | ? FRAME_TERMINAL_CODING (f) : &safe_terminal_coding); | 773 | = (FRAME_TERMINAL_CODING (f)->common_flags & CODING_REQUIRE_ENCODING_MASK |
| 774 | ? FRAME_TERMINAL_CODING (f) : &safe_terminal_coding); | ||
| 775 | |||
| 780 | /* The mode bit CODING_MODE_LAST_BLOCK should be set to 1 only at | 776 | /* The mode bit CODING_MODE_LAST_BLOCK should be set to 1 only at |
| 781 | the tail. */ | 777 | the tail. */ |
| 782 | coding->mode &= ~CODING_MODE_LAST_BLOCK; | 778 | coding->mode &= ~CODING_MODE_LAST_BLOCK; |
| 783 | 779 | ||
| 784 | for (stringlen = len; stringlen != 0; stringlen -= n) | 780 | for (int stringlen = len, n; stringlen; stringlen -= n, string += n) |
| 785 | { | 781 | { |
| 786 | /* Identify a run of glyphs with the same face. */ | 782 | /* Identify a run of glyphs with the same face. */ |
| 787 | int face_id = string->face_id; | 783 | int face_id = string->face_id; |
| 788 | 784 | struct frame *face_id_frame = string->frame; | |
| 789 | /* FIXME/tty: it happens that a single glyph's frame is NULL. It | ||
| 790 | might depend on a tab bar line being present, then switching | ||
| 791 | from a buffer without header line to one with header line and | ||
| 792 | opening a child frame. */ | ||
| 793 | struct frame *face_id_frame = string->frame ? string->frame : f; | ||
| 794 | 785 | ||
| 795 | for (n = 1; n < stringlen; ++n) | 786 | for (n = 1; n < stringlen; ++n) |
| 796 | if (string[n].face_id != face_id || string[n].frame != face_id_frame) | 787 | if (string[n].face_id != face_id || string[n].frame != face_id_frame) |
| @@ -804,7 +795,8 @@ tty_write_glyphs (struct frame *f, struct glyph *string, int len) | |||
| 804 | if (n == stringlen) | 795 | if (n == stringlen) |
| 805 | /* This is the last run. */ | 796 | /* This is the last run. */ |
| 806 | coding->mode |= CODING_MODE_LAST_BLOCK; | 797 | coding->mode |= CODING_MODE_LAST_BLOCK; |
| 807 | conversion_buffer = encode_terminal_code (string, n, coding); | 798 | unsigned char *conversion_buffer |
| 799 | = encode_terminal_code (string, n, coding); | ||
| 808 | if (coding->produced > 0) | 800 | if (coding->produced > 0) |
| 809 | { | 801 | { |
| 810 | block_input (); | 802 | block_input (); |
| @@ -814,7 +806,6 @@ tty_write_glyphs (struct frame *f, struct glyph *string, int len) | |||
| 814 | fwrite (conversion_buffer, 1, coding->produced, tty->termscript); | 806 | fwrite (conversion_buffer, 1, coding->produced, tty->termscript); |
| 815 | unblock_input (); | 807 | unblock_input (); |
| 816 | } | 808 | } |
| 817 | string += n; | ||
| 818 | 809 | ||
| 819 | /* Turn appearance modes off. */ | 810 | /* Turn appearance modes off. */ |
| 820 | turn_off_face (f, face); | 811 | turn_off_face (f, face); |