-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathTOOL.BOX.CLASS.cpp
executable file
·172 lines (158 loc) · 5.26 KB
/
TOOL.BOX.CLASS.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
164
165
166
167
168
169
170
171
172
#include <MENU.CLASS.h>
#include <TOOL.BOX.CLASS.h>
#include <WIN.CLASS.h>
#include <FILE.FOLDER.CLASS.h>
using namespace std;
//####################################################################
//-------Color-Hauptmenue---------------------------------------------
int ToolBoxClass::HaMeFe_HG = 06,//Fenster_Background-----------------
ToolBoxClass::HaMe_FG = 01,//Hauptmenue_Foreground----------------
ToolBoxClass::HaMe_HG = 06,//Hauptmenue_Background----------------
ToolBoxClass::HaMe_grey = 04,//Hauptmenue_inaktive----------------
ToolBoxClass::UMeFe_HG = 01;//Fenster_Untermenue------------------
//####################################################################
//-------Color-InApp-Menues-------------------------------------------
int ToolBoxClass::IlMeFe_HG = 61,//Fenster_Background-----------------
ToolBoxClass::IlMe_FG = 42,//InnLineMenue_Foreground--------------
ToolBoxClass::IlMe_HG = 63,//InnLineMenue_Background--------------
ToolBoxClass::IlMe_grey = 63,//InnLineMenue_inaktive--------------
ToolBoxClass::IlUMeFe_HG = 35;//Fenster_Untermenue----------------
//####################################################################
//-------Uhrzeit-Anzeigen---------------------------------------------
volatile std::sig_atomic_t ToolBoxClass::flag ;
void ToolBoxClass::set_flag(int signal) { flag = signal ; }
struct DatumUhrZeit ToolBoxClass::datumuhrzeit;
void ToolBoxClass::process_signal( DatumUhrZeit& object ) {
while (flag != SIGTERM) {
object.TIMEFIELD(MenuClass::MENEU.HMWin,WinClass::max_xc);
std::this_thread::sleep_for( std::chrono::milliseconds(1000) ) ;
}
}
//####################################################################
//eigenes zählwerk um von forn an fangen zu können
//aktuelle zahl, string ob + oder -, maximale höchste zahl
int ToolBoxClass::zahlenwerk(int zahlen, string i, int max)
{
int tmp = 0;
if (strcmp(i.c_str(),"++")==0){
if(zahlen>=max){
tmp = 1;
}else if(zahlen==0){
tmp = 1;
}else if (zahlen>0){
tmp = ++zahlen;
}else if (zahlen<max){
tmp = ++zahlen;
}
}else if(strcmp(i.c_str(),"--")==0){
if(zahlen<=0){
tmp = max;
}else if (zahlen==1){
tmp = max;
}else if (zahlen>1){
tmp = --zahlen;
}else if(zahlen<=max){
tmp = --zahlen;
}
}else{
tmp = 1;
}
return tmp;
}
int ToolBoxClass::ZahlenBerechnen(int posa, RANGE range, string wahl)
{
int tmp;
if (wahl.compare("+") == 0){
posa++;
}else if (wahl.compare("-") == 0){
posa--;
}
if (posa >= range.min && posa <= range.max){
tmp = ((posa - range.min) + range.min);
}else if (posa >= range.min && posa > range.max){
tmp = (posa - range.max);// + range.min;
while(tmp > range.max){
tmp = (tmp - range.max);// + range.min;
}
}else if (posa < range.min && posa <= range.max){
tmp = range.max + posa;
while(tmp < range.min){
if(tmp == 0){tmp = range.max;}
else{tmp = range.max + tmp;}
}
}else if (posa == 0){
tmp = range.max;
}else{tmp = posa;}
return tmp;
}
int ToolBoxClass::ZahlenWerk(int mina, int posa, int maxa, string wahl){
vector<RANGE> list;
int included;
RANGE range;
range.min = mina;
range.max = maxa;
range.count();
range.range = 1;
list.push_back(range);
do {
included = ToolBoxClass::ZahlenBerechnen(posa, range, wahl);
}while (included > range.max);
return included;
}
WINDOW *ToolBoxClass::ClearWindow(WINDOW *TEMPWINDOW) {
clearok(TEMPWINDOW,true);
return TEMPWINDOW;
}
void ToolBoxClass::ClearScreen() {
if (!cur_term) {
int result;
setupterm( nullptr, STDOUT_FILENO, &result );
if (result <= 0) return;
}
putp(tigetstr("clear"));
}
NO_RETURN void ToolBoxClass::TermQuit(int sig) {
UNUSED(sig);
FileFolderClass::ConfigDateiList.clear();
vector<string>().swap(FileFolderClass::ConfigDateiList);
ToolBoxClass::DeletAllWin("Ende");
clear();
raise(SIGTERM);
exit(EXIT_SUCCESS);
}
void ToolBoxClass::DeletAllWin(const char *name) {
try {
if (strcmp(name,"Ende")==0){
if (WinClass::START.TMPWin1){
werase(WinClass::START.TMPWin1);
delwin(WinClass::START.TMPWin1);
endwin();
}
if (WinClass::START.TMPWin1){
werase(WinClass::START.TMPWin2);
delwin(WinClass::START.TMPWin2);
endwin();
}
if (WinClass::START.TMPWin1){
werase(WinClass::START.TMPWin3);
delwin(WinClass::START.TMPWin3);
endwin();
}
endwin();
}
} catch (const NCursesException *e) {
endwin();
std::cerr << e->message << std::endl;
cout << e->errorno;
} catch (const NCursesException &e) {
endwin();
std::cerr << e.message << std::endl;
cout << e.errorno;
} catch (const std::exception &e) {
endwin();
std::cerr << "Exception: " << e.what() << std::endl;
cout << EXIT_FAILURE;
}
}
ToolBoxClass::ToolBoxClass() {
}