mirror of
				https://github.com/ArthurSonzogni/FTXUI.git
				synced 2025-11-04 05:28:15 +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:
		@@ -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,22 +488,24 @@ 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.
 | 
			
		||||
      // 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
 | 
			
		||||
  // 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
 | 
			
		||||
  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);
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user