#include "boxes.h" Boxes::Boxes(int width, int style, bool newline) { width_ = width; style_ = style; newline_ = newline; } std::string Boxes::top(void) { std::string line; box_style &bs = boxes[style_]; line.append(boxcolor); line.append(1, bs.top_left); // for (int x = 0; x < width_; ++x) line.append(width_, bs.top); line.append(1, bs.top_right); line.append(reset); if (newline_) line.append(nl); return line; } std::string Boxes::middle(void) { std::string line; box_style &bs = boxes[style_]; line.append(boxcolor); line.append(1, bs.middle_left); // for (int x = 0; x < width_; ++x) line.append(width_, bs.top); line.append(1, bs.middle_right); line.append(reset); if (newline_) line.append(nl); return line; } std::string Boxes::row(std::string &text) { std::string line; box_style &bs = boxes[style_]; line.append(boxcolor); line.append(1, bs.side); if (boxcolor != textcolor) { line.append(reset); line.append(textcolor); } line.append(text); if (textcolor != boxcolor) { line.append(reset); line.append(boxcolor); } line.append(1, bs.side); line.append(reset); if (newline_) line.append(nl); return line; } std::string Boxes::bottom(void) { std::string line; box_style &bs = boxes[style_]; line.append(boxcolor); line.append(1, bs.bottom_left); // for (int x = 0; x < width_; ++x) line.append(width_, bs.top); line.append(1, bs.bottom_right); line.append(reset); if (newline_) line.append(nl); return line; } std::array Boxes::alert(std::string message, std::string bcolor, std::string tcolor, int width, int style, bool newline) { std::array results; Boxes abox(width, style, newline); abox.boxcolor = bcolor; abox.textcolor = tcolor; results[0] = abox.top(); results[1] = abox.row(message); results[2] = abox.bottom(); return results; }