-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.cpp
165 lines (151 loc) · 4.88 KB
/
main.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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
//#include "TextVideo.h"
//#include <iostream>
//#include "Shape.h"
//#include "Console.h"
//#include "ConsoleEngine.h"
//#include <thread>
//#include <atomic>
//
//
//void TestEngine()
//{
// console.printConsoleInfo();
// std::cin.get();
// ConsoleEngine eng{console};
// auto [left, right] = eng.add<RectangleArea>().divide(RectangleArea::Divisor::Vertical, 0);
// auto [upper_left, bottom_left] = left.divide(RectangleArea::Divisor::Horizontal, 0);
// auto [upper_right, bottom_right] = right.divide(RectangleArea::Divisor::Horizontal, 0);
//
// auto upper_left_bar = upper_left.add<ProgressBar>();
// upper_left_bar.setPercentage(20);
// upper_left_bar.setColor(Color::RED);
// /*auto upper_right_bar =*/ upper_right.add<ProgressBar>().setPercentage(30);
// /*auto bottom_left_bar =*/ bottom_left.add<ProgressBar>().setPercentage(40);
// /*auto bottom_right_bar =*/ bottom_right.add<ProgressBar>().setPercentage(50);
//
//
// eng.draw();
// std::cin.get();
//}
//
//void TestConsole()
//{
//
// /*Setting text color using familiar syntax */
// console << Color::RED << "This is a red text on black background\n";
// /*Or use traditional member function*/
// console.set(Color::MAGENTA).writeln("This is magenta text");
//
// /*Setting background color using the same syntax */
// console << BackgroundColor::WHITE << "This is a magenta text on white background\n";
// console.set(BackgroundColor::DEFAULT, false).set(Color::WHITE);
//
// /*Moving cursor using relative or absolute position */
// console.moveCursor(4, Direction::RIGHT);
// console << "Indent text\n";
// console.moveCursorTo({ 20,10 });
// console << "Text start at [20,10]\n";
// console.moveCursorTo(MIDDLE{});
//
// /*Erase one line or clear the whole window */
// console << "Press enter to delete this line: ";
// std::cin.get();
// console.eraseLine();
// std::cin.get();
// console.clear();
//}
//void TestColor()
//{
// std::array test{
// to_text(20, 100, 50), //Green
// to_text(200, 0, 0), //RED
// to_text(100, 100, 100), //WHITE
// to_text(0, 100, 100), //CYAN
// to_text(0, 100, 0), //Green
// to_text(100,0,100), //MAGANTA
// to_text(20,50,150), //BLUE
// to_text(100,120,0) //YELLOW
// };
// ConsoleEngine eng{ console };
// for (auto i = 0; i < test.size(); ++i)
// eng.buffer(i+2, 1) = test[i];
// eng.draw();
//}
//void ScrollViewTest()
//{
// ConsoleEngine eng{ console };
// auto canvas = eng.add<RectangleArea>();
// canvas.setBorder('U', 'D', 'L', 'R');
// auto [left, right] = canvas.divide(RectangleArea::Divisor::Vertical, 0);
// left.setBorder('1', '2', '3', '4');
// auto area = left.add<ScrollView>();
//
// /*add text -> area*/
// area.push("Hello world1");
// area.push("Hello world1");
// area.push("Hello world1");
// area.push("Hello world1");
// area.push("Hello world1");
// area.push("Hello world1");
// area.push("Hello world1");
// area.push("Hello world1");
// area.push("A long text that needs two line to display ABCDEFGHIJKLMNOPQRSTUVWXYZ");
// area.push("Hello world1");
//
// area.draw();
//
// eng.draw();
//}
#include "Console.h"
#include <iostream>
#ifdef LINUX
static void test()
{
initscr();
start_color();
init_pair(1, COLOR_RED, COLOR_GREEN);
attron(COLOR_PAIR(1));
printw("RED text + Green back\n");
refresh();
//attroff(COLOR_PAIR(1));
init_pair(2, COLOR_GREEN, COLOR_WHITE);
attron(COLOR_PAIR(2));
attron(A_BOLD);
printw("Green text + white back\n");
refresh();
getch();
endwin();
}
#endif
static void test2()
{
console.printConsoleInfo();
/*Setting text color using familiar syntax */
console << Color::RED << "This is a red text on black background\n";
/*Or use traditional member function*/
console.set(Color::MAGENTA).writeln("This is magenta text");
/*Setting background color using the same syntax */
console << BackgroundColor::WHITE << "This is a magenta text on white background\n";
console.set(BackgroundColor::DEFAULT, false).set(Color::WHITE);
/*Moving cursor using relative or absolute position */
console.moveCursor(4, Direction::RIGHT);
console << "Indent text\n";
console.moveCursorTo({ 20,10 });
console << "Text start at [20,10]\n";
console.moveCursorTo(MIDDLE{});
/*Erase one line or clear the whole window */
console << "Press enter to delete this line: ";
console.waitEnter();
console.eraseLine();
/*Read data using familiar syntax, always work as you intended*/
console << "Read a string: ";
auto str = console.read<std::string>();
console << "You entered: " << str << '\n';
console.waitEnter();
console.clear();
}
int main(int argc, char *argv[])
{
//test();
test2();
}