-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSource.cpp
More file actions
167 lines (128 loc) · 2.45 KB
/
Copy pathSource.cpp
File metadata and controls
167 lines (128 loc) · 2.45 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
#include <iostream>
#include <Windows.h>
#include"Header.h"
#include<fstream>
using namespace std;
linked_list list;
int main(int argc, char* argv[])
{
maximizeConsole();
show_menu();
display_fun();
HANDLE rhnd = GetStdHandle(STD_INPUT_HANDLE);
DWORD Events = 0;
DWORD EventsRead = 0;
bool Running = true;
bool isFull = false;
bool screen_clear = false;
int x = left_, y = top_;
gotoxy(x, y);
while (Running)
{
GetNumberOfConsoleInputEvents(rhnd, &Events);
if (Events != 0)
{
INPUT_RECORD eventBuffer[200];
ReadConsoleInput(rhnd, eventBuffer, Events, &EventsRead);
for (DWORD i = 0; i < EventsRead; ++i)
{
if (eventBuffer[i].EventType == KEY_EVENT && eventBuffer[i].Event.KeyEvent.bKeyDown)
{
if (!screen_clear)
{
clear_fun();
screen_clear = true;
}
switch (eventBuffer[i].Event.KeyEvent.wVirtualKeyCode)
{
case VK_UP:
if (y > top_)
{
y--;
}
gotoxy(x, y);
break;
case VK_DOWN:
if (y < bottom_)
{
y++;
}
gotoxy(x, y);
break;
case VK_RIGHT:
if (x < right_ - 1)
{
insert_character(' ');
x++;
}
gotoxy(x, y);
break;
case VK_LEFT:
if (x > left_)
{
x--;
}
gotoxy(x, y);
break;
case VK_RETURN:
if (y < bottom_)
{ y++;
x = left_;
insert_character('\n');
gotoxy(x, y);
}
break;
case VK_F1:
system("cls");
show_menu();
break;
case VK_BACK:
if (x > left_)
{
x--;
list.delete_at_end(y, x);
gotoxy(left_, y);
list.fun1(y);
}
break;
default:
break;
}
if (y == bottom_ && x == right_ - 1)
{
isFull = true;
warning_msg();
}
if (!isFull)
{
char ch = eventBuffer[i].Event.KeyEvent.uChar.AsciiChar;
if ((ch >='A' && ch<='Z') || (ch>='a' && ch<='z'))
{
list.insert_at_end(ch, y, x);
cout << ch;
insert_character(ch);
x++;
if (x >= right_)
{
if (y < bottom_)
{
x = left_;
y++;
}
else
{
isFull = true;
warning_msg();
gotoxy(x, y);
continue;
}
}
}
}
gotoxy(x, y);
}
}
}
}
return 0;
}