mirror of
https://github.com/geode-sdk/geode.git
synced 2025-04-24 13:23:50 -04:00
add support for forcing terminal colors via env variable GEODE_FORCE_ENABLE_TERMINAL_COLORS
This commit is contained in:
parent
3bdff36baf
commit
39b1beffe4
5 changed files with 30 additions and 2 deletions
loader
|
@ -157,6 +157,8 @@ namespace geode {
|
|||
* On most platforms this is 1.0, but on retina displays for example this returns 2.0.
|
||||
*/
|
||||
GEODE_DLL float getDisplayFactor();
|
||||
|
||||
GEODE_DLL std::string getEnvironmentVariable(const char* name);
|
||||
}
|
||||
|
||||
template <class... Args>
|
||||
|
|
|
@ -393,3 +393,8 @@ std::string geode::utils::thread::getDefaultName() {
|
|||
void geode::utils::thread::platformSetName(std::string const& name) {
|
||||
pthread_setname_np(pthread_self(), name.c_str());
|
||||
}
|
||||
|
||||
std::string geode::utils::getEnvironmentVariable(const char* name) {
|
||||
auto result = std::getenv(name);
|
||||
return result ? result : "";
|
||||
}
|
||||
|
|
|
@ -351,4 +351,9 @@ float geode::utils::getDisplayFactor() {
|
|||
}
|
||||
}
|
||||
return displayScale;
|
||||
}
|
||||
}
|
||||
|
||||
std::string geode::utils::getEnvironmentVariable(const char* name) {
|
||||
auto result = std::getenv(name);
|
||||
return result ? result : "";
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
#include <loader/LogImpl.hpp>
|
||||
#include <io.h>
|
||||
#include <Geode/utils/string.hpp>
|
||||
#include <Geode/utils/general.hpp>
|
||||
|
||||
using namespace geode::prelude;
|
||||
|
||||
|
@ -127,7 +128,12 @@ void console::setup() {
|
|||
}
|
||||
|
||||
// clion console supports escape codes but we can't query that because it's a named pipe
|
||||
setupConsole(string::contains(path, "cidr-"));
|
||||
// allow the user to forcefully enable colors via an environment variable too
|
||||
|
||||
setupConsole(
|
||||
string::contains(path, "cidr-")
|
||||
|| geode::utils::getEnvironmentVariable("GEODE_FORCE_ENABLE_TERMINAL_COLORS") == "1"
|
||||
);
|
||||
}
|
||||
|
||||
auto oldStdout = _dup(_fileno(stdout));
|
||||
|
|
|
@ -319,3 +319,13 @@ void geode::utils::thread::platformSetName(std::string const& name) {
|
|||
}
|
||||
obliterate(name);
|
||||
}
|
||||
|
||||
std::string geode::utils::getEnvironmentVariable(const char* name) {
|
||||
char buffer[1024];
|
||||
size_t count = 0;
|
||||
if (0 == getenv_s(&count, buffer, name) && count != 0) {
|
||||
return buffer;
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue