Skip to content

Commit 0f6e427

Browse files
clean code
1 parent cb7f1ea commit 0f6e427

File tree

1 file changed

+0
-72
lines changed

1 file changed

+0
-72
lines changed

packages/cli/src/components/ansiString.ts

Lines changed: 0 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -22,23 +22,6 @@ export interface CharStyle {
2222
dim?: boolean;
2323
}
2424

25-
/**
26-
* Apply hex color to text using chalk
27-
*/
28-
export function hexToAnsi(hex: string, isBg = false): string {
29-
if (isBg) {
30-
return chalk.bgHex(hex)("");
31-
}
32-
return chalk.hex(hex)("");
33-
}
34-
35-
/**
36-
* Reset all styles - chalk handles this automatically when string ends
37-
*/
38-
export function resetAnsi(): string {
39-
return chalk.reset("");
40-
}
41-
4225
/**
4326
* Style a string with the given CharStyle using chalk
4427
*/
@@ -60,41 +43,6 @@ function styleText(text: string, style?: CharStyle): string {
6043
return styledChalk(text);
6144
}
6245

63-
/**
64-
* Build an ANSI-styled string from characters with individual styles.
65-
* This allows Ink to wrap the text at character boundaries while preserving styling.
66-
*/
67-
export function buildAnsiString(chars: Array<{ char: string; style?: CharStyle }>): string {
68-
let result = "";
69-
let currentStyle: CharStyle | undefined;
70-
let currentText = "";
71-
72-
for (const { char, style } of chars) {
73-
const styleChanged =
74-
currentStyle?.color !== style?.color ||
75-
currentStyle?.backgroundColor !== style?.backgroundColor ||
76-
currentStyle?.dim !== style?.dim;
77-
78-
if (styleChanged) {
79-
// Flush previous text with its style
80-
if (currentText) {
81-
result += styleText(currentText, currentStyle);
82-
currentText = "";
83-
}
84-
currentStyle = style;
85-
}
86-
87-
currentText += char;
88-
}
89-
90-
// Flush remaining text
91-
if (currentText) {
92-
result += styleText(currentText, currentStyle);
93-
}
94-
95-
return result;
96-
}
97-
9846
/**
9947
* Optimized version that batches consecutive characters with the same style.
10048
* More efficient for long strings with few style changes.
@@ -172,26 +120,6 @@ export function buildAnsiStringWithLineBreaks(
172120
return lines.map((line) => buildAnsiStringOptimized(line)).join("\n");
173121
}
174122

175-
/**
176-
* Create a styled line with background color filling the entire width.
177-
* Useful for line numbers and operator columns.
178-
*
179-
* @param text - Text to display (will be on first row only if multiline)
180-
* @param height - Number of rows
181-
* @param style - Style to apply
182-
* @returns ANSI string with newlines
183-
*/
184-
export function buildStyledLines(text: string, height: number, style: CharStyle): string {
185-
const lines: string[] = [];
186-
187-
for (let row = 0; row < height; row++) {
188-
const lineText = row === 0 ? text : " ".repeat(text.length);
189-
lines.push(styleText(lineText, style));
190-
}
191-
192-
return lines.join("\n");
193-
}
194-
195123
/**
196124
* Create a styled block with consistent background across all rows.
197125
* Each row has fixed width, filled with spaces if needed.

0 commit comments

Comments
 (0)