MCPcopy Create free account
hub / github.com/coder/ghostty-web / BufferCell

Class BufferCell

lib/buffer.ts:295–407  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

293 * A single cell in the buffer
294 */
295export class BufferCell implements IBufferCell {
296 private cell: GhosttyCell;
297 private x: number;
298
299 constructor(cell: GhosttyCell, x: number) {
300 this.cell = cell;
301 this.x = x;
302 }
303
304 getChars(): string {
305 const codepoint = this.cell.codepoint;
306
307 // Return empty string for null character or invalid codepoints
308 if (codepoint === 0) {
309 return '';
310 }
311
312 // Validate codepoint is within valid Unicode range
313 // Valid: 0x0000 to 0x10FFFF, excluding surrogates (0xD800-0xDFFF)
314 if (codepoint < 0 || codepoint > 0x10ffff || (codepoint >= 0xd800 && codepoint <= 0xdfff)) {
315 // Return replacement character for invalid codepoints
316 return '\uFFFD';
317 }
318
319 return String.fromCodePoint(codepoint);
320 }
321
322 getCode(): number {
323 return this.cell.codepoint;
324 }
325
326 getWidth(): number {
327 return this.cell.width;
328 }
329
330 getFgColorMode(): number {
331 // Return -1 for RGB (we always use RGB in our WASM implementation)
332 // xterm.js uses different values:
333 // 0 = default, 1 = palette 16, 2 = palette 256, 3 = RGB
334 // For simplicity, we return -1 for RGB
335 return -1;
336 }
337
338 getBgColorMode(): number {
339 return -1;
340 }
341
342 getFgColor(): number {
343 // Pack RGB into a single number: 0xRRGGBB
344 return (this.cell.fg_r << 16) | (this.cell.fg_g << 8) | this.cell.fg_b;
345 }
346
347 getBgColor(): number {
348 // Pack RGB into a single number: 0xRRGGBB
349 return (this.cell.bg_r << 16) | (this.cell.bg_g << 8) | this.cell.bg_b;
350 }
351
352 isBold(): number {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…