void me(string args) { if (!hasSetup) { if (streql(splitArg(args, 1), "-H")) { // a super legit help section brought to you by @plankp print("\nMe is here to help you... Believe me...", brown); } else if (streql(splitArg(args, 1), "TEST") && !hasSetup) { hasSetup = true; messageBox("\nYou have skipped the Me setup process."); } else if (!hasSetup) { meHeader(); messageBox("\nWelcome to Me. To start using Me,\n\rpress <RET> to setup Me."); meHeader(); name = messageBox_I("What is your name?"); meHeader(); while (!birthYearValid) { birthYear = messageBox_I("What year were you born in?"); birthYearInt = stoi(birthYear); // need to make this always the current year + 1 if (birthYearInt < getTime("year") && birthYearInt > 1900) { birthYearValid = true; goodAnswer(); } if (!birthYearValid) { badAnswer(); } } meHeader(); while (!birthDateValid) { newline(); birthDate = messageBox_I("What day were you born on"); birthDateInt = stoi(birthDate); if (birthDateInt < 32) { birthDateValid = true; goodAnswer(); } if (!birthDateValid) { badAnswer(); } } meHeader(); while (!birthMonthValid) { newline(); birthMonth = messageBox_I("What month were you born in?"); birthMonth = toUpper(birthMonth); if (findInDictionary("me/setup/month.text",birthMonth)) { birthMonthValid = true; goodAnswer(); } if (!birthMonthValid) { badAnswer(); } } meHeader(); while (!continentValid) { newline(); continent = messageBox_I("What continent do you live in?"); continent = toUpper(continent); if (findInDictionary("me/setup/continent.text",continent)) { continentValid = true; goodAnswer(); } if (!continentValid) { badAnswer(); } } meHeader(); while (!countryValid) { newline(); country = messageBox_I("What country do you live in?"); country = toUpper(country); if (findInDictionary("me/setup/country.text",country)) { countryValid = true; goodAnswer(); } if (!countryValid) { badAnswer(); } } meHeader(); while (!stateValid) { newline(); state = messageBox_I("What state/province do you live in?"); state = toUpper(state); if (findInDictionary("me/setup/state.text",state)) { stateValid = true; goodAnswer(); } if (!stateValid) { badAnswer(); } } meHeader(); newline(); city = messageBox_I("What city/town do you live in?"); clearLine(0,26,0x88); drawFrame(header_background, 20, 8, 60, 11); printAt("Me Setup Process", 0x3D, 21, 9); while (!zipValid) { newline(); zip = messageBox_I("What is your zip/post code?"); zipInt = htoi(zip); if (zipInt > 0) { zipValid = true; goodAnswer(); } else { badAnswer(); } } meHeader(); hasSetup = "true"; messageBox("Me is now ready to use! Type 'me' on\n\rthe command line to begin."); printIntro(); drawBorder(screen_background, 0, 4, 80, sh - 1); actualY = 5; printAt("Q-Kernel> ", light_grey, 1, actualY); } else { print("\nYou have already completed the setup process for Me!",purple); } } else if (streql(splitArg(args, 1),"")) { querying = true; string meArgs = NULL; while (querying) { newline(); //meArgs = ""; print("me> ",green); meArgs = readstr(); print(answer(meArgs,0),red); } } else { answer(args,1); } }
void launchShell() { initialize_calc(); //allocate some memory for command string buffer. 1kB should be enough for now const int bufSize = 128; char bufStr[bufSize];//Store sanitized user command (no arguments) char rawCommand[bufSize];//Gets user raw command from command line char arguments[bufSize/2][bufSize/2];//Store command arguments int fs = 1;//First space (first word means actual command) int ay = -1;//Y location for arguments int ax = 0;//X location for argumetns //prepare variable for(int i = 0; i < bufSize; ++i){ bufStr[i] = 0; } for(int y = 0; y < bufSize; ++y){ for(int x = 0; x < bufSize; ++x){ arguments[y][x] = 0; } } #define TIP print("\nTip: If enter key does not work, it might mean that the input is too long",0x0F); #define HELP print("\nWorking Commands in Q OS: \nwriter\nclear\nexecute\nhi\nskip (the no action)\nfiles\ncat\nreboot\ncalc", 0x0F); #define BIGHELP kbHelp(); TIP; HELP; #define SYSTEMMAN system(arguments); #define SAYHI print("\nHello!", 0x3F); #define CATFILE print("\nFile Name> ", 0x0F); readStr(bufStr, bufSize); ASSERT(strlength(bufStr) < MAX_FNAME_LEN); cat(finddir_fs(fs_root, bufStr)); #define SWITCHDIR print("\nThe specified directory was not found ", 0x0F); #define CALCULATE calc(arguments); #define BIGCLEAR clearScreen(); printIntro(); #define MKDIR print("\nThis Command is Reserved for when we have a FAT32 or better FileSystem...", 0x3F); #define RMFILE print("\nThis Command is Reserved for when we have a FAT32 or better FileSystem...", 0x3F); #define SKIP skip(rawCommand); #define FILEMAN files(arguments); #define WRITE writer(arguments); #define ME me(rawCommand); #define CMDNOTFOUND print("\n", 0x0F); print(bufStr, 0x0F); print(": Command Not Found ", 0x0F); while (true) { print("\nQ-Kernel> ", 0x08); typingCmd = true; newCmd = true; readStr(rawCommand, bufSize); typingCmd = false; for(int i = 0; i < bufSize; ++i){ bufStr[i] = 0; } for(int y = 0; y < bufSize; ++y){ for(int x = 0; x < bufSize; ++x){ arguments[y][x] = 0; } } fs = 1; ay = -1; ax = 0; if(MULTI_ARG_DEBUG == true) { //Sanitize raw input. Move first word to bufStr and move the rest of the word to arguments for(int i = 0; i < bufSize; ++i) { if(rawCommand[i] != 0 || rawCommand[i] != 10) { if(fs == 1) bufStr[i] = rawCommand[i]; else if(fs == 0) arguments[ay][ax] = rawCommand[i]; if(i < bufSize && rawCommand[i+1] == 32) { fs = 0; ay++; } } else break; } } else { //Sanitize raw input. Move first word to bufStr and move the rest of the word to arguments for(int i = 0; i < bufSize; ++i) { if(rawCommand[i] != 0 || rawCommand[i] != 10) { if(fs == 1) bufStr[i] = rawCommand[i]; if(i < bufSize && rawCommand[i+1] == 32) { fs = 0; ay++; ax = 0; } else if(fs == 0) { arguments[ay][ax] = rawCommand[i]; ax++; } } else break; } } if (strEql(strTrim(bufStr), "")) { HELP; } else if(strEql(bufStr, "help")) { BIGHELP; } else if(strEql(bufStr, "system")) { SYSTEMMAN; } else if(strEql(bufStr, "skip")) { SKIP; } else if(strEql(bufStr, "hi")) { SAYHI; } else if(strEql(bufStr, "files")) { FILEMAN; } else if(strEql(bufStr, "cat")) { CATFILE; } else if(strEql(bufStr,"execute")) { execute(); } else if(strEql(bufStr,"switch")) { SWITCHDIR; } else if(strEql(bufStr,"writer")) { WRITE; } else if(strEql(bufStr, "calc")) { CALCULATE; } else if(strEql(bufStr, "clear")) { clearScreen(); } else if(strEql(bufStr, "clear -i")) { BIGCLEAR; } else if(strEql(bufStr, "newdir")) { MKDIR; } else if(strEql(bufStr, "erase")) { RMFILE; } else if(strEql(bufStr, "me")) { ME; } else if(strEql(bufStr, "search")) { print("\nDictionary File Name> ", 0x0F); readStr(bufStr, bufSize); ASSERT(strlength(bufStr) < MAX_FNAME_LEN); findInDictionary(finddir_fs(fs_root, bufStr),1013,"ACCEPT"); } else { CMDNOTFOUND; } newline(); } }