MCPcopy Create free account
hub / github.com/echoVic/blade-code / formatText

Method formatText

src/ui/components/Display.ts:24–46  ·  view source on GitHub ↗

* 格式化输出文本

(text: string, options: DisplayOptions = {})

Source from the content-addressed store, hash-verified

22 * 格式化输出文本
23 */
24 private static formatText(text: string, options: DisplayOptions = {}): string {
25 const opts = { ...this.defaultOptions, ...options };
26
27 let result = text;
28
29 // 添加前缀
30 if (opts.prefix) {
31 result = opts.prefix + result;
32 }
33
34 // 添加后缀
35 if (opts.suffix) {
36 result = result + opts.suffix;
37 }
38
39 // 添加缩进
40 if (opts.indent && opts.indent > 0) {
41 const indent = ' '.repeat(opts.indent);
42 result = indent + result.split('\n').join('\n' + indent);
43 }
44
45 return result;
46 }
47
48 /**
49 * 输出文本

Callers 1

outputMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected