1 Commits

Author SHA1 Message Date
KenReneris
c73a35ce01 Merge 2d50269730 into d20b84f720 2025-08-17 12:39:51 -07:00
3 changed files with 57 additions and 31 deletions

View File

@@ -29,8 +29,6 @@ Next
### Component
- Fix ScreenInteractive::FixedSize screen stomps on the preceding terminal
output. Thanks @zozowell in #1064.
- Fix vertical `ftxui::Slider`. The "up" key was previously decreasing the
value. Thanks @its-pablo in #1093 for reporting the issue.
6.1.9 (2025-05-07)

View File

@@ -17,12 +17,10 @@ add_subdirectory(dom)
if (EMSCRIPTEN)
get_property(EXAMPLES GLOBAL PROPERTY FTXUI::EXAMPLES)
foreach(file
"index.css"
"index.html"
"index.mjs"
"run_webassembly.py"
"sw.js"
)
"index.css"
"run_webassembly.py")
configure_file(${file} ${file})
endforeach(file)
endif()

View File

@@ -33,20 +33,6 @@ Decorator flexDirection(Direction direction) {
return xflex; // NOT_REACHED()
}
Direction Opposite(Direction d) {
switch (d) {
case Direction::Up:
return Direction::Down;
case Direction::Down:
return Direction::Up;
case Direction::Left:
return Direction::Right;
case Direction::Right:
return Direction::Left;
}
return d; // NOT_REACHED()
}
template <class T>
class SliderBase : public SliderOption<T>, public ComponentBase {
public:
@@ -61,15 +47,59 @@ class SliderBase : public SliderOption<T>, public ComponentBase {
flexDirection(this->direction) | reflect(gauge_box_) | gauge_color;
}
void OnDirection(Direction pressed) {
if (pressed == this->direction) {
this->value() += this->increment();
return;
void OnLeft() {
switch (this->direction) {
case Direction::Right:
this->value() -= this->increment();
break;
case Direction::Left:
this->value() += this->increment();
break;
case Direction::Up:
case Direction::Down:
break;
}
}
if (pressed == Opposite(this->direction)) {
this->value() -= this->increment();
return;
void OnRight() {
switch (this->direction) {
case Direction::Right:
this->value() += this->increment();
break;
case Direction::Left:
this->value() -= this->increment();
break;
case Direction::Up:
case Direction::Down:
break;
}
}
void OnUp() {
switch (this->direction) {
case Direction::Up:
this->value() -= this->increment();
break;
case Direction::Down:
this->value() += this->increment();
break;
case Direction::Left:
case Direction::Right:
break;
}
}
void OnDown() {
switch (this->direction) {
case Direction::Down:
this->value() += this->increment();
break;
case Direction::Up:
this->value() -= this->increment();
break;
case Direction::Left:
case Direction::Right:
break;
}
}
@@ -80,16 +110,16 @@ class SliderBase : public SliderOption<T>, public ComponentBase {
T old_value = this->value();
if (event == Event::ArrowLeft || event == Event::Character('h')) {
OnDirection(Direction::Left);
OnLeft();
}
if (event == Event::ArrowRight || event == Event::Character('l')) {
OnDirection(Direction::Right);
OnRight();
}
if (event == Event::ArrowUp || event == Event::Character('k')) {
OnDirection(Direction::Up);
OnDown();
}
if (event == Event::ArrowDown || event == Event::Character('j')) {
OnDirection(Direction::Down);
OnUp();
}
this->value() = std::max(this->min(), std::min(this->max(), this->value()));