mirror of
https://github.com/ArthurSonzogni/FTXUI.git
synced 2025-09-28 16:29:34 +08:00
Implement Fallback for microsoft's terminals. (#138)
I finally got access to a computer using the Microsoft's Windows OS. That's the opportunity to find and mitigate all the problems encountered. This patch: 1. Introduce an option and a C++ definition to enable fallback for Microsoft's terminal emulators. This allows me to see/test the Microsoft output from Linux. This also allows Windows users to remove the fallback and target non Microsoft terminals on Windows if needed. 2. Microsoft's terminal suffer from a race condition bug when reporting the cursor position: https://github.com/microsoft/terminal/pull/7583. The mitigation is not to ask for the cursor position in fullscreen mode where it isn't really needed and request it less often. This fixes: https://github.com/ArthurSonzogni/FTXUI/issues/136 3. Microsoft's terminal do not handle properly hidding the cursor. Instead the character under the cursor is hidden, which is a big problem. As a result, we don't enable setting the cursor to the best position for [input method editors](https://en.wikipedia.org/wiki/Input_method), It will be displayed at the bottom right corner. See: - https://github.com/microsoft/terminal/issues/1203 - https://github.com/microsoft/terminal/issues/3093 4. Microsoft's terminals do not provide a way to query if they support colors. As a fallback, assume true colors is supported. See issue: - https://github.com/microsoft/terminal/issues/1040 This mitigates: - https://github.com/ArthurSonzogni/FTXUI/issues/135 5. The "cmd" on Windows do not properly report its dimension. Powershell works correctly. As a fallback, use a 80x80 size instead of 0x0. 6. There are several dom elements and component displayed incorrectly, because the font used is missing several unicode glyph. Use alternatives or less detailled one as a fallback.
This commit is contained in:
@@ -450,10 +450,25 @@ void ScreenInteractive::Draw(Component component) {
|
||||
cursor_.y = dimy_ - 1;
|
||||
}
|
||||
|
||||
static int i = -2;
|
||||
if (i % 10 == 0)
|
||||
std::cout << DeviceStatusReport(DSRMode::kCursor);
|
||||
// Periodically request the terminal emulator the frame position relative to
|
||||
// the screen. This is useful for converting mouse position reported in
|
||||
// screen's coordinates to frame's coordinates.
|
||||
static constexpr int cursor_refresh_rate =
|
||||
#if defined(FTXUI_MICROSOFT_TERMINAL_FALLBACK)
|
||||
// Microsoft's terminal suffers from a [bug]. When reporting the cursor
|
||||
// position, several output sequences are mixed together into garbage.
|
||||
// This causes FTXUI user to see some "1;1;R" sequences into the Input
|
||||
// component. See [issue]. Solution is to request cursor position less
|
||||
// often. [bug]: https://github.com/microsoft/terminal/pull/7583 [issue]:
|
||||
// https://github.com/ArthurSonzogni/FTXUI/issues/136
|
||||
150;
|
||||
#else
|
||||
20;
|
||||
#endif
|
||||
static int i = -3;
|
||||
++i;
|
||||
if (!use_alternative_screen_ && (i % cursor_refresh_rate == 0))
|
||||
std::cout << DeviceStatusReport(DSRMode::kCursor);
|
||||
|
||||
Render(*this, document);
|
||||
|
||||
|
Reference in New Issue
Block a user