From 284b0832746daccc26b523018eb7fdd735cf0a2d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Breitbart?= Date: Sat, 1 Sep 2018 02:10:11 +0200 Subject: [PATCH] note on copy on data access --- src/BufferLine.ts | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/BufferLine.ts b/src/BufferLine.ts index 170fc81d..eef73a90 100644 --- a/src/BufferLine.ts +++ b/src/BufferLine.ts @@ -100,6 +100,20 @@ const enum Cell { SIZE = 3 } + +/** + * Typed array based bufferline implementation. + * Note: Unlike the JS variant the access to the data + * via set/get is always a copy action. + * Sloppy ref style coding will not work anymore: + * line = new BufferLine(10); + * char = line.get(0); // char is a copy + * char[some_index] = 123; // will not update the line + * line.set(0, ch); // do this to update line data + * TODO: + * - provide getData/setData to directly access the data + * - clear/reset method + */ export class BufferLine implements IBufferLine { static blankLine(cols: number, attr: number, isWrapped?: boolean): IBufferLine { const ch: CharData = [attr, NULL_CELL_CHAR, NULL_CELL_WIDTH, NULL_CELL_CODE];