aboutsummaryrefslogtreecommitdiffstats
path: root/src/term.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/term.c')
-rw-r--r--src/term.c25
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,
751static void 751static void
752tty_write_glyphs (struct frame *f, struct glyph *string, int len) 752tty_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);