Merge branch 'master' into full

This commit is contained in:
Megan Rogge
2022-03-17 15:20:00 -04:00
committed by GitHub
4 changed files with 32 additions and 10 deletions
+1 -5
View File
@@ -548,11 +548,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() {
@@ -92,7 +92,7 @@ export class OverviewRulerRenderer extends Disposable {
return;
}
this._ctx.lineWidth = 1;
this._ctx.fillStyle = decoration.options.overviewRulerOptions.color;
this._ctx.fillStyle = decoration.overviewRulerOptions?.color || decoration.options.overviewRulerOptions.color;
this._ctx.fillRect(
decoration.options.overviewRulerOptions.position === 'full' || 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)),
@@ -120,7 +120,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 {
+11 -1
View File
@@ -98,6 +98,12 @@ export class Terminal extends CoreTerminal implements ITerminal {
*/
private _keyDownHandled: boolean = false;
/**
* Records whether a keydown event has occured since the last keyup event, i.e. whether a key
* is currently "pressed".
*/
private _keyDownSeen: boolean = false;
/**
* Records whether the keypress event has already been handled and triggered a data event, if so
* the input event should not trigger a data event but should still print to the textarea so
@@ -1083,6 +1089,7 @@ export class Terminal extends CoreTerminal implements ITerminal {
*/
protected _keyDown(event: KeyboardEvent): boolean | undefined {
this._keyDownHandled = false;
this._keyDownSeen = true;
if (this._customKeyEventHandler && this._customKeyEventHandler(event) === false) {
return false;
@@ -1168,6 +1175,8 @@ export class Terminal extends CoreTerminal implements ITerminal {
}
protected _keyUp(ev: KeyboardEvent): void {
this._keyDownSeen = false;
if (this._customKeyEventHandler && this._customKeyEventHandler(ev) === false) {
return;
}
@@ -1241,7 +1250,8 @@ export class Terminal extends CoreTerminal implements ITerminal {
protected _inputEvent(ev: InputEvent): boolean {
// Only support emoji IMEs when screen reader mode is disabled as the event must bubble up to
// support reading out character input which can doubling up input characters
if (ev.data && ev.inputType === 'insertText' && !ev.composed && !this.optionsService.rawOptions.screenReaderMode) {
// Based on these event traces: https://github.com/xtermjs/xterm.js/issues/3679
if (ev.data && ev.inputType === 'insertText' && (!ev.composed || !this._keyDownSeen) && !this.optionsService.rawOptions.screenReaderMode) {
if (this._keyPressHandled) {
return false;
}
+19 -2
View File
@@ -436,10 +436,27 @@ 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<
Options, 'color'>;
}
/**
* Overview ruler decoration options
*/
interface IDecorationOverviewRulerOptions {
color: string;
position?: 'left' | 'center' | 'right' | 'full';
}
/*
@@ -481,7 +498,7 @@ declare module 'xterm' {
* @param color The color of the decoration.
* @param position The position of the decoration.
*/
readonly overviewRulerOptions?: IModelDecorationOverviewRulerOptions
overviewRulerOptions?: IDecorationOverviewRulerOptions
}
/**