Skip to content

Commit

Permalink
Merge branch 'master' into issue_1654
Browse files Browse the repository at this point in the history
  • Loading branch information
noamyogev84 committed Nov 30, 2018
2 parents 376c790 + 5f98992 commit 38adfcd
Show file tree
Hide file tree
Showing 22 changed files with 60 additions and 91 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
"ts-loader": "^4.5.0",
"tslint": "^5.9.1",
"tslint-consistent-codestyle": "^1.13.0",
"typescript": "3.0",
"typescript": "3.1",
"vinyl-buffer": "^1.0.0",
"vinyl-source-stream": "^1.1.0",
"webpack": "^4.17.1",
Expand Down
2 changes: 1 addition & 1 deletion src/AccessibilityManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import * as Strings from './Strings';
import { ITerminal, IBuffer } from './Types';
import { isMac } from './shared/utils/Browser';
import { isMac } from './core/Platform';
import { RenderDebouncer } from './ui/RenderDebouncer';
import { addDisposableDomListener } from './ui/Lifecycle';
import { Disposable } from './common/Lifecycle';
Expand Down
2 changes: 1 addition & 1 deletion src/SelectionManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import { ITerminal, ISelectionManager, IBuffer, CharData, IBufferLine } from './Types';
import { XtermListener } from './common/Types';
import { MouseHelper } from './utils/MouseHelper';
import * as Browser from './shared/utils/Browser';
import * as Browser from './core/Platform';
import { CharMeasure } from './ui/CharMeasure';
import { EventEmitter } from './common/EventEmitter';
import { SelectionModel } from './SelectionModel';
Expand Down
8 changes: 4 additions & 4 deletions src/Terminal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,14 @@ import { Buffer, MAX_BUFFER_SIZE, DEFAULT_ATTR, NULL_CELL_CODE, NULL_CELL_WIDTH,
import { CompositionHelper } from './CompositionHelper';
import { EventEmitter } from './common/EventEmitter';
import { Viewport } from './Viewport';
import { rightClickHandler, moveTextAreaUnderMouseCursor, pasteHandler, copyHandler } from './handlers/Clipboard';
import { rightClickHandler, moveTextAreaUnderMouseCursor, pasteHandler, copyHandler } from './ui/Clipboard';
import { C0 } from './common/data/EscapeSequences';
import { InputHandler } from './InputHandler';
import { Renderer } from './renderer/Renderer';
import { Linkifier } from './Linkifier';
import { SelectionManager } from './SelectionManager';
import { CharMeasure } from './ui/CharMeasure';
import * as Browser from './shared/utils/Browser';
import * as Browser from './core/Platform';
import { addDisposableDomListener } from './ui/Lifecycle';
import * as Strings from './Strings';
import { MouseHelper } from './utils/MouseHelper';
Expand Down Expand Up @@ -1157,9 +1157,9 @@ export class Terminal extends EventEmitter implements ITerminal, IDisposable, II
*/
public updateCursorStyle(ev: KeyboardEvent): void {
if (this.selectionManager && this.selectionManager.shouldColumnSelect(ev)) {
this.element.classList.add('xterm-cursor-crosshair');
this.element.classList.add('column-select');
} else {
this.element.classList.remove('xterm-cursor-crosshair');
this.element.classList.remove('column-select');
}
}

Expand Down
File renamed without changes.
3 changes: 1 addition & 2 deletions src/renderer/ColorManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
* @license MIT
*/

import { IColorManager } from './Types';
import { IColor, IColorSet } from '../shared/Types';
import { IColorManager, IColor, IColorSet } from './Types';
import { ITheme } from 'xterm';

const DEFAULT_FOREGROUND = fromHex('#ffffff');
Expand Down
18 changes: 14 additions & 4 deletions src/renderer/Types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

import { ITerminal, CharacterJoinerHandler } from '../Types';
import { IEventEmitter, ITheme, IDisposable } from 'xterm';
import { IColorSet } from '../shared/Types';

/**
* Flags used to render terminal text properly.
Expand Down Expand Up @@ -48,9 +47,6 @@ export interface IColorManager {
colors: IColorSet;
}

// TODO: We should probably rewrite the imports for IColorSet, but there's a lot of them
export { IColorSet };

export interface IRenderDimensions {
scaledCharWidth: number;
scaledCharHeight: number;
Expand Down Expand Up @@ -134,3 +130,17 @@ export interface ICharacterJoinerRegistry {
deregisterCharacterJoiner(joinerId: number): boolean;
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[];
}
2 changes: 1 addition & 1 deletion src/renderer/atlas/CharAtlasCache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@

import { ITerminal } from '../../Types';
import { IColorSet } from '../Types';
import { ICharAtlasConfig } from '../../shared/atlas/Types';
import { generateConfig, configEquals } from './CharAtlasUtils';
import BaseCharAtlas from './BaseCharAtlas';
import DynamicCharAtlas from './DynamicCharAtlas';
import NoneCharAtlas from './NoneCharAtlas';
import StaticCharAtlas from './StaticCharAtlas';
import { ICharAtlasConfig } from './Types';

const charAtlasImplementations = {
'none': NoneCharAtlas,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,17 @@
*/

import { FontWeight } from 'xterm';
import { CHAR_ATLAS_CELL_SPACING, ICharAtlasConfig } from './Types';
import { isFirefox, isSafari } from '../../core/Platform';
import { IColor } from '../Types';
import { isFirefox, isSafari } from '../utils/Browser';

declare const Promise: any;

export interface IOffscreenCanvas {
width: number;
height: number;
getContext(type: '2d', config?: Canvas2DContextAttributes): CanvasRenderingContext2D;
transferToImageBitmap(): ImageBitmap;
}
import { ICharAtlasConfig, CHAR_ATLAS_CELL_SPACING } from './Types';

/**
* Generates a char atlas.
* @param context The window or worker context.
* @param canvasFactory A function to generate a canvas with a width or height.
* @param config The config for the new char atlas.
*/
export function generateStaticCharAtlasTexture(context: Window, canvasFactory: (width: number, height: number) => HTMLCanvasElement | IOffscreenCanvas, config: ICharAtlasConfig): HTMLCanvasElement | Promise<ImageBitmap> {
export function generateStaticCharAtlasTexture(context: Window, canvasFactory: (width: number, height: number) => HTMLCanvasElement, config: ICharAtlasConfig): HTMLCanvasElement | Promise<ImageBitmap> {
const cellWidth = config.scaledCharWidth + CHAR_ATLAS_CELL_SPACING;
const cellHeight = config.scaledCharHeight + CHAR_ATLAS_CELL_SPACING;
const canvas = canvasFactory(
Expand Down Expand Up @@ -101,12 +92,7 @@ export function generateStaticCharAtlasTexture(context: Window, canvasFactory: (
// performance (tested on v55).
if (!('createImageBitmap' in context) || isFirefox || isSafari) {
// Don't attempt to clear background colors if createImageBitmap is not supported
if (canvas instanceof HTMLCanvasElement) {
// Just return the HTMLCanvas if it's a HTMLCanvasElement
return canvas;
}
// Transfer to an ImageBitmap is this is an OffscreenCanvas
return new Promise((r: (bitmap: ImageBitmap) => void) => r(canvas.transferToImageBitmap()));
return canvas;
}

const charAtlasImageData = ctx.getImageData(0, 0, canvas.width, canvas.height);
Expand Down
3 changes: 1 addition & 2 deletions src/renderer/atlas/CharAtlasUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@

import { ITerminal } from '../../Types';
import { IColorSet } from '../Types';
import { ICharAtlasConfig } from '../../shared/atlas/Types';
import { DEFAULT_COLOR } from './Types';
import { DEFAULT_COLOR, ICharAtlasConfig } from './Types';

export function generateConfig(scaledCharWidth: number, scaledCharHeight: number, terminal: ITerminal, colors: IColorSet): ICharAtlasConfig {
// null out some fields that don't matter
Expand Down
9 changes: 4 additions & 5 deletions src/renderer/atlas/DynamicCharAtlas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,13 @@
* @license MIT
*/

import { DIM_OPACITY, IGlyphIdentifier, INVERTED_DEFAULT_COLOR } from './Types';
import { ICharAtlasConfig } from '../../shared/atlas/Types';
import { IColor } from '../../shared/Types';
import { DIM_OPACITY, IGlyphIdentifier, INVERTED_DEFAULT_COLOR, ICharAtlasConfig } from './Types';
import BaseCharAtlas from './BaseCharAtlas';
import { DEFAULT_ANSI_COLORS } from '../ColorManager';
import { clearColor } from '../../shared/atlas/CharAtlasGenerator';
import { clearColor } from './CharAtlasGenerator';
import LRUMap from './LRUMap';
import { isFirefox, isSafari } from '../../shared/utils/Browser';
import { isFirefox, isSafari } from '../../core/Platform';
import { IColor } from '../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.
Expand Down
3 changes: 1 addition & 2 deletions src/renderer/atlas/NoneCharAtlas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
* A dummy CharAtlas implementation that always fails to draw characters.
*/

import { IGlyphIdentifier } from './Types';
import { ICharAtlasConfig } from '../../shared/atlas/Types';
import { IGlyphIdentifier, ICharAtlasConfig } from './Types';
import BaseCharAtlas from './BaseCharAtlas';

export default class NoneCharAtlas extends BaseCharAtlas {
Expand Down
5 changes: 2 additions & 3 deletions src/renderer/atlas/StaticCharAtlas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@
* @license MIT
*/

import { DIM_OPACITY, IGlyphIdentifier, DEFAULT_COLOR } from './Types';
import { CHAR_ATLAS_CELL_SPACING, ICharAtlasConfig } from '../../shared/atlas/Types';
import { generateStaticCharAtlasTexture } from '../../shared/atlas/CharAtlasGenerator';
import { DIM_OPACITY, IGlyphIdentifier, DEFAULT_COLOR, ICharAtlasConfig, CHAR_ATLAS_CELL_SPACING } from './Types';
import { generateStaticCharAtlasTexture } from './CharAtlasGenerator';
import BaseCharAtlas from './BaseCharAtlas';
import { is256Color } from './CharAtlasUtils';

Expand Down
18 changes: 18 additions & 0 deletions src/renderer/atlas/Types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,15 @@
* @license MIT
*/

import { FontWeight } from 'xterm';
import { IColorSet } from '../Types';

export const DEFAULT_COLOR = 256;
export const INVERTED_DEFAULT_COLOR = 257;
export const DIM_OPACITY = 0.5;

export const CHAR_ATLAS_CELL_SPACING = 1;

export interface IGlyphIdentifier {
chars: string;
code: number;
Expand All @@ -16,3 +21,16 @@ export interface IGlyphIdentifier {
dim: boolean;
italic: boolean;
}

export interface ICharAtlasConfig {
type: 'none' | 'static' | 'dynamic';
devicePixelRatio: number;
fontSize: number;
fontFamily: string;
fontWeight: FontWeight;
fontWeightBold: FontWeight;
scaledCharWidth: number;
scaledCharHeight: number;
allowTransparency: boolean;
colors: IColorSet;
}
18 changes: 0 additions & 18 deletions src/shared/Types.ts

This file was deleted.

22 changes: 0 additions & 22 deletions src/shared/atlas/Types.ts

This file was deleted.

File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion src/ui/ScreenDprMonitor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export type ScreenDprListener = (newDevicePixelRatio?: number, oldDevicePixelRat
*/
export class ScreenDprMonitor extends Disposable {
private _currentDevicePixelRatio: number;
private _outerListener: MediaQueryListListener;
private _outerListener: (this: MediaQueryList, ev: MediaQueryListEvent) => any;
private _listener: ScreenDprListener;
private _resolutionMediaMatchList: MediaQueryList;

Expand Down
2 changes: 1 addition & 1 deletion src/utils/TestUtils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { IColorSet, IRenderer, IRenderDimensions, IColorManager } from '../rende
import { IInputHandlingTerminal, IViewport, ICompositionHelper, ITerminal, IBuffer, IBufferSet, IBrowser, ICharMeasure, ISelectionManager, ITerminalOptions, ILinkifier, IMouseHelper, ILinkMatcherOptions, CharacterJoinerHandler, IBufferLine, IBufferStringIterator } from '../Types';
import { ICircularList, XtermListener } from '../common/Types';
import { Buffer } from '../Buffer';
import * as Browser from '../shared/utils/Browser';
import * as Browser from '../core/Platform';
import { ITheme, IDisposable, IMarker } from 'xterm';
import { Terminal } from '../Terminal';

Expand Down
2 changes: 1 addition & 1 deletion src/xterm.css
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@
cursor: pointer;
}

.xterm.xterm-cursor-crosshair {
.xterm.column-select.focus {
/* Column selection mode */
cursor: crosshair;
}
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6716,10 +6716,10 @@ typedarray@^0.0.6, typedarray@~0.0.5:
resolved "https://registry.yarnpkg.com/typedarray/-/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777"
integrity sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c=

typescript@3.0:
version "3.0.3"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.0.3.tgz#4853b3e275ecdaa27f78fda46dc273a7eb7fc1c8"
integrity sha512-kk80vLW9iGtjMnIv11qyxLqZm20UklzuR2tL0QAnDIygIUIemcZMxlMWudl9OOt76H3ntVzcTiddQ1/pAAJMYg==
typescript@3.1:
version "3.1.6"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.1.6.tgz#b6543a83cfc8c2befb3f4c8fba6896f5b0c9be68"
integrity sha512-tDMYfVtvpb96msS1lDX9MEdHrW4yOuZ4Kdc4Him9oU796XldPYF/t2+uKoX0BBa0hXXwDlqYQbXY5Rzjzc5hBA==

uglify-es@^3.3.4:
version "3.3.9"
Expand Down

0 comments on commit 38adfcd

Please sign in to comment.