UNPKG

malwoden

Version:

![alt text](./coverage/badge-lines.svg) ![alt text](./coverage/badge-statements.svg) ![alt text](./coverage/badge-functions.svg) ![alt text](./coverage/badge-branches.svg)

73 lines 2.87 kB
"use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; return extendStatics(d, b); }; return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); var __assign = (this && this.__assign) || function () { __assign = Object.assign || function(t) { for (var s, i = 1, n = arguments.length; i < n; i++) { s = arguments[i]; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; } return t; }; return __assign.apply(this, arguments); }; Object.defineProperty(exports, "__esModule", { value: true }); exports.PanelWidget = void 0; var struct_1 = require("../struct"); var terminal_1 = require("../terminal"); var draw_borders_1 = require("./util/draw-borders"); var widget_1 = require("./widget"); /** * Represents a rectangle drawn on the screen, often with a border. */ var PanelWidget = /** @class */ (function (_super) { __extends(PanelWidget, _super); function PanelWidget(config) { var _this = _super.call(this, config) || this; _this.state = __assign({ foreColor: terminal_1.Color.White, backColor: terminal_1.Color.Black }, config.initialState); return _this; } PanelWidget.prototype.getAbsTopLeft = function () { return this.getAbsoluteOrigin(); }; PanelWidget.prototype.getAbsBottomRight = function () { var o = this.getAbsoluteOrigin(); return { x: o.x + this.state.width - 1, y: o.y + this.state.height - 1, }; }; PanelWidget.prototype.onDraw = function () { if (!this.terminal) return; var _a = this.state, backColor = _a.backColor, foreColor = _a.foreColor; var bgGlyph = new terminal_1.Glyph(" ", foreColor, backColor); var tl = this.getAbsTopLeft(); var br = this.getAbsBottomRight(); this.terminal.fill(tl, br, bgGlyph); if (this.state.borderStyle) { draw_borders_1.drawBorder({ terminal: this.terminal, foreColor: foreColor, backColor: backColor, style: this.state.borderStyle, bounds: new struct_1.Rect(this.getAbsTopLeft(), this.getAbsBottomRight()), }); } }; return PanelWidget; }(widget_1.Widget)); exports.PanelWidget = PanelWidget; //# sourceMappingURL=panel-widget.js.map