installed pty
[VSoRC/.git] / node_modules / node-pty / src / interfaces.ts
1 /**
2  * Copyright (c) 2016, Daniel Imms (MIT License).
3  * Copyright (c) 2018, Microsoft Corporation (MIT License).
4  */
5
6 import * as net from 'net';
7
8 export interface IProcessEnv {
9   [key: string]: string;
10 }
11
12 export interface ITerminal {
13   /**
14    * Gets the name of the process.
15    */
16   process: string;
17
18   /**
19    * Gets the process ID.
20    */
21   pid: number;
22
23   /**
24    * The socket for the master file descriptor. This is not supported on
25    * Windows.
26    */
27   master: net.Socket;
28
29   /**
30    * The socket for the slave file descriptor. This is not supported on Windows.
31    */
32   slave: net.Socket;
33
34   /**
35    * Writes data to the socket.
36    * @param data The data to write.
37    */
38   write(data: string): void;
39
40   /**
41    * Resize the pty.
42    * @param cols The number of columns.
43    * @param rows The number of rows.
44    */
45   resize(cols: number, rows: number): void;
46
47   /**
48    * Close, kill and destroy the socket.
49    */
50   destroy(): void;
51
52   /**
53    * Kill the pty.
54    * @param signal The signal to send, by default this is SIGHUP. This is not
55    * supported on Windows.
56    */
57   kill(signal?: string): void;
58
59   /**
60    * Set the pty socket encoding.
61    */
62   setEncoding(encoding: string | null): void;
63
64   /**
65    * Resume the pty socket.
66    */
67   resume(): void;
68
69   /**
70    * Pause the pty socket.
71    */
72   pause(): void;
73
74   /**
75    * Alias for ITerminal.on(eventName, listener).
76    */
77   addListener(eventName: string, listener: (...args: any[]) => any): void;
78
79   /**
80    * Adds the listener function to the end of the listeners array for the event
81    * named eventName.
82    * @param eventName The event name.
83    * @param listener The callback function
84    */
85   on(eventName: string, listener: (...args: any[]) => any): void;
86
87   /**
88    * Returns a copy of the array of listeners for the event named eventName.
89    */
90   listeners(eventName: string): Function[];
91
92   /**
93    * Removes the specified listener from the listener array for the event named
94    * eventName.
95    */
96   removeListener(eventName: string, listener: (...args: any[]) => any): void;
97
98   /**
99    * Removes all listeners, or those of the specified eventName.
100    */
101   removeAllListeners(eventName: string): void;
102
103   /**
104    * Adds a one time listener function for the event named eventName. The next
105    * time eventName is triggered, this listener is removed and then invoked.
106    */
107   once(eventName: string, listener: (...args: any[]) => any): void;
108 }
109
110 interface IBasePtyForkOptions {
111   name?: string;
112   cols?: number;
113   rows?: number;
114   cwd?: string;
115   env?: { [key: string]: string };
116   encoding?: string;
117   handleFlowControl?: boolean;
118   flowControlPause?: string;
119   flowControlResume?: string;
120 }
121
122 export interface IPtyForkOptions extends IBasePtyForkOptions {
123   uid?: number;
124   gid?: number;
125 }
126
127 export interface IWindowsPtyForkOptions extends IBasePtyForkOptions {
128   useConpty?: boolean;
129   conptyInheritCursor?: boolean;
130 }
131
132 export interface IPtyOpenOptions {
133   cols?: number;
134   rows?: number;
135   encoding?: string;
136 }