-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.cpp
125 lines (102 loc) · 4 KB
/
test.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
#include <SinesBox/SinesBox.h>
#include <SinesBox/SinesGlobalSettings.h>
#include <iostream>
#include <thread>
#include <chrono>
void basicExample() {
std::cout << "\nBasic Example:\n";
SinesBoxLib::SinesBox box;
box.setText("Hello, World!");
box.setBorderColor("cyan");
box.setTextColor("yellow");
box.setBorderBold(true);
box.draw();
}
void multilineExample() {
std::cout << "\nMultiline Example:\n";
SinesBoxLib::SinesBox box;
box.setText("This is a longer text that will automatically wrap to multiple lines based on your terminal width.It demonstrates how the box adjusts to content length while maintaining proper formatting and alignment.This is a longer text that will automatically wrap to multiple lines based on your terminal width.It demonstrates how the box adjusts to content length while maintaining proper formatting and alignment.");
box.setBorderColor("green");
box.setTextColor("white");
box.setBackgroundColor("brightblack");
box.setBorderBold(true);
box.draw();
}
void rainbowExample() {
std::cout << "\nRainbow Example:\n";
SinesBoxLib::SinesBox box;
box.setText("Rainbow text with automatic wrapping and colorful borders This example shows how to create eye-catching displays.This is a longer text that will automatically wrap to multiple lines based on your terminal width.It demonstrates how the box adjusts to content length while maintaining proper formatting and alignment.This is a longer text that will automatically wrap to multiple lines based on your terminal width.It demonstrates how the box adjusts to content length while maintaining proper formatting and alignment.");
box.drawRainbow();
}
void styleExamples() {
std::cout << "\nStyle Examples:\n";
// Normal style
SinesBoxLib::SinesBox normal;
normal.setText("Normal border");
normal.setBorderColor("white");
normal.draw();
std::cout << "\n";
// Bold border
SinesBoxLib::SinesBox bold;
bold.setText("Bold border");
bold.setBorderColor("white");
bold.setBorderBold(true);
bold.draw();
std::cout << "\n";
// Bold text
SinesBoxLib::SinesBox boldText;
boldText.setText("Bold text");
boldText.setTextBold(true);
boldText.draw();
}
void colorExamples() {
std::cout << "\nColor Examples:\n";
const std::vector<std::string> colors = {
"red", "green", "yellow", "blue", "magenta", "cyan",
"brightred", "brightgreen", "brightyellow", "brightblue", "brightmagenta", "brightcyan"
};
for (const auto& color : colors) {
SinesBoxLib::SinesBox box;
box.setText("Color: " + color);
box.setBorderColor(color);
box.setTextColor(color);
box.draw();
std::cout << "\n";
}
}
void animatedExample() {
std::cout << "\nAnimated Example (press Ctrl+C to stop):\n";
SinesBoxLib::SinesBox box;
box.setText("Animated Box!");
const std::vector<std::string> colors = {
"red", "yellow", "green", "cyan", "blue", "magenta"
};
size_t colorIndex = 0;
while (true) {
// Clear previous output (move cursor up and clear line)
std::cout << "\033[3A\033[J";
box.setBorderColor(colors[colorIndex]);
box.setTextColor(colors[(colorIndex + 2) % colors.size()]);
box.setBorderBold(colorIndex % 2 == 0);
box.draw();
colorIndex = (colorIndex + 1) % colors.size();
std::this_thread::sleep_for(std::chrono::milliseconds(200));
}
}
int main() {
// Initialize global settings (important for Windows compatibility)
SinesBoxLib::SinesGlobalSettings::initialize();
std::cout << "BoxDesign Examples\n";
std::cout << "=================\n";
basicExample();
multilineExample();
rainbowExample();
styleExamples();
colorExamples();
try {
animatedExample(); // This will run until Ctrl+C is pressed
} catch (...) {
std::cout << "\nAnimation stopped.\n";
}
return 0;
}