Compare commits

...

3 Commits

Author SHA1 Message Date
Alex
a70f80cb8f
Merge baa5973128 into dfb9558eaf 2024-08-28 10:57:24 +03:00
ljrrjl
dfb9558eaf
add ftxui-image-view (#924)
Some checks failed
Build / Tests (gcc, gcov, Linux GCC, ubuntu-latest) (push) Failing after 6m43s
Build / Tests (llvm, llvm-cov gcov, Linux Clang, ubuntu-latest) (push) Successful in 6m22s
Build / documentation (push) Failing after 1m5s
Build / Tests (cl, Windows MSVC, windows-latest) (push) Has been cancelled
Build / Create release (push) Has been cancelled
Build / Build packages (build/ftxui*Darwin*, macos-latest) (push) Has been cancelled
Build / Build packages (build/ftxui*Linux*, ubuntu-latest) (push) Has been cancelled
Build / Build packages (build/ftxui*Win64*, windows-latest) (push) Has been cancelled
CodeQL / Analyze (cpp) (push) Failing after 35s
2024-08-27 14:35:15 +02:00
alexv-ds
baa5973128
msvc getenv deprecation warn fix 2024-07-18 18:34:34 +03:00
2 changed files with 20 additions and 6 deletions

View File

@ -296,6 +296,7 @@ Prebuilt components are declared in [<ftxui/component/component.hpp>](https://ar
- *Want to share a useful Component for FTXUI? Feel free to add yours here*
- [ftxui-grid-container](https://github.com/mingsheng13/grid-container-ftxui)
- [ftxui-ip-input](https://github.com/mingsheng13/ip-input-ftxui)
- [ftxui-image-view](https://github.com/ljrrjl/ftxui-image-view.git): For Image Display.
## Project using FTXUI

View File

@ -48,25 +48,38 @@ Dimensions& FallbackSize() {
return g_fallback_size;
}
const char* Safe(const char* c) {
return (c != nullptr) ? c : "";
}
bool Contains(const std::string& s, const char* key) {
return s.find(key) != std::string::npos;
}
// https://github.com/gabime/spdlog/blob/885b5473e291833b148eeac3b7ce227e582cd88b/include/spdlog/details/os-inl.h#L566
std::string getenv_safe(const char *field) {
#if defined(_MSC_VER)
#if defined(__cplusplus_winrt)
return std::string{}; // not supported under uwp
#else
size_t len = 0;
char buf[1024];
bool ok = ::getenv_s(&len, buf, sizeof(buf), field) == 0;
return ok ? buf : std::string{};
#endif
#else // revert to getenv
char *buf = ::getenv(field); // NOLINT(*-mt-unsafe)
return buf ? buf : std::string{};
#endif
}
Terminal::Color ComputeColorSupport() {
#if defined(__EMSCRIPTEN__)
return Terminal::Color::TrueColor;
#endif
std::string COLORTERM = Safe(std::getenv("COLORTERM")); // NOLINT
std::string COLORTERM = getenv_safe("COLORTERM");
if (Contains(COLORTERM, "24bit") || Contains(COLORTERM, "truecolor")) {
return Terminal::Color::TrueColor;
}
std::string TERM = Safe(std::getenv("TERM")); // NOLINT
std::string TERM = getenv_safe("TERM");
if (Contains(COLORTERM, "256") || Contains(TERM, "256")) {
return Terminal::Color::Palette256;
}