Remove renderer API
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
* Copyright (c) 2018 The xterm.js authors. All rights reserved.
|
||||
*/
|
||||
|
||||
import { IColor } from 'xterm';
|
||||
import { IColor } from 'browser/Types';
|
||||
|
||||
export function getLuminance(color: IColor): number {
|
||||
// Coefficients taken from: https://www.w3.org/TR/AERT/#color-contrast
|
||||
|
||||
@@ -11,7 +11,9 @@ import { COMBINED_CHAR_BIT_MASK } from './RenderModel';
|
||||
import { fill, slice } from 'common/TypedArrayUtils';
|
||||
import { NULL_CELL_CODE, WHITESPACE_CELL_CODE } from '../../common/buffer/BufferLine';
|
||||
import { getLuminance } from './ColorUtils';
|
||||
import { IColorSet, Terminal, IBufferLine, IRenderDimensions } from 'xterm';
|
||||
import { Terminal, IBufferLine } from 'xterm';
|
||||
import { IColorSet } from 'browser/Types';
|
||||
import { IRenderDimensions } from 'browser/renderer/Types';
|
||||
|
||||
interface IVertices {
|
||||
attributes: Float32Array;
|
||||
|
||||
@@ -9,7 +9,9 @@ import { fill } from 'common/TypedArrayUtils';
|
||||
import { INVERTED_DEFAULT_COLOR } from './atlas/Types';
|
||||
import { is256Color } from './atlas/CharAtlasUtils';
|
||||
import { DEFAULT_COLOR } from '../../common/buffer/Constants';
|
||||
import { IColorSet, IColor, Terminal, IRenderDimensions } from 'xterm';
|
||||
import { Terminal } from 'xterm';
|
||||
import { IColorSet, IColor } from 'browser/Types';
|
||||
import { IRenderDimensions } from 'browser/renderer/Types';
|
||||
|
||||
const enum VertexAttribLocations {
|
||||
POSITION = 0,
|
||||
|
||||
@@ -16,9 +16,11 @@ import { RenderModel, COMBINED_CHAR_BIT_MASK } from './RenderModel';
|
||||
import { Disposable } from 'common/Lifecycle';
|
||||
import { CHAR_DATA_CHAR_INDEX, CHAR_DATA_CODE_INDEX, CHAR_DATA_ATTR_INDEX, NULL_CELL_CODE } from 'common/buffer/BufferLine';
|
||||
import { DEFAULT_COLOR, FLAGS } from '../../common/buffer/Constants';
|
||||
import { IColorSet, Terminal, IRenderDimensions, IRenderer } from 'xterm';
|
||||
import { Terminal } from 'xterm';
|
||||
import { getLuminance } from './ColorUtils';
|
||||
import { IRenderLayer } from './renderLayer/Types';
|
||||
import { IRenderDimensions, IRenderer } from 'browser/renderer/Types';
|
||||
import { IColorSet } from 'browser/Types';
|
||||
|
||||
export const INDICIES_PER_CELL = 4;
|
||||
|
||||
@@ -50,8 +52,8 @@ export class WebglRenderer extends Disposable implements IRenderer {
|
||||
this._applyBgLuminanceBasedSelection();
|
||||
|
||||
this._renderLayers = [
|
||||
new LinkRenderLayer(this._terminal.screenElement, 2, this._colors, this._core),
|
||||
new CursorRenderLayer(this._terminal.screenElement, 3, this._colors)
|
||||
new LinkRenderLayer((<any>this._terminal).screenElement, 2, this._colors, this._core),
|
||||
new CursorRenderLayer((<any>this._terminal).screenElement, 3, this._colors)
|
||||
];
|
||||
this.dimensions = {
|
||||
scaledCharWidth: null,
|
||||
@@ -81,7 +83,7 @@ export class WebglRenderer extends Disposable implements IRenderer {
|
||||
if (!this._gl) {
|
||||
throw new Error('WebGL2 not supported');
|
||||
}
|
||||
this._terminal.screenElement.appendChild(this._canvas);
|
||||
(<any>this._terminal).screenElement.appendChild(this._canvas);
|
||||
|
||||
this._rectangleRenderer = new RectangleRenderer(this._terminal, this._colors, this._gl, this.dimensions);
|
||||
this._glyphRenderer = new GlyphRenderer(this._terminal, this._colors, this._gl, this.dimensions);
|
||||
@@ -92,7 +94,7 @@ export class WebglRenderer extends Disposable implements IRenderer {
|
||||
|
||||
public dispose(): void {
|
||||
this._renderLayers.forEach(l => l.dispose());
|
||||
this._terminal.screenElement.removeChild(this._canvas);
|
||||
(<any>this._terminal).screenElement.removeChild(this._canvas);
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@@ -151,8 +153,8 @@ export class WebglRenderer extends Disposable implements IRenderer {
|
||||
this._canvas.style.height = `${this.dimensions.canvasHeight}px`;
|
||||
|
||||
// Resize the screen
|
||||
this._terminal.screenElement.style.width = `${this.dimensions.canvasWidth}px`;
|
||||
this._terminal.screenElement.style.height = `${this.dimensions.canvasHeight}px`;
|
||||
(<any>this._terminal).screenElement.style.width = `${this.dimensions.canvasWidth}px`;
|
||||
(<any>this._terminal).screenElement.style.height = `${this.dimensions.canvasHeight}px`;
|
||||
this._glyphRenderer.setDimensions(this.dimensions);
|
||||
this._glyphRenderer.onResize();
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ export class WebglRendererAddon implements ITerminalAddon {
|
||||
throw new Error('Cannot activate WebglRendererAddon before Terminal.open');
|
||||
}
|
||||
this._terminal = terminal;
|
||||
this._terminal.setRenderer(new WebglRenderer(terminal, (terminal as any)._core._colorManager.colors, this._preserveDrawingBuffer));
|
||||
(<any>this._terminal)._renderService.setRenderer(new WebglRenderer(terminal, (terminal as any)._core._colorManager.colors, this._preserveDrawingBuffer));
|
||||
}
|
||||
|
||||
public dispose(): void {
|
||||
|
||||
@@ -7,7 +7,8 @@ import { generateConfig, configEquals } from './CharAtlasUtils';
|
||||
import BaseCharAtlas from './BaseCharAtlas';
|
||||
import WebglCharAtlas from './WebglCharAtlas';
|
||||
import { ICharAtlasConfig } from './Types';
|
||||
import { IColorSet, Terminal } from 'xterm';
|
||||
import { Terminal } from 'xterm';
|
||||
import { IColorSet } from 'browser/Types';
|
||||
|
||||
interface ICharAtlasCacheEntry {
|
||||
atlas: BaseCharAtlas;
|
||||
|
||||
@@ -5,7 +5,8 @@
|
||||
|
||||
import { ICharAtlasConfig } from './Types';
|
||||
import { DEFAULT_COLOR } from '../../../common/buffer/Constants';
|
||||
import { IColorSet, Terminal, FontWeight } from 'xterm';
|
||||
import { Terminal, FontWeight } from 'xterm';
|
||||
import { IColorSet } from 'browser/Types';
|
||||
|
||||
export function generateConfig(scaledCharWidth: number, scaledCharHeight: number, terminal: Terminal, colors: IColorSet): ICharAtlasConfig {
|
||||
// null out some fields that don't matter
|
||||
|
||||
@@ -3,7 +3,8 @@
|
||||
* @license MIT
|
||||
*/
|
||||
|
||||
import { FontWeight, IColorSet } from 'xterm';
|
||||
import { FontWeight } from 'xterm';
|
||||
import { IColorSet } from 'browser/Types';
|
||||
|
||||
export const INVERTED_DEFAULT_COLOR = 257;
|
||||
export const DIM_OPACITY = 0.5;
|
||||
|
||||
@@ -9,7 +9,7 @@ import { IRasterizedGlyph, IBoundingBox, IRasterizedGlyphSet } from '../Types';
|
||||
import { FLAGS, DEFAULT_COLOR } from '../../../common/buffer/Constants';
|
||||
import { is256Color } from './CharAtlasUtils';
|
||||
import { DEFAULT_ATTR } from 'common/buffer/BufferLine';
|
||||
import { IColor } from 'xterm';
|
||||
import { IColor } from 'browser/Types';
|
||||
|
||||
// In practice we're probably never going to exhaust a texture this large. For debugging purposes,
|
||||
// however, it can be useful to set this to a really tiny value, to verify that LRU eviction works.
|
||||
|
||||
@@ -10,7 +10,9 @@ import { DIM_OPACITY, INVERTED_DEFAULT_COLOR, IGlyphIdentifier } from '../atlas/
|
||||
import BaseCharAtlas from '../atlas/BaseCharAtlas';
|
||||
import { acquireCharAtlas } from '../atlas/CharAtlasCache';
|
||||
import { CellData, AttributeData, WHITESPACE_CELL_CHAR, WHITESPACE_CELL_CODE } from '../../../common/buffer/BufferLine';
|
||||
import { IColorSet, IRenderDimensions, Terminal } from 'xterm';
|
||||
import { Terminal } from 'xterm';
|
||||
import { IColorSet } from 'browser/Types';
|
||||
import { IRenderDimensions } from 'browser/renderer/Types';
|
||||
|
||||
export abstract class BaseRenderLayer implements IRenderLayer {
|
||||
private _canvas: HTMLCanvasElement;
|
||||
|
||||
@@ -3,10 +3,12 @@
|
||||
* @license MIT
|
||||
*/
|
||||
|
||||
import { IRenderDimensions, IColorSet, Terminal } from 'xterm';
|
||||
import { Terminal } from 'xterm';
|
||||
import { BaseRenderLayer } from './BaseRenderLayer';
|
||||
import { ICellData } from '../../../common/Types';
|
||||
import { CellData } from '../../../common/buffer/BufferLine';
|
||||
import { IColorSet } from 'browser/Types';
|
||||
import { IRenderDimensions } from 'browser/renderer/Types';
|
||||
|
||||
interface ICursorState {
|
||||
x: number;
|
||||
|
||||
@@ -4,10 +4,12 @@
|
||||
*/
|
||||
|
||||
import { ILinkifierEvent, ILinkifierAccessor } from '../../../Types';
|
||||
import { IRenderDimensions, IColorSet, Terminal } from 'xterm';
|
||||
import { Terminal } from 'xterm';
|
||||
import { BaseRenderLayer } from './BaseRenderLayer';
|
||||
import { INVERTED_DEFAULT_COLOR } from '../atlas/Types';
|
||||
import { is256Color } from '../atlas/CharAtlasUtils';
|
||||
import { IColorSet } from 'browser/Types';
|
||||
import { IRenderDimensions } from 'browser/renderer/Types';
|
||||
|
||||
export class LinkRenderLayer extends BaseRenderLayer {
|
||||
private _state: ILinkifierEvent = null;
|
||||
|
||||
@@ -3,7 +3,9 @@
|
||||
* @license MIT
|
||||
*/
|
||||
|
||||
import { IDisposable, IRenderDimensions, IColorSet, Terminal } from 'xterm';
|
||||
import { IDisposable, Terminal } from 'xterm';
|
||||
import { IColorSet } from 'browser/Types';
|
||||
import { IRenderDimensions } from 'browser/renderer/Types';
|
||||
|
||||
export interface IRenderLayer extends IDisposable {
|
||||
/**
|
||||
|
||||
Vendored
-69
@@ -793,75 +793,6 @@ declare module 'xterm' {
|
||||
* @param addon The addon to load.
|
||||
*/
|
||||
loadAddon(addon: ITerminalAddon): void;
|
||||
|
||||
/**
|
||||
* (EXPERIMENTAL)
|
||||
*/
|
||||
setRenderer(renderer: IRenderer): void;
|
||||
screenElement: HTMLElement;
|
||||
}
|
||||
|
||||
export namespace Renderer {
|
||||
const DEFAULT_COLOR: number;
|
||||
const NULL_CELL_CODE: number;
|
||||
const WHITESPACE_CELL_CODE: number;
|
||||
const DEFAULT_ATTR: number;
|
||||
const DEFAULT_ANSI_COLORS: string[];
|
||||
const FLAGS: any;
|
||||
}
|
||||
|
||||
export interface IRenderer extends IDisposable {
|
||||
readonly dimensions: IRenderDimensions;
|
||||
|
||||
dispose(): void;
|
||||
setColors(colors: IColorSet): void;
|
||||
onDevicePixelRatioChange(): void;
|
||||
onResize(cols: number, rows: number): void;
|
||||
onCharSizeChanged(): void;
|
||||
onBlur(): void;
|
||||
onFocus(): void;
|
||||
onSelectionChanged(start: [number, number], end: [number, number], columnSelectMode: boolean): void;
|
||||
onCursorMove(): void;
|
||||
onOptionsChanged(): void;
|
||||
clear(): void;
|
||||
renderRows(start: number, end: number): void;
|
||||
registerCharacterJoiner(handler: (text: string) => [number, number][]): number;
|
||||
deregisterCharacterJoiner(joinerId: number): boolean;
|
||||
}
|
||||
|
||||
export interface IRenderDimensions {
|
||||
scaledCharWidth: number;
|
||||
scaledCharHeight: number;
|
||||
scaledCellWidth: number;
|
||||
scaledCellHeight: number;
|
||||
scaledCharLeft: number;
|
||||
scaledCharTop: number;
|
||||
scaledCanvasWidth: number;
|
||||
scaledCanvasHeight: number;
|
||||
canvasWidth: number;
|
||||
canvasHeight: number;
|
||||
actualCellWidth: number;
|
||||
actualCellHeight: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* (EXPERIMENTAL)
|
||||
*/
|
||||
export interface IColor {
|
||||
css: string;
|
||||
rgba: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* (EXPERIMENTAL)
|
||||
*/
|
||||
export interface IColorSet {
|
||||
foreground: IColor;
|
||||
background: IColor;
|
||||
cursor: IColor;
|
||||
cursorAccent: IColor;
|
||||
selection: IColor;
|
||||
ansi: IColor[];
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user