#include "boxes.h" Boxes::Boxes(int size, int style, int color, bool newline) { size_ = size; style_ = style; color_ = color; newline_ = newline; } std::string Boxes::top(void) { std::string line; box_style &bs = boxes[style_]; const char *clr = colors[color_]; line.append(clr); line.append(bs.top_left); for (int x = 0; x < size_; ++x) line.append(bs.top); line.append(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_]; const char *clr = colors[color_]; line.append(clr); line.append(bs.middle_left); for (int x = 0; x < size_; ++x) line.append(bs.top); line.append(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_]; const char *clr = colors[color_]; line.append(clr); line.append(bs.side); line.append(reset); line.append(text); line.append(clr); line.append(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_]; const char *clr = colors[color_]; line.append(clr); line.append(bs.bottom_left); for (int x = 0; x < size_; ++x) line.append(bs.top); line.append(bs.bottom_right); line.append(reset); if (newline_) line.append(nl); return line; } std::tuple Boxes::alert(std::string message, int color, int style, int size) { size_t len = size; if (len == 0) { len = message.length(); } else { while (message.length() < len) message.append(" "); } Boxes abox(len, style, color); std::string s1, s2, s3; s1 = abox.top(); s2 = abox.row(message); s3 = abox.bottom(); return std::make_tuple(s1, s2, s3); }