add overviewRuler to addDecoration

This commit is contained in:
meganrogge
2022-03-15 20:50:13 -04:00
parent 7f8592282f
commit c277fb742d
2 changed files with 5 additions and 2 deletions
+3 -1
View File
@@ -545,13 +545,15 @@ function loadTest() {
}
function addDecoration() {
term.options['overviewRulerWidth'] = 15;
const marker = term.addMarker(1);
const decoration = term.registerDecoration({ marker });
decoration.onRender((e) => {
if (e.classList.value === 'xterm-decoration') {
e.style.backgroundColor = 'red';
e.style.backgroundColor = '#ef2929';
}
});
term.registerDecoration({marker, overviewRulerOptions: { color: '#ef2929'}})
}
function addOverviewRuler() {
@@ -61,6 +61,7 @@ export class OverviewRulerRenderer extends Disposable {
this._queueRefresh();
}
}));
console.log(this._width/3);
renderSizes[SizeIndex.OUTER_SIZE] = Math.floor(this._width / 3);
renderSizes[SizeIndex.INNER_SIZE] = Math.ceil(this._width / 3);
}
@@ -96,7 +97,7 @@ export class OverviewRulerRenderer extends Disposable {
this._ctx.strokeRect(
!decoration.options.overviewRulerOptions.position || decoration.options.overviewRulerOptions.position === 'left' ? 0 : decoration.options.overviewRulerOptions.position === 'right' ? renderSizes[SizeIndex.OUTER_SIZE] + renderSizes[SizeIndex.INNER_SIZE]: renderSizes[SizeIndex.OUTER_SIZE],
Math.round(this._canvas.height * (decoration.options.marker.line / this._bufferService.buffers.active.lines.length)),
!decoration.options.overviewRulerOptions.position ? this._width : decoration.options.overviewRulerOptions.position === 'center' ? renderSizes[SizeIndex.INNER_SIZE] : renderSizes[SizeIndex.OUTER_SIZE],
!decoration.options.overviewRulerOptions.position ? this._width : decoration.options.overviewRulerOptions.position === 'center' ? renderSizes[SizeIndex.INNER_SIZE]: renderSizes[SizeIndex.OUTER_SIZE],
window.devicePixelRatio
);
}