Website Summary Files Commits Branches @commit @diff @stats
path: root / src / ConsoleInterface / Toolbox.cpp
diff options
context:
space:
mode:
1 files changed, 23 insertions, 5 deletions
-rw-r--r--src/ConsoleInterface/Toolbox.cpp28
diff --git a/src/ConsoleInterface/Toolbox.cpp b/src/ConsoleInterface/Toolbox.cpp
index 25f1c64..31e5277 100644
--- a/src/ConsoleInterface/Toolbox.cpp
+++ b/src/ConsoleInterface/Toolbox.cpp
@@ -32,18 +32,36 @@ void errorBox(const char* message) {
std::cout << "<E> " << message << std::endl;
}
+void __printTableHeaderNumber(unsigned number) {
+ std::cout << ((number < 100) ? " " : "") << number << ((number < 10) ? " " : "");
+}
+
void __printTableColumnHeader(unsigned start, unsigned count) {
- for (unsigned i = 0; i < count; i++, start++)
- std::cout << ":" << ((start < 100) ? " " : "") << start << ((start < 10) ? " " : "");
+ for (unsigned i = 0; i < count; i++) {
+ std::cout << ":";
+ __printTableHeaderNumber(start++);
+ }
std::cout << ":" << std::endl;
+}
- for (unsigned i = 0; i < count; i++)
- std::cout << "....";
- std::cout << "." << std::endl;
+void __printTableLine(unsigned columns) {
+ for (unsigned i = 0; i < columns; i++)
+ std::cout << "----";
+ std::cout << "-" << std::endl;
}
void table(unsigned startNumber, unsigned columns, const char* items) {
__printTableColumnHeader(startNumber, columns);
+
+ for (unsigned i = 0, colInd = 0, rowCnt = startNumber; items[i] != '\0'; i++, (++colInd) %= columns) {
+ if (colInd == 0) {
+ __printTableLine(columns);
+ __printTableHeaderNumber(rowCnt++);
+ continue;
+ }
+
+ std::cout << items[rowCnt * columns + colInd] << std::endl;
+ }
}
void _printOrderedListBeginning() {