Move ColorManager to ui

Part of #2005
Part of #1507
This commit is contained in:
Daniel Imms
2019-05-18 17:49:48 -07:00
parent 33955398e7
commit 000fefdead
19 changed files with 50 additions and 36 deletions
+2 -1
View File
@@ -3,7 +3,7 @@
* @license MIT * @license MIT
*/ */
import { IColorSet, IRenderer, IRenderDimensions, IColorManager } from './renderer/Types'; import { IRenderer, IRenderDimensions } from './renderer/Types';
import { IInputHandlingTerminal, IViewport, ICompositionHelper, ITerminal, IBuffer, IBufferSet, IBrowser, ICharMeasure, ISelectionManager, ITerminalOptions, ILinkifier, IMouseHelper, ILinkMatcherOptions, CharacterJoinerHandler, IBufferStringIterator } from './Types'; import { IInputHandlingTerminal, IViewport, ICompositionHelper, ITerminal, IBuffer, IBufferSet, IBrowser, ICharMeasure, ISelectionManager, ITerminalOptions, ILinkifier, IMouseHelper, ILinkMatcherOptions, CharacterJoinerHandler, IBufferStringIterator } from './Types';
import { IBufferLine, ICellData, IAttributeData } from './core/Types'; import { IBufferLine, ICellData, IAttributeData } from './core/Types';
import { ICircularList, XtermListener } from './common/Types'; import { ICircularList, XtermListener } from './common/Types';
@@ -12,6 +12,7 @@ import * as Browser from './common/Platform';
import { ITheme, IDisposable, IMarker, IEvent, ISelectionPosition } from 'xterm'; import { ITheme, IDisposable, IMarker, IEvent, ISelectionPosition } from 'xterm';
import { Terminal } from './Terminal'; import { Terminal } from './Terminal';
import { AttributeData } from './core/buffer/BufferLine'; import { AttributeData } from './core/buffer/BufferLine';
import { IColorManager, IColorSet } from './ui/Types';
export class TestTerminal extends Terminal { export class TestTerminal extends Terminal {
writeSync(data: string): void { writeSync(data: string): void {
+2 -1
View File
@@ -4,10 +4,11 @@
*/ */
import { ITerminalOptions as IPublicTerminalOptions, IEventEmitter, IDisposable, IMarker, ISelectionPosition } from 'xterm'; 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 { ICharset, IAttributeData, ICellData, IBufferLine, CharData } from './core/Types';
import { ICircularList } from './common/Types'; import { ICircularList } from './common/Types';
import { IEvent } from './common/EventEmitter2'; import { IEvent } from './common/EventEmitter2';
import { IColorSet } from './ui/Types';
export type CustomKeyEventHandler = (event: KeyboardEvent) => boolean; export type CustomKeyEventHandler = (event: KeyboardEvent) => boolean;
+1 -1
View File
@@ -3,11 +3,11 @@
* @license MIT * @license MIT
*/ */
import { IColorSet } from './renderer/Types';
import { ITerminal, IViewport } from './Types'; import { ITerminal, IViewport } from './Types';
import { CharMeasure } from './CharMeasure'; import { CharMeasure } from './CharMeasure';
import { Disposable } from './common/Lifecycle'; import { Disposable } from './common/Lifecycle';
import { addDisposableDomListener } from './ui/Lifecycle'; import { addDisposableDomListener } from './ui/Lifecycle';
import { IColorSet } from './ui/Types';
const FALLBACK_SCROLL_BAR_WIDTH = 15; const FALLBACK_SCROLL_BAR_WIDTH = 15;
+2 -1
View File
@@ -3,7 +3,7 @@
* @license MIT * @license MIT
*/ */
import { IRenderLayer, IColorSet, IRenderDimensions } from './Types'; import { IRenderLayer, IRenderDimensions } from './Types';
import { ITerminal } from '../Types'; import { ITerminal } from '../Types';
import { ICellData } from '../core/Types'; import { ICellData } from '../core/Types';
import { DEFAULT_COLOR } from '../common/Types'; import { DEFAULT_COLOR } from '../common/Types';
@@ -11,6 +11,7 @@ import { DIM_OPACITY, INVERTED_DEFAULT_COLOR, IGlyphIdentifier } from './atlas/T
import BaseCharAtlas from './atlas/BaseCharAtlas'; import BaseCharAtlas from './atlas/BaseCharAtlas';
import { acquireCharAtlas } from './atlas/CharAtlasCache'; import { acquireCharAtlas } from './atlas/CharAtlasCache';
import { CellData, AttributeData, WHITESPACE_CELL_CHAR, WHITESPACE_CELL_CODE } from '../core/buffer/BufferLine'; import { CellData, AttributeData, WHITESPACE_CELL_CHAR, WHITESPACE_CELL_CODE } from '../core/buffer/BufferLine';
import { IColorSet } from '../ui/Types';
export abstract class BaseRenderLayer implements IRenderLayer { export abstract class BaseRenderLayer implements IRenderLayer {
private _canvas: HTMLCanvasElement; private _canvas: HTMLCanvasElement;
+2 -1
View File
@@ -3,11 +3,12 @@
* @license MIT * @license MIT
*/ */
import { IColorSet, IRenderDimensions } from './Types'; import { IRenderDimensions } from './Types';
import { BaseRenderLayer } from './BaseRenderLayer'; import { BaseRenderLayer } from './BaseRenderLayer';
import { ITerminal } from '../Types'; import { ITerminal } from '../Types';
import { ICellData } from '../core/Types'; import { ICellData } from '../core/Types';
import { CellData } from '../core/buffer/BufferLine'; import { CellData } from '../core/buffer/BufferLine';
import { IColorSet } from '../ui/Types';
interface ICursorState { interface ICursorState {
x: number; x: number;
+2 -1
View File
@@ -4,10 +4,11 @@
*/ */
import { ILinkifierEvent, ITerminal, ILinkifierAccessor } from '../Types'; import { ILinkifierEvent, ITerminal, ILinkifierAccessor } from '../Types';
import { IColorSet, IRenderDimensions } from './Types'; import { IRenderDimensions } from './Types';
import { BaseRenderLayer } from './BaseRenderLayer'; import { BaseRenderLayer } from './BaseRenderLayer';
import { INVERTED_DEFAULT_COLOR } from './atlas/Types'; import { INVERTED_DEFAULT_COLOR } from './atlas/Types';
import { is256Color } from './atlas/CharAtlasUtils'; import { is256Color } from './atlas/CharAtlasUtils';
import { IColorSet } from '../ui/Types';
export class LinkRenderLayer extends BaseRenderLayer { export class LinkRenderLayer extends BaseRenderLayer {
private _state: ILinkifierEvent = null; private _state: ILinkifierEvent = null;
+3 -2
View File
@@ -6,8 +6,8 @@
import { TextRenderLayer } from './TextRenderLayer'; import { TextRenderLayer } from './TextRenderLayer';
import { SelectionRenderLayer } from './SelectionRenderLayer'; import { SelectionRenderLayer } from './SelectionRenderLayer';
import { CursorRenderLayer } from './CursorRenderLayer'; import { CursorRenderLayer } from './CursorRenderLayer';
import { ColorManager } from './ColorManager'; import { ColorManager } from '../ui/ColorManager';
import { IRenderLayer, IColorSet, IRenderer, IRenderDimensions, ICharacterJoinerRegistry } from './Types'; import { IRenderLayer, IRenderer, IRenderDimensions, ICharacterJoinerRegistry } from './Types';
import { ITerminal, CharacterJoinerHandler } from '../Types'; import { ITerminal, CharacterJoinerHandler } from '../Types';
import { LinkRenderLayer } from './LinkRenderLayer'; import { LinkRenderLayer } from './LinkRenderLayer';
import { RenderDebouncer } from '../ui/RenderDebouncer'; import { RenderDebouncer } from '../ui/RenderDebouncer';
@@ -16,6 +16,7 @@ import { ITheme } from 'xterm';
import { CharacterJoinerRegistry } from '../renderer/CharacterJoinerRegistry'; import { CharacterJoinerRegistry } from '../renderer/CharacterJoinerRegistry';
import { EventEmitter2, IEvent } from '../common/EventEmitter2'; import { EventEmitter2, IEvent } from '../common/EventEmitter2';
import { Disposable } from '../common/Lifecycle'; import { Disposable } from '../common/Lifecycle';
import { IColorSet } from '../ui/Types';
export class Renderer extends Disposable implements IRenderer { export class Renderer extends Disposable implements IRenderer {
private _renderDebouncer: RenderDebouncer; private _renderDebouncer: RenderDebouncer;
+2 -1
View File
@@ -4,8 +4,9 @@
*/ */
import { ITerminal } from '../Types'; import { ITerminal } from '../Types';
import { IColorSet, IRenderDimensions } from './Types'; import { IRenderDimensions } from './Types';
import { BaseRenderLayer } from './BaseRenderLayer'; import { BaseRenderLayer } from './BaseRenderLayer';
import { IColorSet } from '../ui/Types';
interface ISelectionState { interface ISelectionState {
start: [number, number]; start: [number, number];
+2 -1
View File
@@ -3,13 +3,14 @@
* @license MIT * @license MIT
*/ */
import { IColorSet, IRenderDimensions, ICharacterJoinerRegistry } from './Types'; import { IRenderDimensions, ICharacterJoinerRegistry } from './Types';
import { ITerminal } from '../Types'; import { ITerminal } from '../Types';
import { CharData, ICellData } from '../core/Types'; import { CharData, ICellData } from '../core/Types';
import { GridCache } from './GridCache'; import { GridCache } from './GridCache';
import { BaseRenderLayer } from './BaseRenderLayer'; import { BaseRenderLayer } from './BaseRenderLayer';
import { CellData, AttributeData, Content, NULL_CELL_CODE } from '../core/buffer/BufferLine'; import { CellData, AttributeData, Content, NULL_CELL_CODE } from '../core/buffer/BufferLine';
import { JoinedCellData } from './CharacterJoinerRegistry'; import { JoinedCellData } from './CharacterJoinerRegistry';
import { IColorSet } from '../ui/Types';
/** /**
* This CharData looks like a null character, which will forc a clear and render * This CharData looks like a null character, which will forc a clear and render
+1 -18
View File
@@ -6,6 +6,7 @@
import { ITerminal, CharacterJoinerHandler } from '../Types'; import { ITerminal, CharacterJoinerHandler } from '../Types';
import { ITheme, IDisposable } from 'xterm'; import { ITheme, IDisposable } from 'xterm';
import { IEvent } from '../common/EventEmitter2'; import { IEvent } from '../common/EventEmitter2';
import { IColorManager, IColorSet } from '../ui/Types';
/** /**
* Flags used to render terminal text properly. * Flags used to render terminal text properly.
@@ -47,10 +48,6 @@ export interface IRenderer extends IDisposable {
deregisterCharacterJoiner(joinerId: number): boolean; deregisterCharacterJoiner(joinerId: number): boolean;
} }
export interface IColorManager {
colors: IColorSet;
}
export interface IRenderDimensions { export interface IRenderDimensions {
scaledCharWidth: number; scaledCharWidth: number;
scaledCharHeight: number; scaledCharHeight: number;
@@ -134,17 +131,3 @@ export interface ICharacterJoinerRegistry {
deregisterCharacterJoiner(joinerId: number): boolean; deregisterCharacterJoiner(joinerId: number): boolean;
getJoinedCharacters(row: number): [number, number][]; getJoinedCharacters(row: number): [number, number][];
} }
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[];
}
+1 -1
View File
@@ -4,13 +4,13 @@
*/ */
import { ITerminal } from '../../Types'; import { ITerminal } from '../../Types';
import { IColorSet } from '../Types';
import { generateConfig, configEquals } from './CharAtlasUtils'; import { generateConfig, configEquals } from './CharAtlasUtils';
import BaseCharAtlas from './BaseCharAtlas'; import BaseCharAtlas from './BaseCharAtlas';
import DynamicCharAtlas from './DynamicCharAtlas'; import DynamicCharAtlas from './DynamicCharAtlas';
import NoneCharAtlas from './NoneCharAtlas'; import NoneCharAtlas from './NoneCharAtlas';
import StaticCharAtlas from './StaticCharAtlas'; import StaticCharAtlas from './StaticCharAtlas';
import { ICharAtlasConfig } from './Types'; import { ICharAtlasConfig } from './Types';
import { IColorSet } from '../../ui/Types';
const charAtlasImplementations = { const charAtlasImplementations = {
'none': NoneCharAtlas, 'none': NoneCharAtlas,
+1 -1
View File
@@ -5,8 +5,8 @@
import { FontWeight } from 'xterm'; import { FontWeight } from 'xterm';
import { isFirefox, isSafari } from '../../common/Platform'; import { isFirefox, isSafari } from '../../common/Platform';
import { IColor } from '../Types';
import { ICharAtlasConfig, CHAR_ATLAS_CELL_SPACING } from './Types'; import { ICharAtlasConfig, CHAR_ATLAS_CELL_SPACING } from './Types';
import { IColor } from '../../ui/Types';
/** /**
* Generates a char atlas. * Generates a char atlas.
+1 -1
View File
@@ -4,9 +4,9 @@
*/ */
import { ITerminal } from '../../Types'; import { ITerminal } from '../../Types';
import { IColorSet } from '../Types';
import { ICharAtlasConfig } from './Types'; import { ICharAtlasConfig } from './Types';
import { DEFAULT_COLOR } from '../../common/Types'; import { DEFAULT_COLOR } from '../../common/Types';
import { IColorSet } from '../../ui/Types';
export function generateConfig(scaledCharWidth: number, scaledCharHeight: number, terminal: ITerminal, colors: IColorSet): ICharAtlasConfig { export function generateConfig(scaledCharWidth: number, scaledCharHeight: number, terminal: ITerminal, colors: IColorSet): ICharAtlasConfig {
// null out some fields that don't matter // null out some fields that don't matter
+2 -2
View File
@@ -5,11 +5,11 @@
import { DIM_OPACITY, IGlyphIdentifier, INVERTED_DEFAULT_COLOR, ICharAtlasConfig } from './Types'; import { DIM_OPACITY, IGlyphIdentifier, INVERTED_DEFAULT_COLOR, ICharAtlasConfig } from './Types';
import BaseCharAtlas from './BaseCharAtlas'; import BaseCharAtlas from './BaseCharAtlas';
import { DEFAULT_ANSI_COLORS } from '../ColorManager'; import { DEFAULT_ANSI_COLORS } from '../../ui/ColorManager';
import { clearColor } from './CharAtlasGenerator'; import { clearColor } from './CharAtlasGenerator';
import LRUMap from './LRUMap'; import LRUMap from './LRUMap';
import { isFirefox, isSafari } from '../../common/Platform'; import { isFirefox, isSafari } from '../../common/Platform';
import { IColor } from '../Types'; import { IColor } from '../../ui/Types';
// In practice we're probably never going to exhaust a texture this large. For debugging purposes, // 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. // however, it can be useful to set this to a really tiny value, to verify that LRU eviction works.
+1 -1
View File
@@ -4,7 +4,7 @@
*/ */
import { FontWeight } from 'xterm'; import { FontWeight } from 'xterm';
import { IColorSet } from '../Types'; import { IColorSet } from '../../ui/Types';
export const INVERTED_DEFAULT_COLOR = 257; export const INVERTED_DEFAULT_COLOR = 257;
export const DIM_OPACITY = 0.5; export const DIM_OPACITY = 0.5;
+3 -2
View File
@@ -3,15 +3,16 @@
* @license MIT * @license MIT
*/ */
import { IRenderer, IRenderDimensions, IColorSet } from '../Types'; import { IRenderer, IRenderDimensions } from '../Types';
import { ILinkifierEvent, ITerminal, CharacterJoinerHandler } from '../../Types'; import { ILinkifierEvent, ITerminal, CharacterJoinerHandler } from '../../Types';
import { ITheme } from 'xterm'; import { ITheme } from 'xterm';
import { ColorManager } from '../ColorManager'; import { ColorManager } from '../../ui/ColorManager';
import { RenderDebouncer } from '../../ui/RenderDebouncer'; import { RenderDebouncer } from '../../ui/RenderDebouncer';
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 { 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 { INVERTED_DEFAULT_COLOR } from '../atlas/Types'; import { INVERTED_DEFAULT_COLOR } from '../atlas/Types';
import { EventEmitter2, IEvent } from '../../common/EventEmitter2'; import { EventEmitter2, IEvent } from '../../common/EventEmitter2';
import { Disposable } from '../../common/Lifecycle'; import { Disposable } from '../../common/Lifecycle';
import { IColorSet } from '../../ui/Types';
const TERMINAL_CLASS_PREFIX = 'xterm-dom-renderer-owner-'; const TERMINAL_CLASS_PREFIX = 'xterm-dom-renderer-owner-';
const ROW_CONTAINER_CLASS = 'xterm-rows'; const ROW_CONTAINER_CLASS = 'xterm-rows';
+22
View File
@@ -0,0 +1,22 @@
/**
* Copyright (c) 2017 The xterm.js authors. All rights reserved.
* @license MIT
*/
export interface IColorManager {
colors: IColorSet;
}
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[];
}