MCPcopy
hub / github.com/Doorman11991/smallcode / _highlightCode

Method _highlightCode

src/tui/fullscreen.js:1181–1197  ·  view source on GitHub ↗
(line)

Source from the content-addressed store, hash-verified

1179 }
1180
1181 _highlightCode(line) {
1182 const t = this.theme;
1183 let hl = line;
1184 // Strings
1185 hl = hl.replace(/(["'`])(?:(?!\1).)*\1/g, m => ANSI.fgRgb(140, 200, 120) + m + ANSI.reset);
1186 // Comments
1187 hl = hl.replace(/(\/\/.*)$/, m => t.muted + m + ANSI.reset);
1188 hl = hl.replace(/(#.*)$/, m => t.muted + m + ANSI.reset);
1189 // Keywords
1190 const kws = ['const','let','var','function','return','if','else','for','while','class','import','export','from','async','await','new','this','true','false','null','undefined','pub','fn','struct','impl','mut','match','def','self','None','type','interface','enum'];
1191 for (const kw of kws) {
1192 hl = hl.replace(new RegExp(`\\b${kw}\\b`, 'g'), ANSI.fgRgb(180, 140, 220) + kw + ANSI.reset);
1193 }
1194 // Numbers
1195 hl = hl.replace(/\b(\d+)\b/g, ANSI.fgRgb(120, 200, 220) + '$1' + ANSI.reset);
1196 return hl;
1197 }
1198}
1199
1200module.exports = { FullScreenTUI, ANSI, BOX, THEMES };

Callers 1

addChatMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected