-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathui.cpp
More file actions
205 lines (189 loc) · 6.79 KB
/
ui.cpp
File metadata and controls
205 lines (189 loc) · 6.79 KB
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
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
/**
* @file: ui.h
* @author: fhn
* @date: 4/20
* @description: textual interface
* @version: 1.0 has fulfilled
*/
//--------------------------------------------------------------------------------------------
#include "ui.hpp"
const std::string kMysql = "mysql> ";
//--------------------------------------------------------------------------------------------
//--------------------------------------------------------------------------------------------
/**
* @file: ui.cpp
* @author: fhn
* @date: 4/21
* @description: three main parts of textual ui. Hello() is the welcome cover.
* @version: 1.0
*/
void Intro();
void Blingbling();
void FakeUser(const std::string&);
/**
* @author: fhn
* @date: 4/21
* @description: 1.0: simulate the interface of mysql
hoping to do : to make the inputting more real;
* @version: 1.0
*/
void Interface::Hello()
{
Intro();
Blingbling();
using std::cin;
using std::cout;
using std::endl;
cout << "Windows PowerShell" << endl
<< "版权所有 (C) Microsoft Corporation。保留所有权利。" << endl
<< "尝试新的跨平台 PowerShell https://aka.ms/pscore6" << endl
<< "PS C:\\Users\\abc44> ";
FakeUser("net start mysql");
cout << "请求的服务已经启动。\n\n"
<< "请键入 NET HELPMSG 2182 以获得更多的帮助。\n\n";
cout << "PS C:\\Users\\abc44> ";
FakeUser("cd D:\\Mysql\\mysql-8.0.19-winx64\\bin");
cout << "PS D:\\Mysql\\mysql-8.0.19-winx64\\bin> ";
FakeUser("mysql -u root -p");
cout << "Enter password: ";
FakeUser("********");
cout << "Welcome to the MySQL monitor. Commands end with ; or \\g.\n";
cout << "Your MySQL connection id is 9\n";
cout << "Server version: 8.0.19 MySQL Community Server - GPL\n\n";
cout << "Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.\n\n";
cout << "Oracle is a registered trademark of Oracle Corporation and/or its\n";
cout << "affiliates. Other names may be trademarks of their respective\n";
cout << "owners.\n\n";
cout << "Type 'help;' or '\\h' for help. Type '\\c' to clear the current input statement.\n\n";
}
//--------------------------------------------------------------------------------------------
/**
* @author: fhn
* @date: 4/21
* @description: to input a string, one line or more.
* @output: string ending with char ';'
* @version:
*/
std::string Interface::Input()
{
using namespace std;
cout << kMysql;
string line, sentence;
stringstream ss;
bool already_in = false, danger = true;// to indicate whether we have input or not
cin.clear();
while (getline(cin, line))
{
danger = false;
if (already_in && line.size() > 1)
ss << ' ';
if (line.size()){
ss << line;
already_in = true;
}
if (line[line.size()-1] == ';'){
sentence = ss.str(); // using `ss>>` we'll only get the first word of ss.
//(which is defined by the rules of stream inserting)
break;
}
else
cout << " -> ";
}
extern bool broken;
// if (danger)
// if (broken)
// error("Data Broken");
// else
// error("No input at all");
time_cnt::start();
#ifdef _LOC_
cout << "src sentence was : " << sentence << endl;
#endif
if (sentence == "exit;")
exit_ = true;
return sentence;
}
//--------------------------------------------------------------------------------------------
/**
* @author: fhn
* @date: 4/21
* @description: 3 of the three main ui interface.
* @version:
*/
void Interface::Goodbye()
{
using namespace std;
cout << endl << "Bye!" << endl;
}
//--------------------------------------------------------------------------------------------
/**
* @author: fhn
* @date: 4/20
* @description: the basic information of myself.
* @version: 1.0
*/
void Intro()
{
system("cls");
system("mode con cols=80 lines=14");
using std::cout; using std::endl;
cout << endl << endl;
cout << R"( )" << endl;
cout << R"( DBMS LAB: A Scale Modeling of Mysql )" << endl;
cout << R"( )" << endl;
cout << R"( Fan Haonian, Depart. of EE )" << endl;
cout << R"( )" << endl;
cout << R"( Date: 4/21 )" << endl;
cout << R"( )" << endl;
cout << R"( * Press any key to continue... )" << endl;
std::cin.get();
}
/**
* @author: fhn
* @date: 4/20
* @description: a dynamic blingbling~ opening of this program.
* @version: 1.0
*/
void Blingbling()
{
system("cls");
system("mode con cols=120 lines=20");
using std::cout; using std::endl;
cout << endl
<< endl
<< endl
<< endl;
cout << R"( ************* ******************* ***** ************** **** **** )" << endl;
cout << R"( ***** ***** ******************* ******* **************** **** **** )" << endl;
cout << R"( ***** ***** ****** **** **** ***** ***** **** **** )" << endl;
cout << R"( ***** ***** ***************** **** **** ***** **** **** **** )" << endl;
cout << R"( ************* ***************** ************* ***** **** ***** )" << endl;
cout << R"( ***** **** ****** **************** ***** ***** ***** )" << endl;
cout << R"( ***** **** ******************* **** **** *************** ***** )" << endl;
cout << R"( ***** ****** ******************* **** **** ************** ***** )" << endl;
system("color 48");
time_cnt::Sleep3();
system("color 0F");
time_cnt::Sleep2();
system("color 68");
time_cnt::Sleep3();
system("color 0F");
time_cnt::Sleep2();
system("color F8");
time_cnt::Sleep3();
system("color 0F");
time_cnt::Sleep1();
system("mode con cols=110 lines=25");
};
void FakeUser(const std::string& info)
{
time_cnt::Sleep1();
for (int i = 0; i < info.size(); i++)
{
std::cout << info[i];
time_cnt::Sleep4();
if (i % 5 == 0)
time_cnt::Sleep5();
}
std::cout << std::endl;
}