@xterm/xterm 5.4.0-beta.31 → 5.4.0-beta.33

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@xterm/xterm",
3
3
  "description": "Full xterm terminal, in your browser",
4
- "version": "5.4.0-beta.31",
4
+ "version": "5.4.0-beta.33",
5
5
  "main": "lib/xterm.js",
6
6
  "style": "css/xterm.css",
7
7
  "types": "typings/xterm.d.ts",
@@ -138,6 +138,9 @@ export class Terminal extends Disposable implements ITerminalApi {
138
138
  public focus(): void {
139
139
  this._core.focus();
140
140
  }
141
+ public input(data: string, wasUserInput: boolean = true): void {
142
+ this._core.input(data, wasUserInput);
143
+ }
141
144
  public resize(columns: number, rows: number): void {
142
145
  this._verifyIntegers(columns, rows);
143
146
  this._core.resize(columns, rows);
@@ -134,9 +134,14 @@ export class WidthCache implements IDisposable {
134
134
  public get(c: string, bold: boolean | number, italic: boolean | number): number {
135
135
  let cp = 0;
136
136
  if (!bold && !italic && c.length === 1 && (cp = c.charCodeAt(0)) < WidthCacheSettings.FLAT_SIZE) {
137
- return this._flat[cp] !== WidthCacheSettings.FLAT_UNSET
138
- ? this._flat[cp]
139
- : (this._flat[cp] = this._measure(c, 0));
137
+ if (this._flat[cp] !== WidthCacheSettings.FLAT_UNSET) {
138
+ return this._flat[cp];
139
+ }
140
+ const width = this._measure(c, 0);
141
+ if (width > 0) {
142
+ this._flat[cp] = width;
143
+ }
144
+ return width;
140
145
  }
141
146
  let key = c;
142
147
  if (bold) key += 'B';
@@ -147,7 +152,9 @@ export class WidthCache implements IDisposable {
147
152
  if (bold) variant |= FontVariant.BOLD;
148
153
  if (italic) variant |= FontVariant.ITALIC;
149
154
  width = this._measure(c, variant);
150
- this._holey!.set(key, width);
155
+ if (width > 0) {
156
+ this._holey!.set(key, width);
157
+ }
151
158
  }
152
159
  return width;
153
160
  }
@@ -168,6 +168,10 @@ export abstract class CoreTerminal extends Disposable implements ICoreTerminal {
168
168
  this._writeBuffer.writeSync(data, maxSubsequentCalls);
169
169
  }
170
170
 
171
+ public input(data: string, wasUserInput: boolean = true): void {
172
+ this.coreService.triggerDataEvent(data, wasUserInput);
173
+ }
174
+
171
175
  public resize(x: number, y: number): void {
172
176
  if (isNaN(x) || isNaN(y)) {
173
177
  return;
@@ -81,6 +81,10 @@ export class Terminal extends CoreTerminal {
81
81
  this._onBell.fire();
82
82
  }
83
83
 
84
+ public input(data: string, wasUserInput: boolean = true): void {
85
+ this.coreService.triggerDataEvent(data, wasUserInput);
86
+ }
87
+
84
88
  /**
85
89
  * Resizes the terminal.
86
90
  *
@@ -134,6 +134,9 @@ export class Terminal extends Disposable implements ITerminalApi {
134
134
  this._publicOptions[propName] = options[propName];
135
135
  }
136
136
  }
137
+ public input(data: string, wasUserInput: boolean = true): void {
138
+ this._core.input(data, wasUserInput);
139
+ }
137
140
  public resize(columns: number, rows: number): void {
138
141
  this._verifyIntegers(columns, rows);
139
142
  this._core.resize(columns, rows);
@@ -963,6 +963,18 @@ declare module '@xterm/xterm' {
963
963
  */
964
964
  focus(): void;
965
965
 
966
+ /**
967
+ * Input data to application side. The data is treated the same way input
968
+ * typed into the terminal would (ie. the {@link onData} event will fire).
969
+ * @param data The data to forward to the application.
970
+ * @param wasUserInput Whether the input is genuine user input. This is true
971
+ * by default and triggers additionalbehavior like focus or selection
972
+ * clearing. Set this to false if the data sent should not be treated like
973
+ * user input would, for example passing an escape sequence to the
974
+ * application.
975
+ */
976
+ input(data: string, wasUserInput?: boolean): void;
977
+
966
978
  /**
967
979
  * Resizes the terminal. It's best practice to debounce calls to resize,
968
980
  * this will help ensure that the pty can respond to the resize event