mirror of
https://github.com/wavetermdev/xterm.js.git
synced 2026-08-05 13:43:48 -07:00
type fixes & docs
This commit is contained in:
@@ -17,4 +17,7 @@ import { Unicode11Addon } from 'xterm-addon-unicode11';
|
||||
const terminal = new Terminal();
|
||||
const unicode11Addon = new 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 {
|
||||
public version = '11';
|
||||
public readonly version = '11';
|
||||
|
||||
constructor() {
|
||||
if (!table) {
|
||||
|
||||
@@ -1039,7 +1039,7 @@ describe('Terminal', () => {
|
||||
// to get the special handling of fullwidth, surrogate and combining chars in the input handler
|
||||
beforeEach(() => {
|
||||
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();
|
||||
linkifier.attachToDom({} as any, mouseZoneManager);
|
||||
});
|
||||
|
||||
+7
-7
@@ -99,7 +99,7 @@ export class Terminal extends Disposable implements ITerminal, IDisposable, IInp
|
||||
private _instantiationService: IInstantiationService;
|
||||
private _logService: ILogService;
|
||||
public optionsService: IOptionsService;
|
||||
private _unicodeService: IUnicodeService;
|
||||
public unicodeService: IUnicodeService;
|
||||
|
||||
// browser services
|
||||
private _charSizeService: ICharSizeService;
|
||||
@@ -211,8 +211,8 @@ export class Terminal extends Disposable implements ITerminal, IDisposable, IInp
|
||||
this._instantiationService.setService(ICoreMouseService, this._coreMouseService);
|
||||
this._dirtyRowService = this._instantiationService.createInstance(DirtyRowService);
|
||||
this._instantiationService.setService(IDirtyRowService, this._dirtyRowService);
|
||||
this._unicodeService = this._instantiationService.createInstance(UnicodeService);
|
||||
this._instantiationService.setService(IUnicodeService, this._unicodeService);
|
||||
this.unicodeService = this._instantiationService.createInstance(UnicodeService);
|
||||
this._instantiationService.setService(IUnicodeService, this.unicodeService);
|
||||
this._charsetService = this._instantiationService.createInstance(CharsetService);
|
||||
this._instantiationService.setService(ICharsetService, this._charsetService);
|
||||
|
||||
@@ -248,7 +248,7 @@ export class Terminal extends Disposable implements ITerminal, IDisposable, IInp
|
||||
this._inputHandler.reset();
|
||||
} else {
|
||||
// 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.onRequestRefreshRows((start, end) => this.refresh(start, end));
|
||||
this._inputHandler.onRequestReset(() => this.reset());
|
||||
@@ -258,7 +258,7 @@ export class Terminal extends Disposable implements ITerminal, IDisposable, IInp
|
||||
}
|
||||
|
||||
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) {
|
||||
@@ -348,8 +348,8 @@ export class Terminal extends Disposable implements ITerminal, IDisposable, IInp
|
||||
}
|
||||
break;
|
||||
case 'unicodeVersion':
|
||||
if (this._unicodeService.activeVersion !== this.optionsService.options.unicodeVersion) {
|
||||
this._unicodeService.activeVersion = this.optionsService.options.unicodeVersion;
|
||||
if (this.unicodeService.activeVersion !== this.optionsService.options.unicodeVersion) {
|
||||
this.unicodeService.activeVersion = this.optionsService.options.unicodeVersion;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ import { IDisposable, IMarker, IEvent, ISelectionPosition } from 'xterm';
|
||||
import { Terminal } from './Terminal';
|
||||
import { AttributeData } from 'common/buffer/AttributeData';
|
||||
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 { IParams, IFunctionIdentifier } from 'common/parser/Types';
|
||||
import { ISelectionService } from 'browser/services/Services';
|
||||
@@ -41,6 +41,7 @@ export class MockTerminal implements ITerminal {
|
||||
onResize: IEvent<{ cols: number; rows: number; }>;
|
||||
markers: IMarker[];
|
||||
optionsService: IOptionsService;
|
||||
unicodeService: IUnicodeService;
|
||||
addMarker(cursorYOffset: number): IMarker {
|
||||
throw new Error('Method not implemented.');
|
||||
}
|
||||
|
||||
Vendored
+2
-1
@@ -7,7 +7,7 @@ import { ITerminalOptions as IPublicTerminalOptions, IDisposable, IMarker, ISele
|
||||
import { ICharset, IAttributeData, CharData, CoreMouseEventType } from 'common/Types';
|
||||
import { IEvent, IEventEmitter } from 'common/EventEmitter';
|
||||
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 { IParams, IFunctionIdentifier } from 'common/parser/Types';
|
||||
|
||||
@@ -140,6 +140,7 @@ export interface ITerminal extends IPublicTerminal, IElementAccessor, IBufferAcc
|
||||
optionsService: IOptionsService;
|
||||
// TODO: We should remove options once components adopt optionsService
|
||||
options: ITerminalOptions;
|
||||
unicodeService: IUnicodeService;
|
||||
|
||||
onBlur: IEvent<void>;
|
||||
onFocus: IEvent<void>;
|
||||
|
||||
@@ -84,7 +84,7 @@ function bisearch(ucs: number, data: number[][]): boolean {
|
||||
}
|
||||
|
||||
export class UnicodeV6 implements IUnicodeVersionProvider {
|
||||
public version = '6';
|
||||
public readonly version = '6';
|
||||
|
||||
constructor() {
|
||||
// init lookup table once
|
||||
|
||||
@@ -328,6 +328,6 @@ export interface IUnicodeService {
|
||||
}
|
||||
|
||||
export interface IUnicodeVersionProvider {
|
||||
version: string;
|
||||
readonly version: string;
|
||||
wcwidth(ucs: number): 0 | 1 | 2;
|
||||
}
|
||||
|
||||
@@ -263,18 +263,18 @@ class UnicodeApi implements IUnicodeHandling {
|
||||
constructor(private _core: ITerminal) {}
|
||||
|
||||
public register(provider: IUnicodeVersionProvider): void {
|
||||
(this._core as any)._unicodeService.register(provider);
|
||||
this._core.unicodeService.register(provider);
|
||||
}
|
||||
|
||||
public get versions(): string[] {
|
||||
return (this._core as any)._unicodeService.versions;
|
||||
return this._core.unicodeService.versions;
|
||||
}
|
||||
|
||||
public get activeVersion(): string {
|
||||
return (this._core as any)._unicodeService.activeVersion;
|
||||
return this._core.unicodeService.activeVersion;
|
||||
}
|
||||
|
||||
public set activeVersion(version: string) {
|
||||
(this._core as any)._unicodeService.activeVersion = version;
|
||||
this._core.unicodeService.activeVersion = version;
|
||||
}
|
||||
}
|
||||
|
||||
Vendored
+8
-2
@@ -217,6 +217,7 @@ declare module 'xterm' {
|
||||
|
||||
/**
|
||||
* 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;
|
||||
|
||||
@@ -1173,7 +1174,7 @@ declare module 'xterm' {
|
||||
*/
|
||||
export interface IUnicodeVersionProvider {
|
||||
/** String indicating the Unicode version provided. */
|
||||
version: string;
|
||||
readonly version: string;
|
||||
/** Unicode version dependent wcwidth implementation. */
|
||||
wcwidth(codepoint: number): 0 | 1 | 2;
|
||||
}
|
||||
@@ -1189,6 +1190,11 @@ declare module 'xterm' {
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user