Merge branch 'master' into updated_wcwidth
This commit is contained in:
+15
-15
@@ -5,28 +5,28 @@
|
||||
|
||||
import { IDisposable } from 'common/Types';
|
||||
|
||||
interface IListener<T> {
|
||||
(e: T): void;
|
||||
interface IListener<T, U = void> {
|
||||
(arg1: T, arg2: U): void;
|
||||
}
|
||||
|
||||
export interface IEvent<T> {
|
||||
(listener: (e: T) => any): IDisposable;
|
||||
export interface IEvent<T, U = void> {
|
||||
(listener: (arg1: T, arg2: U) => any): IDisposable;
|
||||
}
|
||||
|
||||
export interface IEventEmitter<T> {
|
||||
event: IEvent<T>;
|
||||
fire(data: T): void;
|
||||
export interface IEventEmitter<T, U = void> {
|
||||
event: IEvent<T, U>;
|
||||
fire(arg1: T, arg2: U): void;
|
||||
dispose(): void;
|
||||
}
|
||||
|
||||
export class EventEmitter<T> implements IEventEmitter<T> {
|
||||
private _listeners: IListener<T>[] = [];
|
||||
private _event?: IEvent<T>;
|
||||
export class EventEmitter<T, U = void> implements IEventEmitter<T, U> {
|
||||
private _listeners: IListener<T, U>[] = [];
|
||||
private _event?: IEvent<T, U>;
|
||||
private _disposed: boolean = false;
|
||||
|
||||
public get event(): IEvent<T> {
|
||||
public get event(): IEvent<T, U> {
|
||||
if (!this._event) {
|
||||
this._event = (listener: (e: T) => any) => {
|
||||
this._event = (listener: (arg1: T, arg2: U) => any) => {
|
||||
this._listeners.push(listener);
|
||||
const disposable = {
|
||||
dispose: () => {
|
||||
@@ -46,13 +46,13 @@ export class EventEmitter<T> implements IEventEmitter<T> {
|
||||
return this._event;
|
||||
}
|
||||
|
||||
public fire(data: T): void {
|
||||
const queue: IListener<T>[] = [];
|
||||
public fire(arg1: T, arg2: U): void {
|
||||
const queue: IListener<T, U>[] = [];
|
||||
for (let i = 0; i < this._listeners.length; i++) {
|
||||
queue.push(this._listeners[i]);
|
||||
}
|
||||
for (let i = 0; i < queue.length; i++) {
|
||||
queue[i].call(undefined, data);
|
||||
queue[i].call(undefined, arg1, arg2);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -3,13 +3,13 @@
|
||||
* @license MIT
|
||||
*/
|
||||
|
||||
import { IBufferService, ICoreService, ILogService, IOptionsService, ITerminalOptions, IPartialTerminalOptions, IDirtyRowService, ICoreMouseService, IUnicodeService, IUnicodeVersionProvider } from 'common/services/Services';
|
||||
import { IBufferService, ICoreService, ILogService, IOptionsService, ITerminalOptions, IPartialTerminalOptions, IDirtyRowService, ICoreMouseService, ICharsetService, IUnicodeService, IUnicodeVersionProvider } from 'common/services/Services';
|
||||
import { IEvent, EventEmitter } from 'common/EventEmitter';
|
||||
import { clone } from 'common/Clone';
|
||||
import { DEFAULT_OPTIONS } from 'common/services/OptionsService';
|
||||
import { IBufferSet, IBuffer } from 'common/buffer/Types';
|
||||
import { BufferSet } from 'common/buffer/BufferSet';
|
||||
import { IDecPrivateModes, ICoreMouseEvent, CoreMouseEventType } from 'common/Types';
|
||||
import { IDecPrivateModes, ICoreMouseEvent, CoreMouseEventType, ICharset } from 'common/Types';
|
||||
import { UnicodeV6 } from 'common/input/UnicodeV6';
|
||||
|
||||
export class MockBufferService implements IBufferService {
|
||||
@@ -43,12 +43,27 @@ export class MockCoreMouseService implements ICoreMouseService {
|
||||
}
|
||||
}
|
||||
|
||||
export class MockCharsetService implements ICharsetService {
|
||||
serviceBrand: any;
|
||||
charset: ICharset | undefined;
|
||||
glevel: number = 0;
|
||||
charsets: readonly ICharset[] = [];
|
||||
reset(): void {}
|
||||
setgLevel(g: number): void {}
|
||||
setgCharset(g: number, charset: ICharset): void {}
|
||||
}
|
||||
|
||||
export class MockCoreService implements ICoreService {
|
||||
serviceBrand: any;
|
||||
isCursorInitialized: boolean = false;
|
||||
isCursorHidden: boolean = false;
|
||||
isFocused: boolean = false;
|
||||
serviceBrand: any;
|
||||
decPrivateModes: IDecPrivateModes = {} as any;
|
||||
decPrivateModes: IDecPrivateModes = {
|
||||
applicationCursorKeys: false,
|
||||
applicationKeypad: false,
|
||||
origin: false,
|
||||
wraparound: true
|
||||
};
|
||||
onData: IEvent<string> = new EventEmitter<string>().event;
|
||||
onUserInput: IEvent<void> = new EventEmitter<void>().event;
|
||||
onBinary: IEvent<string> = new EventEmitter<string>().event;
|
||||
|
||||
Vendored
+4
-1
@@ -62,7 +62,7 @@ export interface IKeyboardResult {
|
||||
}
|
||||
|
||||
export interface ICharset {
|
||||
[key: string]: string;
|
||||
[key: string]: string | undefined;
|
||||
}
|
||||
|
||||
export type CharData = [number, string, number, number];
|
||||
@@ -152,6 +152,9 @@ export interface IMarker extends IDisposable {
|
||||
|
||||
export interface IDecPrivateModes {
|
||||
applicationCursorKeys: boolean;
|
||||
applicationKeypad: boolean;
|
||||
origin: boolean;
|
||||
wraparound: boolean; // defaults: xterm - true, vt100 - false
|
||||
}
|
||||
|
||||
export interface IRowRange {
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
/**
|
||||
* Copyright (c) 2019 The xterm.js authors. All rights reserved.
|
||||
* @license MIT
|
||||
*/
|
||||
|
||||
import { ICharsetService } from 'common/services/Services';
|
||||
import { ICharset } from 'common/Types';
|
||||
|
||||
export class CharsetService implements ICharsetService {
|
||||
serviceBrand: any;
|
||||
|
||||
public charset: ICharset | undefined;
|
||||
public charsets: ICharset[] = [];
|
||||
public glevel: number = 0;
|
||||
|
||||
public reset(): void {
|
||||
this.charset = undefined;
|
||||
this.charsets = [];
|
||||
this.glevel = 0;
|
||||
}
|
||||
|
||||
public setgLevel(g: number): void {
|
||||
this.glevel = g;
|
||||
this.charset = this.charsets[g];
|
||||
}
|
||||
|
||||
public setgCharset(g: number, charset: ICharset): void {
|
||||
this.charsets[g] = charset;
|
||||
if (this.glevel === g) {
|
||||
this.charset = charset;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5,11 +5,14 @@
|
||||
|
||||
import { ICoreService, ILogService, IOptionsService, IBufferService } from 'common/services/Services';
|
||||
import { EventEmitter, IEvent } from 'common/EventEmitter';
|
||||
import { IDecPrivateModes } from 'common/Types';
|
||||
import { IDecPrivateModes, ICharset } from 'common/Types';
|
||||
import { clone } from 'common/Clone';
|
||||
|
||||
const DEFAULT_DEC_PRIVATE_MODES: IDecPrivateModes = Object.freeze({
|
||||
applicationCursorKeys: false
|
||||
applicationCursorKeys: false,
|
||||
applicationKeypad: false,
|
||||
origin: false,
|
||||
wraparound: true // defaults: xterm - true, vt100 - false
|
||||
});
|
||||
|
||||
export class CoreService implements ICoreService {
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
import { IEvent } from 'common/EventEmitter';
|
||||
import { IBuffer, IBufferSet } from 'common/buffer/Types';
|
||||
import { IDecPrivateModes, ICoreMouseEvent, CoreMouseEncoding, ICoreMouseProtocol, CoreMouseEventType } from 'common/Types';
|
||||
import { IDecPrivateModes, ICoreMouseEvent, CoreMouseEncoding, ICoreMouseProtocol, CoreMouseEventType, ICharset } from 'common/Types';
|
||||
import { createDecorator } from 'common/services/ServiceRegistry';
|
||||
|
||||
export const IBufferService = createDecorator<IBufferService>('BufferService');
|
||||
@@ -64,6 +64,7 @@ export interface ICoreService {
|
||||
*/
|
||||
isCursorInitialized: boolean;
|
||||
isCursorHidden: boolean;
|
||||
|
||||
readonly decPrivateModes: IDecPrivateModes;
|
||||
|
||||
readonly onData: IEvent<string>;
|
||||
@@ -89,6 +90,30 @@ export interface ICoreService {
|
||||
triggerBinaryEvent(data: string): void;
|
||||
}
|
||||
|
||||
export const ICharsetService = createDecorator<ICharsetService>('CharsetService');
|
||||
export interface ICharsetService {
|
||||
serviceBrand: any;
|
||||
|
||||
charset: ICharset | undefined;
|
||||
readonly glevel: number;
|
||||
readonly charsets: ReadonlyArray<ICharset>;
|
||||
|
||||
reset(): void;
|
||||
|
||||
/**
|
||||
* Set the G level of the terminal.
|
||||
* @param g
|
||||
*/
|
||||
setgLevel(g: number): void;
|
||||
|
||||
/**
|
||||
* Set the charset for the given G level of the terminal.
|
||||
* @param g
|
||||
* @param charset
|
||||
*/
|
||||
setgCharset(g: number, charset: ICharset): void;
|
||||
}
|
||||
|
||||
export const IDirtyRowService = createDecorator<IDirtyRowService>('DirtyRowService');
|
||||
export interface IDirtyRowService {
|
||||
serviceBrand: any;
|
||||
|
||||
Reference in New Issue
Block a user