MCPcopy Create free account
hub / github.com/SethGammon/Citadel / container

Method container

scripts/grid.cjs:121–149  ·  view source on GitHub ↗
(x, y, w, h, title, style = 'single')

Source from the content-addressed store, hash-verified

119
120 // Container box with a title in the top border
121 container(x, y, w, h, title, style = 'single') {
122 const s = STYLES[style] || STYLES.single;
123
124 // Corners
125 this.put(x, y, s.tl);
126 this.put(x + w - 1, y, s.tr);
127 this.put(x, y + h - 1, s.bl);
128 this.put(x + w - 1, y + h - 1, s.br);
129
130 // Top border with title
131 const titleStr = `[ ${title} ]`;
132 for (let i = 1; i < w - 1; i++) {
133 this.put(x + i, y, s.h);
134 }
135 this.text(x + 2, y, titleStr);
136
137 // Bottom border
138 for (let i = 1; i < w - 1; i++) {
139 this.put(x + i, y + h - 1, s.h);
140 }
141
142 // Sides
143 for (let j = 1; j < h - 1; j++) {
144 this.put(x, y + j, s.v);
145 this.put(x + w - 1, y + j, s.v);
146 }
147
148 return { x, y, w, h };
149 }
150
151 render() {
152 return this.cells.map(row => row.join('').trimEnd()).join('\n');

Callers

nothing calls this directly

Calls 2

putMethod · 0.95
textMethod · 0.95

Tested by

no test coverage detected