Merge branch 'xtermjs:master' into findAll
This commit is contained in:
+1
-5
@@ -553,11 +553,7 @@ function addDecoration() {
|
||||
term.options['overviewRulerWidth'] = 15;
|
||||
const marker = term.addMarker(1);
|
||||
const decoration = term.registerDecoration({ marker, overviewRulerOptions: { color: '#ef2929'} });
|
||||
decoration.onRender((e) => {
|
||||
if (e.classList.value === 'xterm-decoration') {
|
||||
e.style.backgroundColor = '#ef2929';
|
||||
}
|
||||
});
|
||||
decoration.onRender((e) => e.style.backgroundColor = '#ef2929');
|
||||
}
|
||||
|
||||
function addOverviewRuler() {
|
||||
|
||||
@@ -15,7 +15,7 @@ import { IBufferService, IDecorationService, IInternalDecoration, IOptionsServic
|
||||
const renderSizes = new Uint16Array(3);
|
||||
const enum SizeIndex {
|
||||
OUTER_SIZE = 0,
|
||||
INNER_SIZE = 0
|
||||
INNER_SIZE = 1
|
||||
}
|
||||
|
||||
export class OverviewRulerRenderer extends Disposable {
|
||||
@@ -91,13 +91,14 @@ export class OverviewRulerRenderer extends Disposable {
|
||||
this._decorationElements.delete(decoration);
|
||||
return;
|
||||
}
|
||||
this._ctx.lineWidth = !decoration.options.overviewRulerOptions.position ? 2 : 6;
|
||||
this._ctx.strokeStyle = decoration.options.overviewRulerOptions.color;
|
||||
this._ctx.strokeRect(
|
||||
this._ctx.lineWidth = 1;
|
||||
this._ctx.fillStyle = decoration.overviewRulerOptions?.color || decoration.options.overviewRulerOptions.color;
|
||||
this._ctx.fillRect(
|
||||
!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],
|
||||
window.devicePixelRatio
|
||||
!decoration.options.overviewRulerOptions.position ? this._width : decoration.options.overviewRulerOptions.position === 'center' ? renderSizes[SizeIndex.INNER_SIZE] : renderSizes[SizeIndex.OUTER_SIZE],
|
||||
// when a position is provided, the element has less width, so increase its height
|
||||
window.devicePixelRatio * (decoration.options.overviewRulerOptions.position ? 6 : 2)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -120,7 +121,6 @@ export class OverviewRulerRenderer extends Disposable {
|
||||
this._decorationElements.set(decoration, this._canvas);
|
||||
}
|
||||
this._refreshStyle(decoration, updateAnchor);
|
||||
decoration.onRenderEmitter.fire(this._canvas);
|
||||
}
|
||||
|
||||
private _queueRefresh(updateCanvasDimensions?: boolean, updateAnchor?: boolean): void {
|
||||
|
||||
Vendored
+18
-2
@@ -434,10 +434,26 @@ declare module 'xterm' {
|
||||
|
||||
/**
|
||||
* The element that the decoration is rendered to. This will be undefined
|
||||
* until it is rendered for the first time by @{link IDecoration.onRender}.
|
||||
* until it is rendered for the first time by {@link IDecoration.onRender}.
|
||||
* that.
|
||||
*/
|
||||
element: HTMLElement | undefined;
|
||||
|
||||
/**
|
||||
* The options for the overview ruler that can be updated.
|
||||
* This will only take effect when {@link IDecorationOptions.overviewRulerOptions}
|
||||
* were provided initially.
|
||||
*/
|
||||
overviewRulerOptions?: Pick<IDecorationOverviewRulerOptions, 'color'>;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Overview ruler decoration options
|
||||
*/
|
||||
interface IDecorationOverviewRulerOptions {
|
||||
color: string;
|
||||
position?: 'left' | 'center' | 'right';
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -479,7 +495,7 @@ declare module 'xterm' {
|
||||
* @param color The color of the decoration.
|
||||
* @param position The position of the decoration.
|
||||
*/
|
||||
readonly overviewRulerOptions?: { color: string; position?: 'left' | 'center' | 'right'}
|
||||
overviewRulerOptions?: IDecorationOverviewRulerOptions
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user