Skip to content
Merged
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
29 changes: 26 additions & 3 deletions packages/cli/src/test-utils/svg.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ export const generateSvgForTerminal = (terminal: Terminal): string => {
break;
}
}

if (contentRows === 0) contentRows = 1; // Minimum 1 row

const width = terminal.cols * charWidth + padding * 2;
Expand All @@ -113,6 +114,9 @@ export const generateSvgForTerminal = (terminal: Terminal): string => {

let currentFgHex: string | null = null;
let currentBgHex: string | null = null;
let currentIsBold = false;
let currentIsItalic = false;
let currentIsUnderline = false;
let currentBlockStartCol = -1;
let currentBlockText = '';
let currentBlockNumCells = 0;
Expand All @@ -128,12 +132,20 @@ export const generateSvgForTerminal = (terminal: Terminal): string => {
svg += ` <rect x="${xPos}" y="${yPos}" width="${rectWidth}" height="${charHeight}" fill="${currentBgHex}" />
`;
}
if (currentBlockText.trim().length > 0) {
if (currentBlockText.trim().length > 0 || currentIsUnderline) {
const fill = currentFgHex || '#ffffff'; // Default text color
const textWidth = currentBlockNumCells * charWidth;

let extraAttrs = '';
if (currentIsBold) extraAttrs += ' font-weight="bold"';
if (currentIsItalic) extraAttrs += ' font-style="italic"';
if (currentIsUnderline)
extraAttrs += ' text-decoration="underline"';

// Use textLength to ensure the block fits exactly into its designated cells
svg += ` <text x="${xPos}" y="${yPos + 2}" fill="${fill}" textLength="${textWidth}" lengthAdjust="spacingAndGlyphs">${escapeXml(currentBlockText)}</text>
`;
const textElement = `<text x="${xPos}" y="${yPos + 2}" fill="${fill}" textLength="${textWidth}" lengthAdjust="spacingAndGlyphs"${extraAttrs}>${escapeXml(currentBlockText)}</text>`;

svg += ` ${textElement}\n`;
}
}
}
Expand Down Expand Up @@ -164,17 +176,27 @@ export const generateSvgForTerminal = (terminal: Terminal): string => {
bgHex = tempFgHex || '#ffffff';
}

const isBold = !!cell.isBold();
const isItalic = !!cell.isItalic();
const isUnderline = !!cell.isUnderline();

let chars = cell.getChars();
if (chars === '') chars = ' '.repeat(cellWidth);

if (
fgHex !== currentFgHex ||
bgHex !== currentBgHex ||
isBold !== currentIsBold ||
isItalic !== currentIsItalic ||
isUnderline !== currentIsUnderline ||
currentBlockStartCol === -1
) {
finalizeBlock(x);
currentFgHex = fgHex;
currentBgHex = bgHex;
currentIsBold = isBold;
currentIsItalic = isItalic;
currentIsUnderline = isUnderline;
currentBlockStartCol = x;
currentBlockText = chars;
currentBlockNumCells = cellWidth;
Expand All @@ -185,6 +207,7 @@ export const generateSvgForTerminal = (terminal: Terminal): string => {
}
finalizeBlock(line.length);
}

svg += ` </g>\n</svg>`;
return svg;
};
7 changes: 4 additions & 3 deletions packages/cli/src/ui/components/StatusDisplay.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,12 @@ const renderStatusDisplay = async (
};

describe('StatusDisplay', () => {
const originalEnv = process.env;
beforeEach(() => {
vi.stubEnv('GEMINI_SYSTEM_MD', '');
});

afterEach(() => {
process.env = { ...originalEnv };
delete process.env['GEMINI_SYSTEM_MD'];
vi.unstubAllEnvs();
vi.restoreAllMocks();
});

Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Loading