-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Support setting a padding on the .xterm element #1123
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
Conversation
Tyriar
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see a scroll bar anymore on macOS Sierra, even during scrolling?
|
|
||
| if (this.lastRecordedViewportHeight !== this.terminal.renderer.dimensions.canvasHeight) { | ||
| this.lastRecordedViewportHeight = this.terminal.renderer.dimensions.canvasHeight; | ||
| this.viewportElement.style.height = this.lastRecordedViewportHeight + 'px'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we not need to set this anymore?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well the new .xterm-screen element is positioned relative to the .xterm parent and has the same height as the canvas elements inside. Its width equals the width of the canvas + the width of the scrollbar on the viewport. If you add a padding to the .xterm element, that means that the .xterm element will grow by that padding. The viewport is positioned absolute to always match the size of the .xterm element. For that reason, we don't have to manually set the height of the viewport element any longer.
|
The scrollbar is still there, but OSX draws it black, so it is really hard to see: OSX draws a light or dark scrollbar, depending on the background color of the scrolling container. Unfortunately we cannot set the background color on the scrolling container because that would hide the content (canvas) underneath it 😟 Setting a opacity on the scroll container also applies that opacity to the scrollbar, so that doesn't work. The only thing that is working is to set the terminal background color on the scroll container with a very low alpha value e.g. |
|
I have added a workaround for the overlay scrollbar being barely visible on OSX. It sets the background color of the viewport element by taking the background color from the theme (which by the current design must be a 7 digit hex value, e.g. This background color on the viewport is not perceptible by the human eye, but it fools OSX into calculating the scrollbar thumb color based on that background color, ignoring the alpha. This solution adds another alpha pass to the browser's rendering pipeline which will slow it down a little bit. Unfortunately I couldn't find any other workaround, so I made sure this workaround is only applied on OSX, and if an overlay scrollbar is used (which we can detect if the scrollbar width is 0). |
|
The approach above doesn't work on all browsers (tested with the demo):
Conclusion: Solutions:
Workarounds I've tried:
|
|
I've fixed the code to support Firefox. At this stage, Chrome and Firefox both show the scrollbar thumb correctly - based on the terminal background color. I still can't get Safari to work correctly, but I'd argue that that's not a huge problem. The scrollbar is still visible on Safari, it's only dark no matter what background the terminal has... |
|
I don't think the
The dark scroll bar still happens on Safari but that was there before. Here's a very messy diff as a proof of concept: |
|
@Tyriar I'm tempted to not use a workaround for this at all. I agree that the hex value hack is bad and shouldn't go into production. I think that having empty space beside the screen area is even worse than having a barely visible overlay scrollbar. Ultimately, this bug should be solved by Chrome and Safari - Firefox seems to do the best job here. Last but not least, implementors can always provide their own scrollbar style via css (like vscode does), which will work just fine. @parisk @Tyriar Any thoughts? |
parisk
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For me it works great on Chrome and Firefox on High Sierra, but I get the barely visible scrollbar on Safari.
I think it's quite important to fix this, as it can lead Safari users to believe that they cannot scroll.
What we could do here is just detect safari and apply a custom scrollbar color on it. It won't look stellar, but it would do the work.
In general I am all in for this update after we fix this somehow. 👍
|
@Tyriar no problem. I'll get to it tomorrow, hope that's soon enough. |
|
@mofux sounds good 👌 |
|
There is also a test failure on Linux ( |
|
Pulled the |
The main reason for updating xterm.js is to get the fixes for the wrong height and width computation. Now, the output should not be too long or to short for the available space, both vertically and horizontally. Because of how things are computed now, it is not possible to apply a padding on the terminal container as we currently do. The padding will work, but the canvas width won't be adjusted, so the output will go too far on the right and at the bottom. Once this PR xtermjs/xterm.js#1123 gets merged in xterm.js, we should be able to add back the padding. The addon system has been reworked. Before, just importing the addons (fit and attach) would modify the Terminal prototype and add some methods. Now, we have to call the static method Terminal.applyAddon. Also, because of the changes to the addon system, we don't need the ignore-loader snippets in the webpack configuration anymore. Signed-off-by: Simon Marchi <simon.marchi@ericsson.com>
The main reason for updating xterm.js is to get the fixes for the wrong height and width computation. Now, the output should not be too long or to short for the available space, both vertically and horizontally. Because of how things are computed now, it is not possible to apply a padding on the terminal container as we currently do. The padding will work, but the canvas width won't be adjusted, so the output will go too far on the right and at the bottom. Once this PR xtermjs/xterm.js#1123 gets merged in xterm.js, we should be able to add back the padding. The addon system has been reworked. Before, just importing the addons (fit and attach) would modify the Terminal prototype and add some methods. Now, we have to call the static method Terminal.applyAddon. Also, because of the changes to the addon system, we don't need the ignore-loader snippets in the webpack configuration anymore. Signed-off-by: Simon Marchi <simon.marchi@ericsson.com>
The main reason for updating xterm.js is to get the fixes for the wrong height and width computation. Now, the output should not be too long or to short for the available space, both vertically and horizontally. Because of how things are computed now, it is not possible to apply a padding on the terminal container as we currently do. The padding will work, but the canvas width won't be adjusted, so the output will go too far on the right and at the bottom. Once this PR xtermjs/xterm.js#1123 gets merged in xterm.js, we should be able to add back the padding. The addon system has been reworked. Before, just importing the addons (fit and attach) would modify the Terminal prototype and add some methods. Now, we have to call the static method Terminal.applyAddon. Also, because of the changes to the addon system, we don't need the ignore-loader snippets in the webpack configuration anymore. Signed-off-by: Simon Marchi <simon.marchi@ericsson.com>
The main reason for updating xterm.js is to get the fixes for the wrong height and width computation. Now, the output should not be too long or to short for the available space, both vertically and horizontally. Because of how things are computed now, it is not possible to apply a padding on the terminal container as we currently do. The padding will work, but the canvas width won't be adjusted, so the output will go too far on the right and at the bottom. Once this PR xtermjs/xterm.js#1123 gets merged in xterm.js, we should be able to add back the padding. The addon system has been reworked. Before, just importing the addons (fit and attach) would modify the Terminal prototype and add some methods. Now, we have to call the static method Terminal.applyAddon. Also, because of the changes to the addon system, we don't need the ignore-loader snippets in the webpack configuration anymore. Signed-off-by: Simon Marchi <simon.marchi@ericsson.com> Signed-off-by: Anton Kosiakov <anton.kosyakov@typefox.io>
The main reason for updating xterm.js is to get the fixes for the wrong height and width computation. Now, the output should not be too long or to short for the available space, both vertically and horizontally. Because of how things are computed now, it is not possible to apply a padding on the terminal container as we currently do. The padding will work, but the canvas width won't be adjusted, so the output will go too far on the right and at the bottom. Once this PR xtermjs/xterm.js#1123 gets merged in xterm.js, we should be able to add back the padding. The addon system has been reworked. Before, just importing the addons (fit and attach) would modify the Terminal prototype and add some methods. Now, we have to call the static method Terminal.applyAddon. Also, because of the changes to the addon system, we don't need the ignore-loader snippets in the webpack configuration anymore. Signed-off-by: Simon Marchi <simon.marchi@ericsson.com>
The main reason for updating xterm.js is to get the fixes for the wrong height and width computation. Now, the output should not be too long or to short for the available space, both vertically and horizontally. Because of how things are computed now, it is not possible to apply a padding on the terminal container as we currently do. The padding will work, but the canvas width won't be adjusted, so the output will go too far on the right and at the bottom. Once this PR xtermjs/xterm.js#1123 gets merged in xterm.js, we should be able to add back the padding. The addon system has been reworked. Before, just importing the addons (fit and attach) would modify the Terminal prototype and add some methods. Now, we have to call the static method Terminal.applyAddon. Also, because of the changes to the addon system, we don't need the ignore-loader snippets in the webpack configuration anymore. Finally, I think we don't need @types/xterm anymore, since the xterm package provides its own typings. Signed-off-by: Simon Marchi <simon.marchi@ericsson.com>
The main reason for updating xterm.js is to get the fixes for the wrong height and width computation. Now, the output should not be too long or to short for the available space, both vertically and horizontally. Because of how things are computed now, it is not possible to apply a padding on the terminal container as we currently do. The padding will work, but the canvas width won't be adjusted, so the output will go too far on the right and at the bottom. Once this PR xtermjs/xterm.js#1123 gets merged in xterm.js, we should be able to add back the padding. The addon system has been reworked. Before, just importing the addons (fit and attach) would modify the Terminal prototype and add some methods. Now, we have to call the static method Terminal.applyAddon. Also, because of the changes to the addon system, we don't need the ignore-loader snippets in the webpack configuration anymore. Finally, I think we don't need @types/xterm anymore, since the xterm package provides its own typings. Signed-off-by: Simon Marchi <simon.marchi@ericsson.com>
|
Any updates on this PR? Also it seems like the black scroll bars are already an issue on master. |
|
Closing this PR in favour of #1208 |

Fixes #946
Fixes #1081
This PR moves the canvas layers into their own div element, .xterm-screen. This allows us to apply a css padding to the .xterm element and to have the scrollbar still fill the whole height of the .xterm element.
The fit() addon has also been updated to support this new feature.