mirror of
https://github.com/ArthurSonzogni/FTXUI.git
synced 2024-11-25 20:27:31 +08:00
Main (#303)
* Refresh cursor reporting on resize. * Fix invalid size write. This resolves: https://github.com/ArthurSonzogni/FTXUI/issues/302
This commit is contained in:
parent
84299de2e1
commit
1888631bec
@ -66,6 +66,7 @@ class ScreenInteractive : public Screen {
|
||||
int cursor_y_ = 1;
|
||||
|
||||
bool mouse_captured = false;
|
||||
bool previous_frame_resized_ = false;
|
||||
};
|
||||
|
||||
} // namespace ftxui
|
||||
|
@ -64,8 +64,9 @@ void ComponentBase::Detach() {
|
||||
[this](const Component& that) { //
|
||||
return this == that.get();
|
||||
});
|
||||
parent_->children_.erase(it);
|
||||
ComponentBase* parent = parent_;
|
||||
parent_ = nullptr;
|
||||
parent->children_.erase(it); // Might delete |this|.
|
||||
}
|
||||
|
||||
/// @brief Remove all children.
|
||||
|
@ -488,7 +488,6 @@ void ScreenInteractive::Draw(Component component) {
|
||||
// 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.
|
||||
@ -496,14 +495,17 @@ void ScreenInteractive::Draw(Component component) {
|
||||
// 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))
|
||||
if (!use_alternative_screen_ && (i % 150 == 0))
|
||||
std::cout << DeviceStatusReport(DSRMode::kCursor);
|
||||
#else
|
||||
static int i = -3;
|
||||
++i;
|
||||
if (!use_alternative_screen_ && (previous_frame_resized_ || i % 40 == 0))
|
||||
std::cout << DeviceStatusReport(DSRMode::kCursor);
|
||||
#endif
|
||||
previous_frame_resized_ = resized;
|
||||
|
||||
Render(*this, document);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user