note on copy on data access

This commit is contained in:
Jörg Breitbart
2018-09-01 02:10:11 +02:00
parent f9453ef4fa
commit 284b083274
+14
View File
@@ -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];