C++ "single header file" library for drawing tables in console.
Report Bug π
A C++ "single header file" library for drawing tables in the console.
"Copy and Paste" or "Download" the table.h file, and add it to your project.
- Clone the repo and enter the folder
- Run
make.bat
or./make.bat
Coming Soon π
#include "table.h"
clitable::Table table;
Arg No. | Description |
---|---|
0 | Name of the Column Header |
1 | Alignment of Column Header |
2 | Alignment of Column values |
3 | Column padding |
4 | Column size (amount of letter it can contain) |
5 | Column resizability |
- clitable::Column::CENTER_ALIGN: For aligning value or header to the center.
- clitable::Column::RIGHT_ALIGN: For aligning value or header to the right.
- clitable::Column::LEFT_ALIGN: For aligning value or header to the left.
- clitable::Column::RESIZABLE: The 'column size'1 will increase automatically if the values don't fit.
- clitable::Column::NON_RESIZABLE: The 'column size'1 will not change even if the values don't fit.
1 'Column size' means the same as mentioned in Description of Column constructor Arg No. 4
clitable::Column c[3] = {
clitable::Column("Name", clitable::Column::CENTER_ALIGN, clitable::Column::LEFT_ALIGN, 1,7, clitable::Column::NON_RESIZABLE),
clitable::Column("Topic", clitable::Column::CENTER_ALIGN, clitable::Column::RIGHT_ALIGN, 1,2, clitable::Column::RESIZABLE),
clitable::Column("Nation", clitable::Column::CENTER_ALIGN, clitable::Column::LEFT_ALIGN, 1,5, clitable::Column::NON_RESIZABLE)
};
for (int i = 0; i < 3; i++) {
table.addColumn(c[i]);
}
std::string r[3][3] = {
{"Samuel Miller", "Coding Memes", "Venezuela"},
{"DevEd", "Web Development", "Germany"},
{"Mykull", "Crack Head", "U.S.A"}
};
for (int i = 0; i < 3; i++) {
table.addRow(r[i]);
}
table.addTitle("These Are YOUTUBERS");
table.draw();
These Are YOUTUBERS
+=========+=================+=======+
| Name | Topic | Natio |
| | | n |
+=========+=================+=======+
| Samuel | Coding Memes | Venez |
| Miller | | uela |
+---------+-----------------+-------+
| DevEd | Web Development | Germa |
| | | ny |
+---------+-----------------+-------+
| Mykull | Crack Head | U.S.A |
+---------+-----------------+-------+
For breaking line use \n
character.
std::string r[3][3] = {
{"Samuel Miller", "Coding Memes", "Venezuela"},
{"DevEd", "Web Development", "Germany"},
{"Mykull", "Crack\n Head", "U.S.A"}
};
These Are YOUTUBERS
+=========+=================+=======+
| Name | Topic | Natio |
| | | n |
+=========+=================+=======+
| Samuel | Coding Memes | Venez |
| Miller | | uela |
+---------+-----------------+-------+
| DevEd | Web Development | Germa |
| | | ny |
+---------+-----------------+-------+
| Mykull | Crack | U.S.A |
| | Head | |
+---------+-----------------+-------+
Just send me a pull request. Mention your discord or instagram id.
(if the instructions were unclear, please let me know)
Send me a message on discord or instagram. Check out my Profile Readme