Skip to content

Commit d6a48ad

Browse files
- The Echo and Title commands have been redesigned to now use data string arguments for input. How this works is that any string with spaces has to be quoted (e.g echo "Hello World" is quoted) to be outputted in the exact way it was written. However, if you include 2 or more strings separately (up to 128 strings), they are automatically concatenated (e.g "echo test hello cool" would output "testhellocool"). This allows for the introduction of help pages for both commands.
- The Echo and Title commands have been redesigned to now include help pages! This feature inclusion in these commands improves their accessibility towards people that don't know how they work. The help command has been slightly modified to reflect this.
1 parent ebc4429 commit d6a48ad

File tree

3 files changed

+83
-25
lines changed

3 files changed

+83
-25
lines changed

CommandFiles/CommandFileAssets.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ void help(bool bFromTutorial) {
223223
colourSubheading();
224224
std::cout << wordWrap("___LIST OF COMMANDS___") << NOULINE_STR;
225225
colour(LCYN, ConfigObjMain.sColourGlobalBack);
226-
std::cout << wordWrap("\n\nTo see more info about a command, type in \"<command> -h\". This will work for all commands, except: echo and title.\n\n");
226+
std::cout << wordWrap("\n\nTo see more info about a command, type in \"<command> -h\". Put the command in the place of <command> here.\n\n");
227227
colour(ConfigObjMain.sColourGlobal, ConfigObjMain.sColourGlobalBack);
228228

229229
// Output help commands

CommandFiles/CommandHelpMessages.cpp

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,26 @@ namespace helpmsgs
4141
return;
4242
}
4343

44+
// Echo
45+
void EchoHelp() {
46+
CentreColouredText(" ___ECHO___ ", 1);
47+
std::cout << "\n";
48+
CentreColouredText("This command allows you to output any text of your liking.", 2);
49+
std::cout << "\n\n";
50+
51+
colourSubheading();
52+
std::cout << "What this command does:" << NOULINE_STR;
53+
colour(ConfigObjMain.sColourGlobal, ConfigObjMain.sColourGlobalBack);
54+
std::cout << wordWrap("\n- This command allows you to output desired text of your liking.\n- This, as the name suggests, 'echoes' the text that you write to it.\n\n");
55+
56+
colourSubheading();
57+
std::cout << "Possible arguments for this command:" << NOULINE_STR;
58+
colour(ConfigObjMain.sColourGlobal, ConfigObjMain.sColourGlobalBack);
59+
std::cout << wordWrap("\n -h\tDisplays this help message.\n <text>\tThe text to echo. Put the text in place of <text>.\n\nExample: echo \"Hello, World!\"\n\nNOTE: If the text contains spaces, use quotes like in the example.\n\n");
60+
61+
return;
62+
}
63+
4464
// Cls
4565
void ClsHelp() {
4666
CentreColouredText(" ___CLS___ ", 1);
@@ -188,6 +208,26 @@ namespace helpmsgs
188208
return;
189209
}
190210

211+
// Title
212+
void TitleHelp() {
213+
CentreColouredText(" ___TITLE___ ", 1);
214+
std::cout << "\n";
215+
CentreColouredText("This command allows you to set the title of the current window running ZeeTerminal.", 2);
216+
std::cout << "\n\n";
217+
218+
colourSubheading();
219+
std::cout << "What this command does:" << NOULINE_STR;
220+
colour(ConfigObjMain.sColourGlobal, ConfigObjMain.sColourGlobalBack);
221+
std::cout << wordWrap("\n- This command allows you to set the title of this window, which is the window running ZeeTerminal.\n- The title can only be a maximum of 256 characters.\n\n");
222+
223+
colourSubheading();
224+
std::cout << "Possible arguments for this command:" << NOULINE_STR;
225+
colour(ConfigObjMain.sColourGlobal, ConfigObjMain.sColourGlobalBack);
226+
std::cout << wordWrap("\n -h\tDisplays this help message.\n <title>\tThe title to set. Put the title in place of <title>.\n\nExample: title \"Test Title\"\n\nNOTE: If the title contains spaces, use quotes like the example.\n\n");
227+
228+
return;
229+
}
230+
191231
// Date
192232
void DateHelp() {
193233
CentreColouredText(" ___DATE___ ", 1);

CommandFiles/CommandsFiles/CommandsFile_1to10.cpp

Lines changed: 42 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -52,16 +52,29 @@ bool commands::Commands1To10(const std::string sCommand, char* cCommandArgs, con
5252

5353
// Echo
5454
else if (sCommand == "echo" || sCommand == "4") {
55+
std::string sEchoString = "";
5556

56-
// Output what is after echo
57-
if (sCommandArgsBuffer != " ") {
58-
std::cout << sCommandArgsBuffer;
57+
// Arguments Interface
58+
for (int i = 0; i < nArgArraySize; i++) {
59+
if (cCommandArgs[i] == 'h') {
60+
helpmsgs::EchoHelp();
61+
return true;
62+
}
63+
64+
// Concatenate all data argument strings
65+
sEchoString += sStringDataCommandArgs[i];
5966
}
67+
6068
// Output what user wants to input within echo
69+
if (sEchoString == "") {
70+
sEchoString = StrInput("Input what you would like ZeeTerminal to echo (output): > ");
71+
72+
// Output the input
73+
std::cout << sEchoString << std::endl;
74+
}
6175
else {
62-
std::string sEcho = StrInput("Input what you would like ZeeTerminal to output: > ");
6376
// Output the input
64-
std::cout << sEcho << std::endl;
77+
std::cout << sEchoString;
6578
}
6679

6780
return true;
@@ -933,32 +946,37 @@ bool commands::Commands1To10(const std::string sCommand, char* cCommandArgs, con
933946

934947
// Title
935948
else if (sCommand == "title" || sCommand == "10") {
949+
std::string sTitle = "";
936950

937-
if (sCommandArgsBuffer == " ") {
951+
// Arguments Interface
952+
for (int i = 0; i < nArgArraySize; i++) {
953+
if (cCommandArgs[i] == 'h') {
954+
helpmsgs::TitleHelp();
955+
return true;
956+
}
957+
958+
// Concatenate all data arguments
959+
sTitle += sStringDataCommandArgs[i];
960+
}
961+
962+
// User UI
963+
if (sTitle == "") {
938964
CentreColouredText(" ___TITLE___ ", 1);
939965
std::cout << "\n";
940966

941967
// Take title input
942-
std::string sTitle = StrInput("Please input your desired title (256 characters max): > ");
943-
// Set window title using WindowTitleSet engine function
944-
if (SetWindowTitle(sTitle)) {
945-
colour(LGRN, ConfigObjMain.sColourGlobalBack);
946-
std::cout << wordWrap("Setting console window title succeeded!\n");
947-
colour(ConfigObjMain.sColourGlobal, ConfigObjMain.sColourGlobalBack);
948-
}
949-
else {
950-
UserErrorDisplay("Setting console window title failed!\nPlease check if your title is too long. It cannot be longer than 256 characters.\n");
951-
}
968+
sTitle = StrInput("Please input your desired title (256 characters max): > ");
969+
}
970+
971+
// Set the window title
972+
if (SetWindowTitle(sTitle)) {
973+
colour(LGRN, ConfigObjMain.sColourGlobalBack);
974+
std::cout << wordWrap("Setting console window title succeeded!\n");
975+
colour(ConfigObjMain.sColourGlobal, ConfigObjMain.sColourGlobalBack);
952976
}
953977
else {
954-
if (SetWindowTitle(sCommandArgsBuffer)) {
955-
colour(LGRN, ConfigObjMain.sColourGlobalBack);
956-
std::cout << wordWrap("Setting console window title succeeded!\n");
957-
colour(ConfigObjMain.sColourGlobal, ConfigObjMain.sColourGlobalBack);
958-
}
959-
else {
960-
UserErrorDisplay("Setting console window title failed!\nPlease check if your title is too long. It cannot be longer than 256 characters.\n");
961-
}
978+
// Failed - too long of a string
979+
UserErrorDisplay("Setting console window title failed!\nPlease check if your title is too long. It cannot be longer than 256 characters.\n");
962980
}
963981

964982
return true;

0 commit comments

Comments
 (0)