2 * Copyright (c) 2019 The xterm.js authors. All rights reserved.
6 import { IEvent } from 'common/EventEmitter';
7 import { IBuffer, IBufferSet } from 'common/buffer/Types';
8 import { IDecPrivateModes, ICoreMouseEvent, CoreMouseEncoding, ICoreMouseProtocol, CoreMouseEventType } from 'common/Types';
9 import { createDecorator } from 'common/services/ServiceRegistry';
11 export const IBufferService = createDecorator<IBufferService>('BufferService');
12 export interface IBufferService {
15 readonly cols: number;
16 readonly rows: number;
17 readonly buffer: IBuffer;
18 readonly buffers: IBufferSet;
20 // TODO: Move resize event here
22 resize(cols: number, rows: number): void;
26 export const ICoreMouseService = createDecorator<ICoreMouseService>('CoreMouseService');
27 export interface ICoreMouseService {
28 activeProtocol: string;
29 activeEncoding: string;
30 addProtocol(name: string, protocol: ICoreMouseProtocol): void;
31 addEncoding(name: string, encoding: CoreMouseEncoding): void;
35 * Triggers a mouse event to be sent.
37 * Returns true if the event passed all protocol restrictions and a report
38 * was sent, otherwise false. The return value may be used to decide whether
39 * the default event action in the bowser component should be omitted.
41 * Note: The method will change values of the given event object
42 * to fullfill protocol and encoding restrictions.
44 triggerMouseEvent(event: ICoreMouseEvent): boolean;
47 * Event to announce changes in mouse tracking.
49 onProtocolChange: IEvent<CoreMouseEventType>;
52 * Human readable version of mouse events.
54 explainEvents(events: CoreMouseEventType): {[event: string]: boolean};
57 export const ICoreService = createDecorator<ICoreService>('CoreService');
58 export interface ICoreService {
61 readonly decPrivateModes: IDecPrivateModes;
63 readonly onData: IEvent<string>;
64 readonly onUserInput: IEvent<void>;
69 * Triggers the onData event in the public API.
70 * @param data The data that is being emitted.
71 * @param wasFromUser Whether the data originated from the user (as opposed to
72 * resulting from parsing incoming data). When true this will also:
73 * - Scroll to the bottom of the buffer.s
74 * - Fire the `onUserInput` event (so selection can be cleared).
76 triggerDataEvent(data: string, wasUserInput?: boolean): void;
79 export const IDirtyRowService = createDecorator<IDirtyRowService>('DirtyRowService');
80 export interface IDirtyRowService {
83 readonly start: number;
87 markDirty(y: number): void;
88 markRangeDirty(y1: number, y2: number): void;
92 export interface IServiceIdentifier<T> {
93 (...args: any[]): void;
97 export interface IConstructorSignature0<T> {
98 new(...services: { serviceBrand: any; }[]): T;
101 export interface IConstructorSignature1<A1, T> {
102 new(first: A1, ...services: { serviceBrand: any; }[]): T;
105 export interface IConstructorSignature2<A1, A2, T> {
106 new(first: A1, second: A2, ...services: { serviceBrand: any; }[]): T;
109 export interface IConstructorSignature3<A1, A2, A3, T> {
110 new(first: A1, second: A2, third: A3, ...services: { serviceBrand: any; }[]): T;
113 export interface IConstructorSignature4<A1, A2, A3, A4, T> {
114 new(first: A1, second: A2, third: A3, fourth: A4, ...services: { serviceBrand: any; }[]): T;
117 export interface IConstructorSignature5<A1, A2, A3, A4, A5, T> {
118 new(first: A1, second: A2, third: A3, fourth: A4, fifth: A5, ...services: { serviceBrand: any; }[]): T;
121 export interface IConstructorSignature6<A1, A2, A3, A4, A5, A6, T> {
122 new(first: A1, second: A2, third: A3, fourth: A4, fifth: A5, sixth: A6, ...services: { serviceBrand: any; }[]): T;
125 export interface IConstructorSignature7<A1, A2, A3, A4, A5, A6, A7, T> {
126 new(first: A1, second: A2, third: A3, fourth: A4, fifth: A5, sixth: A6, seventh: A7, ...services: { serviceBrand: any; }[]): T;
129 export interface IConstructorSignature8<A1, A2, A3, A4, A5, A6, A7, A8, T> {
130 new(first: A1, second: A2, third: A3, fourth: A4, fifth: A5, sixth: A6, seventh: A7, eigth: A8, ...services: { serviceBrand: any; }[]): T;
133 export const IInstantiationService = createDecorator<IInstantiationService>('InstantiationService');
134 export interface IInstantiationService {
135 setService<T>(id: IServiceIdentifier<T>, instance: T): void;
137 createInstance<T>(ctor: IConstructorSignature0<T>): T;
138 createInstance<A1, T>(ctor: IConstructorSignature1<A1, T>, first: A1): T;
139 createInstance<A1, A2, T>(ctor: IConstructorSignature2<A1, A2, T>, first: A1, second: A2): T;
140 createInstance<A1, A2, A3, T>(ctor: IConstructorSignature3<A1, A2, A3, T>, first: A1, second: A2, third: A3): T;
141 createInstance<A1, A2, A3, A4, T>(ctor: IConstructorSignature4<A1, A2, A3, A4, T>, first: A1, second: A2, third: A3, fourth: A4): T;
142 createInstance<A1, A2, A3, A4, A5, T>(ctor: IConstructorSignature5<A1, A2, A3, A4, A5, T>, first: A1, second: A2, third: A3, fourth: A4, fifth: A5): T;
143 createInstance<A1, A2, A3, A4, A5, A6, T>(ctor: IConstructorSignature6<A1, A2, A3, A4, A5, A6, T>, first: A1, second: A2, third: A3, fourth: A4, fifth: A5, sixth: A6): T;
144 createInstance<A1, A2, A3, A4, A5, A6, A7, T>(ctor: IConstructorSignature7<A1, A2, A3, A4, A5, A6, A7, T>, first: A1, second: A2, third: A3, fourth: A4, fifth: A5, sixth: A6, seventh: A7): T;
145 createInstance<A1, A2, A3, A4, A5, A6, A7, A8, T>(ctor: IConstructorSignature8<A1, A2, A3, A4, A5, A6, A7, A8, T>, first: A1, second: A2, third: A3, fourth: A4, fifth: A5, sixth: A6, seventh: A7, eigth: A8): T;
148 export const ILogService = createDecorator<ILogService>('LogService');
149 export interface ILogService {
152 debug(message: any, ...optionalParams: any[]): void;
153 info(message: any, ...optionalParams: any[]): void;
154 warn(message: any, ...optionalParams: any[]): void;
155 error(message: any, ...optionalParams: any[]): void;
158 export const IOptionsService = createDecorator<IOptionsService>('OptionsService');
159 export interface IOptionsService {
162 readonly options: ITerminalOptions;
164 readonly onOptionChange: IEvent<string>;
166 setOption<T>(key: string, value: T): void;
167 getOption<T>(key: string): T | undefined;
170 export type FontWeight = 'normal' | 'bold' | '100' | '200' | '300' | '400' | '500' | '600' | '700' | '800' | '900';
171 export type LogLevel = 'debug' | 'info' | 'warn' | 'error' | 'off';
172 export type RendererType = 'dom' | 'canvas';
174 export interface IPartialTerminalOptions {
175 allowTransparency?: boolean;
177 bellStyle?: 'none' /*| 'visual'*/ | 'sound' /*| 'both'*/;
179 cursorBlink?: boolean;
180 cursorStyle?: 'block' | 'underline' | 'bar';
181 disableStdin?: boolean;
182 drawBoldTextInBrightColors?: boolean;
183 fastScrollModifier?: 'alt' | 'ctrl' | 'shift';
184 fastScrollSensitivity?: number;
187 fontWeight?: FontWeight;
188 fontWeightBold?: FontWeight;
189 letterSpacing?: number;
192 macOptionIsMeta?: boolean;
193 macOptionClickForcesSelection?: boolean;
194 rendererType?: RendererType;
195 rightClickSelectsWord?: boolean;
197 screenReaderMode?: boolean;
199 scrollSensitivity?: number;
200 tabStopWidth?: number;
202 windowsMode?: boolean;
203 wordSeparator?: string;
206 export interface ITerminalOptions {
207 allowTransparency: boolean;
209 bellStyle: 'none' /*| 'visual'*/ | 'sound' /*| 'both'*/;
211 cursorBlink: boolean;
212 cursorStyle: 'block' | 'underline' | 'bar';
213 disableStdin: boolean;
214 drawBoldTextInBrightColors: boolean;
215 fastScrollModifier: 'alt' | 'ctrl' | 'shift' | undefined;
216 fastScrollSensitivity: number;
219 fontWeight: FontWeight;
220 fontWeightBold: FontWeight;
221 letterSpacing: number;
224 macOptionIsMeta: boolean;
225 macOptionClickForcesSelection: boolean;
226 rendererType: RendererType;
227 rightClickSelectsWord: boolean;
229 screenReaderMode: boolean;
231 scrollSensitivity: number;
232 tabStopWidth: number;
234 windowsMode: boolean;
235 wordSeparator: string;
238 cancelEvents: boolean;
242 useFlowControl: boolean;
245 export interface ITheme {
249 cursorAccent?: string;
259 brightBlack?: string;
261 brightGreen?: string;
262 brightYellow?: string;
264 brightMagenta?: string;
266 brightWhite?: string;