diff --git a/examples/dom/border.cpp b/examples/dom/border.cpp index 77b0f81..bed5765 100644 --- a/examples/dom/border.cpp +++ b/examples/dom/border.cpp @@ -39,6 +39,6 @@ int main(int argc, const char* argv[]) { filler(), }); auto screen = Screen::Create(Dimension::Full(), Dimension::Fit(document)); - Render(screen, document.get()); + Render(screen, document); std::cout << screen.ToString() << std::endl; } diff --git a/examples/dom/dbox.cpp b/examples/dom/dbox.cpp index 8e917ff..afac9fc 100644 --- a/examples/dom/dbox.cpp +++ b/examples/dom/dbox.cpp @@ -20,7 +20,7 @@ int main(int argc, const char* argv[]) { text(L"overlay") | border | center, }); auto screen = Screen::Create(Dimension::Full(), Dimension::Fit(document)); - Render(screen, document.get()); + Render(screen, document); std::cout << screen.ToString(); diff --git a/examples/dom/gauge.cpp b/examples/dom/gauge.cpp index 3d36bd3..4837e57 100644 --- a/examples/dom/gauge.cpp +++ b/examples/dom/gauge.cpp @@ -23,7 +23,7 @@ int main(int argc, const char* argv[]) { text(L" " + data_downloaded), }); auto screen = Screen(100, 1); - Render(screen, document.get()); + Render(screen, document); std::cout << reset_position << screen.ToString() << std::flush; reset_position = screen.ResetPosition(); diff --git a/examples/dom/graph.cpp b/examples/dom/graph.cpp index cae49ac..a394d4f 100644 --- a/examples/dom/graph.cpp +++ b/examples/dom/graph.cpp @@ -64,7 +64,7 @@ int main(int argc, const char* argv[]) { border | size(HEIGHT, GREATER_THAN, 40); auto screen = Screen::Create(Dimension::Full(), Dimension::Fit(document)); - Render(screen, document.get()); + Render(screen, document); std::cout << reset_position << screen.ToString() << std::flush; reset_position = screen.ResetPosition(); diff --git a/examples/dom/hflow.cpp b/examples/dom/hflow.cpp index 6adecbe..da17492 100644 --- a/examples/dom/hflow.cpp +++ b/examples/dom/hflow.cpp @@ -43,7 +43,7 @@ int main(int argc, const char* argv[]) { style; auto screen = Screen::Create(Dimension::Full(), Dimension::Fit(document)); - Render(screen, document.get()); + Render(screen, document); std::cout << screen.ToString() << std::endl; return 0; diff --git a/examples/dom/html_like.cpp b/examples/dom/html_like.cpp index 1c855bb..a89cfc8 100644 --- a/examples/dom/html_like.cpp +++ b/examples/dom/html_like.cpp @@ -45,7 +45,7 @@ int main(int argc, const char* argv[]) { border; auto screen = Screen::Create(Dimension::Full()); - Render(screen, document.get()); + Render(screen, document); std::cout << reset_position << screen.ToString() << std::flush; reset_position = screen.ResetPosition(); diff --git a/examples/dom/package_manager.cpp b/examples/dom/package_manager.cpp index dc8acee..c7d310c 100644 --- a/examples/dom/package_manager.cpp +++ b/examples/dom/package_manager.cpp @@ -125,7 +125,7 @@ int main(int argc, const char* argv[]) { // Draw. auto document = render(); auto screen = Screen::Create(Dimension::Full(), Dimension::Fit(document)); - Render(screen, document.get()); + Render(screen, document); std::cout << reset_position << screen.ToString() << std::flush; reset_position = screen.ResetPosition(); diff --git a/examples/dom/paragraph.cpp b/examples/dom/paragraph.cpp index 0e1b7f1..95de2a6 100644 --- a/examples/dom/paragraph.cpp +++ b/examples/dom/paragraph.cpp @@ -29,7 +29,7 @@ int main(int argc, const char* argv[]) { }); auto screen = Screen::Create(Dimension::Full(), Dimension::Full()); - Render(screen, document.get()); + Render(screen, document); std::cout << screen.ToString(); getchar(); diff --git a/examples/dom/separator.cpp b/examples/dom/separator.cpp index 71b495f..715e47c 100644 --- a/examples/dom/separator.cpp +++ b/examples/dom/separator.cpp @@ -22,7 +22,7 @@ int main(int argc, const char* argv[]) { }) | border; auto screen = Screen::Create(Dimension::Full(), Dimension::Fit(document)); - Render(screen, document.get()); + Render(screen, document); std::cout << screen.ToString() << std::endl; diff --git a/examples/dom/size.cpp b/examples/dom/size.cpp index 3005ab2..45614d2 100644 --- a/examples/dom/size.cpp +++ b/examples/dom/size.cpp @@ -22,7 +22,7 @@ int main(int argc, const char* argv[]) { auto document = hbox(std::move(content)); auto screen = Screen::Create(Dimension::Fit(document)); - Render(screen, document.get()); + Render(screen, document); std::cout << screen.ToString() << std::endl; return 0; diff --git a/examples/dom/spinner.cpp b/examples/dom/spinner.cpp index 4a2333a..721f919 100644 --- a/examples/dom/spinner.cpp +++ b/examples/dom/spinner.cpp @@ -32,7 +32,7 @@ int main(int argc, const char* argv[]) { filler(), }); auto screen = Screen::Create(Dimension::Full(), Dimension::Fit(document)); - Render(screen, document.get()); + Render(screen, document); std::cout << reset_position << screen.ToString() << std::flush; reset_position = screen.ResetPosition(); diff --git a/examples/dom/style_blink.cpp b/examples/dom/style_blink.cpp index e2b6bbc..c086163 100644 --- a/examples/dom/style_blink.cpp +++ b/examples/dom/style_blink.cpp @@ -16,7 +16,7 @@ int main(int argc, const char* argv[]) { text(L". Do you like it?"), }); auto screen = Screen::Create(Dimension::Full(), Dimension::Fit(document)); - Render(screen, document.get()); + Render(screen, document); std::cout << screen.ToString(); diff --git a/examples/dom/style_bold.cpp b/examples/dom/style_bold.cpp index 7fa3216..5e36f82 100644 --- a/examples/dom/style_bold.cpp +++ b/examples/dom/style_bold.cpp @@ -16,7 +16,7 @@ int main(int argc, const char* argv[]) { text(L". Do you like it?"), }); auto screen = Screen::Create(Dimension::Full(), Dimension::Fit(document)); - Render(screen, document.get()); + Render(screen, document); std::cout << screen.ToString(); diff --git a/examples/dom/style_color.cpp b/examples/dom/style_color.cpp index 06151bd..5d6c2c9 100644 --- a/examples/dom/style_color.cpp +++ b/examples/dom/style_color.cpp @@ -55,7 +55,7 @@ int main(int argc, const char* argv[]) { // clang-format on auto screen = Screen::Create(Dimension::Full(), Dimension::Fit(document)); - Render(screen, document.get()); + Render(screen, document); std::cout << screen.ToString(); diff --git a/examples/dom/style_dim.cpp b/examples/dom/style_dim.cpp index e95d876..75d0fc2 100644 --- a/examples/dom/style_dim.cpp +++ b/examples/dom/style_dim.cpp @@ -16,7 +16,7 @@ int main(int argc, const char* argv[]) { text(L". Do you like it?"), }); auto screen = Screen::Create(Dimension::Full(), Dimension::Fit(document)); - Render(screen, document.get()); + Render(screen, document); std::cout << screen.ToString(); diff --git a/examples/dom/style_gallery.cpp b/examples/dom/style_gallery.cpp index ff858e9..245f99b 100644 --- a/examples/dom/style_gallery.cpp +++ b/examples/dom/style_gallery.cpp @@ -23,7 +23,7 @@ int main(int argc, const char* argv[]) { }); // clang-format on auto screen = Screen::Create(Dimension::Full(), Dimension::Fit(document)); - Render(screen, document.get()); + Render(screen, document); std::cout << screen.ToString(); diff --git a/examples/dom/style_inverted.cpp b/examples/dom/style_inverted.cpp index bf9a7be..47236f0 100644 --- a/examples/dom/style_inverted.cpp +++ b/examples/dom/style_inverted.cpp @@ -15,7 +15,7 @@ int main(int argc, const char* argv[]) { text(L". Do you like it?"), }); auto screen = Screen::Create(Dimension::Full(), Dimension::Fit(document)); - Render(screen, document.get()); + Render(screen, document); std::cout << screen.ToString(); diff --git a/examples/dom/style_underlined.cpp b/examples/dom/style_underlined.cpp index 7335409..0fa9b9c 100644 --- a/examples/dom/style_underlined.cpp +++ b/examples/dom/style_underlined.cpp @@ -16,7 +16,7 @@ int main(int argc, const char* argv[]) { text(L". Do you like it?"), }); auto screen = Screen::Create(Dimension::Full(), Dimension::Fit(document)); - Render(screen, document.get()); + Render(screen, document); std::cout << screen.ToString(); diff --git a/examples/dom/vbox_hbox.cpp b/examples/dom/vbox_hbox.cpp index 265b270..2a0a53c 100644 --- a/examples/dom/vbox_hbox.cpp +++ b/examples/dom/vbox_hbox.cpp @@ -30,7 +30,7 @@ int main(int argc, const char* argv[]) { }), }); auto screen = Screen::Create(Dimension::Full()); - Render(screen, document.get()); + Render(screen, document); std::cout << screen.ToString(); getchar(); diff --git a/examples/html/test.html.disabled b/examples/html/test.html.disabled index 3ecf075..acd3442 100644 --- a/examples/html/test.html.disabled +++ b/examples/html/test.html.disabled @@ -65,7 +65,7 @@ filler() ); auto screen = Screen::Create(Dimension::Fit(document)); - Render(screen, document.get()); + Render(screen, document); std::cout << screen.ToString() << std::endl; return 0; } diff --git a/include/ftxui/dom/node.hpp b/include/ftxui/dom/node.hpp index 4cd5577..9f061a4 100644 --- a/include/ftxui/dom/node.hpp +++ b/include/ftxui/dom/node.hpp @@ -43,6 +43,7 @@ class Node { Box box_; }; +void Render(Screen& screen, const Element& node); void Render(Screen& screen, Node* node); } // namespace ftxui diff --git a/src/ftxui/component/screen_interactive.cpp b/src/ftxui/component/screen_interactive.cpp index 0b4a434..8972079 100644 --- a/src/ftxui/component/screen_interactive.cpp +++ b/src/ftxui/component/screen_interactive.cpp @@ -321,7 +321,7 @@ void ScreenInteractive::Draw(Component* component) { cursor_.y = dimy_ - 1; } - Render(*this, document.get()); + Render(*this, document); // Set cursor position for user using tools to insert CJK characters. set_cursor_position = ""; diff --git a/src/ftxui/dom/gauge_test.cpp b/src/ftxui/dom/gauge_test.cpp index 0e702a7..eca3338 100644 --- a/src/ftxui/dom/gauge_test.cpp +++ b/src/ftxui/dom/gauge_test.cpp @@ -12,7 +12,7 @@ using namespace ftxui; TEST(GaugeTest, zero) { auto root = gauge(0); Screen screen(11, 1); - Render(screen, root.get()); + Render(screen, root); EXPECT_EQ(" ", screen.ToString()); } @@ -20,7 +20,7 @@ TEST(GaugeTest, zero) { TEST(GaugeTest, half) { auto root = gauge(0.5); Screen screen(11, 1); - Render(screen, root.get()); + Render(screen, root); EXPECT_EQ("█████▍ ", screen.ToString()); //" ▏▎▍▌▊▉█"; @@ -29,7 +29,7 @@ TEST(GaugeTest, half) { TEST(GaugeTest, one) { auto root = gauge(1.0); Screen screen(11, 1); - Render(screen, root.get()); + Render(screen, root); EXPECT_EQ("███████████", screen.ToString()); } diff --git a/src/ftxui/dom/hbox_test.cpp b/src/ftxui/dom/hbox_test.cpp index 55564b5..f7b55f9 100644 --- a/src/ftxui/dom/hbox_test.cpp +++ b/src/ftxui/dom/hbox_test.cpp @@ -12,7 +12,7 @@ using namespace ftxui; TEST(HBoxTest, ScreenSmaller1) { auto root = hbox(text(L"text_1"), text(L"text_2")); Screen screen(11, 1); - Render(screen, root.get()); + Render(screen, root); EXPECT_EQ("text_1text_", screen.ToString()); } @@ -20,7 +20,7 @@ TEST(HBoxTest, ScreenSmaller1) { TEST(HBoxTest, ScreenSmaller2) { auto root = hbox(text(L"text_1"), text(L"text_2")); Screen screen(10, 1); - Render(screen, root.get()); + Render(screen, root); EXPECT_EQ("text_1text", screen.ToString()); } @@ -28,7 +28,7 @@ TEST(HBoxTest, ScreenSmaller2) { TEST(HBoxTest, ScreenFit) { auto root = hbox(text(L"text_1"), text(L"text_2")); Screen screen(12, 1); - Render(screen, root.get()); + Render(screen, root); EXPECT_EQ("text_1text_2", screen.ToString()); } @@ -36,14 +36,14 @@ TEST(HBoxTest, ScreenFit) { TEST(HBoxTest, ScreenBigger1) { auto root = hbox(text(L"text_1"), text(L"text_2")); Screen screen(13, 1); - Render(screen, root.get()); + Render(screen, root); EXPECT_EQ("text_1text_2 ", screen.ToString()); } TEST(HBoxTest, ScreenBigger2) { auto root = hbox(text(L"text_1"), text(L"text_2")); Screen screen(14, 1); - Render(screen, root.get()); + Render(screen, root); EXPECT_EQ("text_1text_2 ", screen.ToString()); } @@ -51,7 +51,7 @@ TEST(HBoxTest, ScreenBigger2) { TEST(HBoxTest, ScreenSmaller1Flex) { auto root = hbox(text(L"text_1"), filler(), text(L"text_2")); Screen screen(11, 1); - Render(screen, root.get()); + Render(screen, root); EXPECT_EQ("text_text_2", screen.ToString()); } @@ -59,7 +59,7 @@ TEST(HBoxTest, ScreenSmaller1Flex) { TEST(HBoxTest, ScreenSmaller2Flex) { auto root = hbox(text(L"text_1"), filler(), text(L"text_2")); Screen screen(10, 1); - Render(screen, root.get()); + Render(screen, root); EXPECT_EQ("texttext_2", screen.ToString()); } @@ -67,7 +67,7 @@ TEST(HBoxTest, ScreenSmaller2Flex) { TEST(HBoxTest, ScreenFitFlex) { auto root = hbox(text(L"text_1"), filler(), text(L"text_2")); Screen screen(12, 1); - Render(screen, root.get()); + Render(screen, root); EXPECT_EQ("text_1text_2", screen.ToString()); } @@ -75,7 +75,7 @@ TEST(HBoxTest, ScreenFitFlex) { TEST(HBoxTest, ScreenBigger1Flex) { auto root = hbox(text(L"text_1"), filler(), text(L"text_2")); Screen screen(13, 1); - Render(screen, root.get()); + Render(screen, root); EXPECT_EQ("text_1 text_2", screen.ToString()); } @@ -83,7 +83,7 @@ TEST(HBoxTest, ScreenBigger1Flex) { TEST(HBoxTest, ScreenBigger2Flex) { auto root = hbox(text(L"text_1"), filler(), text(L"text_2")); Screen screen(14, 1); - Render(screen, root.get()); + Render(screen, root); EXPECT_EQ("text_1 text_2", screen.ToString()); } diff --git a/src/ftxui/dom/node.cpp b/src/ftxui/dom/node.cpp index 984ec87..a2dd001 100644 --- a/src/ftxui/dom/node.cpp +++ b/src/ftxui/dom/node.cpp @@ -26,6 +26,10 @@ void Node::Render(Screen& screen) { child->Render(screen); } +void Render(Screen& screen, const Element& element) { + Render(screen, element); +} + void Render(Screen& screen, Node* node) { // Step 1: Find what dimension this elements wants to be. node->ComputeRequirement(); diff --git a/src/ftxui/dom/text_test.cpp b/src/ftxui/dom/text_test.cpp index f8616e2..b400462 100644 --- a/src/ftxui/dom/text_test.cpp +++ b/src/ftxui/dom/text_test.cpp @@ -12,7 +12,7 @@ using namespace ftxui; TEST(TextTest, ScreenHeightSmaller) { auto element = text(L"test"); Screen screen(2, 0); - Render(screen, element.get()); + Render(screen, element); EXPECT_EQ("", screen.ToString()); } @@ -20,7 +20,7 @@ TEST(TextTest, ScreenHeightSmaller) { TEST(TextTest, ScreenSmaller) { auto element = text(L"test"); Screen screen(2, 1); - Render(screen, element.get()); + Render(screen, element); EXPECT_EQ("te", screen.ToString()); } @@ -28,7 +28,7 @@ TEST(TextTest, ScreenSmaller) { TEST(TextTest, ScreenFit) { auto element = text(L"test"); Screen screen(4, 1); - Render(screen, element.get()); + Render(screen, element); EXPECT_EQ("test", screen.ToString()); } @@ -36,7 +36,7 @@ TEST(TextTest, ScreenFit) { TEST(TextTest, ScreenBigger) { auto element = text(L"test"); Screen screen(6, 1); - Render(screen, element.get()); + Render(screen, element); EXPECT_EQ("test ", screen.ToString()); } @@ -44,7 +44,7 @@ TEST(TextTest, ScreenBigger) { TEST(TextTest, ScreenBigger2) { auto element = text(L"test"); Screen screen(6, 2); - Render(screen, element.get()); + Render(screen, element); EXPECT_EQ("test \n ", screen.ToString()); } @@ -53,7 +53,7 @@ TEST(TextTest, ScreenBigger2) { TEST(TextTest, CJK) { auto element = text(L"测试") | border; Screen screen(6, 3); - Render(screen, element.get()); + Render(screen, element); EXPECT_EQ( "┌────┐\n" "│测试│\n" @@ -65,7 +65,7 @@ TEST(TextTest, CJK) { TEST(TextTest, CJK_2) { auto element = text(L"测试") | border; Screen screen(5, 3); - Render(screen, element.get()); + Render(screen, element); EXPECT_EQ( "┌───┐\n" "│测试\n" @@ -77,7 +77,7 @@ TEST(TextTest, CJK_2) { TEST(TextTest, CJK_3) { auto element = text(L"测试") | border; Screen screen(4, 3); - Render(screen, element.get()); + Render(screen, element); EXPECT_EQ( "┌──┐\n" "│测│\n" diff --git a/src/ftxui/dom/vbox_test.cpp b/src/ftxui/dom/vbox_test.cpp index 770c8d0..dd2abaa 100644 --- a/src/ftxui/dom/vbox_test.cpp +++ b/src/ftxui/dom/vbox_test.cpp @@ -12,7 +12,7 @@ using namespace ftxui; TEST(VBoxTest, ScreenSmaller1) { auto root = vbox(text(L"text_1"), text(L"text_2")); Screen screen(6, 1); - Render(screen, root.get()); + Render(screen, root); EXPECT_EQ("text_1", screen.ToString()); } @@ -20,7 +20,7 @@ TEST(VBoxTest, ScreenSmaller1) { TEST(VBoxTest, ScreenFit) { auto root = vbox(text(L"text_1"), text(L"text_2")); Screen screen(6, 2); - Render(screen, root.get()); + Render(screen, root); EXPECT_EQ("text_1\ntext_2", screen.ToString()); } @@ -28,14 +28,14 @@ TEST(VBoxTest, ScreenFit) { TEST(VBoxTest, ScreenBigger1) { auto root = vbox(text(L"text_1"), text(L"text_2")); Screen screen(6, 3); - Render(screen, root.get()); + Render(screen, root); EXPECT_EQ("text_1\ntext_2\n ", screen.ToString()); } TEST(VBoxTest, ScreenBigger2) { auto root = vbox(text(L"text_1"), text(L"text_2")); Screen screen(6, 4); - Render(screen, root.get()); + Render(screen, root); EXPECT_EQ("text_1\ntext_2\n \n ", screen.ToString()); } @@ -43,7 +43,7 @@ TEST(VBoxTest, ScreenBigger2) { TEST(VBoxTest, ScreenSmaller1Flex) { auto root = vbox(text(L"text_1"), filler(), text(L"text_2")); Screen screen(6, 1); - Render(screen, root.get()); + Render(screen, root); EXPECT_EQ("text_2", screen.ToString()); } @@ -51,7 +51,7 @@ TEST(VBoxTest, ScreenSmaller1Flex) { TEST(VBoxTest, ScreenFitFlex) { auto root = vbox(text(L"text_1"), filler(), text(L"text_2")); Screen screen(7, 5); - Render(screen, root.get()); + Render(screen, root); EXPECT_EQ( "text_1 \n" @@ -65,14 +65,14 @@ TEST(VBoxTest, ScreenFitFlex) { TEST(VBoxTest, ScreenBigger1Flex) { auto root = vbox(text(L"text_1"), filler(), text(L"text_2")); Screen screen(6, 3); - Render(screen, root.get()); + Render(screen, root); EXPECT_EQ("text_1\n \ntext_2", screen.ToString()); } TEST(VBoxTest, ScreenBigger2Flex) { auto root = vbox(text(L"text_1"), filler(), text(L"text_2")); Screen screen(6, 4); - Render(screen, root.get()); + Render(screen, root); EXPECT_EQ("text_1\n \n \ntext_2", screen.ToString()); }