Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fill lines inserted from scrolling with erase attributes #1706

Merged
merged 2 commits into from
Oct 24, 2018

Conversation

whydoubt
Copy link
Contributor

When scrolling occurs due to a LF or scroll code, the new line should be
filled with the currently set background color. As with VTE, fill with
the default color if the new line was caused by line-wrap.

Copy link
Member

@jerch jerch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yupp nice finding, just on issue from my side.

src/Terminal.ts Outdated
@@ -1170,7 +1170,8 @@ export class Terminal extends EventEmitter implements ITerminal, IDisposable, II
* @param isWrapped Whether the new line is wrapped from the previous line.
*/
public scroll(isWrapped?: boolean): void {
const newLine = BufferLine.blankLine(this.cols, DEFAULT_ATTR, isWrapped);
const blankAttr = isWrapped ? DEFAULT_ATTR : this.eraseAttr();
Copy link
Member

@jerch jerch Sep 22, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be compliant to xterm & vte imho the new line should always follow the erase char so this conditional is not needed. To see the difference you have to test it at the lower viewport border (not within the viewport, new lines are only spawned at the end).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

xterm (and others) always use the erase character.
vte (since 0.48.3) uses the erase character unless it is a new line caused by line-wrapping, diverging from xterm for reasons given in the following issue and commit.

So for vte behavior, you could accept the PR as-is.
If you do in-fact want xterm behavior instead, let me know and I will adjust accordingly.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah well, this is kinda messed up. Need to test first the behavior with a newer vte (tested with an older version above) as I think this will need more adjustments to get it right. So this has to wait for now.

Also up for discussion, whether to go with xterm (+most of others) or vte.

@Tyriar
Copy link
Member

Tyriar commented Sep 23, 2018

@whydoubt thanks for the PR! Is there an issue tracking this or just the PR? Also what's the test you're using to repro the issue?

@whydoubt
Copy link
Contributor Author

whydoubt commented Sep 24, 2018

No issue, just the PR.

If you cat tt_line_wrap_scroll in each terminal (while set between 76 and 100 columns), the difference between xterm and vte (>= 0.48.3) should be fairly obvious. I gzipped the file to make sure it doesn't get mangled in transmission.
tt_line_wrap_scroll.gz

@Tyriar
Copy link
Member

Tyriar commented Oct 11, 2018

For these sorts of issues we tend to opt for whatever the majority does, so it would be good to test this out in Terminal.app, iTerm2 as well as VTE.

@whydoubt
Copy link
Contributor Author

While I don't have a Mac to check what those terminals do, I have checked several that work on Linux. I suspect that VTE is unique. As I understand it, they rejected the majority on the grounds that—for the identified use case—their deviation was visually superior.

I will change this PR to follow xterm behavior, and may later submit a separate PR for VTE behavior. Improving the appearance of vim is my primary concern, and for that the xterm behavior is sufficient.

When scrolling occurs due to a LF or scroll code, fill the new line with
the currently-set background color.
@jerch
Copy link
Member

jerch commented Oct 22, 2018

@whydoubt LGTM 👍 Maybe we can add vte special behavior with a later PR and option. I see a valid point in vte's way, still I wonder whether the whole wrapped line should carry the customized background or just the wrapped content cells (dont like the latter either as it would introduce awkward state handling conditions). Maybe @egmontkob could shed some light on this too?

@jerch jerch added this to the 3.9.0 milestone Oct 24, 2018
@jerch jerch merged commit c77af88 into xtermjs:master Oct 24, 2018
@egmontkob
Copy link

Our side of the story was discussed in VTE 754596 along with the initial implementation, plus the partial revert we unfortunately had to make to please ncurses.

I'm not sure what you mean by "or just the wrapped content cells", could you please clarify? As far as I recall, this story is only relevant when a new line (consisting of unused aka empty cells) is scrolled in. Cells will get content as text is printed, which obviously needs to use the currently active attributes. But it was a long time ago and I might be missing something.

The point is that commands like

echo -e 'blah blah blah blah blah blah \e[43mblablablabla\e[0m'

should behave "sanely" even if the linebreak occurs while having a custom background color set, and even if this linebreak causes scrolling.

But there's no standard to adhere to, or if there's one then the standard is the "insane" behavior VTE intentionally deviates from.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants