* Render a cell's background only (Pass 1 of two-pass rendering) * Selection highlighting is integrated here to avoid z-order issues with * complex glyphs (like Devanagari) that extend outside their cell bounds.
(cell: GhosttyCell, x: number, y: number)
| 546 | * complex glyphs (like Devanagari) that extend outside their cell bounds. |
| 547 | */ |
| 548 | private renderCellBackground(cell: GhosttyCell, x: number, y: number): void { |
| 549 | const cellX = x * this.metrics.width; |
| 550 | const cellY = y * this.metrics.height; |
| 551 | const cellWidth = this.metrics.width * cell.width; |
| 552 | |
| 553 | // Check if this cell is selected |
| 554 | const isSelected = this.isInSelection(x, y); |
| 555 | |
| 556 | if (isSelected) { |
| 557 | // Draw selection background (solid color, not overlay) |
| 558 | this.ctx.fillStyle = this.theme.selectionBackground; |
| 559 | this.ctx.fillRect(cellX, cellY, cellWidth, this.metrics.height); |
| 560 | return; // Selection background replaces cell background |
| 561 | } |
| 562 | |
| 563 | // Extract background color and handle inverse |
| 564 | let bg_r = cell.bg_r, |
| 565 | bg_g = cell.bg_g, |
| 566 | bg_b = cell.bg_b; |
| 567 | |
| 568 | if (cell.flags & CellFlags.INVERSE) { |
| 569 | // When inverted, background becomes foreground |
| 570 | bg_r = cell.fg_r; |
| 571 | bg_g = cell.fg_g; |
| 572 | bg_b = cell.fg_b; |
| 573 | } |
| 574 | |
| 575 | // Only draw cell background if it's different from the default (black) |
| 576 | // This lets the theme background (drawn earlier) show through for default cells |
| 577 | const isDefaultBg = bg_r === 0 && bg_g === 0 && bg_b === 0; |
| 578 | if (!isDefaultBg) { |
| 579 | this.ctx.fillStyle = this.rgbToCSS(bg_r, bg_g, bg_b); |
| 580 | this.ctx.fillRect(cellX, cellY, cellWidth, this.metrics.height); |
| 581 | } |
| 582 | } |
| 583 | |
| 584 | /** |
| 585 | * Render a cell's text and decorations (Pass 2 of two-pass rendering) |
no test coverage detected