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