term: term_print(): clear line break flag

The line break flag is used by the text reflow and text
extraction (i.e. copy-paste) logic, to determine whether or not to
insert a newline between two lines.

There’s some amount of heuristics involved in this. For example, the
client application could emit a newline, move the cursor back up, and
print text. What does that mean for us?

Foot’s behavior up until now has been this:

The line break flag is set on the row, when the application emits an
explicit linefeed. The flag is cleared when the line is erased. But
otherwise not.

This meant that emitting a linefeed and then moving the cursor back up
and printing text, did not clear the line break flag. This in turn
meant that text copied always had newlines inserted, even though that
was not the client applications intention.

By clearing the line break flag whenever _anything_ is printed to a
row, the new behavior is, in practice, that the line break flag is
only set on a row if a linefeed was that *last* thing printed to that
row.

Closes #410
This commit is contained in:
Daniel Eklöf 2021-03-23 11:02:51 +01:00
parent deaf17e01d
commit ee75e10e71
No known key found for this signature in database
GPG key ID: 5BBD4992C116573F

View file

@ -2870,6 +2870,7 @@ term_print(struct terminal *term, wchar_t wc, int width)
cell->attrs = term->vt.attrs;
row->dirty = true;
row->linebreak = false;
cell->attrs.clean = 0;
/* Advance cursor the 'additional' columns while dirty:ing the cells */
@ -2909,6 +2910,7 @@ ascii_printer_fast(struct terminal *term, wchar_t wc)
cell->attrs = term->vt.attrs;
row->dirty = true;
row->linebreak = false;
cell->attrs.clean = 0;
/* Advance cursor */