mirror of
https://github.com/ArthurSonzogni/FTXUI.git
synced 2025-06-26 01:21:12 +08:00
Add Changelog.
This commit is contained in:
parent
25476f757b
commit
4c1d30b1bd
@ -16,6 +16,9 @@ current (development)
|
|||||||
- Feature: Add support for `Input`'s insert mode. Add `InputOption::insert`
|
- Feature: Add support for `Input`'s insert mode. Add `InputOption::insert`
|
||||||
option. Added by @mingsheng13.
|
option. Added by @mingsheng13.
|
||||||
- Feature: Add `DropdownOption` to configure the dropdown. See #826.
|
- Feature: Add `DropdownOption` to configure the dropdown. See #826.
|
||||||
|
- Feature: Add support for Selection. Thanks @clement-roblot. See #926.
|
||||||
|
- See `ScreenInteractive::GetSelection()`.
|
||||||
|
- See `ScreenInteractive::SelectionChange(...)` listener.
|
||||||
- Bugfix/Breaking change: `Mouse transition`:
|
- Bugfix/Breaking change: `Mouse transition`:
|
||||||
- Detect when the mouse move, as opposed to being pressed.
|
- Detect when the mouse move, as opposed to being pressed.
|
||||||
The Mouse::Moved motion was added.
|
The Mouse::Moved motion was added.
|
||||||
@ -49,6 +52,12 @@ current (development)
|
|||||||
- Feature: Add `extend_beyond_screen` option to `Dimension::Fit(..)`, allowing
|
- Feature: Add `extend_beyond_screen` option to `Dimension::Fit(..)`, allowing
|
||||||
the element to be larger than the screen. Proposed by @LordWhiro. See #572 and
|
the element to be larger than the screen. Proposed by @LordWhiro. See #572 and
|
||||||
#949.
|
#949.
|
||||||
|
- Feature: Add support for Selection. Thanks @clement-roblot. See #926.
|
||||||
|
- See `selectionColor` decorator.
|
||||||
|
- See `selectionBackgroundColor` decorator.
|
||||||
|
- See `selectionForegroundColor` decorator.
|
||||||
|
- See `selectionStyle(style)` decorator.
|
||||||
|
- See `selectionStyleReset` decorator.
|
||||||
|
|
||||||
### Screen
|
### Screen
|
||||||
- Feature: Add `Box::IsEmpty()`.
|
- Feature: Add `Box::IsEmpty()`.
|
||||||
|
@ -14,12 +14,10 @@ using namespace ftxui;
|
|||||||
|
|
||||||
Element LoremIpsum() {
|
Element LoremIpsum() {
|
||||||
return vbox({
|
return vbox({
|
||||||
text("Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do "
|
text("FTXUI: A powerful library for building user interfaces."),
|
||||||
"eiusmod tempor incididunt ut labore et dolore magna aliqua."),
|
text("Enjoy a rich set of components and a declarative style."),
|
||||||
text("Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris "
|
text("Create beautiful and responsive UIs with minimal effort."),
|
||||||
"nisi ut aliquip ex ea commodo consequat."),
|
text("Join the community and experience the power of FTXUI."),
|
||||||
text("Duis aute irure dolor in reprehenderit in voluptate velit esse "
|
|
||||||
"cillum dolore eu fugiat nulla pariatur."),
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -31,9 +29,9 @@ int main() {
|
|||||||
|
|
||||||
int selection_change_counter = 0;
|
int selection_change_counter = 0;
|
||||||
std::string selection_content = "";
|
std::string selection_content = "";
|
||||||
screen.SelectionOnChange([&] {
|
screen.SelectionChange([&] {
|
||||||
selection_change_counter++;
|
selection_change_counter++;
|
||||||
selection_content = screen.SelectionAsString();
|
selection_content = screen.GetSelection();
|
||||||
});
|
});
|
||||||
|
|
||||||
// The components:
|
// The components:
|
||||||
@ -42,7 +40,7 @@ int main() {
|
|||||||
text("Select changed: " + std::to_string(selection_change_counter) +
|
text("Select changed: " + std::to_string(selection_change_counter) +
|
||||||
" times"),
|
" times"),
|
||||||
text("Currently selected: "),
|
text("Currently selected: "),
|
||||||
paragraph(selection_content) | frame | border | xflex |
|
paragraph(selection_content) | vscroll_indicator | frame | border |
|
||||||
size(HEIGHT, EQUAL, 10),
|
size(HEIGHT, EQUAL, 10),
|
||||||
window(text("Horizontal split"), hbox({
|
window(text("Horizontal split"), hbox({
|
||||||
LoremIpsum(),
|
LoremIpsum(),
|
||||||
@ -58,7 +56,7 @@ int main() {
|
|||||||
separator(),
|
separator(),
|
||||||
LoremIpsum(),
|
LoremIpsum(),
|
||||||
})),
|
})),
|
||||||
window(text("Grid split"),
|
window(text("Grid split with different style"),
|
||||||
vbox({
|
vbox({
|
||||||
hbox({
|
hbox({
|
||||||
LoremIpsum(),
|
LoremIpsum(),
|
||||||
|
@ -70,8 +70,8 @@ class ScreenInteractive : public Screen {
|
|||||||
void ForceHandleCtrlZ(bool force);
|
void ForceHandleCtrlZ(bool force);
|
||||||
|
|
||||||
// Selection API.
|
// Selection API.
|
||||||
std::string SelectionAsString();
|
std::string GetSelection();
|
||||||
void SelectionOnChange(std::function<void()> callback);
|
void SelectionChange(std::function<void()> callback);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void ExitNow();
|
void ExitNow();
|
||||||
|
@ -577,14 +577,14 @@ void ScreenInteractive::ForceHandleCtrlZ(bool force) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// @brief Returns the content of the current selection
|
/// @brief Returns the content of the current selection
|
||||||
std::string ScreenInteractive::SelectionAsString() {
|
std::string ScreenInteractive::GetSelection() {
|
||||||
if (!selection_) {
|
if (!selection_) {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
return selection_->GetParts();
|
return selection_->GetParts();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScreenInteractive::SelectionOnChange(std::function<void()> callback) {
|
void ScreenInteractive::SelectionChange(std::function<void()> callback) {
|
||||||
selection_on_change_ = std::move(callback);
|
selection_on_change_ = std::move(callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -58,20 +58,20 @@ Event MouseMove(int x, int y) {
|
|||||||
TEST(SelectionTest, DefaultSelection) {
|
TEST(SelectionTest, DefaultSelection) {
|
||||||
auto component = Renderer([&] { return text("Lorem ipsum dolor"); });
|
auto component = Renderer([&] { return text("Lorem ipsum dolor"); });
|
||||||
auto screen = ScreenInteractive::FixedSize(20, 1);
|
auto screen = ScreenInteractive::FixedSize(20, 1);
|
||||||
EXPECT_EQ(screen.SelectionAsString(), "");
|
EXPECT_EQ(screen.GetSelection(), "");
|
||||||
Loop loop(&screen, component);
|
Loop loop(&screen, component);
|
||||||
screen.PostEvent(MousePressed(3, 1));
|
screen.PostEvent(MousePressed(3, 1));
|
||||||
screen.PostEvent(MouseReleased(10, 1));
|
screen.PostEvent(MouseReleased(10, 1));
|
||||||
loop.RunOnce();
|
loop.RunOnce();
|
||||||
|
|
||||||
EXPECT_EQ(screen.SelectionAsString(), "rem ipsu");
|
EXPECT_EQ(screen.GetSelection(), "rem ipsu");
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(SelectionTest, SelectionOnChange) {
|
TEST(SelectionTest, SelectionChange) {
|
||||||
int selectionChangeCounter = 0;
|
int selectionChangeCounter = 0;
|
||||||
auto component = Renderer([&] { return text("Lorem ipsum dolor"); });
|
auto component = Renderer([&] { return text("Lorem ipsum dolor"); });
|
||||||
auto screen = ScreenInteractive::FixedSize(20, 1);
|
auto screen = ScreenInteractive::FixedSize(20, 1);
|
||||||
screen.SelectionOnChange([&] { selectionChangeCounter++; });
|
screen.SelectionChange([&] { selectionChangeCounter++; });
|
||||||
|
|
||||||
Loop loop(&screen, component);
|
Loop loop(&screen, component);
|
||||||
loop.RunOnce();
|
loop.RunOnce();
|
||||||
@ -97,7 +97,7 @@ TEST(SelectionTest, SelectionOnChange) {
|
|||||||
loop.RunOnce();
|
loop.RunOnce();
|
||||||
EXPECT_EQ(selectionChangeCounter, 3);
|
EXPECT_EQ(selectionChangeCounter, 3);
|
||||||
|
|
||||||
EXPECT_EQ(screen.SelectionAsString(), "rem ipsu");
|
EXPECT_EQ(screen.GetSelection(), "rem ipsu");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check that submitting multiple mouse events quickly doesn't trigger multiple
|
// Check that submitting multiple mouse events quickly doesn't trigger multiple
|
||||||
@ -106,7 +106,7 @@ TEST(SelectionTest, SelectionOnChangeSquashedEvents) {
|
|||||||
int selectionChangeCounter = 0;
|
int selectionChangeCounter = 0;
|
||||||
auto component = Renderer([&] { return text("Lorem ipsum dolor"); });
|
auto component = Renderer([&] { return text("Lorem ipsum dolor"); });
|
||||||
auto screen = ScreenInteractive::FixedSize(20, 1);
|
auto screen = ScreenInteractive::FixedSize(20, 1);
|
||||||
screen.SelectionOnChange([&] { selectionChangeCounter++; });
|
screen.SelectionChange([&] { selectionChangeCounter++; });
|
||||||
|
|
||||||
Loop loop(&screen, component);
|
Loop loop(&screen, component);
|
||||||
loop.RunOnce();
|
loop.RunOnce();
|
||||||
@ -123,7 +123,7 @@ TEST(SelectionTest, SelectionOnChangeSquashedEvents) {
|
|||||||
loop.RunOnce();
|
loop.RunOnce();
|
||||||
EXPECT_EQ(selectionChangeCounter, 2);
|
EXPECT_EQ(selectionChangeCounter, 2);
|
||||||
|
|
||||||
EXPECT_EQ(screen.SelectionAsString(), "rem ipsu");
|
EXPECT_EQ(screen.GetSelection(), "rem ipsu");
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(SelectionTest, StyleSelection) {
|
TEST(SelectionTest, StyleSelection) {
|
||||||
|
Loading…
Reference in New Issue
Block a user