]> git.proxmox.com Git - mirror_xterm.js.git/blob - src/Buffer.ts
Merge branch 'master' into alt-selection
[mirror_xterm.js.git] / src / Buffer.ts
1 /**
2 * @license MIT
3 */
4
5 import { ITerminal } from './Interfaces';
6 import { CircularList } from './utils/CircularList';
7
8 /**
9 * This class represents a terminal buffer (an internal state of the terminal), where the
10 * following information is stored (in high-level):
11 * - text content of this particular buffer
12 * - cursor position
13 * - scroll position
14 */
15 export class Buffer {
16 public lines: CircularList<[number, string, number][]>;
17
18 public savedY: number;
19 public savedX: number;
20
21 /**
22 * Create a new Buffer.
23 * @param {Terminal} terminal - The terminal the Buffer will belong to
24 * @param {number} ydisp - The scroll position of the Buffer in the viewport
25 * @param {number} ybase - The scroll position of the y cursor (ybase + y = the y position within the Buffer)
26 * @param {number} y - The cursor's y position after ybase
27 * @param {number} x - The cursor's x position after ybase
28 */
29 constructor(
30 private terminal: ITerminal,
31 public ydisp: number = 0,
32 public ybase: number = 0,
33 public y: number = 0,
34 public x: number = 0,
35 public scrollBottom: number = 0,
36 public scrollTop: number = 0,
37 public tabs: any = {},
38 ) {
39 this.lines = new CircularList<[number, string, number][]>(this.terminal.scrollback);
40 this.scrollBottom = this.terminal.rows - 1;
41 }
42 }