refresh canvas dimensions on refresh

This commit is contained in:
meganrogge
2022-03-22 01:53:10 -04:00
parent dddde8ec23
commit 21e1c5ef58
2 changed files with 9 additions and 5 deletions
@@ -49,7 +49,7 @@ export class OverviewRulerRenderer extends Disposable {
super();
this._canvas = document.createElement('canvas');
this._canvas.classList.add('xterm-decoration-overview-ruler');
this._refreshCanvasDimensions();
this.refreshCanvasDimensions();
this._viewportElement.parentElement?.insertBefore(this._canvas, this._viewportElement);
const ctx = this._canvas.getContext('2d');
if (!ctx) {
@@ -129,7 +129,7 @@ export class OverviewRulerRenderer extends Disposable {
);
}
private _refreshCanvasDimensions(): void {
public refreshCanvasDimensions(): void {
this._canvas.style.width = `${this._width}px`;
this._canvas.style.height = `${this._screenElement.clientHeight}px`;
this._canvas.width = Math.round(this._width * window.devicePixelRatio);
@@ -139,7 +139,7 @@ export class OverviewRulerRenderer extends Disposable {
private _refreshDecorations(updateCanvasDimensions?: boolean, updateAnchor?: boolean): void {
if (updateCanvasDimensions) {
this._refreshCanvasDimensions();
this.refreshCanvasDimensions();
}
this._ctx.clearRect(0, 0, this._canvas.width, this._canvas.height);
for (const decoration of this._decorationService.decorations) {
+6 -2
View File
@@ -175,7 +175,9 @@ export class Terminal extends CoreTerminal implements ITerminal {
// Setup InputHandler listeners
this.register(this._inputHandler.onRequestBell(() => this.bell()));
this.register(this._inputHandler.onRequestRefreshRows((start, end) => this.refresh(start, end)));
this.register(this._inputHandler.onRequestRefreshRows((start, end) => {
this.refresh(start, end);
}));
this.register(this._inputHandler.onRequestSendFocus(() => this._reportFocus()));
this.register(this._inputHandler.onRequestReset(() => this.reset()));
this.register(this._inputHandler.onRequestWindowsOptionsReport(type => this._reportWindowsOptions(type)));
@@ -613,7 +615,8 @@ export class Terminal extends CoreTerminal implements ITerminal {
this.optionsService.onOptionChange(() => {
if (!this._overviewRulerRenderer && this.options.overviewRulerWidth && this._viewportElement && this.screenElement) {
this._overviewRulerRenderer = this._instantiationService.createInstance(OverviewRulerRenderer, this._viewportElement, this.screenElement);
}});
}
});
// Measure the character size
this._charSizeService.measure();
@@ -906,6 +909,7 @@ export class Terminal extends CoreTerminal implements ITerminal {
*/
public refresh(start: number, end: number): void {
this._renderService?.refreshRows(start, end);
this._overviewRulerRenderer?.refreshCanvasDimensions();
}
/**