mirror of
https://github.com/sam-astro/Z-Sharp.git
synced 2025-12-11 16:22:12 +00:00
Color printing text for windows
This commit is contained in:
parent
0350150563
commit
7a4464725f
@ -39,6 +39,12 @@
|
||||
}
|
||||
"Entry"
|
||||
{
|
||||
"MsmKey" = "8:_46D1C7842E24CD892F141F606320254D"
|
||||
"OwnerKey" = "8:_2441313DD4DA406BBC1915DDEE0AC74C"
|
||||
"MsmSig" = "8:_UNDEFINED"
|
||||
}
|
||||
"Entry"
|
||||
{
|
||||
"MsmKey" = "8:_4B23F888FF8342319507C8AAA3334953"
|
||||
"OwnerKey" = "8:_UNDEFINED"
|
||||
"MsmSig" = "8:_UNDEFINED"
|
||||
@ -75,12 +81,24 @@
|
||||
}
|
||||
"Entry"
|
||||
{
|
||||
"MsmKey" = "8:_B45D1C0CAD47E39747A5D61CA224DD63"
|
||||
"OwnerKey" = "8:_2441313DD4DA406BBC1915DDEE0AC74C"
|
||||
"MsmSig" = "8:_UNDEFINED"
|
||||
}
|
||||
"Entry"
|
||||
{
|
||||
"MsmKey" = "8:_EF059CAB8D2A4444B8233E61C53F3349"
|
||||
"OwnerKey" = "8:_UNDEFINED"
|
||||
"MsmSig" = "8:_UNDEFINED"
|
||||
}
|
||||
"Entry"
|
||||
{
|
||||
"MsmKey" = "8:_FE3DC1C6AB05AF8BE37B122F3511FF54"
|
||||
"OwnerKey" = "8:_2441313DD4DA406BBC1915DDEE0AC74C"
|
||||
"MsmSig" = "8:_UNDEFINED"
|
||||
}
|
||||
"Entry"
|
||||
{
|
||||
"MsmKey" = "8:_FEA298B841784CB2933DCEB504513792"
|
||||
"OwnerKey" = "8:_UNDEFINED"
|
||||
"MsmSig" = "8:_UNDEFINED"
|
||||
@ -232,6 +250,26 @@
|
||||
"IsDependency" = "11:FALSE"
|
||||
"IsolateTo" = "8:"
|
||||
}
|
||||
"{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_46D1C7842E24CD892F141F606320254D"
|
||||
{
|
||||
"SourcePath" = "8:VCRUNTIME140.dll"
|
||||
"TargetName" = "8:VCRUNTIME140.dll"
|
||||
"Tag" = "8:"
|
||||
"Folder" = "8:_BCDF457FF4564F7BBFD6AEF054FE16C2"
|
||||
"Condition" = "8:"
|
||||
"Transitive" = "11:FALSE"
|
||||
"Vital" = "11:TRUE"
|
||||
"ReadOnly" = "11:FALSE"
|
||||
"Hidden" = "11:FALSE"
|
||||
"System" = "11:FALSE"
|
||||
"Permanent" = "11:FALSE"
|
||||
"SharedLegacy" = "11:FALSE"
|
||||
"PackageAs" = "3:1"
|
||||
"Register" = "3:1"
|
||||
"Exclude" = "11:FALSE"
|
||||
"IsDependency" = "11:TRUE"
|
||||
"IsolateTo" = "8:"
|
||||
}
|
||||
"{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_4B23F888FF8342319507C8AAA3334953"
|
||||
{
|
||||
"SourcePath" = "8:..\\Releases\\ZSharp-Win-x64\\libpng16-16.dll"
|
||||
@ -352,6 +390,26 @@
|
||||
"IsDependency" = "11:FALSE"
|
||||
"IsolateTo" = "8:"
|
||||
}
|
||||
"{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_B45D1C0CAD47E39747A5D61CA224DD63"
|
||||
{
|
||||
"SourcePath" = "8:MSVCP140.dll"
|
||||
"TargetName" = "8:MSVCP140.dll"
|
||||
"Tag" = "8:"
|
||||
"Folder" = "8:_BCDF457FF4564F7BBFD6AEF054FE16C2"
|
||||
"Condition" = "8:"
|
||||
"Transitive" = "11:FALSE"
|
||||
"Vital" = "11:TRUE"
|
||||
"ReadOnly" = "11:FALSE"
|
||||
"Hidden" = "11:FALSE"
|
||||
"System" = "11:FALSE"
|
||||
"Permanent" = "11:FALSE"
|
||||
"SharedLegacy" = "11:FALSE"
|
||||
"PackageAs" = "3:1"
|
||||
"Register" = "3:1"
|
||||
"Exclude" = "11:FALSE"
|
||||
"IsDependency" = "11:TRUE"
|
||||
"IsolateTo" = "8:"
|
||||
}
|
||||
"{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_EF059CAB8D2A4444B8233E61C53F3349"
|
||||
{
|
||||
"SourcePath" = "8:..\\Releases\\ZSharp-Win-x64\\Pong-Example-Project\\script.zs"
|
||||
@ -372,6 +430,26 @@
|
||||
"IsDependency" = "11:FALSE"
|
||||
"IsolateTo" = "8:"
|
||||
}
|
||||
"{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_FE3DC1C6AB05AF8BE37B122F3511FF54"
|
||||
{
|
||||
"SourcePath" = "8:VCRUNTIME140_1.dll"
|
||||
"TargetName" = "8:VCRUNTIME140_1.dll"
|
||||
"Tag" = "8:"
|
||||
"Folder" = "8:_BCDF457FF4564F7BBFD6AEF054FE16C2"
|
||||
"Condition" = "8:"
|
||||
"Transitive" = "11:FALSE"
|
||||
"Vital" = "11:TRUE"
|
||||
"ReadOnly" = "11:FALSE"
|
||||
"Hidden" = "11:FALSE"
|
||||
"System" = "11:FALSE"
|
||||
"Permanent" = "11:FALSE"
|
||||
"SharedLegacy" = "11:FALSE"
|
||||
"PackageAs" = "3:1"
|
||||
"Register" = "3:1"
|
||||
"Exclude" = "11:FALSE"
|
||||
"IsDependency" = "11:TRUE"
|
||||
"IsolateTo" = "8:"
|
||||
}
|
||||
"{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_FEA298B841784CB2933DCEB504513792"
|
||||
{
|
||||
"SourcePath" = "8:..\\Releases\\ZSharp-Win-x64\\libfreetype-6.dll"
|
||||
@ -459,15 +537,15 @@
|
||||
{
|
||||
"Name" = "8:Microsoft Visual Studio"
|
||||
"ProductName" = "8:ZSharp"
|
||||
"ProductCode" = "8:{B75754F2-622A-4EEE-9B96-1D044E1D851A}"
|
||||
"PackageCode" = "8:{43E9A0EA-2D92-4C19-B840-BADB645A9016}"
|
||||
"ProductCode" = "8:{627A4201-79CB-478F-8428-14290415EB37}"
|
||||
"PackageCode" = "8:{CC2CE192-0CB8-470F-A41F-324CE6C0C71E}"
|
||||
"UpgradeCode" = "8:{8ABDE53F-7FF9-455B-A777-B4C1C624FA13}"
|
||||
"AspNetVersion" = "8:2.0.50727.0"
|
||||
"RestartWWWService" = "11:FALSE"
|
||||
"RemovePreviousVersions" = "11:TRUE"
|
||||
"DetectNewerInstalledVersion" = "11:TRUE"
|
||||
"InstallAllUsers" = "11:FALSE"
|
||||
"ProductVersion" = "8:2.0.0"
|
||||
"ProductVersion" = "8:2.0.1"
|
||||
"Manufacturer" = "8:Sam-Astro"
|
||||
"ARPHELPTELEPHONE" = "8:"
|
||||
"ARPHELPLINK" = "8:"
|
||||
|
||||
@ -4,6 +4,7 @@
|
||||
#include <string>
|
||||
#define DEVELOPER_MESSAGES false
|
||||
#define EXAMPLE_PROJECT false
|
||||
#define NAMEVERSION "ZSharp v2.0.1"
|
||||
|
||||
#if defined(__unix__)
|
||||
#define UNIX true
|
||||
@ -667,6 +668,9 @@ int parseZSharp(string script)
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
PrintColored(NAMEVERSION, blackFGColor, whiteBGColor, false);
|
||||
cout << endl << endl;
|
||||
|
||||
// Gathers builtin functions and variables
|
||||
GetBuiltins(ZSContents);
|
||||
functionValues = builtinFunctionValues;
|
||||
|
||||
139
ZSharp/builtin.h
139
ZSharp/builtin.h
@ -16,7 +16,9 @@
|
||||
#include "strops.h"
|
||||
#include "graphics.h"
|
||||
#include "anyops.h"
|
||||
#if WINDOWS
|
||||
#include "color.hpp"
|
||||
#endif
|
||||
|
||||
//#define DEVELOPER_MESSAGES false
|
||||
|
||||
@ -28,41 +30,42 @@ vector<string> types = { "int", "float", "string", "bool", "void", "null", "Spri
|
||||
unordered_map<string, vector<vector<string>>> builtinFunctionValues;
|
||||
unordered_map<string, boost::any> builtinVarVals;
|
||||
|
||||
// Foreground colors
|
||||
const std::string blackFGColor = "\x1B[30m";
|
||||
const std::string redFGColor = "\x1B[31m";
|
||||
const std::string greenFGColor = "\x1B[32m";
|
||||
const std::string yellowFGColor = "\x1B[33m";
|
||||
const std::string blueFGColor = "\x1B[34m";
|
||||
const std::string magentaFGColor = "\x1B[35m";
|
||||
const std::string cyanFGColor = "\x1B[36m";
|
||||
const std::string whiteFGColor = "\x1B[37m";
|
||||
const std::string brightBlackFGColor = "\x1B[90m";
|
||||
const std::string brightRedFGColor = "\x1B[91m";
|
||||
const std::string brightGreenFGColor = "\x1B[92m";
|
||||
const std::string brightYellowFGColor = "\x1B[93m";
|
||||
const std::string brightBlueFGColor = "\x1B[94m";
|
||||
const std::string brightMagentaFGColor = "\x1B[95m";
|
||||
const std::string brightCyanFGColor = "\x1B[96m";
|
||||
const std::string brightWhiteFGColor = "\x1B[97m";
|
||||
|
||||
//Background colors
|
||||
const std::string blackBGColor = "\x1B[40m";
|
||||
const std::string redBGColor = "\x1B[41m";
|
||||
const std::string greenBGColor = "\x1B[42m";
|
||||
const std::string yellowBGColor = "\x1B[43m";
|
||||
const std::string blueBGColor = "\x1B[44m";
|
||||
const std::string magentaBGColor = "\x1B[45m";
|
||||
const std::string cyanBGColor = "\x1B[46m";
|
||||
const std::string whiteBGColor = "\x1B[47m";
|
||||
const std::string brightBlackBGColor = "\x1B[100m";
|
||||
const std::string brightRedBGColor = "\x1B[101m";
|
||||
const std::string brightGreenBGColor = "\x1B[102m";
|
||||
const std::string brightYellowBGColor = "\x1B[103m";
|
||||
const std::string brightBlueBGColor = "\x1B[104m";
|
||||
const std::string brightMagentaBGColor = "\x1B[105m";
|
||||
const std::string brightCyanBGColor = "\x1B[106m";
|
||||
const std::string brightWhiteBGColor = "\x1B[107m";
|
||||
// Foreground colors
|
||||
const std::string blackFGColor = "\x1B[30m";
|
||||
const std::string redFGColor = "\x1B[31m";
|
||||
const std::string greenFGColor = "\x1B[32m";
|
||||
const std::string yellowFGColor = "\x1B[33m";
|
||||
const std::string blueFGColor = "\x1B[34m";
|
||||
const std::string magentaFGColor = "\x1B[35m";
|
||||
const std::string cyanFGColor = "\x1B[36m";
|
||||
const std::string whiteFGColor = "\x1B[37m";
|
||||
const std::string brightBlackFGColor = "\x1B[90m";
|
||||
const std::string brightRedFGColor = "\x1B[91m";
|
||||
const std::string brightGreenFGColor = "\x1B[92m";
|
||||
const std::string brightYellowFGColor = "\x1B[93m";
|
||||
const std::string brightBlueFGColor = "\x1B[94m";
|
||||
const std::string brightMagentaFGColor = "\x1B[95m";
|
||||
const std::string brightCyanFGColor = "\x1B[96m";
|
||||
const std::string brightWhiteFGColor = "\x1B[97m";
|
||||
//Background colors
|
||||
const std::string blackBGColor = "\x1B[40m";
|
||||
const std::string redBGColor = "\x1B[41m";
|
||||
const std::string greenBGColor = "\x1B[42m";
|
||||
const std::string yellowBGColor = "\x1B[43m";
|
||||
const std::string blueBGColor = "\x1B[44m";
|
||||
const std::string magentaBGColor = "\x1B[45m";
|
||||
const std::string cyanBGColor = "\x1B[46m";
|
||||
const std::string whiteBGColor = "\x1B[47m";
|
||||
const std::string brightBlackBGColor = "\x1B[100m";
|
||||
const std::string brightRedBGColor = "\x1B[101m";
|
||||
const std::string brightGreenBGColor = "\x1B[102m";
|
||||
const std::string brightYellowBGColor = "\x1B[103m";
|
||||
const std::string brightBlueBGColor = "\x1B[104m";
|
||||
const std::string brightMagentaBGColor = "\x1B[105m";
|
||||
const std::string brightCyanBGColor = "\x1B[106m";
|
||||
const std::string brightWhiteBGColor = "\x1B[107m";
|
||||
// Reset color
|
||||
const std::string resetColor = "\033[0m";
|
||||
|
||||
class NullType {
|
||||
public:
|
||||
@ -87,32 +90,46 @@ float lerp(float a, float b, float f)
|
||||
void PrintColored(std::string text, std::string fgColor, std::string bgColor, bool isError)
|
||||
{
|
||||
#if WINDOWS
|
||||
auto fg = dye::white(text);
|
||||
if (fgColor == blackFGColor)
|
||||
fg = dye::black(text);
|
||||
cerr << hue::black;
|
||||
else if (fgColor == redFGColor)
|
||||
fg = dye::red(text);
|
||||
cerr << hue::red;
|
||||
else if (fgColor == greenFGColor)
|
||||
fg = dye::green(text);
|
||||
cerr << hue::green;
|
||||
else if (fgColor == yellowFGColor)
|
||||
fg = dye::yellow(text);
|
||||
cerr << hue::yellow;
|
||||
else if (fgColor == blueFGColor)
|
||||
fg = dye::blue(text);
|
||||
cerr << hue::blue;
|
||||
else if (fgColor == magentaFGColor)
|
||||
fg = dye::purple(text);
|
||||
cerr << hue::purple;
|
||||
else if (fgColor == cyanFGColor)
|
||||
fg = dye::aqua(text);
|
||||
cerr << hue::aqua;
|
||||
else if (fgColor == whiteFGColor)
|
||||
fg = dye::white(text);
|
||||
if(!isError)
|
||||
std::cout << fg;
|
||||
else
|
||||
std::cerr << fg;
|
||||
cerr << hue::white;
|
||||
|
||||
if (bgColor == blackBGColor)
|
||||
cerr << hue::on_black;
|
||||
else if (bgColor == redBGColor)
|
||||
cerr << hue::on_red;
|
||||
else if (bgColor == greenBGColor)
|
||||
cerr << hue::on_green;
|
||||
else if (bgColor == yellowBGColor)
|
||||
cerr << hue::on_yellow;
|
||||
else if (bgColor == blueBGColor)
|
||||
cerr << hue::on_blue;
|
||||
else if (bgColor == magentaBGColor)
|
||||
cerr << hue::on_purple;
|
||||
else if (bgColor == cyanBGColor)
|
||||
cerr << hue::on_aqua;
|
||||
else if (bgColor == whiteBGColor)
|
||||
cerr << hue::on_white;
|
||||
|
||||
std::cerr << text << hue::reset;
|
||||
#else
|
||||
if(!isError)
|
||||
cout << fgColor + bgColor + name + resetColor;
|
||||
if (!isError)
|
||||
cout << fgColor + bgColor + text + resetColor;
|
||||
else
|
||||
cerr << fgColor + bgColor + name + resetColor;
|
||||
cerr << fgColor + bgColor + text + resetColor;
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -134,9 +151,9 @@ int InterpreterLog(const string& logText)
|
||||
time_t timer = time(0);
|
||||
|
||||
tm bt{};
|
||||
#if defined(__unix__)
|
||||
#if UNIX
|
||||
//localtime_r(&timer, &bt);
|
||||
#elif defined(_MSC_VER)
|
||||
#elif WINDOWS
|
||||
localtime_s(&bt, &timer);
|
||||
Hour = bt.tm_hour;
|
||||
Min = bt.tm_min;
|
||||
@ -147,9 +164,9 @@ int InterpreterLog(const string& logText)
|
||||
bt = *localtime(&timer);
|
||||
#endif
|
||||
|
||||
PrintColored("[" + to_string(Hour) + ":" + to_string(Min) + ":" + to_string(Sec) + "] ", blueFGColor, "");
|
||||
PrintColored("ZSharp: ", yellowFGColor, "");
|
||||
PrintColored(logText, greenFGColor, "");
|
||||
PrintColored("[" + to_string(Hour) + ":" + to_string(Min) + ":" + to_string(Sec) + "] ", blueFGColor, "", true);
|
||||
PrintColored("ZSharp: ", yellowFGColor, "", true);
|
||||
PrintColored(logText, greenFGColor, "", true);
|
||||
cout << std::endl;
|
||||
//cout << "\x1B[34m[" + to_string(Hour) + ":" + to_string(Min) + ":" + to_string(Sec) + "] \x1B[33mZSharp: \x1B[32m" << logText << "\033[0m\t\t" << endl;
|
||||
return 1;
|
||||
@ -176,9 +193,9 @@ int LogCriticalError(const string& errorText)
|
||||
bt = *localtime(&timer);
|
||||
#endif
|
||||
|
||||
PrintColoredErr("[" + to_string(Hour) + ":" + to_string(Min) + ":" + to_string(Sec) + "] ", blueFGColor, "", true);
|
||||
PrintColoredErr("ZSharp: ", yellowFGColor, "", true);
|
||||
PrintColoredErr(errorText, redFGColor, "", true);
|
||||
PrintColored("[" + to_string(Hour) + ":" + to_string(Min) + ":" + to_string(Sec) + "] ", blueFGColor, "", true);
|
||||
PrintColored("ZSharp: ", yellowFGColor, "", true);
|
||||
PrintColored(errorText, redFGColor, "", true);
|
||||
cerr << std::endl;
|
||||
//cerr << "\x1B[34m[" + to_string(Hour) + ":" + to_string(Min) + ":" + to_string(Sec) + "] \x1B[33mZSharp: \x1B[31mERROR: " << errorText << "\033[0m\t\t" << endl;
|
||||
exit(EXIT_FAILURE);
|
||||
@ -297,7 +314,7 @@ int GetBuiltins(std::string s)
|
||||
}
|
||||
builtinFunctionValues[functName] = functionContents;
|
||||
//cout << functName << " is \n" << Vec2Str(functionContents) << endl << endl;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (words.at(lineNum).at(0) == "string")
|
||||
@ -334,7 +351,7 @@ int GetBuiltins(std::string s)
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
// Executes
|
||||
boost::any ZSFunction(const string& name, const vector<boost::any>& args)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user