ξQuentξ
Anyone knows how to code a Color Syntax?
I also haave this old script where i tryed to script a color scheme but it failed badly:
private Color GetTokenColor(string token)
{
if (token.TrimStart().StartsWith(":"))
return Color.Red; // Color for labels
if (IsCommand(token, "echo", "pause", "time", "ping", "cls"))
return Color.FromArgb(0, 183, 255); // Command color
if (IsCommand(token, "cd", "dir", "rename", "ren", "replace", "xcopy", "del", "move", "rmdir"))
return Color.FromArgb(13, 112, 0); // File system command color
if (IsBracket(token))
return Color.FromArgb(30, 255, 0); // Bracket color
if (IsCommand(token, "powershell", "dxdiag", "chkdsk", "diskpart", "mrt", "explorer", "eventvwr", "taskschd", "taskmgr", "mmc", "bcdedit"))
return Color.FromArgb(68, 0, 255); // Special command color
if (IsCommand(token, "call", "goto", "errorlevel", "com1", "com2", "com3", "com4", "com", "ipconfig", "cacls", "icacls"))
return Color.FromArgb(0, 17, 255); // Another command color
return ScriptingPane.ForeColor; // Default color
}
private bool IsBracket(string token) =>
token.Contains("(") token.Contains(")") token.Contains("[") token.Contains("]") token.Contains("{") || token.Contains("}");
private bool IsCommand(string token, params string[] commands)
{
foreach (var command in commands)
{
if (token.Equals(command, StringComparison.OrdinalIgnoreCase))
return true;
}
return false;
}
}
}
14 replies