Add support for emscripten screen resize. (#463)

This resolves:
https://github.com/ArthurSonzogni/FTXUI/issues/432
This commit is contained in:
Arthur Sonzogni
2022-08-21 23:04:32 +02:00
committed by GitHub
parent 3ec765e1f0
commit ec994a4e65
4 changed files with 46 additions and 7 deletions

View File

@@ -135,6 +135,17 @@ void EventListener(std::atomic<bool>* quit, Sender<Task> out) {
}
}
extern "C" {
EMSCRIPTEN_KEEPALIVE
void ftxui_on_resize(int columns, int rows) {
Terminal::SetFallbackSize({
columns,
rows,
});
std::raise(SIGWINCH);
}
}
#else
#include <sys/time.h> // for timeval

View File

@@ -38,7 +38,10 @@ Dimensions& FallbackSize() {
constexpr int fallback_width = 80;
constexpr int fallback_height = 24;
#endif
static Dimensions g_fallback_size{fallback_width, fallback_height};
static Dimensions g_fallback_size{
fallback_width,
fallback_height,
};
return g_fallback_size;
}