MCPcopy Create free account
hub / github.com/WJX20/claude-code / render

Method render

packages/color-diff-napi/src/index.ts:951–974  ·  view source on GitHub ↗
(themeName: string, width: number, dim: boolean)

Source from the content-addressed store, hash-verified

949 }
950
951 render(themeName: string, width: number, dim: boolean): string[] | null {
952 const mode = detectColorMode(themeName)
953 const theme = buildTheme(themeName, mode)
954 const lines = this.code.split('\n')
955 // Rust .lines() drops trailing empty line from trailing \n
956 if (lines.length > 0 && lines[lines.length - 1] === '') lines.pop()
957 const firstLine = lines[0] ?? null
958 const lang = detectLanguage(this.filePath, firstLine)
959 const hlState = { lang, stack: null }
960
961 const maxDigits = String(lines.length).length
962 const effectiveWidth = Math.max(1, width - maxDigits - 2)
963
964 const out: string[] = []
965 for (let i = 0; i < lines.length; i++) {
966 const tokens = highlightLine(hlState, lines[i]!, theme)
967 const h: Highlight = { marker: null, lineNumber: i + 1, lines: [tokens] }
968 removeNewlines(h)
969 wrapText(h, effectiveWidth, theme)
970 addLineNumber(h, theme, maxDigits, dim)
971 out.push(...intoLines(h, dim, true, mode))
972 }
973 return out
974 }
975}
976
977export function getSyntaxTheme(themeName: string): SyntaxTheme {

Callers

nothing calls this directly

Calls 9

detectColorModeFunction · 0.85
buildThemeFunction · 0.85
highlightLineFunction · 0.85
removeNewlinesFunction · 0.85
addLineNumberFunction · 0.85
intoLinesFunction · 0.85
maxMethod · 0.80
detectLanguageFunction · 0.70
wrapTextFunction · 0.70

Tested by

no test coverage detected