Merge branch 'master' into cleanup_coreservice

This commit is contained in:
Daniel Imms
2022-12-11 07:36:01 -08:00
committed by GitHub
9 changed files with 42 additions and 19 deletions
@@ -373,6 +373,9 @@ export abstract class BaseRenderLayer extends Disposable implements IRenderLayer
} else {
glyph = this._charAtlas.getRasterizedGlyph(cell.getCode() || WHITESPACE_CELL_CODE, this._cellColorResolver.result.bg, this._cellColorResolver.result.fg, this._cellColorResolver.result.ext);
}
if (!glyph.size.x || !glyph.size.y) {
return;
}
this._ctx.save();
this._clipRow(y);
// Draw the image, use the bitmap if it's available
@@ -95,6 +95,12 @@ export class TextRenderLayer extends BaseRenderLayer {
continue;
}
// exit early for NULL and SP
const code = cell.getCode();
if (code === 0 || code === 32) {
continue;
}
// Process any joined character ranges as needed. Because of how the
// ranges are produced, we know that they are valid for the characters
// and attributes of our input.
+3 -5
View File
@@ -9,7 +9,6 @@ import { EventEmitter, forwardEvent } from 'common/EventEmitter';
import { Disposable, toDisposable } from 'common/Lifecycle';
import { getSafariVersion, isSafari } from 'common/Platform';
import { ICoreService, IDecorationService, IOptionsService } from 'common/services/Services';
import { ICoreTerminal } from 'common/Types';
import { ITerminalAddon, Terminal } from 'xterm';
import { WebglRenderer } from './WebglRenderer';
@@ -29,14 +28,13 @@ export class WebglAddon extends Disposable implements ITerminalAddon {
constructor(
private _preserveDrawingBuffer?: boolean
) {
if (isSafari && getSafariVersion() < 16) {
throw new Error('Webgl2 is only supported on Safari 16 and above');
}
super();
}
public activate(terminal: Terminal): void {
if (isSafari && getSafariVersion() < 16) {
throw new Error('Webgl2 is only supported on Safari 16 and above');
}
const core = (terminal as any)._core as ITerminal;
if (!terminal.element) {
this.register(core.onWillOpen(() => this.activate(terminal)));
+18 -10
View File
@@ -250,7 +250,11 @@ function createTerminal(): void {
addons.serialize.instance = new SerializeAddon();
addons.fit.instance = new FitAddon();
addons.unicode11.instance = new Unicode11Addon();
addons.webgl.instance = new WebglAddon();
try { // try to start with webgl renderer (might throw on older safari/webkit)
addons.webgl.instance = new WebglAddon();
} catch (e) {
console.warn(e);
}
addons['web-links'].instance = new WebLinksAddon();
typedTerm.loadAddon(addons.fit.instance);
typedTerm.loadAddon(addons.search.instance);
@@ -273,22 +277,26 @@ function createTerminal(): void {
socketURL = protocol + location.hostname + ((location.port) ? (':' + location.port) : '') + '/terminals/';
addons.fit.instance!.fit();
typedTerm.loadAddon(addons.webgl.instance);
setTimeout(() => {
if (addons.webgl.instance !== undefined) {
if (addons.webgl.instance) {
try {
typedTerm.loadAddon(addons.webgl.instance);
term.open(terminalContainer);
setTextureAtlas(addons.webgl.instance.textureAtlas);
addons.webgl.instance.onChangeTextureAtlas(e => setTextureAtlas(e));
addons.webgl.instance.onAddTextureAtlasCanvas(e => appendTextureAtlas(e));
addons.webgl.instance.onRemoveTextureAtlasCanvas(e => removeTextureAtlas(e));
} catch (e) {
console.warn('error during loading webgl addon:', e);
addons.webgl.instance.dispose();
addons.webgl.instance = undefined;
}
}, 0);
try { // try-catch to allow the demo to load if webgl is not supported
}
if (!typedTerm.element) {
// webgl loading failed for some reason, attach with DOM renderer
term.open(terminalContainer);
}
catch {
addons.webgl.instance = undefined;
}
term.focus();
addDomListener(paddingElement, 'change', setPadding);
+1 -1
View File
@@ -995,7 +995,7 @@ export class Terminal extends CoreTerminal implements ITerminal {
const shouldIgnoreComposition = this.browser.isMac && this.options.macOptionIsMeta && event.altKey;
if (!shouldIgnoreComposition && !this._compositionHelper!.keydown(event)) {
if (this.buffer.ybase !== this.buffer.ydisp) {
if (this.options.scrollOnUserInput && this.buffer.ybase !== this.buffer.ydisp) {
this._bufferService.scrollToBottom();
}
return false;
+1 -1
View File
@@ -63,7 +63,7 @@ export class CoreService extends Disposable implements ICoreService {
// Input is being sent to the terminal, the terminal should focus the prompt.
const buffer = this._bufferService.buffer;
if (buffer.ybase !== buffer.ydisp) {
if (wasUserInput && this._optionsService.rawOptions.scrollOnUserInput && buffer.ybase !== buffer.ydisp) {
this._onRequestScrollToBottom.fire();
}
+1
View File
@@ -28,6 +28,7 @@ export const DEFAULT_OPTIONS: Readonly<Required<ITerminalOptions>> = {
linkHandler: null,
logLevel: 'info',
scrollback: 1000,
scrollOnUserInput: true,
scrollSensitivity: 1,
screenReaderMode: false,
smoothScrollDuration: 0,
+3 -2
View File
@@ -86,9 +86,9 @@ export interface ICoreService {
/**
* Triggers the onData event in the public API.
* @param data The data that is being emitted.
* @param wasFromUser Whether the data originated from the user (as opposed to
* @param wasUserInput Whether the data originated from the user (as opposed to
* resulting from parsing incoming data). When true this will also:
* - Scroll to the bottom of the buffer.s
* - Scroll to the bottom of the buffer if option scrollOnUserInput is true.
* - Fire the `onUserInput` event (so selection can be cleared).
*/
triggerDataEvent(data: string, wasUserInput?: boolean): void;
@@ -244,6 +244,7 @@ export interface ITerminalOptions {
rows?: number;
screenReaderMode?: boolean;
scrollback?: number;
scrollOnUserInput?: boolean;
scrollSensitivity?: number;
smoothScrollDuration?: number;
tabStopWidth?: number;
+6
View File
@@ -193,6 +193,12 @@ declare module 'xterm' {
*/
scrollback?: number;
/**
* Whether to scroll to the bottom whenever there is some user input. The
* default is true.
*/
scrollOnUserInput?: boolean;
/**
* The scrolling speed multiplier used for adjusting normal scrolling speed.
*/