From e6614d6363906da16b0bd7e2109487fcbf548084 Mon Sep 17 00:00:00 2001 From: Arthur Sonzogni Date: Sun, 6 Jan 2019 22:45:10 +0100 Subject: [PATCH] Fix cursor position for dom. --- ftxui/src/ftxui/dom/vbox.cpp | 2 +- ftxui/src/ftxui/dom/vbox_test.cpp | 2 +- ftxui/src/ftxui/screen/screen.cpp | 1 + 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/ftxui/src/ftxui/dom/vbox.cpp b/ftxui/src/ftxui/dom/vbox.cpp index ab2e2b7..1ad9896 100644 --- a/ftxui/src/ftxui/dom/vbox.cpp +++ b/ftxui/src/ftxui/dom/vbox.cpp @@ -51,7 +51,7 @@ class VBox : public Node { remaining_flex -= child->requirement().flex.y; child_box.bottom += added_space; } - child_box.bottom = std::min(child_box.bottom, box.bottom); + child_box.bottom = std::min(child_box.bottom, box.bottom-1); child->SetBox(child_box); y = child_box.bottom + 1; diff --git a/ftxui/src/ftxui/dom/vbox_test.cpp b/ftxui/src/ftxui/dom/vbox_test.cpp index 1ac7d39..aabaaa6 100644 --- a/ftxui/src/ftxui/dom/vbox_test.cpp +++ b/ftxui/src/ftxui/dom/vbox_test.cpp @@ -46,7 +46,7 @@ TEST(VBoxTest, ScreenSmaller1Flex) { TEST(VBoxTest, ScreenFitFlex) { auto root = vbox(text(L"text_1"), filler(), text(L"text_2")); - Screen screen(6, 2); + Screen screen(15, 10); Render(screen, root.get()); EXPECT_EQ("text_1\ntext_2", screen.ToString()); diff --git a/ftxui/src/ftxui/screen/screen.cpp b/ftxui/src/ftxui/screen/screen.cpp index 30f0bfb..3c5abd9 100644 --- a/ftxui/src/ftxui/screen/screen.cpp +++ b/ftxui/src/ftxui/screen/screen.cpp @@ -96,6 +96,7 @@ std::string Screen::ResetPosition() { for (size_t y = 1; y < dimy_; ++y) { ss << "\e[2K\r\e[1A"; } + ss << '\r'; return ss.str(); }