mirror of
https://github.com/ArthurSonzogni/FTXUI.git
synced 2025-12-16 01:48:56 +08:00
Compare commits
3 Commits
49ac5e546a
...
0e314cf1b9
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0e314cf1b9 | ||
|
|
fe86d06595 | ||
|
|
baa5973128 |
@@ -91,6 +91,40 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
<script type="module">
|
||||||
|
// Click on the navtree, except for the main page where this is already done
|
||||||
|
// automatically.
|
||||||
|
let delay = 0;
|
||||||
|
while(true) {
|
||||||
|
const navtree = document.querySelector("div.item.selected");
|
||||||
|
if (!navtree) {
|
||||||
|
delay *= 2;
|
||||||
|
delay += 1;
|
||||||
|
await new Promise(resolve => setTimeout(resolve, delay));
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Include only selected navtree items.
|
||||||
|
console.log("navtree.textContent", navtree.textContent);
|
||||||
|
if (!navtree.textContent.includes("Getting Started") &&
|
||||||
|
!navtree.textContent.includes("Installation") &&
|
||||||
|
!navtree.textContent.includes("Modules") &&
|
||||||
|
!navtree.textContent.includes("ftxui / screen") &&
|
||||||
|
!navtree.textContent.includes("ftxui / dom") &&
|
||||||
|
!navtree.textContent.includes("ftxui / component") &&
|
||||||
|
!navtree.textContent.includes("Reference")) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Find the first link inside the navtree.
|
||||||
|
const link = navtree.querySelector("a");
|
||||||
|
if (link) {
|
||||||
|
// Simulate a click on the link.
|
||||||
|
link.click();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
$treeview
|
$treeview
|
||||||
$search
|
$search
|
||||||
|
|||||||
@@ -48,25 +48,38 @@ Dimensions& FallbackSize() {
|
|||||||
return g_fallback_size;
|
return g_fallback_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* Safe(const char* c) {
|
|
||||||
return (c != nullptr) ? c : "";
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Contains(const std::string& s, const char* key) {
|
bool Contains(const std::string& s, const char* key) {
|
||||||
return s.find(key) != std::string::npos;
|
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() {
|
Terminal::Color ComputeColorSupport() {
|
||||||
#if defined(__EMSCRIPTEN__)
|
#if defined(__EMSCRIPTEN__)
|
||||||
return Terminal::Color::TrueColor;
|
return Terminal::Color::TrueColor;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
std::string COLORTERM = Safe(std::getenv("COLORTERM")); // NOLINT
|
std::string COLORTERM = getenv_safe("COLORTERM");
|
||||||
if (Contains(COLORTERM, "24bit") || Contains(COLORTERM, "truecolor")) {
|
if (Contains(COLORTERM, "24bit") || Contains(COLORTERM, "truecolor")) {
|
||||||
return Terminal::Color::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")) {
|
if (Contains(COLORTERM, "256") || Contains(TERM, "256")) {
|
||||||
return Terminal::Color::Palette256;
|
return Terminal::Color::Palette256;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user