MCPcopy
hub / github.com/codeaashu/claude-code / wrapText

Function wrapText

src/ink/wrap-text.ts:40–74  ·  view source on GitHub ↗
(
  text: string,
  maxWidth: number,
  wrapType: Styles['textWrap'],
)

Source from the content-addressed store, hash-verified

38}
39
40export default function wrapText(
41 text: string,
42 maxWidth: number,
43 wrapType: Styles['textWrap'],
44): string {
45 if (wrapType === 'wrap') {
46 return wrapAnsi(text, maxWidth, {
47 trim: false,
48 hard: true,
49 })
50 }
51
52 if (wrapType === 'wrap-trim') {
53 return wrapAnsi(text, maxWidth, {
54 trim: true,
55 hard: true,
56 })
57 }
58
59 if (wrapType!.startsWith('truncate')) {
60 let position: 'end' | 'middle' | 'start' = 'end'
61
62 if (wrapType === 'truncate-middle') {
63 position = 'middle'
64 }
65
66 if (wrapType === 'truncate-start') {
67 position = 'start'
68 }
69
70 return truncate(text, maxWidth, position)
71 }
72
73 return text
74}
75

Callers 2

wrapWithSoftWrapFunction · 0.70
measureTextNodeFunction · 0.70

Calls 1

truncateFunction · 0.70

Tested by

no test coverage detected