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

Support for lineHeight in DOM Renderer #1733

Merged
merged 6 commits into from
Oct 28, 2018
Merged

Conversation

leomoty
Copy link
Contributor

@leomoty leomoty commented Oct 9, 2018

Related to #1700. I've attempted to port the calculations from Canvas renderer, it seems to be a few pixels off.

Also, does xterm.js support zooming the browser officially? That is not working properly.

@Tyriar, can you please take a look.

@Tyriar
Copy link
Member

Tyriar commented Oct 9, 2018

Also, does xterm.js support zooming the browser officially? That is not working properly.

@leomoty yes using the browser zoom should work.

@Tyriar
Copy link
Member

Tyriar commented Oct 9, 2018

@leomoty it looks like browser zoom is working? I do notice that selection is not taking line height into account though (click and drag in the terminal with line height = 2).

@leomoty
Copy link
Contributor Author

leomoty commented Oct 9, 2018

@Tyriar, maybe what I am seeing is font sizing/spacing related? Yeah, I didn't test selection. Will do after work.

@Tyriar
Copy link
Member

Tyriar commented Oct 9, 2018

Hm, seems alright to me. Note that you're not aiming for exact parity with the canvas renderer, it's fine if they're a little different.

@leomoty
Copy link
Contributor Author

leomoty commented Oct 9, 2018

@Tyriar, updated _createSelectionElement, the selection height is working properly now, but the selection doesn't seem to match as you go down the lines. Any pointers?

@Tyriar
Copy link
Member

Tyriar commented Oct 11, 2018

@leomoty here's the function that grabs the coordinates from the MouseEvent:

this._model.selectionStart = this._getMouseBufferCoords(event);

@Tyriar Tyriar added the work-in-progress Do not merge label Oct 24, 2018
@Tyriar Tyriar self-assigned this Oct 24, 2018
@Tyriar Tyriar self-requested a review October 24, 2018 23:29
@leomoty
Copy link
Contributor Author

leomoty commented Oct 25, 2018

@Tyriar I have been a bit busy with work, just noticed the status change, I also took another look, I might have found the issue. Unsure why it happens tho.

Following the code you gave me it goes here:

https://github.com/xtermjs/xterm.js/blob/master/src/utils/MouseHelper.ts#L51-L72

When I tried to inspect this._renderer.dimensions there, it doesnt seem to account for the changes I did in:

https://github.com/xtermjs/xterm.js/pull/1733/files#diff-0a9d734ca7737653ca5c980f3c663f7aR96

I.e. actualCellHeight is 17px instead of the expected 34px. I can confirm that inside _updateDimensions it is fine.

@leomoty
Copy link
Contributor Author

leomoty commented Oct 25, 2018

As a follow-up: getCoords gets lineHeight passed in, if I apply that to actualCellHeight it works as expected.

I wonder if this might break the canvas renderer tho. I'll wait for your feedback.

@Tyriar
Copy link
Member

Tyriar commented Oct 26, 2018

I don't think you'll need to change anything in the selection or coord code that would impact the canvas renderer as it's working for the canvas renderer. You could use the canvas renderer and see how exactly the line height is being taken into account for the selection stuff. That way you can apply whatever the canvas renderer does to the DOM renderer.

I have been a bit busy with work, just noticed the status change, I also took another look

No rush of course, that was just me organizing a little.

@leomoty
Copy link
Contributor Author

leomoty commented Oct 26, 2018

@Tyriar Yeah, I didn't mean to change canvas renderer nor selection at all, when I noticed the MouseHelper@getCoords function, I checked the this._renderer object there.

What I noticed is:

  • Canvas renderer works fine
  • The changes I did to Dom Renderer are not applied

Inside DomRenderer@_updateDimensions with lineHeight = 2.0, I get 34px for actualCellHeight.
However MouseHelper@getCoords still accounts for 17px.

I have not been able to track down why it happens.

src/Terminal.ts Outdated
@@ -473,6 +473,7 @@ export class Terminal extends EventEmitter implements ITerminal, IDisposable, II
if (this._theme) {
this.renderer.setTheme(this._theme);
}
this.mouseHelper = new MouseHelper(this.renderer);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@Tyriar when lineHeight is updated, it falls through to rendererType, and thus destroying the renderer, in which mouseHelper is never updated.

I am not sure we want to destroy the current renderer when those props are updated.

Either way, selection works properly with this change.

@leomoty leomoty changed the title [WIP] Support for lineHeight in DOM Renderer Support for lineHeight in DOM Renderer Oct 28, 2018
@Tyriar Tyriar removed the work-in-progress Do not merge label Oct 28, 2018
@Tyriar Tyriar added this to the 3.9.0 milestone Oct 28, 2018
Copy link
Member

@Tyriar Tyriar left a comment

Choose a reason for hiding this comment

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

Thanks for figuring that out 😄

Looks good, I made a couple of tweaks

@Tyriar Tyriar merged commit f3cd652 into xtermjs:master Oct 28, 2018
@leomoty leomoty deleted the line-height branch October 28, 2018 20:20
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.

2 participants