boxes.cpp 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. #include "boxes.h"
  2. Boxes::Boxes(int size, int style, int color, bool newline) {
  3. size_ = size;
  4. style_ = style;
  5. color_ = color;
  6. newline_ = newline;
  7. }
  8. std::string Boxes::top(void) {
  9. std::string line;
  10. box_style &bs = boxes[style_];
  11. const char *clr = colors[color_];
  12. line.append(clr);
  13. line.append(bs.top_left);
  14. for (int x = 0; x < size_; ++x)
  15. line.append(bs.top);
  16. line.append(bs.top_right);
  17. line.append(reset);
  18. if (newline_)
  19. line.append(nl);
  20. return line;
  21. }
  22. std::string Boxes::middle(void) {
  23. std::string line;
  24. box_style &bs = boxes[style_];
  25. const char *clr = colors[color_];
  26. line.append(clr);
  27. line.append(bs.middle_left);
  28. for (int x = 0; x < size_; ++x)
  29. line.append(bs.top);
  30. line.append(bs.middle_right);
  31. line.append(reset);
  32. if (newline_)
  33. line.append(nl);
  34. return line;
  35. }
  36. std::string Boxes::row(std::string &text) {
  37. std::string line;
  38. box_style &bs = boxes[style_];
  39. const char *clr = colors[color_];
  40. line.append(clr);
  41. line.append(bs.side);
  42. line.append(reset);
  43. line.append(text);
  44. line.append(clr);
  45. line.append(bs.side);
  46. line.append(reset);
  47. if (newline_)
  48. line.append(nl);
  49. return line;
  50. }
  51. std::string Boxes::bottom(void) {
  52. std::string line;
  53. box_style &bs = boxes[style_];
  54. const char *clr = colors[color_];
  55. line.append(clr);
  56. line.append(bs.bottom_left);
  57. for (int x = 0; x < size_; ++x)
  58. line.append(bs.top);
  59. line.append(bs.bottom_right);
  60. line.append(reset);
  61. if (newline_)
  62. line.append(nl);
  63. return line;
  64. }
  65. /*
  66. std::tuple<std::string, std::string, std::string>
  67. Boxes::alert(std::string message, int size, int color, int style = 1) {}
  68. */