mirror of
https://github.com/wavetermdev/xterm.js.git
synced 2026-08-05 13:43:48 -07:00
several fixes
This commit is contained in:
@@ -1304,28 +1304,6 @@ describe('InputHandler', () => {
|
||||
term.writeSync('\x1b[18t');
|
||||
assert.deepEqual(stack, ['\x1b[8;10;10t', '\x1b[8;20;50t']);
|
||||
});
|
||||
it('20 - GetIconTitle', () => {
|
||||
const term = new TestTerminal({cols: 10, rows: 10, windowOptions: {getIconTitle: true}});
|
||||
const stack: string[] = [];
|
||||
term.onData(data => stack.push(data));
|
||||
term.writeSync('\x1b]1;hello world!\x07');
|
||||
term.writeSync('\x1b[20t');
|
||||
assert.deepEqual(stack, ['\x1b]Lhello world!\x1b\\']);
|
||||
term.writeSync('\x1b]1;some other\x07');
|
||||
term.writeSync('\x1b[20t');
|
||||
assert.deepEqual(stack, ['\x1b]Lhello world!\x1b\\', '\x1b]Lsome other\x1b\\']);
|
||||
});
|
||||
it('21 - GetWinTitle', () => {
|
||||
const term = new TestTerminal({cols: 10, rows: 10, windowOptions: {getWinTitle: true}});
|
||||
const stack: string[] = [];
|
||||
term.onData(data => stack.push(data));
|
||||
term.writeSync('\x1b]2;hello world!\x07');
|
||||
term.writeSync('\x1b[21t');
|
||||
assert.deepEqual(stack, ['\x1b]lhello world!\x1b\\']);
|
||||
term.writeSync('\x1b]2;some other\x07');
|
||||
term.writeSync('\x1b[21t');
|
||||
assert.deepEqual(stack, ['\x1b]lhello world!\x1b\\', '\x1b]lsome other\x1b\\']);
|
||||
});
|
||||
it('22/23 - PushTitle/PopTitle', () => {
|
||||
const term = new TestTerminal({cols: 10, rows: 10, windowOptions: {pushTitle: true, popTitle: true}});
|
||||
const stack: string[] = [];
|
||||
|
||||
+4
-10
@@ -2146,20 +2146,14 @@ export class InputHandler extends Disposable implements IInputHandler {
|
||||
this._coreService.triggerDataEvent(`${C0.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);
|
||||
}
|
||||
break;
|
||||
case 20: // GetIconTitle, returns OSC L label ST
|
||||
this._coreService.triggerDataEvent(`${C0.ESC}]L${this._iconName}${C0.ESC}\\`);
|
||||
break;
|
||||
case 21: // GetWinTitle, returns OSC l label ST
|
||||
this._coreService.triggerDataEvent(`${C0.ESC}]l${this._windowTitle}${C0.ESC}\\`);
|
||||
break;
|
||||
case 22: // PushTitle
|
||||
if (!second || second === 2) {
|
||||
if (second === 0 || second === 2) {
|
||||
this._windowTitleStack.push(this._windowTitle);
|
||||
if (this._windowTitleStack.length > STACK_LIMIT) {
|
||||
this._windowTitleStack.shift();
|
||||
}
|
||||
}
|
||||
if (!second || second === 1) {
|
||||
if (second === 0 || second === 1) {
|
||||
this._iconNameStack.push(this._iconName);
|
||||
if (this._iconNameStack.length > STACK_LIMIT) {
|
||||
this._iconNameStack.shift();
|
||||
@@ -2167,12 +2161,12 @@ export class InputHandler extends Disposable implements IInputHandler {
|
||||
}
|
||||
break;
|
||||
case 23: // PopTitle
|
||||
if (!second || second === 2) {
|
||||
if (second === 0 || second === 2) {
|
||||
if (this._windowTitleStack.length) {
|
||||
this.setTitle(this._windowTitleStack.pop());
|
||||
}
|
||||
}
|
||||
if (!second || second === 1) {
|
||||
if (second === 0 || second === 1) {
|
||||
if (this._iconNameStack.length) {
|
||||
this.setIconName(this._iconNameStack.pop());
|
||||
}
|
||||
|
||||
+1
-10
@@ -127,13 +127,9 @@ export class Terminal extends Disposable implements ITerminal, IDisposable, IInp
|
||||
public mouseEvents: CoreMouseEventType = CoreMouseEventType.NONE;
|
||||
public sendFocus: boolean;
|
||||
|
||||
// misc
|
||||
public curAttrData: IAttributeData;
|
||||
private _eraseAttrData: IAttributeData;
|
||||
|
||||
public params: (string | number)[];
|
||||
public currentParam: string | number;
|
||||
|
||||
// write buffer
|
||||
private _writeBuffer: WriteBuffer;
|
||||
|
||||
@@ -268,9 +264,6 @@ export class Terminal extends Disposable implements ITerminal, IDisposable, IInp
|
||||
this.curAttrData = DEFAULT_ATTR_DATA.clone();
|
||||
this._eraseAttrData = DEFAULT_ATTR_DATA.clone();
|
||||
|
||||
this.params = [];
|
||||
this.currentParam = 0;
|
||||
|
||||
this._userScrolling = false;
|
||||
|
||||
// Register input handler and refire/handle events
|
||||
@@ -1430,9 +1423,7 @@ export class Terminal extends Disposable implements ITerminal, IDisposable, IInp
|
||||
|
||||
// Sync the scroll area to make sure scroll events don't fire and scroll the viewport to an
|
||||
// invalid location
|
||||
if (this.viewport) {
|
||||
this.viewport.syncScrollArea(true);
|
||||
}
|
||||
this.viewport?.syncScrollArea(true);
|
||||
|
||||
this.refresh(0, this.rows - 1);
|
||||
this._onResize.fire({ cols: x, rows: y });
|
||||
|
||||
Vendored
+1
-1
@@ -256,7 +256,7 @@ export interface ICoreMouseProtocol {
|
||||
export type CoreMouseEncoding = (event: ICoreMouseEvent) => string;
|
||||
|
||||
/**
|
||||
* WindowOption settings.
|
||||
* windowOptions
|
||||
*/
|
||||
export interface IWindowOptions {
|
||||
restoreWin?: boolean;
|
||||
|
||||
@@ -443,11 +443,7 @@ async function getCursor(): Promise<{col: number, row: number}> {
|
||||
}
|
||||
|
||||
async function getDimensions(): Promise<any> {
|
||||
const dim = await page.evaluate(`
|
||||
(function() {
|
||||
return term._core._renderService.dimensions;
|
||||
})();
|
||||
`);
|
||||
const dim = await page.evaluate(`term._core._renderService.dimensions`);
|
||||
return {
|
||||
cellWidth: dim.actualCellWidth.toFixed(0),
|
||||
cellHeight: dim.actualCellHeight.toFixed(0),
|
||||
|
||||
Vendored
+62
-33
@@ -383,45 +383,63 @@ declare module 'xterm' {
|
||||
/**
|
||||
* Enable various window manipulation and report features (CSI Ps ; Ps ; Ps t).
|
||||
*
|
||||
* Note that most settings have no default implementation, as they heavily
|
||||
* rely on the embedding environment.
|
||||
* Most settings have no default implementation, as they heavily rely on
|
||||
* the embedding environment.
|
||||
*
|
||||
* To implement a features, create a custom CSI hook like this:
|
||||
* ```Typescript
|
||||
* To implement a feature, create a custom CSI hook like this:
|
||||
* ```ts
|
||||
* term.parser.addCsiHandler({final: 't'}, params => {
|
||||
* const ps = params[0];
|
||||
* switch (ps) {
|
||||
* case XY:
|
||||
* ... // your implementation
|
||||
* ... // your implementation for option XY
|
||||
* return true; // signal Ps=XY was handled
|
||||
* }
|
||||
* return false; // any Ps that was not handled
|
||||
* });
|
||||
* ```
|
||||
*
|
||||
* All features are disabled by default for security reasons.
|
||||
* All custom implementations are guarded by the boolean values automatically.
|
||||
* Note on security:
|
||||
* Most features are meant to deal with some information of the host machine
|
||||
* where the terminal runs on. This is seen as a security risk possibly leaking
|
||||
* sensitive data of the host to the program in the terminal. Therefore all options
|
||||
* (even those without a default implementation) are guarded by the boolean flag
|
||||
* and disabled by default.
|
||||
*/
|
||||
export interface IWindowOptions {
|
||||
/** Ps=1 De-iconify window. */
|
||||
/**
|
||||
* Ps=1 De-iconify window.
|
||||
* No default implementation.
|
||||
*/
|
||||
restoreWin?: boolean;
|
||||
/** Ps=2 Iconify window. */
|
||||
/**
|
||||
* Ps=2 Iconify window.
|
||||
* No default implementation.
|
||||
*/
|
||||
minimizeWin?: boolean;
|
||||
/**
|
||||
* Ps=3 ; x ; y
|
||||
* Move window to [x, y].
|
||||
* Move window to [x, y].
|
||||
* No default implementation.
|
||||
*/
|
||||
setWinPosition?: boolean;
|
||||
/**
|
||||
* Ps = 4 ; height ; width
|
||||
* Resize the window to given `height` and `width` in pixels.
|
||||
* Omitted parameters should reuse the current height or width.
|
||||
* Zero parameters should use the display's height or width.
|
||||
* Zero parameters should use the display's height or width.
|
||||
* No default implementation.
|
||||
*/
|
||||
setWinSizePixels?: boolean;
|
||||
/** Ps=5 Raise the window to the front of the stacking order. */
|
||||
/**
|
||||
* Ps=5 Raise the window to the front of the stacking order.
|
||||
* No default implementation.
|
||||
*/
|
||||
raiseWin?: boolean;
|
||||
/** Ps=6 Lower the xterm window to the bottom of the stacking order. */
|
||||
/**
|
||||
* Ps=6 Lower the xterm window to the bottom of the stacking order.
|
||||
* No default implementation.
|
||||
*/
|
||||
lowerWin?: boolean;
|
||||
/** Ps=7 Refresh the window. */
|
||||
refreshWin?: boolean;
|
||||
@@ -429,78 +447,89 @@ declare module 'xterm' {
|
||||
* Ps = 8 ; height ; width
|
||||
* Resize the text area to given height and width in characters.
|
||||
* Omitted parameters should reuse the current height or width.
|
||||
* Zero parameters use the display's height or width.
|
||||
* Zero parameters use the display's height or width.
|
||||
* No default implementation.
|
||||
*/
|
||||
setWinSizeChars?: boolean;
|
||||
/**
|
||||
* Ps=9 ; 0 Restore maximized window.
|
||||
* Ps=9 ; 1 Maximize window (i.e., resize to screen size).
|
||||
* Ps=9 ; 2 Maximize window vertically.
|
||||
* Ps=9 ; 3 Maximize window horizontally.
|
||||
* Ps=9 ; 3 Maximize window horizontally.
|
||||
* No default implementation.
|
||||
*/
|
||||
maximizeWin?: boolean;
|
||||
/**
|
||||
* Ps=10 ; 0 Undo full-screen mode.
|
||||
* Ps=10 ; 1 Change to full-screen.
|
||||
* Ps=10 ; 2 Toggle full-screen.
|
||||
* Ps=10 ; 2 Toggle full-screen.
|
||||
* No default implementation.
|
||||
*/
|
||||
fullscreenWin?: boolean;
|
||||
/** Ps=11 Report xterm window state.
|
||||
* If the xterm window is non-iconified, it returns "CSI 1 t".
|
||||
* If the xterm window is iconified, it returns "CSI 2 t".
|
||||
* If the xterm window is iconified, it returns "CSI 2 t".
|
||||
* No default implementation.
|
||||
*/
|
||||
getWinState?: boolean;
|
||||
/**
|
||||
* Ps=13 Report xterm window position. Result is "CSI 3 ; x ; y t".
|
||||
* Ps=13 ; 2 Report xterm text-area position. Result is "CSI 3 ; x ; y t".
|
||||
* Ps=13 ; 2 Report xterm text-area position. Result is "CSI 3 ; x ; y t".
|
||||
* No default implementation.
|
||||
*/
|
||||
getWinPosition?: boolean;
|
||||
/**
|
||||
* Ps=14 Report xterm text area size in pixels. Result is "CSI 4 ; height ; width t".
|
||||
* Ps=14 ; 2 Report xterm window size in pixels. Result is "CSI 4 ; height ; width t".
|
||||
* Ps=14 has a default implementation (also handles Ps=14 ; 2 if not overwritten by custom implementation).
|
||||
* Ps=14 ; 2 Report xterm window size in pixels. Result is "CSI 4 ; height ; width t".
|
||||
* Has a default implementation.
|
||||
*/
|
||||
getWinSizePixels?: boolean;
|
||||
/** Ps=15 Report size of the screen in pixels. Result is "CSI 5 ; height ; width t". */
|
||||
/**
|
||||
* Ps=15 Report size of the screen in pixels. Result is "CSI 5 ; height ; width t".
|
||||
* No default implementation.
|
||||
*/
|
||||
getScreenSizePixels?: boolean;
|
||||
/**
|
||||
* Ps=16 Report xterm character cell size in pixels. Result is "CSI 6 ; height ; width t".
|
||||
* Implemented by default.
|
||||
* Ps=16 Report xterm character cell size in pixels. Result is "CSI 6 ; height ; width t".
|
||||
* Has a default implementation.
|
||||
*/
|
||||
getCellSizePixels?: boolean;
|
||||
/**
|
||||
* Ps=18 Report the size of the text area in characters. Result is "CSI 8 ; height ; width t".
|
||||
* Implemented by default.
|
||||
* Ps=18 Report the size of the text area in characters. Result is "CSI 8 ; height ; width t".
|
||||
* Has a default implementation.
|
||||
*/
|
||||
getWinSizeChars?: boolean;
|
||||
/** Ps=19 Report the size of the screen in characters. Result is "CSI 9 ; height ; width t". */
|
||||
/**
|
||||
* Ps=19 Report the size of the screen in characters. Result is "CSI 9 ; height ; width t".
|
||||
* No default implementation.
|
||||
*/
|
||||
getScreenSizeChars?: boolean;
|
||||
/**
|
||||
* Ps=20 Report xterm window's icon label. Result is "OSC L label ST".
|
||||
* Implemented by default.
|
||||
* Ps=20 Report xterm window's icon label. Result is "OSC L label ST".
|
||||
* No default implementation.
|
||||
*/
|
||||
getIconTitle?: boolean;
|
||||
/**
|
||||
* Ps=21 Report xterm window's title. Result is "OSC l label ST".
|
||||
* Implemented by default.
|
||||
* Ps=21 Report xterm window's title. Result is "OSC l label ST".
|
||||
* No default implementation.
|
||||
*/
|
||||
getWinTitle?: boolean;
|
||||
/**
|
||||
* Ps=22 ; 0 Save xterm icon and window title on stack.
|
||||
* Ps=22 ; 1 Save xterm icon title on stack.
|
||||
* Ps=22 ; 2 Save xterm window title on stack.
|
||||
* Ps=22 ; 2 Save xterm window title on stack.
|
||||
* All variants have a default implementation.
|
||||
*/
|
||||
pushTitle?: boolean;
|
||||
/**
|
||||
* Ps=23 ; 0 Restore xterm icon and window title from stack.
|
||||
* Ps=23 ; 1 Restore xterm icon title from stack.
|
||||
* Ps=23 ; 2 Restore xterm window title from stack.
|
||||
* Ps=23 ; 2 Restore xterm window title from stack.
|
||||
* All variants have a default implementation.
|
||||
*/
|
||||
popTitle?: boolean;
|
||||
/**
|
||||
* Ps>=24 Resize to Ps lines (DECSLPP).
|
||||
* Ps>=24 Resize to Ps lines (DECSLPP).
|
||||
* DECSLPP is not implemented. This settings is also used to
|
||||
* enable / disable DECCOLM (earlier variant of DECSLPP).
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user