JetBrains/jediterm — pull request #95 by Plonk42 (2014-05-28 13:29:46+00:00)
Title: Use NUL instead of spaces to clear area

Within the new TerminalTextBuffer, lines do not mandatory have a length equal to the terminal width.

This breaks the "Clear Line" control sequence `ESC[K`, because we clear only to the actual end of the line.
(see https://github.com/JetBrains/jediterm/commit/78f778afab777296eb2d1fd94de89f9160dfc0d2#diff-3 , fixing bug where current line is filled with unwanted spaces)

During `repaint()` we iterate trough the text entries, meaning that we never draw anything from the end of the line to the right border of the terminal (previously, lines where "filled" by spaces when copied from the `textBuffer` to the `backBuffer`).
To reproduce it, simply run `mc` and look at the end of the first line: we have the default background instead of the mc one.

So, we want to have chars to be able to clear to the right border, but we don't want spaces, which pollute selection and copy/paste.

This patch solves this issue by using the char `NUL` instead of spaces to clear lines.
This allow us to both paint the trailing regions if needed, and properly handle selection and copy/paste.
Now, end-of-line selection behave exactly the same than in xterm and gnome-terminal.

This has been successfully tested.