Skip to content

Commit

Permalink
Merge branch 'master' into protect_markers
Browse files Browse the repository at this point in the history
  • Loading branch information
Tyriar authored Apr 30, 2019
2 parents 469d515 + 766b174 commit cb33c89
Show file tree
Hide file tree
Showing 34 changed files with 169 additions and 125 deletions.
25 changes: 17 additions & 8 deletions bin/publish.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,12 @@ const packageJson = require('../package.json');
// Setup auth
fs.writeFileSync(`${process.env['HOME']}/.npmrc`, `//registry.npmjs.org/:_authToken=${process.env['NPM_AUTH_TOKEN']}`);

// Get the version
const tag = 'beta'
const nextVersion = getNextVersion(tag);
// Determine if this is a stable or beta release
const publishedVersions = getPublishedVersions();
const isStableRelease = publishedVersions.indexOf(packageJson.version) === -1;

// Get the next version
let nextVersion = isStableRelease ? packageJson.version : getNextBetaVersion();
console.log(`Publishing version: ${nextVersion}`);

// Set the version in package.json
Expand All @@ -22,16 +25,19 @@ packageJson.version = nextVersion;
fs.writeFileSync(packageJsonFile, JSON.stringify(packageJson, null, 2));

// Publish
const result = cp.spawn('npm', ['publish', '--tag', tag], {
stdio: 'inherit'
});
const args = ['publish'];
if (!isStableRelease) {
args.push('--tag', 'beta');
}
const result = cp.spawn('npm', args, { stdio: 'inherit' });
result.on('exit', code => process.exit(code));

function getNextVersion(tag) {
function getNextBetaVersion() {
if (!/^[0-9]+\.[0-9]+\.[0-9]+$/.exec(packageJson.version)) {
console.error('The package.json version must be of the form x.y.z');
process.exit(1);
}
const tag = 'beta';
const stableVersion = packageJson.version.split('.');
const nextStableVersion = `${stableVersion[0]}.${parseInt(stableVersion[1]) + 1}.${stableVersion[2]}`;
const publishedVersions = getPublishedVersions(nextStableVersion, tag);
Expand All @@ -46,5 +52,8 @@ function getNextVersion(tag) {
function getPublishedVersions(version, tag) {
const versionsProcess = cp.spawnSync('npm', ['view', 'xterm', 'versions', '--json']);
const versionsJson = JSON.parse(versionsProcess.stdout);
return versionsJson.filter(v => !v.search(new RegExp(`${version}-${tag}[0-9]+`)));
if (tag) {
return versionsJson.filter(v => !v.search(new RegExp(`${version}-${tag}[0-9]+`)));
}
return versionsJson;
}
4 changes: 2 additions & 2 deletions src/AccessibilityManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export class AccessibilityManager extends Disposable {
this._refreshRowsDimensions();
this._accessibilityTreeRoot.appendChild(this._rowContainer);

this._renderRowsDebouncer = new RenderDebouncer(this._terminal, this._renderRows.bind(this));
this._renderRowsDebouncer = new RenderDebouncer(this._renderRows.bind(this));
this._refreshRows();

this._liveRegion = document.createElement('div');
Expand Down Expand Up @@ -239,7 +239,7 @@ export class AccessibilityManager extends Disposable {
}

private _refreshRows(start?: number, end?: number): void {
this._renderRowsDebouncer.refresh(start, end);
this._renderRowsDebouncer.refresh(start, end, this._terminal.rows);
}

private _renderRows(start: number, end: number): void {
Expand Down
2 changes: 1 addition & 1 deletion src/Buffer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { assert, expect } from 'chai';
import { ITerminal } from './Types';
import { Buffer, DEFAULT_ATTR_DATA } from './Buffer';
import { CircularList } from './common/CircularList';
import { MockTerminal, TestTerminal } from './ui/TestUtils.test';
import { MockTerminal, TestTerminal } from './TestUtils.test';
import { BufferLine, CellData } from './BufferLine';

const INIT_COLS = 80;
Expand Down
2 changes: 1 addition & 1 deletion src/BufferSet.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { assert } from 'chai';
import { ITerminal } from './Types';
import { BufferSet } from './BufferSet';
import { Buffer } from './Buffer';
import { MockTerminal } from './ui/TestUtils.test';
import { MockTerminal } from './TestUtils.test';

describe('BufferSet', () => {
let terminal: ITerminal;
Expand Down
2 changes: 1 addition & 1 deletion src/ui/CharMeasure.test.ts → src/CharMeasure.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*/

import jsdom = require('jsdom');
import { ICharMeasure } from '../Types';
import { ICharMeasure } from './Types';
import { assert } from 'chai';
import { CharMeasure } from './CharMeasure';

Expand Down
4 changes: 2 additions & 2 deletions src/ui/CharMeasure.ts → src/CharMeasure.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
* @license MIT
*/

import { ICharMeasure, ITerminalOptions } from '../Types';
import { EventEmitter2, IEvent } from '../common/EventEmitter2';
import { ICharMeasure, ITerminalOptions } from './Types';
import { EventEmitter2, IEvent } from './common/EventEmitter2';

/**
* Utility class that measures the size of a character. Measurements are done in
Expand Down
2 changes: 1 addition & 1 deletion src/CharWidth.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* @license MIT
*/

import { TestTerminal } from './ui/TestUtils.test';
import { TestTerminal } from './TestUtils.test';
import { assert } from 'chai';
import { getStringCellWidth, wcwidth } from './CharWidth';
import { IBuffer } from './Types';
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion src/ui/Clipboard.ts → src/Clipboard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* @license MIT
*/

import { ITerminal, ISelectionManager } from '../Types';
import { ITerminal, ISelectionManager } from './Types';

interface IWindow extends Window {
clipboardData?: {
Expand Down
2 changes: 1 addition & 1 deletion src/InputHandler.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import { assert, expect } from 'chai';
import { InputHandler } from './InputHandler';
import { MockInputHandlingTerminal, TestTerminal } from './ui/TestUtils.test';
import { MockInputHandlingTerminal, TestTerminal } from './TestUtils.test';
import { DEFAULT_ATTR_DATA } from './Buffer';
import { Terminal } from './Terminal';
import { IBufferLine } from './Types';
Expand Down
5 changes: 2 additions & 3 deletions src/Linkifier.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@
*/

import { assert } from 'chai';
import { IMouseZoneManager, IMouseZone } from './ui/Types';
import { ILinkMatcher, ITerminal, IBufferLine } from './Types';
import { IMouseZoneManager, IMouseZone, ILinkMatcher, ITerminal, IBufferLine } from './Types';
import { Linkifier } from './Linkifier';
import { MockBuffer, MockTerminal, TestTerminal } from './ui/TestUtils.test';
import { MockBuffer, MockTerminal, TestTerminal } from './TestUtils.test';
import { CircularList } from './common/CircularList';
import { BufferLine, CellData } from './BufferLine';

Expand Down
5 changes: 2 additions & 3 deletions src/Linkifier.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@
* @license MIT
*/

import { IMouseZoneManager } from './ui/Types';
import { ILinkifierEvent, ILinkMatcher, LinkMatcherHandler, ILinkMatcherOptions, ILinkifier, ITerminal, IBufferStringIteratorResult } from './Types';
import { MouseZone } from './ui/MouseZoneManager';
import { ILinkifierEvent, ILinkMatcher, LinkMatcherHandler, ILinkMatcherOptions, ILinkifier, ITerminal, IBufferStringIteratorResult, IMouseZoneManager } from './Types';
import { MouseZone } from './MouseZoneManager';
import { getStringCellWidth } from './CharWidth';
import { EventEmitter2, IEvent } from './common/EventEmitter2';

Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions src/ui/MouseHelper.ts → src/MouseHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
* @license MIT
*/

import { ICharMeasure, IMouseHelper } from '../Types';
import { IRenderer } from '../renderer/Types';
import { ICharMeasure, IMouseHelper } from './Types';
import { IRenderer } from './renderer/Types';

export class MouseHelper implements IMouseHelper {
constructor(private _renderer: IRenderer) {}
Expand Down
7 changes: 3 additions & 4 deletions src/ui/MouseZoneManager.ts → src/MouseZoneManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@
* @license MIT
*/

import { ITerminal } from '../Types';
import { IMouseZoneManager, IMouseZone } from './Types';
import { Disposable } from '../common/Lifecycle';
import { addDisposableDomListener } from './Lifecycle';
import { ITerminal, IMouseZoneManager, IMouseZone } from './Types';
import { Disposable } from './common/Lifecycle';
import { addDisposableDomListener } from './ui/Lifecycle';

const HOVER_DURATION = 500;

Expand Down
4 changes: 2 additions & 2 deletions src/SelectionManager.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
*/

import { assert } from 'chai';
import { CharMeasure } from './ui/CharMeasure';
import { CharMeasure } from './CharMeasure';
import { SelectionManager, SelectionMode } from './SelectionManager';
import { SelectionModel } from './SelectionModel';
import { BufferSet } from './BufferSet';
import { ITerminal, IBuffer, IBufferLine } from './Types';
import { MockTerminal } from './ui/TestUtils.test';
import { MockTerminal } from './TestUtils.test';
import { BufferLine, CellData } from './BufferLine';

class TestMockTerminal extends MockTerminal {
Expand Down
4 changes: 2 additions & 2 deletions src/SelectionManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
*/

import { ITerminal, ISelectionManager, IBuffer, IBufferLine, ISelectionRedrawRequestEvent } from './Types';
import { MouseHelper } from './ui/MouseHelper';
import { MouseHelper } from './MouseHelper';
import * as Browser from './common/Platform';
import { CharMeasure } from './ui/CharMeasure';
import { CharMeasure } from './CharMeasure';
import { SelectionModel } from './SelectionModel';
import { AltClickHandler } from './handlers/AltClickHandler';
import { CellData } from './BufferLine';
Expand Down
2 changes: 1 addition & 1 deletion src/SelectionModel.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { assert } from 'chai';
import { ITerminal } from './Types';
import { SelectionModel } from './SelectionModel';
import { BufferSet } from './BufferSet';
import { MockTerminal } from './ui/TestUtils.test';
import { MockTerminal } from './TestUtils.test';

class TestSelectionModel extends SelectionModel {
constructor(
Expand Down
2 changes: 1 addition & 1 deletion src/Terminal.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import { assert, expect } from 'chai';
import { Terminal } from './Terminal';
import { MockViewport, MockCompositionHelper, MockRenderer } from './ui/TestUtils.test';
import { MockViewport, MockCompositionHelper, MockRenderer } from './TestUtils.test';
import { DEFAULT_ATTR_DATA } from './Buffer';
import { CellData } from './BufferLine';

Expand Down
11 changes: 5 additions & 6 deletions src/Terminal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,27 +21,26 @@
* http://linux.die.net/man/7/urxvt
*/

import { IInputHandlingTerminal, IViewport, ICompositionHelper, ITerminalOptions, ITerminal, IBrowser, ILinkifier, ILinkMatcherOptions, CustomKeyEventHandler, LinkMatcherHandler, CharacterJoinerHandler, IBufferLine, IAttributeData } from './Types';
import { IMouseZoneManager } from './ui/Types';
import { IInputHandlingTerminal, IViewport, ICompositionHelper, ITerminalOptions, ITerminal, IBrowser, ILinkifier, ILinkMatcherOptions, CustomKeyEventHandler, LinkMatcherHandler, CharacterJoinerHandler, IBufferLine, IAttributeData, IMouseZoneManager } from './Types';
import { IRenderer } from './renderer/Types';
import { BufferSet } from './BufferSet';
import { Buffer, MAX_BUFFER_SIZE, DEFAULT_ATTR_DATA } from './Buffer';
import { CompositionHelper } from './CompositionHelper';
import { EventEmitter } from './common/EventEmitter';
import { Viewport } from './Viewport';
import { rightClickHandler, moveTextAreaUnderMouseCursor, pasteHandler, copyHandler } from './ui/Clipboard';
import { rightClickHandler, moveTextAreaUnderMouseCursor, pasteHandler, copyHandler } from './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 { CharMeasure } from './CharMeasure';
import * as Browser from './common/Platform';
import { addDisposableDomListener } from './ui/Lifecycle';
import * as Strings from './Strings';
import { MouseHelper } from './ui/MouseHelper';
import { MouseHelper } from './MouseHelper';
import { DEFAULT_BELL_SOUND, SoundManager } from './SoundManager';
import { MouseZoneManager } from './ui/MouseZoneManager';
import { MouseZoneManager } from './MouseZoneManager';
import { AccessibilityManager } from './AccessibilityManager';
import { ScreenDprMonitor } from './ui/ScreenDprMonitor';
import { ITheme, IMarker, IDisposable } from 'xterm';
Expand Down
14 changes: 7 additions & 7 deletions src/ui/TestUtils.test.ts → src/TestUtils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
* @license MIT
*/

import { IColorSet, IRenderer, IRenderDimensions, IColorManager } from '../renderer/Types';
import { IInputHandlingTerminal, IViewport, ICompositionHelper, ITerminal, IBuffer, IBufferSet, IBrowser, ICharMeasure, ISelectionManager, ITerminalOptions, ILinkifier, IMouseHelper, ILinkMatcherOptions, CharacterJoinerHandler, IBufferLine, IBufferStringIterator, ICellData, IAttributeData } from '../Types';
import { ICircularList, XtermListener } from '../common/Types';
import { Buffer } from '../Buffer';
import * as Browser from '../common/Platform';
import { IColorSet, IRenderer, IRenderDimensions, IColorManager } from './renderer/Types';
import { IInputHandlingTerminal, IViewport, ICompositionHelper, ITerminal, IBuffer, IBufferSet, IBrowser, ICharMeasure, ISelectionManager, ITerminalOptions, ILinkifier, IMouseHelper, ILinkMatcherOptions, CharacterJoinerHandler, IBufferLine, IBufferStringIterator, ICellData, IAttributeData } from './Types';
import { ICircularList, XtermListener } from './common/Types';
import { Buffer } from './Buffer';
import * as Browser from './common/Platform';
import { ITheme, IDisposable, IMarker, IEvent } from 'xterm';
import { Terminal } from '../Terminal';
import { AttributeData } from '../BufferLine';
import { Terminal } from './Terminal';
import { AttributeData } from './BufferLine';

export class TestTerminal extends Terminal {
writeSync(data: string): void {
Expand Down
18 changes: 17 additions & 1 deletion src/Types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

import { Terminal as PublicTerminal, ITerminalOptions as IPublicTerminalOptions, IEventEmitter, IDisposable } from 'xterm';
import { IColorSet, IRenderer } from './renderer/Types';
import { IMouseZoneManager } from './ui/Types';
import { ICharset } from './core/Types';
import { ICircularList } from './common/Types';
import { IEvent } from './common/EventEmitter2';
Expand Down Expand Up @@ -604,3 +603,20 @@ export interface IBufferLine {
isCombined(index: number): number;
getString(index: number): string;
}

export interface IMouseZoneManager extends IDisposable {
add(zone: IMouseZone): void;
clearAll(start?: number, end?: number): void;
}

export interface IMouseZone {
x1: number;
x2: number;
y1: number;
y2: number;
clickCallback: (e: MouseEvent) => any;
hoverCallback: (e: MouseEvent) => any | undefined;
tooltipCallback: (e: MouseEvent) => any | undefined;
leaveCallback: () => any | undefined;
willLinkActivate: (e: MouseEvent) => boolean;
}
2 changes: 1 addition & 1 deletion src/Viewport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import { IColorSet } from './renderer/Types';
import { ITerminal, IViewport } from './Types';
import { CharMeasure } from './ui/CharMeasure';
import { CharMeasure } from './CharMeasure';
import { Disposable } from './common/Lifecycle';
import { addDisposableDomListener } from './ui/Lifecycle';

Expand Down
18 changes: 11 additions & 7 deletions src/renderer/BaseRenderLayer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -322,14 +322,18 @@ export abstract class BaseRenderLayer implements IRenderLayer {
} else {
this._ctx.fillStyle = this._colors.ansi[cell.getBgColor()].css;
}
} else if (cell.isFgRGB()) {
this._ctx.fillStyle = `rgb(${AttributeData.toColorRGB(cell.getFgColor()).join(',')})`;
} else if (cell.isFgPalette()) {
let fg = cell.getFgColor();
if (terminal.options.drawBoldTextInBrightColors && cell.isBold() && fg < 8) {
fg += 8;
} else {
if (cell.isFgDefault()) {
this._ctx.fillStyle = this._colors.foreground.css;
} else if (cell.isFgRGB()) {
this._ctx.fillStyle = `rgb(${AttributeData.toColorRGB(cell.getFgColor()).join(',')})`;
} else {
let fg = cell.getFgColor();
if (terminal.options.drawBoldTextInBrightColors && cell.isBold() && fg < 8) {
fg += 8;
}
this._ctx.fillStyle = this._colors.ansi[fg].css;
}
this._ctx.fillStyle = this._colors.ansi[fg].css;
}

this._clipRow(terminal, y);
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/CharacterJoinerRegistry.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { assert } from 'chai';

import { MockTerminal, MockBuffer } from '../ui/TestUtils.test';
import { MockTerminal, MockBuffer } from '../TestUtils.test';
import { CircularList } from '../common/CircularList';

import { ICharacterJoinerRegistry } from './Types';
Expand Down
4 changes: 2 additions & 2 deletions src/renderer/Renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export class Renderer extends Disposable implements IRenderer {
this._updateDimensions();
this.onOptionsChanged();

this._renderDebouncer = new RenderDebouncer(this._terminal, this._renderRows.bind(this));
this._renderDebouncer = new RenderDebouncer(this._renderRows.bind(this));
this._screenDprMonitor = new ScreenDprMonitor();
this._screenDprMonitor.setListener(() => this.onWindowResize(window.devicePixelRatio));
this.register(this._screenDprMonitor);
Expand Down Expand Up @@ -194,7 +194,7 @@ export class Renderer extends Disposable implements IRenderer {
this._needsFullRefresh = true;
return;
}
this._renderDebouncer.refresh(start, end);
this._renderDebouncer.refresh(start, end, this._terminal.rows);
}

/**
Expand Down
16 changes: 12 additions & 4 deletions src/renderer/TextRenderLayer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -217,10 +217,18 @@ export class TextRenderLayer extends BaseRenderLayer {
} else {
this._ctx.fillStyle = this._colors.ansi[cell.getBgColor()].css;
}
} else if (cell.isFgRGB()) {
this._ctx.fillStyle = `rgb(${AttributeData.toColorRGB(cell.getFgColor()).join(',')})`;
} else if (cell.isFgPalette()) {
this._ctx.fillStyle = this._colors.ansi[cell.getFgColor()].css;
} else {
if (cell.isFgDefault()) {
this._ctx.fillStyle = this._colors.foreground.css;
} else if (cell.isFgRGB()) {
this._ctx.fillStyle = `rgb(${AttributeData.toColorRGB(cell.getFgColor()).join(',')})`;
} else {
let fg = cell.getFgColor();
if (terminal.options.drawBoldTextInBrightColors && cell.isBold() && fg < 8) {
fg += 8;
}
this._ctx.fillStyle = this._colors.ansi[fg].css;
}
}

this.fillBottomLineAtCells(x, y, cell.getWidth());
Expand Down
Loading

0 comments on commit cb33c89

Please sign in to comment.