Browse Source

Upgraded from char* to char. Cleaner inserts.

Steve Thielemann 3 years ago
parent
commit
b7274686b3
2 changed files with 26 additions and 26 deletions
  1. 14 14
      boxes.cpp
  2. 12 12
      boxes.h

+ 14 - 14
boxes.cpp

@@ -11,10 +11,10 @@ std::string Boxes::top(void) {
   box_style &bs = boxes[style_];
 
   line.append(boxcolor);
-  line.append(bs.top_left);
-  for (int x = 0; x < width_; ++x)
-    line.append(bs.top);
-  line.append(bs.top_right);
+  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);
@@ -25,10 +25,10 @@ std::string Boxes::middle(void) {
   std::string line;
   box_style &bs = boxes[style_];
   line.append(boxcolor);
-  line.append(bs.middle_left);
-  for (int x = 0; x < width_; ++x)
-    line.append(bs.top);
-  line.append(bs.middle_right);
+  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);
@@ -39,7 +39,7 @@ std::string Boxes::row(std::string &text) {
   std::string line;
   box_style &bs = boxes[style_];
   line.append(boxcolor);
-  line.append(bs.side);
+  line.append(1, bs.side);
   if (boxcolor != textcolor) {
     line.append(reset);
     line.append(textcolor);
@@ -49,7 +49,7 @@ std::string Boxes::row(std::string &text) {
     line.append(reset);
     line.append(boxcolor);
   }
-  line.append(bs.side);
+  line.append(1, bs.side);
   line.append(reset);
   if (newline_)
     line.append(nl);
@@ -60,10 +60,10 @@ std::string Boxes::bottom(void) {
   std::string line;
   box_style &bs = boxes[style_];
   line.append(boxcolor);
-  line.append(bs.bottom_left);
-  for (int x = 0; x < width_; ++x)
-    line.append(bs.top);
-  line.append(bs.bottom_right);
+  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);

+ 12 - 12
boxes.h

@@ -14,19 +14,19 @@ It might be easier to let this do boxes, and let something else do colors.
 
 class Boxes {
   struct box_style {
-    const char *top_left;
-    const char *top_right;
-    const char *top;
-    const char *side;
-    const char *bottom_left;
-    const char *bottom_right;
-    const char *middle_left;
-    const char *middle_right;
+    const char top_left;
+    const char top_right;
+    const char top;
+    const char side;
+    const char bottom_left;
+    const char bottom_right;
+    const char middle_left;
+    const char middle_right;
   } boxes[4] = {
-      {"\xda", "\xbf", "\xc4", "\xb3", "\xc0", "\xd9", "\xc3", "\xb4"},
-      {"\xc9", "\xbb", "\xcd", "\xba", "\xc8", "\xbc", "\xcc", "\xb9"},
-      {"\xd6", "\xb8", "\xcd", "\xb3", "\xd4", "\xbe", "\xc6", "\xb5"},
-      {"\xd6", "\xb7", "\xc4", "\xba", "\xd3", "\xbd", "\xc7", "\xb6"}};
+      {'\xda', '\xbf', '\xc4', '\xb3', '\xc0', '\xd9', '\xc3', '\xb4'},
+      {'\xc9', '\xbb', '\xcd', '\xba', '\xc8', '\xbc', '\xcc', '\xb9'},
+      {'\xd6', '\xb8', '\xcd', '\xb3', '\xd4', '\xbe', '\xc6', '\xb5'},
+      {'\xd6', '\xb7', '\xc4', '\xba', '\xd3', '\xbd', '\xc7', '\xb6'}};
   int style_;
   int width_;
   bool newline_;