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

Function renderBorder

src/ink/render-border.ts:82–229  ·  view source on GitHub ↗
(
  x: number,
  y: number,
  node: DOMNode,
  output: Output,
)

Source from the content-addressed store, hash-verified

80}
81
82const renderBorder = (
83 x: number,
84 y: number,
85 node: DOMNode,
86 output: Output,
87): void => {
88 if (node.style.borderStyle) {
89 const width = Math.floor(node.yogaNode!.getComputedWidth())
90 const height = Math.floor(node.yogaNode!.getComputedHeight())
91 const box =
92 typeof node.style.borderStyle === 'string'
93 ? (CUSTOM_BORDER_STYLES[
94 node.style.borderStyle as keyof typeof CUSTOM_BORDER_STYLES
95 ] ?? cliBoxes[node.style.borderStyle as keyof Boxes])
96 : node.style.borderStyle
97
98 const topBorderColor = node.style.borderTopColor ?? node.style.borderColor
99 const bottomBorderColor =
100 node.style.borderBottomColor ?? node.style.borderColor
101 const leftBorderColor = node.style.borderLeftColor ?? node.style.borderColor
102 const rightBorderColor =
103 node.style.borderRightColor ?? node.style.borderColor
104
105 const dimTopBorderColor =
106 node.style.borderTopDimColor ?? node.style.borderDimColor
107
108 const dimBottomBorderColor =
109 node.style.borderBottomDimColor ?? node.style.borderDimColor
110
111 const dimLeftBorderColor =
112 node.style.borderLeftDimColor ?? node.style.borderDimColor
113
114 const dimRightBorderColor =
115 node.style.borderRightDimColor ?? node.style.borderDimColor
116
117 const showTopBorder = node.style.borderTop !== false
118 const showBottomBorder = node.style.borderBottom !== false
119 const showLeftBorder = node.style.borderLeft !== false
120 const showRightBorder = node.style.borderRight !== false
121
122 const contentWidth = Math.max(
123 0,
124 width - (showLeftBorder ? 1 : 0) - (showRightBorder ? 1 : 0),
125 )
126
127 const topBorderLine = showTopBorder
128 ? (showLeftBorder ? box.topLeft : '') +
129 box.top.repeat(contentWidth) +
130 (showRightBorder ? box.topRight : '')
131 : ''
132
133 // Handle text in top border
134 let topBorder: string | undefined
135 if (showTopBorder && node.style.borderText?.position === 'top') {
136 const [before, text, after] = embedTextInBorder(
137 topBorderLine,
138 node.style.borderText.content,
139 node.style.borderText.align,

Callers 1

renderNodeToOutputFunction · 0.85

Calls 7

embedTextInBorderFunction · 0.85
styleBorderLineFunction · 0.85
applyColorFunction · 0.85
maxMethod · 0.80
getComputedWidthMethod · 0.45
getComputedHeightMethod · 0.45
writeMethod · 0.45

Tested by

no test coverage detected