aboutsummaryrefslogtreecommitdiffstats
path: root/node_modules/xterm/src/browser/renderer/GridCache.ts
diff options
context:
space:
mode:
Diffstat (limited to 'node_modules/xterm/src/browser/renderer/GridCache.ts')
-rw-r--r--node_modules/xterm/src/browser/renderer/GridCache.ts33
1 files changed, 33 insertions, 0 deletions
diff --git a/node_modules/xterm/src/browser/renderer/GridCache.ts b/node_modules/xterm/src/browser/renderer/GridCache.ts
new file mode 100644
index 0000000..b48798d
--- /dev/null
+++ b/node_modules/xterm/src/browser/renderer/GridCache.ts
@@ -0,0 +1,33 @@
+/**
+ * Copyright (c) 2017 The xterm.js authors. All rights reserved.
+ * @license MIT
+ */
+
+export class GridCache<T> {
+ public cache: (T | undefined)[][];
+
+ public constructor() {
+ this.cache = [];
+ }
+
+ public resize(width: number, height: number): void {
+ for (let x = 0; x < width; x++) {
+ if (this.cache.length <= x) {
+ this.cache.push([]);
+ }
+ for (let y = this.cache[x].length; y < height; y++) {
+ this.cache[x].push(undefined);
+ }
+ this.cache[x].length = height;
+ }
+ this.cache.length = width;
+ }
+
+ public clear(): void {
+ for (let x = 0; x < this.cache.length; x++) {
+ for (let y = 0; y < this.cache[x].length; y++) {
+ this.cache[x][y] = undefined;
+ }
+ }
+ }
+}