type fixes & docs

This commit is contained in:
Jörg Breitbart
2020-01-04 14:47:14 +01:00
parent bd4c2da37c
commit df4b07f9f2
10 changed files with 30 additions and 19 deletions
+3
View File
@@ -17,4 +17,7 @@ import { Unicode11Addon } from 'xterm-addon-unicode11';
const terminal = new Terminal(); const terminal = new Terminal();
const unicode11Addon = new Unicode11Addon(); const unicode11Addon = new Unicode11Addon();
terminal.loadAddon(unicode11Addon); terminal.loadAddon(unicode11Addon);
// activate the new version
terminal.unicode.activeVersion = '11';
``` ```
@@ -193,7 +193,7 @@ function bisearch(ucs: number, data: number[][]): boolean {
export class UnicodeV11 implements IUnicodeVersionProvider { export class UnicodeV11 implements IUnicodeVersionProvider {
public version = '11'; public readonly version = '11';
constructor() { constructor() {
if (!table) { if (!table) {
+1 -1
View File
@@ -1039,7 +1039,7 @@ describe('Terminal', () => {
// to get the special handling of fullwidth, surrogate and combining chars in the input handler // to get the special handling of fullwidth, surrogate and combining chars in the input handler
beforeEach(() => { beforeEach(() => {
terminal = new TestTerminal({ cols: 10, rows: 5 }); terminal = new TestTerminal({ cols: 10, rows: 5 });
linkifier = new TestLinkifier((terminal as any)._bufferService, (terminal as any)._unicodeService); linkifier = new TestLinkifier((terminal as any)._bufferService, terminal.unicodeService);
mouseZoneManager = new TestMouseZoneManager(); mouseZoneManager = new TestMouseZoneManager();
linkifier.attachToDom({} as any, mouseZoneManager); linkifier.attachToDom({} as any, mouseZoneManager);
}); });
+7 -7
View File
@@ -99,7 +99,7 @@ export class Terminal extends Disposable implements ITerminal, IDisposable, IInp
private _instantiationService: IInstantiationService; private _instantiationService: IInstantiationService;
private _logService: ILogService; private _logService: ILogService;
public optionsService: IOptionsService; public optionsService: IOptionsService;
private _unicodeService: IUnicodeService; public unicodeService: IUnicodeService;
// browser services // browser services
private _charSizeService: ICharSizeService; private _charSizeService: ICharSizeService;
@@ -211,8 +211,8 @@ export class Terminal extends Disposable implements ITerminal, IDisposable, IInp
this._instantiationService.setService(ICoreMouseService, this._coreMouseService); this._instantiationService.setService(ICoreMouseService, this._coreMouseService);
this._dirtyRowService = this._instantiationService.createInstance(DirtyRowService); this._dirtyRowService = this._instantiationService.createInstance(DirtyRowService);
this._instantiationService.setService(IDirtyRowService, this._dirtyRowService); this._instantiationService.setService(IDirtyRowService, this._dirtyRowService);
this._unicodeService = this._instantiationService.createInstance(UnicodeService); this.unicodeService = this._instantiationService.createInstance(UnicodeService);
this._instantiationService.setService(IUnicodeService, this._unicodeService); this._instantiationService.setService(IUnicodeService, this.unicodeService);
this._charsetService = this._instantiationService.createInstance(CharsetService); this._charsetService = this._instantiationService.createInstance(CharsetService);
this._instantiationService.setService(ICharsetService, this._charsetService); this._instantiationService.setService(ICharsetService, this._charsetService);
@@ -248,7 +248,7 @@ export class Terminal extends Disposable implements ITerminal, IDisposable, IInp
this._inputHandler.reset(); this._inputHandler.reset();
} else { } else {
// Register input handler and refire/handle events // Register input handler and refire/handle events
this._inputHandler = new InputHandler(this, this._bufferService, this._charsetService, this._coreService, this._dirtyRowService, this._logService, this.optionsService, this._coreMouseService, this._unicodeService); this._inputHandler = new InputHandler(this, this._bufferService, this._charsetService, this._coreService, this._dirtyRowService, this._logService, this.optionsService, this._coreMouseService, this.unicodeService);
this._inputHandler.onRequestBell(() => this.bell()); this._inputHandler.onRequestBell(() => this.bell());
this._inputHandler.onRequestRefreshRows((start, end) => this.refresh(start, end)); this._inputHandler.onRequestRefreshRows((start, end) => this.refresh(start, end));
this._inputHandler.onRequestReset(() => this.reset()); this._inputHandler.onRequestReset(() => this.reset());
@@ -258,7 +258,7 @@ export class Terminal extends Disposable implements ITerminal, IDisposable, IInp
} }
if (!this.linkifier) { if (!this.linkifier) {
this.linkifier = new Linkifier(this._bufferService, this._logService, this.optionsService, this._unicodeService); this.linkifier = new Linkifier(this._bufferService, this._logService, this.optionsService, this.unicodeService);
} }
if (this.options.windowsMode) { if (this.options.windowsMode) {
@@ -348,8 +348,8 @@ export class Terminal extends Disposable implements ITerminal, IDisposable, IInp
} }
break; break;
case 'unicodeVersion': case 'unicodeVersion':
if (this._unicodeService.activeVersion !== this.optionsService.options.unicodeVersion) { if (this.unicodeService.activeVersion !== this.optionsService.options.unicodeVersion) {
this._unicodeService.activeVersion = this.optionsService.options.unicodeVersion; this.unicodeService.activeVersion = this.optionsService.options.unicodeVersion;
} }
break; break;
} }
+2 -1
View File
@@ -13,7 +13,7 @@ import { IDisposable, IMarker, IEvent, ISelectionPosition } from 'xterm';
import { Terminal } from './Terminal'; import { Terminal } from './Terminal';
import { AttributeData } from 'common/buffer/AttributeData'; import { AttributeData } from 'common/buffer/AttributeData';
import { IColorManager, IColorSet, ILinkMatcherOptions, ILinkifier, IViewport } from 'browser/Types'; import { IColorManager, IColorSet, ILinkMatcherOptions, ILinkifier, IViewport } from 'browser/Types';
import { IOptionsService } from 'common/services/Services'; import { IOptionsService, IUnicodeService } from 'common/services/Services';
import { EventEmitter } from 'common/EventEmitter'; import { EventEmitter } from 'common/EventEmitter';
import { IParams, IFunctionIdentifier } from 'common/parser/Types'; import { IParams, IFunctionIdentifier } from 'common/parser/Types';
import { ISelectionService } from 'browser/services/Services'; import { ISelectionService } from 'browser/services/Services';
@@ -41,6 +41,7 @@ export class MockTerminal implements ITerminal {
onResize: IEvent<{ cols: number; rows: number; }>; onResize: IEvent<{ cols: number; rows: number; }>;
markers: IMarker[]; markers: IMarker[];
optionsService: IOptionsService; optionsService: IOptionsService;
unicodeService: IUnicodeService;
addMarker(cursorYOffset: number): IMarker { addMarker(cursorYOffset: number): IMarker {
throw new Error('Method not implemented.'); throw new Error('Method not implemented.');
} }
+2 -1
View File
@@ -7,7 +7,7 @@ import { ITerminalOptions as IPublicTerminalOptions, IDisposable, IMarker, ISele
import { ICharset, IAttributeData, CharData, CoreMouseEventType } from 'common/Types'; import { ICharset, IAttributeData, CharData, CoreMouseEventType } from 'common/Types';
import { IEvent, IEventEmitter } from 'common/EventEmitter'; import { IEvent, IEventEmitter } from 'common/EventEmitter';
import { IColorSet, ILinkifier, ILinkMatcherOptions, IViewport } from 'browser/Types'; import { IColorSet, ILinkifier, ILinkMatcherOptions, IViewport } from 'browser/Types';
import { IOptionsService } from 'common/services/Services'; import { IOptionsService, IUnicodeService } from 'common/services/Services';
import { IBuffer, IBufferSet } from 'common/buffer/Types'; import { IBuffer, IBufferSet } from 'common/buffer/Types';
import { IParams, IFunctionIdentifier } from 'common/parser/Types'; import { IParams, IFunctionIdentifier } from 'common/parser/Types';
@@ -140,6 +140,7 @@ export interface ITerminal extends IPublicTerminal, IElementAccessor, IBufferAcc
optionsService: IOptionsService; optionsService: IOptionsService;
// TODO: We should remove options once components adopt optionsService // TODO: We should remove options once components adopt optionsService
options: ITerminalOptions; options: ITerminalOptions;
unicodeService: IUnicodeService;
onBlur: IEvent<void>; onBlur: IEvent<void>;
onFocus: IEvent<void>; onFocus: IEvent<void>;
+1 -1
View File
@@ -84,7 +84,7 @@ function bisearch(ucs: number, data: number[][]): boolean {
} }
export class UnicodeV6 implements IUnicodeVersionProvider { export class UnicodeV6 implements IUnicodeVersionProvider {
public version = '6'; public readonly version = '6';
constructor() { constructor() {
// init lookup table once // init lookup table once
+1 -1
View File
@@ -328,6 +328,6 @@ export interface IUnicodeService {
} }
export interface IUnicodeVersionProvider { export interface IUnicodeVersionProvider {
version: string; readonly version: string;
wcwidth(ucs: number): 0 | 1 | 2; wcwidth(ucs: number): 0 | 1 | 2;
} }
+4 -4
View File
@@ -263,18 +263,18 @@ class UnicodeApi implements IUnicodeHandling {
constructor(private _core: ITerminal) {} constructor(private _core: ITerminal) {}
public register(provider: IUnicodeVersionProvider): void { public register(provider: IUnicodeVersionProvider): void {
(this._core as any)._unicodeService.register(provider); this._core.unicodeService.register(provider);
} }
public get versions(): string[] { public get versions(): string[] {
return (this._core as any)._unicodeService.versions; return this._core.unicodeService.versions;
} }
public get activeVersion(): string { public get activeVersion(): string {
return (this._core as any)._unicodeService.activeVersion; return this._core.unicodeService.activeVersion;
} }
public set activeVersion(version: string) { public set activeVersion(version: string) {
(this._core as any)._unicodeService.activeVersion = version; this._core.unicodeService.activeVersion = version;
} }
} }
+8 -2
View File
@@ -217,6 +217,7 @@ declare module 'xterm' {
/** /**
* Unicode version to be used for wcwidth. Default is version 6. * Unicode version to be used for wcwidth. Default is version 6.
* New unicode versions can be registered through the `Terminal.unicode.register` API.
*/ */
unicodeVersion?: string; unicodeVersion?: string;
@@ -1173,7 +1174,7 @@ declare module 'xterm' {
*/ */
export interface IUnicodeVersionProvider { export interface IUnicodeVersionProvider {
/** String indicating the Unicode version provided. */ /** String indicating the Unicode version provided. */
version: string; readonly version: string;
/** Unicode version dependent wcwidth implementation. */ /** Unicode version dependent wcwidth implementation. */
wcwidth(codepoint: number): 0 | 1 | 2; wcwidth(codepoint: number): 0 | 1 | 2;
} }
@@ -1189,6 +1190,11 @@ declare module 'xterm' {
/** /**
* Registered Unicode versions. * Registered Unicode versions.
*/ */
versions: string[]; readonly versions: ReadonlyArray<string>;
/**
* Getter/setter for activate Unicode version.
* FIXME: Should we go with this instead of get/SetOption?
*/
activeVersion: string;
} }
} }