mirror of
https://github.com/ArthurSonzogni/FTXUI.git
synced 2025-05-05 22:01:13 +08:00
Bugfix: Avoid crash with ResizeableSplit. (#1025)
Component --------- - Bugfix: Fix a crash with ResizeableSplit. See #1023. - Clamp screen size to terminal size. - Disallow `ResizeableSplit` with negative size. Dom --- - Bugfix: Disallow specifying a negative size constraint. See #1023. Bug: https://github.com/ArthurSonzogni/FTXUI/issues/1023
This commit is contained in:
parent
09eb2f7fb0
commit
07fd3e685a
11
CHANGELOG.md
11
CHANGELOG.md
@ -1,6 +1,17 @@
|
|||||||
Changelog
|
Changelog
|
||||||
=========
|
=========
|
||||||
|
|
||||||
|
Development
|
||||||
|
-----------
|
||||||
|
### Component
|
||||||
|
- Bugfix: Fix a crash with ResizeableSplit. See #1023.
|
||||||
|
- Clamp screen size to terminal size.
|
||||||
|
- Disallow `ResizeableSplit` with negative size.
|
||||||
|
|
||||||
|
### Dom
|
||||||
|
- Bugfix: Disallow specifying a negative size constraint. See #1023.
|
||||||
|
|
||||||
|
|
||||||
6.0.2 (2025-03-30)
|
6.0.2 (2025-03-30)
|
||||||
-----
|
-----
|
||||||
|
|
||||||
|
@ -77,16 +77,16 @@ class ResizableSplitBase : public ComponentBase {
|
|||||||
|
|
||||||
switch (options_->direction()) {
|
switch (options_->direction()) {
|
||||||
case Direction::Left:
|
case Direction::Left:
|
||||||
options_->main_size() = event.mouse().x - box_.x_min;
|
options_->main_size() = std::max(0, event.mouse().x - box_.x_min);
|
||||||
return true;
|
return true;
|
||||||
case Direction::Right:
|
case Direction::Right:
|
||||||
options_->main_size() = box_.x_max - event.mouse().x;
|
options_->main_size() = std::max(0, box_.x_max - event.mouse().x);
|
||||||
return true;
|
return true;
|
||||||
case Direction::Up:
|
case Direction::Up:
|
||||||
options_->main_size() = event.mouse().y - box_.y_min;
|
options_->main_size() = std::max(0, event.mouse().y - box_.y_min);
|
||||||
return true;
|
return true;
|
||||||
case Direction::Down:
|
case Direction::Down:
|
||||||
options_->main_size() = box_.y_max - event.mouse().y;
|
options_->main_size() = std::max(0, box_.y_max - event.mouse().y);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -34,6 +34,7 @@
|
|||||||
#include "ftxui/dom/requirement.hpp" // for Requirement
|
#include "ftxui/dom/requirement.hpp" // for Requirement
|
||||||
#include "ftxui/screen/pixel.hpp" // for Pixel
|
#include "ftxui/screen/pixel.hpp" // for Pixel
|
||||||
#include "ftxui/screen/terminal.hpp" // for Dimensions, Size
|
#include "ftxui/screen/terminal.hpp" // for Dimensions, Size
|
||||||
|
#include "ftxui/screen/util.hpp" // for util::clamp
|
||||||
|
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
#define DEFINE_CONSOLEV2_PROPERTIES
|
#define DEFINE_CONSOLEV2_PROPERTIES
|
||||||
@ -917,15 +918,15 @@ void ScreenInteractive::Draw(Component component) {
|
|||||||
break;
|
break;
|
||||||
case Dimension::TerminalOutput:
|
case Dimension::TerminalOutput:
|
||||||
dimx = terminal.dimx;
|
dimx = terminal.dimx;
|
||||||
dimy = document->requirement().min_y;
|
dimy = util::clamp(document->requirement().min_y, 0, terminal.dimy);
|
||||||
break;
|
break;
|
||||||
case Dimension::Fullscreen:
|
case Dimension::Fullscreen:
|
||||||
dimx = terminal.dimx;
|
dimx = terminal.dimx;
|
||||||
dimy = terminal.dimy;
|
dimy = terminal.dimy;
|
||||||
break;
|
break;
|
||||||
case Dimension::FitComponent:
|
case Dimension::FitComponent:
|
||||||
dimx = std::min(document->requirement().min_x, terminal.dimx);
|
dimx = util::clamp(document->requirement().min_x, 0, terminal.dimx);
|
||||||
dimy = std::min(document->requirement().min_y, terminal.dimy);
|
dimy = util::clamp(document->requirement().min_y, 0, terminal.dimy);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,7 +19,7 @@ class Size : public Node {
|
|||||||
: Node(unpack(std::move(child))),
|
: Node(unpack(std::move(child))),
|
||||||
direction_(direction),
|
direction_(direction),
|
||||||
constraint_(constraint),
|
constraint_(constraint),
|
||||||
value_(value) {}
|
value_(std::max(0, value)) {}
|
||||||
|
|
||||||
void ComputeRequirement() override {
|
void ComputeRequirement() override {
|
||||||
Node::ComputeRequirement();
|
Node::ComputeRequirement();
|
||||||
|
Loading…
Reference in New Issue
Block a user