Create BufferService
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
/**
|
||||
* Copyright (c) 2019 The xterm.js authors. All rights reserved.
|
||||
* @license MIT
|
||||
*/
|
||||
|
||||
import { IBufferService, IOptionsService } from './Services';
|
||||
|
||||
export const MINIMUM_COLS = 2; // Less than 2 can mess with wide chars
|
||||
export const MINIMUM_ROWS = 1;
|
||||
|
||||
export class BufferService implements IBufferService {
|
||||
public cols: number;
|
||||
public rows: number;
|
||||
|
||||
constructor(
|
||||
optionsService: IOptionsService
|
||||
) {
|
||||
this.cols = Math.max(optionsService.options.cols, MINIMUM_COLS);
|
||||
this.rows = Math.max(optionsService.options.rows, MINIMUM_ROWS);
|
||||
}
|
||||
|
||||
public resize(cols: number, rows: number): void {
|
||||
this.cols = cols;
|
||||
this.rows = rows;
|
||||
}
|
||||
}
|
||||
Vendored
+9
@@ -5,6 +5,15 @@
|
||||
|
||||
import { IEvent } from 'common/EventEmitter2';
|
||||
|
||||
export interface IBufferService {
|
||||
readonly cols: number;
|
||||
readonly rows: number;
|
||||
|
||||
// TODO: Move resize event here
|
||||
|
||||
resize(cols: number, rows: number): void;
|
||||
}
|
||||
|
||||
export interface IOptionsService {
|
||||
readonly options: ITerminalOptions;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user