mirror of
https://github.com/wavetermdev/xterm.js.git
synced 2026-08-05 13:43:48 -07:00
Move resize event into bufferservice
This commit is contained in:
+6
-5
@@ -120,8 +120,6 @@ export class Terminal extends CoreTerminal implements ITerminal, IInputHandlingT
|
||||
public get onKey(): IEvent<{ key: string, domEvent: KeyboardEvent }> { return this._onKey.event; }
|
||||
private _onRender = new EventEmitter<{ start: number, end: number }>();
|
||||
public get onRender(): IEvent<{ start: number, end: number }> { return this._onRender.event; }
|
||||
private _onResize = new EventEmitter<{ cols: number, rows: number }>();
|
||||
public get onResize(): IEvent<{ cols: number, rows: number }> { return this._onResize.event; }
|
||||
private _onScroll = new EventEmitter<number>();
|
||||
public get onScroll(): IEvent<number> { return this._onScroll.event; }
|
||||
private _onSelectionChange = new EventEmitter<void>();
|
||||
@@ -1289,19 +1287,22 @@ export class Terminal extends CoreTerminal implements ITerminal, IInputHandlingT
|
||||
return;
|
||||
}
|
||||
|
||||
if (x < MINIMUM_COLS) x = MINIMUM_COLS;
|
||||
if (y < MINIMUM_ROWS) y = MINIMUM_ROWS;
|
||||
x = Math.max(x, MINIMUM_COLS);
|
||||
y = Math.max(y, MINIMUM_ROWS);
|
||||
|
||||
this._bufferService.resize(x, y);
|
||||
|
||||
// TODO: Have charsize, viewport and renderservice depend on IBufferService.onResize?
|
||||
|
||||
this._charSizeService?.measure();
|
||||
|
||||
// TODO: Call on resize event?
|
||||
// Sync the scroll area to make sure scroll events don't fire and scroll the viewport to an
|
||||
// invalid location
|
||||
this.viewport?.syncScrollArea(true);
|
||||
|
||||
// TODO: Move to renderservice
|
||||
this.refresh(0, this.rows - 1);
|
||||
this._onResize.fire({ cols: x, rows: y });
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -29,7 +29,7 @@ import { BufferService } from 'common/services/BufferService';
|
||||
import { OptionsService } from 'common/services/OptionsService';
|
||||
import { ITerminalOptions, IDisposable } from './Types';
|
||||
import { CoreService } from 'common/services/CoreService';
|
||||
import { EventEmitter, IEvent } from 'common/EventEmitter';
|
||||
import { EventEmitter, IEvent, forwardEvent } from 'common/EventEmitter';
|
||||
import { CoreMouseService } from 'common/services/CoreMouseService';
|
||||
import { DirtyRowService } from 'common/services/DirtyRowService';
|
||||
import { UnicodeService } from 'common/services/UnicodeService';
|
||||
@@ -58,6 +58,8 @@ export abstract class CoreTerminal extends Disposable {
|
||||
public get onData(): IEvent<string> { return this._onData.event; }
|
||||
protected _onLineFeed = new EventEmitter<void>();
|
||||
public get onLineFeed(): IEvent<void> { return this._onLineFeed.event; }
|
||||
private _onResize = new EventEmitter<{ cols: number, rows: number }>();
|
||||
public get onResize(): IEvent<{ cols: number, rows: number }> { return this._onResize.event; }
|
||||
|
||||
public get cols(): number { return this._bufferService.cols; }
|
||||
public get rows(): number { return this._bufferService.rows; }
|
||||
@@ -88,8 +90,9 @@ export abstract class CoreTerminal extends Disposable {
|
||||
this._instantiationService.setService(ICharsetService, this._charsetService);
|
||||
|
||||
// Setup listeners
|
||||
this._coreService.onData(e => this._onData.fire(e));
|
||||
this._coreService.onBinary(e => this._onBinary.fire(e));
|
||||
forwardEvent(this._bufferService.onResize, this._onResize);
|
||||
forwardEvent(this._coreService.onData, this._onData);
|
||||
forwardEvent(this._coreService.onBinary, this._onBinary);
|
||||
this.optionsService.onOptionChange(key => this._updateOptions(key));
|
||||
}
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
import { IBufferService, IOptionsService } from 'common/services/Services';
|
||||
import { BufferSet } from 'common/buffer/BufferSet';
|
||||
import { IBufferSet, IBuffer } from 'common/buffer/Types';
|
||||
import { EventEmitter, IEvent } from 'common/EventEmitter';
|
||||
|
||||
export const MINIMUM_COLS = 2; // Less than 2 can mess with wide chars
|
||||
export const MINIMUM_ROWS = 1;
|
||||
@@ -17,6 +18,9 @@ export class BufferService implements IBufferService {
|
||||
public rows: number;
|
||||
public buffers: IBufferSet;
|
||||
|
||||
private _onResize = new EventEmitter<{ cols: number, rows: number }>();
|
||||
public get onResize(): IEvent<{ cols: number, rows: number }> { return this._onResize.event; }
|
||||
|
||||
public get buffer(): IBuffer { return this.buffers.active; }
|
||||
|
||||
constructor(
|
||||
@@ -32,6 +36,7 @@ export class BufferService implements IBufferService {
|
||||
this.rows = rows;
|
||||
this.buffers.resize(cols, rows);
|
||||
this.buffers.setupTabStops(this.cols);
|
||||
this._onResize.fire({ cols, rows });
|
||||
}
|
||||
|
||||
public reset(): void {
|
||||
|
||||
@@ -17,7 +17,7 @@ export interface IBufferService {
|
||||
readonly buffer: IBuffer;
|
||||
readonly buffers: IBufferSet;
|
||||
|
||||
// TODO: Move resize event here
|
||||
onResize: IEvent<{ cols: number, rows: number }>;
|
||||
|
||||
resize(cols: number, rows: number): void;
|
||||
reset(): void;
|
||||
|
||||
Reference in New Issue
Block a user