Comparing version 3.14.0-beta17 to 3.14.0-beta18
@@ -18,3 +18,3 @@ "use strict"; | ||
var BaseCharAtlas_1 = require("./BaseCharAtlas"); | ||
var ColorManager_1 = require("../ColorManager"); | ||
var ColorManager_1 = require("../../ui/ColorManager"); | ||
var CharAtlasGenerator_1 = require("./CharAtlasGenerator"); | ||
@@ -21,0 +21,0 @@ var LRUMap_1 = require("./LRUMap"); |
@@ -53,3 +53,3 @@ "use strict"; | ||
}; | ||
BaseRenderLayer.prototype.onThemeChanged = function (terminal, colorSet) { | ||
BaseRenderLayer.prototype.onThemeChange = function (terminal, colorSet) { | ||
this._refreshCharAtlas(terminal, colorSet); | ||
@@ -56,0 +56,0 @@ }; |
@@ -16,3 +16,2 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var ColorManager_1 = require("../ColorManager"); | ||
var RenderDebouncer_1 = require("../../ui/RenderDebouncer"); | ||
@@ -32,5 +31,6 @@ var DomRendererRowFactory_1 = require("./DomRendererRowFactory"); | ||
__extends(DomRenderer, _super); | ||
function DomRenderer(_terminal, theme) { | ||
function DomRenderer(_terminal, _colors) { | ||
var _this = _super.call(this) || this; | ||
_this._terminal = _terminal; | ||
_this._colors = _colors; | ||
_this._terminalClass = nextTerminalId++; | ||
@@ -40,5 +40,2 @@ _this._rowElements = []; | ||
_this._onRender = new EventEmitter2_1.EventEmitter2(); | ||
var allowTransparency = _this._terminal.options.allowTransparency; | ||
_this.colorManager = new ColorManager_1.ColorManager(document, allowTransparency); | ||
_this.setTheme(theme); | ||
_this._rowContainer = document.createElement('div'); | ||
@@ -129,7 +126,8 @@ _this._rowContainer.classList.add(ROW_CONTAINER_CLASS); | ||
}; | ||
DomRenderer.prototype.setTheme = function (theme) { | ||
DomRenderer.prototype.onThemeChange = function (colors) { | ||
this._colors = colors; | ||
this._injectCss(); | ||
}; | ||
DomRenderer.prototype._injectCss = function () { | ||
var _this = this; | ||
if (theme) { | ||
this.colorManager.setTheme(theme); | ||
} | ||
if (!this._themeStyleElement) { | ||
@@ -140,4 +138,4 @@ this._themeStyleElement = document.createElement('style'); | ||
var styles = this._terminalSelector + " ." + ROW_CONTAINER_CLASS + " {" + | ||
(" color: " + this.colorManager.colors.foreground.css + ";") + | ||
(" background-color: " + this.colorManager.colors.background.css + ";") + | ||
(" color: " + this._colors.foreground.css + ";") + | ||
(" background-color: " + this._colors.background.css + ";") + | ||
(" font-family: " + this._terminal.options.fontFamily + ";") + | ||
@@ -164,3 +162,3 @@ (" font-size: " + this._terminal.options.fontSize + "px;") + | ||
this._terminalSelector + " ." + ROW_CONTAINER_CLASS + ":not(." + FOCUS_CLASS + ") ." + DomRendererRowFactory_1.CURSOR_CLASS + " {" + | ||
(" outline: 1px solid " + this.colorManager.colors.cursor.css + ";") + | ||
(" outline: 1px solid " + this._colors.cursor.css + ";") + | ||
" outline-offset: -1px;" + | ||
@@ -172,10 +170,10 @@ "}" + | ||
(this._terminalSelector + " ." + ROW_CONTAINER_CLASS + "." + FOCUS_CLASS + " ." + DomRendererRowFactory_1.CURSOR_CLASS + "." + DomRendererRowFactory_1.CURSOR_STYLE_BLOCK_CLASS + " {") + | ||
(" background-color: " + this.colorManager.colors.cursor.css + ";") + | ||
(" color: " + this.colorManager.colors.cursorAccent.css + ";") + | ||
(" background-color: " + this._colors.cursor.css + ";") + | ||
(" color: " + this._colors.cursorAccent.css + ";") + | ||
"}" + | ||
(this._terminalSelector + " ." + ROW_CONTAINER_CLASS + "." + FOCUS_CLASS + " ." + DomRendererRowFactory_1.CURSOR_CLASS + "." + DomRendererRowFactory_1.CURSOR_STYLE_BAR_CLASS + " {") + | ||
(" box-shadow: 1px 0 0 " + this.colorManager.colors.cursor.css + " inset;") + | ||
(" box-shadow: 1px 0 0 " + this._colors.cursor.css + " inset;") + | ||
"}" + | ||
(this._terminalSelector + " ." + ROW_CONTAINER_CLASS + "." + FOCUS_CLASS + " ." + DomRendererRowFactory_1.CURSOR_CLASS + "." + DomRendererRowFactory_1.CURSOR_STYLE_UNDERLINE_CLASS + " {") + | ||
(" box-shadow: 0 -1px 0 " + this.colorManager.colors.cursor.css + " inset;") + | ||
(" box-shadow: 0 -1px 0 " + this._colors.cursor.css + " inset;") + | ||
"}"; | ||
@@ -192,5 +190,5 @@ styles += | ||
" position: absolute;" + | ||
(" background-color: " + this.colorManager.colors.selection.css + ";") + | ||
(" background-color: " + this._colors.selection.css + ";") + | ||
"}"; | ||
this.colorManager.colors.ansi.forEach(function (c, i) { | ||
this._colors.ansi.forEach(function (c, i) { | ||
styles += | ||
@@ -201,6 +199,5 @@ _this._terminalSelector + " ." + FG_CLASS_PREFIX + i + " { color: " + c.css + "; }" + | ||
styles += | ||
this._terminalSelector + " ." + FG_CLASS_PREFIX + Types_1.INVERTED_DEFAULT_COLOR + " { color: " + this.colorManager.colors.background.css + "; }" + | ||
(this._terminalSelector + " ." + BG_CLASS_PREFIX + Types_1.INVERTED_DEFAULT_COLOR + " { background-color: " + this.colorManager.colors.foreground.css + "; }"); | ||
this._terminalSelector + " ." + FG_CLASS_PREFIX + Types_1.INVERTED_DEFAULT_COLOR + " { color: " + this._colors.background.css + "; }" + | ||
(this._terminalSelector + " ." + BG_CLASS_PREFIX + Types_1.INVERTED_DEFAULT_COLOR + " { background-color: " + this._colors.foreground.css + "; }"); | ||
this._themeStyleElement.innerHTML = styles; | ||
return this.colorManager.colors; | ||
}; | ||
@@ -281,3 +278,3 @@ DomRenderer.prototype.onWindowResize = function (devicePixelRatio) { | ||
this._updateDimensions(); | ||
this.setTheme(undefined); | ||
this._injectCss(); | ||
this._terminal.refresh(0, this._terminal.rows - 1); | ||
@@ -284,0 +281,0 @@ }; |
@@ -19,3 +19,2 @@ "use strict"; | ||
var CursorRenderLayer_1 = require("./CursorRenderLayer"); | ||
var ColorManager_1 = require("./ColorManager"); | ||
var LinkRenderLayer_1 = require("./LinkRenderLayer"); | ||
@@ -29,5 +28,6 @@ var RenderDebouncer_1 = require("../ui/RenderDebouncer"); | ||
__extends(Renderer, _super); | ||
function Renderer(_terminal, theme) { | ||
function Renderer(_terminal, _colors) { | ||
var _this = _super.call(this) || this; | ||
_this._terminal = _terminal; | ||
_this._colors = _colors; | ||
_this._isPaused = false; | ||
@@ -38,12 +38,8 @@ _this._needsFullRefresh = false; | ||
var allowTransparency = _this._terminal.options.allowTransparency; | ||
_this.colorManager = new ColorManager_1.ColorManager(document, allowTransparency); | ||
_this._characterJoinerRegistry = new CharacterJoinerRegistry_1.CharacterJoinerRegistry(_terminal); | ||
if (theme) { | ||
_this.colorManager.setTheme(theme); | ||
} | ||
_this._renderLayers = [ | ||
new TextRenderLayer_1.TextRenderLayer(_this._terminal.screenElement, 0, _this.colorManager.colors, _this._characterJoinerRegistry, allowTransparency), | ||
new SelectionRenderLayer_1.SelectionRenderLayer(_this._terminal.screenElement, 1, _this.colorManager.colors), | ||
new LinkRenderLayer_1.LinkRenderLayer(_this._terminal.screenElement, 2, _this.colorManager.colors, _this._terminal), | ||
new CursorRenderLayer_1.CursorRenderLayer(_this._terminal.screenElement, 3, _this.colorManager.colors) | ||
new TextRenderLayer_1.TextRenderLayer(_this._terminal.screenElement, 0, _this._colors, _this._characterJoinerRegistry, allowTransparency), | ||
new SelectionRenderLayer_1.SelectionRenderLayer(_this._terminal.screenElement, 1, _this._colors), | ||
new LinkRenderLayer_1.LinkRenderLayer(_this._terminal.screenElement, 2, _this._colors, _this._terminal), | ||
new CursorRenderLayer_1.CursorRenderLayer(_this._terminal.screenElement, 3, _this._colors) | ||
]; | ||
@@ -105,7 +101,6 @@ _this.dimensions = { | ||
}; | ||
Renderer.prototype.setTheme = function (theme) { | ||
Renderer.prototype.onThemeChange = function (colors) { | ||
var _this = this; | ||
this.colorManager.setTheme(theme); | ||
this._renderLayers.forEach(function (l) { | ||
l.onThemeChanged(_this._terminal, _this.colorManager.colors); | ||
l.onThemeChange(_this._terminal, _this._colors); | ||
l.reset(_this._terminal); | ||
@@ -119,3 +114,2 @@ }); | ||
} | ||
return this.colorManager.colors; | ||
}; | ||
@@ -161,3 +155,2 @@ Renderer.prototype.onResize = function (cols, rows) { | ||
var _this = this; | ||
this.colorManager.allowTransparency = this._terminal.options.allowTransparency; | ||
this._runOperation(function (l) { return l.onOptionsChanged(_this._terminal); }); | ||
@@ -164,0 +157,0 @@ }; |
@@ -43,2 +43,3 @@ "use strict"; | ||
var WindowsMode_1 = require("./WindowsMode"); | ||
var ColorManager_1 = require("./ui/ColorManager"); | ||
var document = (typeof window !== 'undefined') ? window.document : null; | ||
@@ -79,3 +80,3 @@ var WRITE_BUFFER_PAUSE_THRESHOLD = 5; | ||
tabStopWidth: 8, | ||
theme: null, | ||
theme: undefined, | ||
rightClickSelectsWord: Browser.isMac, | ||
@@ -363,5 +364,2 @@ rendererType: 'canvas', | ||
this.renderer.onCharSizeChanged(); | ||
if (this._theme) { | ||
this.renderer.setTheme(this._theme); | ||
} | ||
this.mouseHelper.setRenderer(this.renderer); | ||
@@ -542,7 +540,9 @@ break; | ||
this.element.appendChild(fragment); | ||
this._setupRenderer(); | ||
this._theme = this.options.theme; | ||
this.options.theme = null; | ||
this._colorManager = new ColorManager_1.ColorManager(document, this.options.allowTransparency); | ||
this._colorManager.setTheme(this._theme); | ||
this._setupRenderer(); | ||
this.viewport = new Viewport_1.Viewport(this, this._viewportElement, this._viewportScrollArea, this.charMeasure); | ||
this.viewport.onThemeChanged(this.renderer.colorManager.colors); | ||
this.viewport.onThemeChange(this._colorManager.colors); | ||
this.register(this.viewport); | ||
@@ -591,6 +591,6 @@ this.register(this.onCursorMove(function () { return _this.renderer.onCursorMove(); })); | ||
case 'canvas': | ||
this.renderer = new Renderer_1.Renderer(this, this.options.theme); | ||
this.renderer = new Renderer_1.Renderer(this, this._colorManager.colors); | ||
break; | ||
case 'dom': | ||
this.renderer = new DomRenderer_1.DomRenderer(this, this.options.theme); | ||
this.renderer = new DomRenderer_1.DomRenderer(this, this._colorManager.colors); | ||
break; | ||
@@ -604,5 +604,8 @@ default: throw new Error("Unrecognized rendererType \"" + this.options.rendererType + "\""); | ||
this._theme = theme; | ||
var colors = this.renderer.setTheme(theme); | ||
this._colorManager.setTheme(theme); | ||
if (this.renderer) { | ||
this.renderer.onThemeChange(this._colorManager.colors); | ||
} | ||
if (this.viewport) { | ||
this.viewport.onThemeChanged(colors); | ||
this.viewport.onThemeChange(this._colorManager.colors); | ||
} | ||
@@ -609,0 +612,0 @@ }; |
@@ -41,3 +41,3 @@ "use strict"; | ||
} | ||
Viewport.prototype.onThemeChanged = function (colors) { | ||
Viewport.prototype.onThemeChange = function (colors) { | ||
this._viewportElement.style.backgroundColor = colors.background.css; | ||
@@ -44,0 +44,0 @@ }; |
{ | ||
"name": "xterm", | ||
"description": "Full xterm terminal, in your browser", | ||
"version": "3.14.0-beta17", | ||
"version": "3.14.0-beta18", | ||
"main": "lib/public/Terminal.js", | ||
@@ -6,0 +6,0 @@ "types": "typings/xterm.d.ts", |
@@ -7,3 +7,2 @@ /** | ||
import { ITerminal } from '../../Types'; | ||
import { IColorSet } from '../Types'; | ||
import { generateConfig, configEquals } from './CharAtlasUtils'; | ||
@@ -15,2 +14,3 @@ import BaseCharAtlas from './BaseCharAtlas'; | ||
import { ICharAtlasConfig } from './Types'; | ||
import { IColorSet } from '../../ui/Types'; | ||
@@ -17,0 +17,0 @@ const charAtlasImplementations = { |
@@ -8,4 +8,4 @@ /** | ||
import { isFirefox, isSafari } from '../../common/Platform'; | ||
import { IColor } from '../Types'; | ||
import { ICharAtlasConfig, CHAR_ATLAS_CELL_SPACING } from './Types'; | ||
import { IColor } from '../../ui/Types'; | ||
@@ -12,0 +12,0 @@ /** |
@@ -7,5 +7,5 @@ /** | ||
import { ITerminal } from '../../Types'; | ||
import { IColorSet } from '../Types'; | ||
import { ICharAtlasConfig } from './Types'; | ||
import { DEFAULT_COLOR } from '../../common/Types'; | ||
import { IColorSet } from '../../ui/Types'; | ||
@@ -12,0 +12,0 @@ export function generateConfig(scaledCharWidth: number, scaledCharHeight: number, terminal: ITerminal, colors: IColorSet): ICharAtlasConfig { |
@@ -8,7 +8,7 @@ /** | ||
import BaseCharAtlas from './BaseCharAtlas'; | ||
import { DEFAULT_ANSI_COLORS } from '../ColorManager'; | ||
import { DEFAULT_ANSI_COLORS } from '../../ui/ColorManager'; | ||
import { clearColor } from './CharAtlasGenerator'; | ||
import LRUMap from './LRUMap'; | ||
import { isFirefox, isSafari } from '../../common/Platform'; | ||
import { IColor } from '../Types'; | ||
import { IColor } from '../../ui/Types'; | ||
@@ -15,0 +15,0 @@ // In practice we're probably never going to exhaust a texture this large. For debugging purposes, |
@@ -7,3 +7,3 @@ /** | ||
import { FontWeight } from 'xterm'; | ||
import { IColorSet } from '../Types'; | ||
import { IColorSet } from '../../ui/Types'; | ||
@@ -10,0 +10,0 @@ export const INVERTED_DEFAULT_COLOR = 257; |
@@ -6,3 +6,3 @@ /** | ||
import { IRenderLayer, IColorSet, IRenderDimensions } from './Types'; | ||
import { IRenderLayer, IRenderDimensions } from './Types'; | ||
import { ITerminal } from '../Types'; | ||
@@ -15,2 +15,3 @@ import { ICellData } from '../core/Types'; | ||
import { CellData, AttributeData, WHITESPACE_CELL_CHAR, WHITESPACE_CELL_CODE } from '../core/buffer/BufferLine'; | ||
import { IColorSet } from '../ui/Types'; | ||
@@ -78,3 +79,3 @@ export abstract class BaseRenderLayer implements IRenderLayer { | ||
public onThemeChanged(terminal: ITerminal, colorSet: IColorSet): void { | ||
public onThemeChange(terminal: ITerminal, colorSet: IColorSet): void { | ||
this._refreshCharAtlas(terminal, colorSet); | ||
@@ -81,0 +82,0 @@ } |
@@ -6,3 +6,3 @@ /** | ||
import { IColorSet, IRenderDimensions } from './Types'; | ||
import { IRenderDimensions } from './Types'; | ||
import { BaseRenderLayer } from './BaseRenderLayer'; | ||
@@ -12,2 +12,3 @@ import { ITerminal } from '../Types'; | ||
import { CellData } from '../core/buffer/BufferLine'; | ||
import { IColorSet } from '../ui/Types'; | ||
@@ -14,0 +15,0 @@ interface ICursorState { |
@@ -6,6 +6,4 @@ /** | ||
import { IRenderer, IRenderDimensions, IColorSet } from '../Types'; | ||
import { IRenderer, IRenderDimensions } from '../Types'; | ||
import { ILinkifierEvent, ITerminal, CharacterJoinerHandler } from '../../Types'; | ||
import { ITheme } from 'xterm'; | ||
import { ColorManager } from '../ColorManager'; | ||
import { RenderDebouncer } from '../../ui/RenderDebouncer'; | ||
@@ -16,2 +14,3 @@ import { BOLD_CLASS, ITALIC_CLASS, CURSOR_CLASS, CURSOR_STYLE_BLOCK_CLASS, CURSOR_BLINK_CLASS, CURSOR_STYLE_BAR_CLASS, CURSOR_STYLE_UNDERLINE_CLASS, DomRendererRowFactory } from './DomRendererRowFactory'; | ||
import { Disposable } from '../../common/Lifecycle'; | ||
import { IColorSet } from '../../ui/Types'; | ||
@@ -47,3 +46,2 @@ const TERMINAL_CLASS_PREFIX = 'xterm-dom-renderer-owner-'; | ||
public dimensions: IRenderDimensions; | ||
public colorManager: ColorManager; | ||
@@ -55,7 +53,7 @@ private _onCanvasResize = new EventEmitter2<{ width: number, height: number }>(); | ||
constructor(private _terminal: ITerminal, theme: ITheme | undefined) { | ||
constructor( | ||
private _terminal: ITerminal, | ||
private _colors: IColorSet | ||
) { | ||
super(); | ||
const allowTransparency = this._terminal.options.allowTransparency; | ||
this.colorManager = new ColorManager(document, allowTransparency); | ||
this.setTheme(theme); | ||
@@ -149,7 +147,8 @@ this._rowContainer = document.createElement('div'); | ||
public setTheme(theme: ITheme | undefined): IColorSet { | ||
if (theme) { | ||
this.colorManager.setTheme(theme); | ||
} | ||
public onThemeChange(colors: IColorSet): void { | ||
this._colors = colors; | ||
this._injectCss(); | ||
} | ||
private _injectCss(): void { | ||
if (!this._themeStyleElement) { | ||
@@ -163,4 +162,4 @@ this._themeStyleElement = document.createElement('style'); | ||
`${this._terminalSelector} .${ROW_CONTAINER_CLASS} {` + | ||
` color: ${this.colorManager.colors.foreground.css};` + | ||
` background-color: ${this.colorManager.colors.background.css};` + | ||
` color: ${this._colors.foreground.css};` + | ||
` background-color: ${this._colors.background.css};` + | ||
` font-family: ${this._terminal.options.fontFamily};` + | ||
@@ -190,3 +189,3 @@ ` font-size: ${this._terminal.options.fontSize}px;` + | ||
`${this._terminalSelector} .${ROW_CONTAINER_CLASS}:not(.${FOCUS_CLASS}) .${CURSOR_CLASS} {` + | ||
` outline: 1px solid ${this.colorManager.colors.cursor.css};` + | ||
` outline: 1px solid ${this._colors.cursor.css};` + | ||
` outline-offset: -1px;` + | ||
@@ -198,10 +197,10 @@ `}` + | ||
`${this._terminalSelector} .${ROW_CONTAINER_CLASS}.${FOCUS_CLASS} .${CURSOR_CLASS}.${CURSOR_STYLE_BLOCK_CLASS} {` + | ||
` background-color: ${this.colorManager.colors.cursor.css};` + | ||
` color: ${this.colorManager.colors.cursorAccent.css};` + | ||
` background-color: ${this._colors.cursor.css};` + | ||
` color: ${this._colors.cursorAccent.css};` + | ||
`}` + | ||
`${this._terminalSelector} .${ROW_CONTAINER_CLASS}.${FOCUS_CLASS} .${CURSOR_CLASS}.${CURSOR_STYLE_BAR_CLASS} {` + | ||
` box-shadow: 1px 0 0 ${this.colorManager.colors.cursor.css} inset;` + | ||
` box-shadow: 1px 0 0 ${this._colors.cursor.css} inset;` + | ||
`}` + | ||
`${this._terminalSelector} .${ROW_CONTAINER_CLASS}.${FOCUS_CLASS} .${CURSOR_CLASS}.${CURSOR_STYLE_UNDERLINE_CLASS} {` + | ||
` box-shadow: 0 -1px 0 ${this.colorManager.colors.cursor.css} inset;` + | ||
` box-shadow: 0 -1px 0 ${this._colors.cursor.css} inset;` + | ||
`}`; | ||
@@ -219,6 +218,6 @@ // Selection | ||
` position: absolute;` + | ||
` background-color: ${this.colorManager.colors.selection.css};` + | ||
` background-color: ${this._colors.selection.css};` + | ||
`}`; | ||
// Colors | ||
this.colorManager.colors.ansi.forEach((c, i) => { | ||
this._colors.ansi.forEach((c, i) => { | ||
styles += | ||
@@ -229,7 +228,6 @@ `${this._terminalSelector} .${FG_CLASS_PREFIX}${i} { color: ${c.css}; }` + | ||
styles += | ||
`${this._terminalSelector} .${FG_CLASS_PREFIX}${INVERTED_DEFAULT_COLOR} { color: ${this.colorManager.colors.background.css}; }` + | ||
`${this._terminalSelector} .${BG_CLASS_PREFIX}${INVERTED_DEFAULT_COLOR} { background-color: ${this.colorManager.colors.foreground.css}; }`; | ||
`${this._terminalSelector} .${FG_CLASS_PREFIX}${INVERTED_DEFAULT_COLOR} { color: ${this._colors.background.css}; }` + | ||
`${this._terminalSelector} .${BG_CLASS_PREFIX}${INVERTED_DEFAULT_COLOR} { background-color: ${this._colors.foreground.css}; }`; | ||
this._themeStyleElement.innerHTML = styles; | ||
return this.colorManager.colors; | ||
} | ||
@@ -344,3 +342,3 @@ | ||
this._updateDimensions(); | ||
this.setTheme(undefined); | ||
this._injectCss(); | ||
this._terminal.refresh(0, this._terminal.rows - 1); | ||
@@ -347,0 +345,0 @@ } |
@@ -7,6 +7,7 @@ /** | ||
import { ILinkifierEvent, ITerminal, ILinkifierAccessor } from '../Types'; | ||
import { IColorSet, IRenderDimensions } from './Types'; | ||
import { IRenderDimensions } from './Types'; | ||
import { BaseRenderLayer } from './BaseRenderLayer'; | ||
import { INVERTED_DEFAULT_COLOR } from './atlas/Types'; | ||
import { is256Color } from './atlas/CharAtlasUtils'; | ||
import { IColorSet } from '../ui/Types'; | ||
@@ -13,0 +14,0 @@ export class LinkRenderLayer extends BaseRenderLayer { |
@@ -9,4 +9,3 @@ /** | ||
import { CursorRenderLayer } from './CursorRenderLayer'; | ||
import { ColorManager } from './ColorManager'; | ||
import { IRenderLayer, IColorSet, IRenderer, IRenderDimensions, ICharacterJoinerRegistry } from './Types'; | ||
import { IRenderLayer, IRenderer, IRenderDimensions, ICharacterJoinerRegistry } from './Types'; | ||
import { ITerminal, CharacterJoinerHandler } from '../Types'; | ||
@@ -16,6 +15,6 @@ import { LinkRenderLayer } from './LinkRenderLayer'; | ||
import { ScreenDprMonitor } from '../ui/ScreenDprMonitor'; | ||
import { ITheme } from 'xterm'; | ||
import { CharacterJoinerRegistry } from '../renderer/CharacterJoinerRegistry'; | ||
import { EventEmitter2, IEvent } from '../common/EventEmitter2'; | ||
import { Disposable } from '../common/Lifecycle'; | ||
import { IColorSet } from '../ui/Types'; | ||
@@ -32,3 +31,2 @@ export class Renderer extends Disposable implements IRenderer { | ||
public colorManager: ColorManager; | ||
public dimensions: IRenderDimensions; | ||
@@ -41,16 +39,15 @@ | ||
constructor(private _terminal: ITerminal, theme: ITheme) { | ||
constructor( | ||
private _terminal: ITerminal, | ||
private _colors: IColorSet | ||
) { | ||
super(); | ||
const allowTransparency = this._terminal.options.allowTransparency; | ||
this.colorManager = new ColorManager(document, allowTransparency); | ||
this._characterJoinerRegistry = new CharacterJoinerRegistry(_terminal); | ||
if (theme) { | ||
this.colorManager.setTheme(theme); | ||
} | ||
this._renderLayers = [ | ||
new TextRenderLayer(this._terminal.screenElement, 0, this.colorManager.colors, this._characterJoinerRegistry, allowTransparency), | ||
new SelectionRenderLayer(this._terminal.screenElement, 1, this.colorManager.colors), | ||
new LinkRenderLayer(this._terminal.screenElement, 2, this.colorManager.colors, this._terminal), | ||
new CursorRenderLayer(this._terminal.screenElement, 3, this.colorManager.colors) | ||
new TextRenderLayer(this._terminal.screenElement, 0, this._colors, this._characterJoinerRegistry, allowTransparency), | ||
new SelectionRenderLayer(this._terminal.screenElement, 1, this._colors), | ||
new LinkRenderLayer(this._terminal.screenElement, 2, this._colors, this._terminal), | ||
new CursorRenderLayer(this._terminal.screenElement, 3, this._colors) | ||
]; | ||
@@ -111,8 +108,6 @@ this.dimensions = { | ||
public setTheme(theme: ITheme): IColorSet { | ||
this.colorManager.setTheme(theme); | ||
public onThemeChange(colors: IColorSet): void { | ||
// Clear layers and force a full render | ||
this._renderLayers.forEach(l => { | ||
l.onThemeChanged(this._terminal, this.colorManager.colors); | ||
l.onThemeChange(this._terminal, this._colors); | ||
l.reset(this._terminal); | ||
@@ -126,4 +121,2 @@ }); | ||
} | ||
return this.colorManager.colors; | ||
} | ||
@@ -176,3 +169,2 @@ | ||
public onOptionsChanged(): void { | ||
this.colorManager.allowTransparency = this._terminal.options.allowTransparency; | ||
this._runOperation(l => l.onOptionsChanged(this._terminal)); | ||
@@ -179,0 +171,0 @@ } |
@@ -7,4 +7,5 @@ /** | ||
import { ITerminal } from '../Types'; | ||
import { IColorSet, IRenderDimensions } from './Types'; | ||
import { IRenderDimensions } from './Types'; | ||
import { BaseRenderLayer } from './BaseRenderLayer'; | ||
import { IColorSet } from '../ui/Types'; | ||
@@ -11,0 +12,0 @@ interface ISelectionState { |
@@ -6,3 +6,3 @@ /** | ||
import { IColorSet, IRenderDimensions, ICharacterJoinerRegistry } from './Types'; | ||
import { IRenderDimensions, ICharacterJoinerRegistry } from './Types'; | ||
import { ITerminal } from '../Types'; | ||
@@ -14,2 +14,3 @@ import { CharData, ICellData } from '../core/Types'; | ||
import { JoinedCellData } from './CharacterJoinerRegistry'; | ||
import { IColorSet } from '../ui/Types'; | ||
@@ -16,0 +17,0 @@ /** |
@@ -7,4 +7,5 @@ /** | ||
import { ITerminal, CharacterJoinerHandler } from '../Types'; | ||
import { ITheme, IDisposable } from 'xterm'; | ||
import { IDisposable } from 'xterm'; | ||
import { IEvent } from '../common/EventEmitter2'; | ||
import { IColorSet } from '../ui/Types'; | ||
@@ -30,3 +31,2 @@ /** | ||
dimensions: IRenderDimensions; | ||
colorManager: IColorManager; | ||
@@ -37,3 +37,3 @@ onCanvasResize: IEvent<{ width: number, height: number }>; | ||
dispose(): void; | ||
setTheme(theme: ITheme): IColorSet; | ||
onThemeChange(colors: IColorSet): void; | ||
onWindowResize(devicePixelRatio: number): void; | ||
@@ -53,6 +53,2 @@ onResize(cols: number, rows: number): void; | ||
export interface IColorManager { | ||
colors: IColorSet; | ||
} | ||
export interface IRenderDimensions { | ||
@@ -97,3 +93,3 @@ scaledCharWidth: number; | ||
*/ | ||
onThemeChanged(terminal: ITerminal, colorSet: IColorSet): void; | ||
onThemeChange(terminal: ITerminal, colorSet: IColorSet): void; | ||
@@ -142,15 +138,1 @@ /** | ||
} | ||
export interface IColor { | ||
css: string; | ||
rgba: number; // 32-bit int with rgba in each byte | ||
} | ||
export interface IColorSet { | ||
foreground: IColor; | ||
background: IColor; | ||
cursor: IColor; | ||
cursorAccent: IColor; | ||
selection: IColor; | ||
ansi: IColor[]; | ||
} |
@@ -7,6 +7,7 @@ /** | ||
import { ITerminalOptions as IPublicTerminalOptions, IEventEmitter, IDisposable, IMarker, ISelectionPosition } from 'xterm'; | ||
import { IColorSet, IRenderer } from './renderer/Types'; | ||
import { IRenderer } from './renderer/Types'; | ||
import { ICharset, IAttributeData, ICellData, IBufferLine, CharData } from './core/Types'; | ||
import { ICircularList } from './common/Types'; | ||
import { IEvent } from './common/EventEmitter2'; | ||
import { IColorSet } from './ui/Types'; | ||
@@ -91,3 +92,3 @@ export type CustomKeyEventHandler = (event: KeyboardEvent) => boolean; | ||
onTouchMove(ev: TouchEvent): void; | ||
onThemeChanged(colors: IColorSet): void; | ||
onThemeChange(colors: IColorSet): void; | ||
} | ||
@@ -94,0 +95,0 @@ |
@@ -6,3 +6,2 @@ /** | ||
import { IColorSet } from './renderer/Types'; | ||
import { ITerminal, IViewport } from './Types'; | ||
@@ -12,2 +11,3 @@ import { CharMeasure } from './CharMeasure'; | ||
import { addDisposableDomListener } from './ui/Lifecycle'; | ||
import { IColorSet } from './ui/Types'; | ||
@@ -62,3 +62,3 @@ const FALLBACK_SCROLL_BAR_WIDTH = 15; | ||
public onThemeChanged(colors: IColorSet): void { | ||
public onThemeChange(colors: IColorSet): void { | ||
this._viewportElement.style.backgroundColor = colors.background.css; | ||
@@ -65,0 +65,0 @@ } |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
313
2753348
41778