Skip to content

Commit 6016d26

Browse files
TerminalAppGen3 v0.3.2 src
1 parent 965b98d commit 6016d26

File tree

9 files changed

+379
-177
lines changed

9 files changed

+379
-177
lines changed

CommandFiles/CPUStress.cpp

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,11 +132,13 @@ void CpuBenchmark(short int nSingleOrMulti, long long int nArgNum = -1) {
132132
colour(sColourGlobal, sColourGlobalBack);
133133
}
134134
}
135+
135136
// Multi Core
136137
else if (nSingleOrMulti == 2) {
137138

138139
// Make std::vector array for threads in next step
139140
std::vector<std::thread> vThreads(nLogicalCoreCount);
141+
unsigned long long int nPreviousReiterationNum = 0;
140142

141143
// Start timer and call the cpu benchmark worker nLogicalCoreCount times
142144
std::cout << "Starting multi-core benchmark with " << nReiterationCount << " reiterations, " << nLogicalCoreCount << " logical cores.\n";
@@ -149,15 +151,22 @@ void CpuBenchmark(short int nSingleOrMulti, long long int nArgNum = -1) {
149151
}
150152

151153
while (true) {
154+
152155
if (_kbhit()) {
153156
bCpuStressKeyboardTermination = true;
154157
break;
155158
}
156159
else if (nCurrentReiterationNum >= nReiterationCount) {
157160
break;
158161
}
159-
// Output progress
160-
std::cout << "Progress: " << (nCurrentReiterationNum * 100) / nReiterationCount << "% \r";
162+
163+
164+
if (nPreviousReiterationNum < nCurrentReiterationNum) { // <-- Speed is required to make the percentage output operation accurate,
165+
nPreviousReiterationNum = nCurrentReiterationNum; // <-- so these two lines were put right next to each other to make that possible.
166+
// Output progress
167+
std::cout << "Progress: " << (nPreviousReiterationNum * 100) / nReiterationCount << "% \r";
168+
}
169+
161170
}
162171

163172
StopCpuStress = true;

CommandFiles/CommandFileAssets.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,7 @@ int MessageBoxButtonSwitch(std::string sButtonName) {
223223
return 0;
224224
}
225225

226+
226227
/* MessageBox Codes */
227228
//////////////////////
228229
/* Message box codes are the following for icons:

CommandFiles/CommandsFile.cpp

Lines changed: 123 additions & 89 deletions
Large diffs are not rendered by default.

CommandFiles/Settings.cpp

Lines changed: 33 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ void Exiting();
99
long double num(std::string);
1010
void SetCursorAttributes();
1111
void colourSubheading();
12+
void ColourTypeSwitch();
1213

1314
extern bool bDisplayDirections;
1415
extern bool bDisplayVerboseMessages;
@@ -369,6 +370,12 @@ void AnsiSettings(short int nChoice = 0) {
369370
if (nChoice == 1) {
370371
if (EnableVTMode() != false) {
371372
bAnsiVTSequences = true;
373+
374+
// Set new colours
375+
ColourTypeSwitch();
376+
colour(sColourGlobal, sColourGlobalBack);
377+
cls(); // Set colours to whole screen
378+
372379
colour(LGRN, sColourGlobalBack);
373380
std::cout << "ANSI VT sequences successfully enabled.\n";
374381
colour(sColourGlobal, sColourGlobalBack);
@@ -386,12 +393,18 @@ void AnsiSettings(short int nChoice = 0) {
386393
}
387394
else if (nChoice == 2) {
388395
colour(YLW, sColourGlobalBack);
389-
std::cout << wordWrap("WARNING: This WILL disable ALL colours AND text formatting from the point of this message.") << '\n';
396+
std::cout << wordWrap("WARNING: This WILL disable RGB colours AND text formatting from the point of this message.") << '\n';
390397

391-
if (YesNo(wordWrap("Would you like to proceed? [y/n] > "))) {
392-
colour(sColourGlobal, sColourGlobalBack);
398+
if (YesNo(wordWrap("Would you like to proceed? [y/n] > ")))
399+
{
393400
bAnsiVTSequences = false;
394-
colour(YLW, sColourGlobalBack);
401+
402+
// Set new colours
403+
ColourTypeSwitch();
404+
colour(sColourGlobal, sColourGlobalBack);
405+
cls(); // Set to whole screen
406+
407+
colour(LGRN, sColourGlobalBack);
395408
std::cout << "ANSI VT sequences successfully disabled.\n";
396409
colour(sColourGlobal, sColourGlobalBack);
397410

@@ -470,15 +483,6 @@ void WordWrapSettings(short int nChoice = 0) {
470483

471484
void CursorSettings(short int nChoice = 0, short int nChoiceBlink = 0, short int nChoiceShow = 0, short int nChoiceShape = 0) {
472485

473-
// Doesn't work without ANSI (might support Get/SetConsoleCursorInfo in the future for legacy consoles)
474-
if (!bAnsiVTSequences) {
475-
colour(RED, sColourGlobalBack);
476-
std::cout << wordWrap("Sorry, but this setting cannot be modified without terminal ANSI VT support.") << '\n';
477-
Exiting();
478-
colour(sColourGlobal, sColourGlobalBack);
479-
return;
480-
}
481-
482486
if (nChoice == 0) {
483487
OptionSelectEngine oseCursor;
484488
oseCursor.nSizeOfOptions = 3;
@@ -489,7 +493,22 @@ void CursorSettings(short int nChoice = 0, short int nChoiceBlink = 0, short int
489493
};
490494
oseCursor.sOptions = sOptions;
491495

492-
nChoice = oseCursor.OptionSelect("Please select your desired option for the Cursor settings:", " ___CURSOR SETTINGS___ ");
496+
while (true) {
497+
nChoice = oseCursor.OptionSelect("Please select your desired option for the Cursor settings:", " ___CURSOR SETTINGS___ ");
498+
499+
if (nChoice == 1 || nChoice == 3) {
500+
501+
// Doesn't work without ANSI
502+
if (!bAnsiVTSequences) {
503+
colour(RED, sColourGlobalBack);
504+
std::cout << wordWrap("Sorry, but this setting cannot be modified without terminal ANSI VT support.") << '\n';
505+
Exiting();
506+
colour(sColourGlobal, sColourGlobalBack);
507+
}
508+
else break;
509+
}
510+
else break;
511+
}
493512
}
494513

495514
// Enable/Disable Cursor blinking

Definitions.h

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
11
#pragma once
22

33
// Normal colour definitions
4-
#define BLK "0;0;0"
5-
#define RED "255;0;0"
6-
#define GRN "22;198;12"
7-
#define YLW "231;186;0"
8-
#define BLU "0;0;255"
9-
#define MAG "136;23;152"
10-
#define CYN "58;150;221"
11-
#define WHT "242;242;242"
4+
std::string BLK = "0;0;0";
5+
std::string RED = "255;0;0";
6+
std::string GRN = "22;198;12";
7+
std::string YLW = "231;186;0";
8+
std::string BLU = "0;0;255";
9+
std::string MAG = "136;23;152";
10+
std::string CYN = "58;150;221";
11+
std::string WHT = "242;242;242";
1212

1313
// Bright colour definitions
14-
#define GRAY "118;118;118"
15-
#define LRED "231;72;86"
16-
#define LGRN "0;255;0"
17-
#define LYLW "255;255;0"
18-
#define LBLU "59;120;255"
19-
#define LMAG "180;0;158"
20-
#define LCYN "97;214;214"
21-
#define LWHT "255;255;255"
14+
std::string GRAY = "118;118;118";
15+
std::string LRED = "231;72;86";
16+
std::string LGRN = "0;255;0";
17+
std::string LYLW = "255;255;0";
18+
std::string LBLU = "59;120;255";
19+
std::string LMAG = "180;0;158";
20+
std::string LCYN = "97;214;214";
21+
std::string LWHT = "255;255;255";
2222

2323
// Text formatting definitions
2424
#define ULINE 4

Engine/MultimediaEngine.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -416,7 +416,7 @@ class MultimediaEngine {
416416
// Get position
417417
dCurrentPosition = BASS_ChannelBytes2Seconds(stream, BASS_ChannelGetPosition(stream, BASS_POS_BYTE));
418418
// Output position
419-
std::cout << "Media file: ";
419+
std::cout << "Audio file: ";
420420
colour(LCYN, sColourGlobalBack);
421421
std::cout << dCurrentPosition;
422422
colour(sColourGlobal, sColourGlobalBack);

Engine/OptionSelectEngine.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ class OptionSelectEngine {
120120
sHighlightBuffer = ">> " + sOptions[nIndex - 1] + " <<";
121121

122122
// 2. Get length of sBuffer. Put into nHighlightBuffer
123-
int nHighlightBuffer = sHighlightBuffer.length();
123+
size_t nHighlightBuffer = sHighlightBuffer.length();
124124

125125
// Only redraw options on first load - CPU optimisation, reduces flickering
126126
if (bReiterated == false)
@@ -221,8 +221,8 @@ class OptionSelectEngine {
221221
// exit with code -1 if ESC is pressed
222222
else if (nKey == 27) {
223223

224-
// Break if ESC pressed immediately, without any reiterations
225-
if (bReiterated == false) break;
224+
// Break if ESC pressed immediately, without any reiterations - for consoles with windows terminal bug #14774
225+
if (bReiterated == false && bConsoleBugGCSBI == true) break;
226226

227227
// Darken the index highlight to indicate that this OptionSelect session isn't being used anymore
228228
GetConsoleScreenBufferInfo(hOptionSelect, &csbiOptionSelect);

Engine/TableEngine.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ class TableEngine {
99
// GetLargestTableMemberSize - Gets the largest string out of an array of members passed into the function
1010
// Arguments: sMembers is for the array of members that are to be checked.
1111
// The biggest size is returned if successful, otherwise -1 is returned if an error occured.
12-
int GetColumnSize(std::vector<std::string> vsMembers) {
13-
int nLargestSize = 0;
12+
size_t GetColumnSize(std::vector<std::string> vsMembers) {
13+
size_t nLargestSize = 0;
1414

1515
for (int i = 0; i < vsMembers.size(); i++) {
1616
if (vsMembers[i].size() > nLargestSize) {

0 commit comments

Comments
 (0)