chg renable win ansi test. trying turning offlogging. @doegox can refacor this away when we get a prefs.json settings file

This commit is contained in:
iceman1001 2019-10-16 14:46:57 +02:00
commit 5737355985
2 changed files with 38 additions and 33 deletions

View file

@ -154,9 +154,11 @@ void CmdsHelp(const command_t Commands[]) {
if (Commands[0].Name == NULL) return; if (Commands[0].Name == NULL) return;
int i = 0; int i = 0;
while (Commands[i].Name) { while (Commands[i].Name) {
if (Commands[i].IsAvailable()) if (Commands[i].IsAvailable()) {
// PrintAndLogEx(NORMAL, _GREEN_("%-16s")" %s", Commands[i].Name, Commands[i].Help); g_printAndLog = PRINTANDLOG_PRINT;
PrintAndLogEx(NORMAL, _GREEN_("%-16s")" %s", Commands[i].Name, Commands[i].Help); PrintAndLogEx(NORMAL, _GREEN_("%-16s")" %s", Commands[i].Name, Commands[i].Help);
g_printAndLog = PRINTANDLOG_PRINT | PRINTANDLOG_LOG;
}
++i; ++i;
} }
} }

View file

@ -29,6 +29,8 @@
static void showBanner(void) { static void showBanner(void) {
g_printAndLog = PRINTANDLOG_PRINT;
PrintAndLogEx(NORMAL, "\n"); PrintAndLogEx(NORMAL, "\n");
#if defined(__linux__) || (__APPLE__) || (_WIN32) #if defined(__linux__) || (__APPLE__) || (_WIN32)
PrintAndLogEx(NORMAL, _BLUE_("██████╗ ███╗ ███╗ ████╗ ") " ...iceman fork"); PrintAndLogEx(NORMAL, _BLUE_("██████╗ ███╗ ███╗ ████╗ ") " ...iceman fork");
@ -50,6 +52,8 @@ static void showBanner(void) {
// printf("\nMonero: 43mNJLpgBVaTvyZmX9ajcohpvVkaRy1kbZPm8tqAb7itZgfuYecgkRF36rXrKFUkwEGeZedPsASRxgv4HPBHvJwyJdyvQuP"); // printf("\nMonero: 43mNJLpgBVaTvyZmX9ajcohpvVkaRy1kbZPm8tqAb7itZgfuYecgkRF36rXrKFUkwEGeZedPsASRxgv4HPBHvJwyJdyvQuP");
PrintAndLogEx(NORMAL, "\n"); PrintAndLogEx(NORMAL, "\n");
fflush(stdout); fflush(stdout);
g_printAndLog = PRINTANDLOG_PRINT | PRINTANDLOG_LOG;
} }
int check_comm(void) { int check_comm(void) {
@ -466,6 +470,35 @@ finish2:
return ret; return ret;
} }
// Check if windows AnsiColor Support is enabled in the registery
// [HKEY_CURRENT_USER\Console]
// "VirtualTerminalLevel"=dword:00000001
static bool DetectWindowsAnsiSupport(void) {
bool ret = false;
#if defined(_WIN32)
HKEY hKey = NULL;
if (RegOpenKeyA(HKEY_CURRENT_USER, "Console", &hKey) == ERROR_SUCCESS) {
DWORD dwType = REG_SZ;
BYTE KeyValue[sizeof(dwType)];
DWORD len = sizeof(KeyValue);
if (RegQueryValueEx(hKey, "VirtualTerminalLevel", NULL, &dwType, KeyValue, &len) != ERROR_FILE_NOT_FOUND) {
uint8_t i;
uint32_t Data = 0;
for (i = 0; i < 4; i++)
Data += KeyValue[i] << (8 * i);
if (Data == 1) { // Reg key is set to 1, Ansi Color Enabled
ret = true;
}
}
RegCloseKey(hKey);
}
#endif
return ret;
}
int main(int argc, char *argv[]) { int main(int argc, char *argv[]) {
srand(time(0)); srand(time(0));
@ -683,37 +716,7 @@ int main(int argc, char *argv[]) {
return 1; return 1;
} }
session.supports_colors = false; session.supports_colors = DetectWindowsAnsiSupport();
/*
// Removed color on windows until a better option can be implemented.
#if defined(_WIN32)
// Check if windows AnsiColor Support is enabled in the registery
// [HKEY_CURRENT_USER\Console]
// "VirtualTerminalLevel"=dword:00000001
HKEY hKey = NULL;
if (RegOpenKeyA(HKEY_CURRENT_USER, "Console", &hKey) == ERROR_SUCCESS) {
DWORD dwType = REG_SZ;
BYTE KeyValue[sizeof(dwType)];
DWORD len = sizeof(KeyValue);
if (RegQueryValueEx(hKey, "VirtualTerminalLevel", NULL, &dwType, KeyValue, &len) != ERROR_FILE_NOT_FOUND) {
uint8_t i;
uint32_t Data = 0;
for (i = 0; i < 4; i++)
Data += KeyValue[i] << (8 * i);
if (Data == 1) { // Reg key is set to 1, Ansi Color Enabled
session.supports_colors = true;
}
}
RegCloseKey(hKey);
}
#endif
*/
session.stdinOnTTY = isatty(STDIN_FILENO); session.stdinOnTTY = isatty(STDIN_FILENO);
session.stdoutOnTTY = isatty(STDOUT_FILENO); session.stdoutOnTTY = isatty(STDOUT_FILENO);