Linebreak status not cleared when printing on a row #410

Closed
opened 7 months ago by dnkl · 0 comments
dnkl commented 7 months ago
Owner

Foot currently tracks hard linebreaks as a boolean on the row struct. It is set when the client applications prints a \n, but not when foot auto-wraps.

The flag is cleared whenever the row is erased.

The flag is used when reflowing text (when resizing the window), and when extracting text from the grid (for example, when copying text with ctrl+shift+c).

Taking tmux as an example, it seems to move the cursor down the entire screen (to the status bar?), or possibly clearing the screen, by emitting lots of \n. The cursor is then moved back up.

I.e. we'll have set the newline flag on each and every row. This flag is virtually never cleared, unless tmux is forced to re-render the affected lines.

This causes foot to insert linebreaks into text copied from tmux.

One way to solve this is use one of the attribute bits in the cell struct to track newlines. The newline flag would then be cleared whenever that cell is overwritten.

But, what do we do with this flag, that can potentially be set on each and every cell on a single row? My guess is, we'd only care about the last cell.

But if that's the case, we could just as well keep the per-row flag, and simply clear it whenever something is printed to any cell on that row.

To summarize, we can either:

  • Add a newline flag bit to the cell struct. Set it on the cell the cursor is currently at when we see a \n. It is "automatically" cleared when the cell is erased or overwritten.
  • Keep the current newline flag in the row struct, but start clearing it as soon as we write something on the row.
Foot currently tracks hard linebreaks as a boolean on the row struct. It is set when the client applications prints a `\n`, but **not** when foot auto-wraps. The flag is cleared whenever the row is erased. The flag is used when reflowing text (when resizing the window), and when extracting text from the grid (for example, when copying text with <kbd>ctrl</kbd>+<kbd>shift</kbd>+<kbd>c</kbd>). Taking tmux as an example, it seems to move the cursor down the entire screen (to the status bar?), or possibly clearing the screen, by emitting lots of `\n`. The cursor is then moved back up. I.e. we'll have set the newline flag on each and every row. This flag is virtually never cleared, unless tmux is forced to re-render the affected lines. This causes foot to insert linebreaks into text copied from tmux. One way to solve this is use one of the attribute bits in the cell struct to track newlines. The newline flag would then be cleared whenever that cell is overwritten. But, what do we do with this flag, that can potentially be set on each and every cell on a single row? My guess is, we'd only care about the **last** cell. But if that's the case, we could just as well keep the per-row flag, and simply clear it whenever something is printed to _any_ cell on that row. To summarize, we can either: * Add a `newline` flag bit to the cell struct. Set it on the cell the cursor is currently at when we see a `\n`. It is "automatically" cleared when the cell is erased or overwritten. * Keep the current `newline` flag in the row struct, but start clearing it as soon as we write something on the row.
dnkl added the
bug
label 7 months ago
dnkl referenced this issue from a commit 7 months ago
dnkl closed this issue 7 months ago
Sign in to join this conversation.
No Milestone
No Assignees
1 Participants
Notifications
Due Date

No due date set.

Dependencies

This issue currently doesn't have any dependencies.

Loading…
There is no content yet.