malwoden
Version:
   
51 lines • 3.17 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.drawBorder = void 0;
var terminal_1 = require("../../terminal");
var tileMap = {
"double-bar": {
topLeftCorner: terminal_1.CharCode.boxDrawingsDoubleDownAndRight,
topRightCorner: terminal_1.CharCode.boxDrawingsDoubleDownAndLeft,
bottomLeftCorner: terminal_1.CharCode.boxDrawingsDoubleUpAndRight,
bottomRightCorner: terminal_1.CharCode.boxDrawingsDoubleUpAndLeft,
verticalBarsLeft: terminal_1.CharCode.boxDrawingsDoubleVertical,
verticalBarsRight: terminal_1.CharCode.boxDrawingsDoubleVertical,
horizontalBarsTop: terminal_1.CharCode.boxDrawingsDoubleHorizontal,
horizontalBarsBottom: terminal_1.CharCode.boxDrawingsDoubleHorizontal,
},
"single-bar": {
topLeftCorner: terminal_1.CharCode.boxDrawingsLightDownAndRight,
topRightCorner: terminal_1.CharCode.boxDrawingsLightDownAndLeft,
bottomLeftCorner: terminal_1.CharCode.boxDrawingsLightUpAndRight,
bottomRightCorner: terminal_1.CharCode.boxDrawingsLightUpAndLeft,
verticalBarsLeft: terminal_1.CharCode.boxDrawingsLightVertical,
verticalBarsRight: terminal_1.CharCode.boxDrawingsLightVertical,
horizontalBarsTop: terminal_1.CharCode.boxDrawingsLightHorizontal,
horizontalBarsBottom: terminal_1.CharCode.boxDrawingsLightHorizontal,
},
};
function drawBorder(borderOptions) {
var terminal = borderOptions.terminal, foreColor = borderOptions.foreColor, backColor = borderOptions.backColor, bounds = borderOptions.bounds, style = borderOptions.style;
var topLeftCorner = bounds.v1;
var topRightCorner = { x: bounds.v2.x, y: bounds.v1.y };
var bottomLeftCorner = { x: bounds.v1.x, y: bounds.v2.y };
var bottomRightCorner = bounds.v2;
var tiles = tileMap[style];
// Corners
terminal.drawGlyph(topLeftCorner, terminal_1.Glyph.fromCharCode(tiles.topLeftCorner, foreColor, backColor));
terminal.drawGlyph(topRightCorner, terminal_1.Glyph.fromCharCode(tiles.topRightCorner, foreColor, backColor));
terminal.drawGlyph(bottomLeftCorner, terminal_1.Glyph.fromCharCode(tiles.bottomLeftCorner, foreColor, backColor));
terminal.drawGlyph(bottomRightCorner, terminal_1.Glyph.fromCharCode(tiles.bottomRightCorner, foreColor, backColor));
// Horizontal Bars
for (var dx = topLeftCorner.x + 1; dx < topRightCorner.x; dx++) {
terminal.drawGlyph({ x: dx, y: topLeftCorner.y }, terminal_1.Glyph.fromCharCode(tiles.horizontalBarsTop, foreColor, backColor));
terminal.drawGlyph({ x: dx, y: bottomRightCorner.y }, terminal_1.Glyph.fromCharCode(tiles.horizontalBarsBottom, foreColor, backColor));
}
// Vertical Bars
for (var dy = topLeftCorner.y + 1; dy < bottomLeftCorner.y; dy++) {
terminal.drawGlyph({ x: topLeftCorner.x, y: dy }, terminal_1.Glyph.fromCharCode(tiles.verticalBarsLeft, foreColor, backColor));
terminal.drawGlyph({ x: topRightCorner.x, y: dy }, terminal_1.Glyph.fromCharCode(tiles.verticalBarsRight, foreColor, backColor));
}
}
exports.drawBorder = drawBorder;
//# sourceMappingURL=draw-borders.js.map