Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 20 additions & 3 deletions packages/core/src/buffer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,12 +155,23 @@ export class OptimizedBuffer {

public clear(bg: RGBA = RGBA.fromValues(0, 0, 0, 1)): void {
this.guard()
this.lib.bufferClear(this.bufferPtr, bg)
const hasColorTypeInfo = bg.colorType !== undefined
if (hasColorTypeInfo) {
this.lib.bufferClearWithColorType(this.bufferPtr, bg)
} else {
this.lib.bufferClear(this.bufferPtr, bg)
}
}

public setCell(x: number, y: number, char: string, fg: RGBA, bg: RGBA, attributes: number = 0): void {
this.guard()
this.lib.bufferSetCell(this.bufferPtr, x, y, char, fg, bg, attributes)
// Check if either color has color type info (indexed or default)
const hasColorTypeInfo = fg.colorType !== undefined || bg.colorType !== undefined
if (hasColorTypeInfo) {
this.lib.bufferSetCellWithColorType(this.bufferPtr, x, y, char, fg, bg, attributes)
} else {
this.lib.bufferSetCell(this.bufferPtr, x, y, char, fg, bg, attributes)
}
}

public setCellWithAlphaBlending(
Expand All @@ -172,7 +183,13 @@ export class OptimizedBuffer {
attributes: number = 0,
): void {
this.guard()
this.lib.bufferSetCellWithAlphaBlending(this.bufferPtr, x, y, char, fg, bg, attributes)
// Check if either color has color type info (indexed or default)
const hasColorTypeInfo = fg.colorType !== undefined || bg.colorType !== undefined
if (hasColorTypeInfo) {
this.lib.bufferSetCellWithAlphaBlendingAndColorType(this.bufferPtr, x, y, char, fg, bg, attributes)
} else {
this.lib.bufferSetCellWithAlphaBlending(this.bufferPtr, x, y, char, fg, bg, attributes)
}
}

public drawText(
Expand Down
Loading