Skip to content

Commit

Permalink
Merge pull request #1871 from Tyriar/1867_readonly_api_props
Browse files Browse the repository at this point in the history
Make Terminal API properties readonly
  • Loading branch information
Tyriar committed Jan 27, 2019
2 parents 51a1485 + a7f2348 commit c7cfca3
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 23 deletions.
4 changes: 2 additions & 2 deletions src/Buffer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ describe('Buffer', () => {

beforeEach(() => {
terminal = new MockTerminal();
terminal.cols = INIT_COLS;
terminal.rows = INIT_ROWS;
(terminal as any).cols = INIT_COLS;
(terminal as any).rows = INIT_ROWS;
terminal.options.scrollback = 1000;
buffer = new Buffer(terminal, true);
});
Expand Down
4 changes: 2 additions & 2 deletions src/BufferSet.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ describe('BufferSet', () => {

beforeEach(() => {
terminal = new MockTerminal();
terminal.cols = 80;
terminal.rows = 24;
(terminal as any).cols = 80;
(terminal as any).rows = 24;
terminal.options.scrollback = 1000;
bufferSet = new BufferSet(terminal);
});
Expand Down
14 changes: 7 additions & 7 deletions src/Linkifier.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ describe('Linkifier', () => {

beforeEach(() => {
terminal = new MockTerminal();
terminal.cols = 100;
terminal.rows = 10;
(terminal as any).cols = 100;
(terminal as any).rows = 10;
terminal.buffer = new MockBuffer();
(<MockBuffer>terminal.buffer).setLines(new CircularList<IBufferLine>(20));
terminal.buffer.ydisp = 0;
Expand All @@ -65,7 +65,7 @@ describe('Linkifier', () => {
function assertLinkifiesRow(rowText: string, linkMatcherRegex: RegExp, links: {x: number, length: number}[], done: MochaDone): void {
addRow(rowText);
linkifier.registerLinkMatcher(linkMatcherRegex, () => {});
terminal.rows = terminal.buffer.lines.length - 1;
(terminal as any).rows = terminal.buffer.lines.length - 1;
linkifier.linkifyRows();
// Allow linkify to happen
setTimeout(() => {
Expand Down Expand Up @@ -142,19 +142,19 @@ describe('Linkifier', () => {
});
describe('multi-line links', () => {
it('should match links that start on line 1/2 of a wrapped line and end on the last character of line 1/2', done => {
terminal.cols = 4;
(terminal as any).cols = 4;
assertLinkifiesMultiLineLink('12345', /1234/, [{x1: 0, x2: 4, y1: 0, y2: 0}], done);
});
it('should match links that start on line 1/2 of a wrapped line and wrap to line 2/2', done => {
terminal.cols = 4;
(terminal as any).cols = 4;
assertLinkifiesMultiLineLink('12345', /12345/, [{x1: 0, x2: 1, y1: 0, y2: 1}], done);
});
it('should match links that start and end on line 2/2 of a wrapped line', done => {
terminal.cols = 4;
(terminal as any).cols = 4;
assertLinkifiesMultiLineLink('12345678', /5678/, [{x1: 0, x2: 4, y1: 1, y2: 1}], done);
});
it('should match links that start on line 2/3 of a wrapped line and wrap to line 3/3', done => {
terminal.cols = 4;
(terminal as any).cols = 4;
assertLinkifiesMultiLineLink('123456789', /56789/, [{x1: 0, x2: 1, y1: 1, y2: 2}], done);
});
});
Expand Down
4 changes: 2 additions & 2 deletions src/SelectionManager.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ describe('SelectionManager', () => {

beforeEach(() => {
terminal = new TestMockTerminal();
terminal.cols = 80;
terminal.rows = 2;
(terminal as any).cols = 80;
(terminal as any).rows = 2;
terminal.options.scrollback = 100;
terminal.buffers = new BufferSet(terminal);
terminal.buffer = terminal.buffers.active;
Expand Down
4 changes: 2 additions & 2 deletions src/SelectionModel.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ describe('SelectionManager', () => {

beforeEach(() => {
terminal = new MockTerminal();
terminal.cols = 80;
terminal.rows = 2;
(terminal as any).cols = 80;
(terminal as any).rows = 2;
terminal.options.scrollback = 10;
terminal.buffers = new BufferSet(terminal);
terminal.buffer = terminal.buffers.active;
Expand Down
2 changes: 1 addition & 1 deletion src/Types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ export interface IBufferAccessor {
}

export interface IElementAccessor {
element: HTMLElement;
readonly element: HTMLElement;
}

export interface ILinkifierAccessor {
Expand Down
18 changes: 11 additions & 7 deletions typings/xterm.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -314,28 +314,32 @@ declare module 'xterm' {
/**
* The element containing the terminal.
*/
element: HTMLElement;
readonly element: HTMLElement;

/**
* The textarea that accepts input for the terminal.
*/
textarea: HTMLTextAreaElement;
readonly textarea: HTMLTextAreaElement;

/**
* The number of rows in the terminal's viewport.
* The number of rows in the terminal's viewport. Use
* `ITerminalOptions.rows` to set this in the constructor and
* `Terminal.resize` for when the terminal exists.
*/
rows: number;
readonly rows: number;

/**
* The number of columns in the terminal's viewport.
* The number of columns in the terminal's viewport. Use
* `ITerminalOptions.cols` to set this in the constructor and
* `Terminal.resize` for when the terminal exists.
*/
cols: number;
readonly cols: number;

/**
* (EXPERIMENTAL) Get all markers registered against the buffer. If the alt
* buffer is active this will always return [].
*/
markers: IMarker[];
readonly markers: IMarker[];

/**
* Natural language strings that can be localized.
Expand Down

0 comments on commit c7cfca3

Please sign in to comment.