From c2d80698b3a22424ddd3dafbd991788abbd85037 Mon Sep 17 00:00:00 2001 From: Vedant Date: Sun, 10 Sep 2023 22:59:46 +0530 Subject: [PATCH 1/2] Modified tests to include coloring functionality, and updated README Signed-off-by: Vedant --- README.md | 12 +++---- examples/multiple_alignment.qf | 4 +-- examples/multiple_components.qf | 10 +++--- tests/test1.cpp | 56 +++++++++++++++++---------------- 4 files changed, 42 insertions(+), 40 deletions(-) diff --git a/README.md b/README.md index c9ecfe8..2f2ac8d 100644 --- a/README.md +++ b/README.md @@ -11,14 +11,14 @@ It converts this JSON-like [code](./examples/multiple_components.qf) into a TUI ``` Vertical{ str x - Button{ + Blue Button{ "Open firefox", System("/usr/bin/firefox"), Animated, x } int y = 20 - Slider { + Yellow Slider { "A Slider", y, 0, @@ -28,17 +28,17 @@ Vertical{ Horizontal { int z = 1 int w - Dropdown { + Red Dropdown { [ "Zain", "Mahesh", "Alqama", "Vaidic", "Mundane", "Advait", ], z } - Toggle { + Cyan Toggle { [ "On", "Off", ], w } } - Button { + RedLight Button { "Exit", "Exit", Ascii @@ -188,7 +188,7 @@ ninja ## Roadmap for v0.2 release -- [ ] Adding color (component wise) +- [x] Adding color (component wise) - [ ] Adding FTXUI DOM elements (e.g. seperator) - [ ] Adding a way to use C++ defined variables directly, instead of depending on script-variables - [ ] Adding detailed user documentation diff --git a/examples/multiple_alignment.qf b/examples/multiple_alignment.qf index 5690c80..d236c68 100644 --- a/examples/multiple_alignment.qf +++ b/examples/multiple_alignment.qf @@ -1,10 +1,10 @@ Horizontal{ - Button{ + Red Button{ "Button1", "Exit", Simple } - Button{ + Yellow Button{ "Button2", "Exit", Animated diff --git a/examples/multiple_components.qf b/examples/multiple_components.qf index dbbb695..7f4366a 100644 --- a/examples/multiple_components.qf +++ b/examples/multiple_components.qf @@ -1,13 +1,13 @@ Vertical{ str x - Button{ + Blue Button{ "Open firefox", System("/usr/bin/firefox"), Animated, x } int y = 20 - Slider { + Yellow Slider { "A Slider", y, 0, @@ -17,17 +17,17 @@ Vertical{ Horizontal { int z = 1 int w - Dropdown { + Red Dropdown { [ "Zain", "Mahesh", "Alqama", "Vaidic", "Mundane", "Advait", ], z } - Toggle { + Cyan Toggle { [ "On", "Off", ], w } } - Button { + RedLight Button { "Exit", "Exit", Ascii diff --git a/tests/test1.cpp b/tests/test1.cpp index e1051da..cf93e21 100644 --- a/tests/test1.cpp +++ b/tests/test1.cpp @@ -19,41 +19,41 @@ auto parse_helper(std::string &&str) { TEST_CASE("Parse Simple") { // expect pass - REQUIRE(parse_helper("Vertical{Button{\"amool\",\"bmpp\",Ascii}}")); + REQUIRE(parse_helper("Vertical{Red Button{\"amool\",\"bmpp\",Ascii}}")); REQUIRE(parse_helper("Vertical{Button{\"amool\",\"bmpp\",Simple}}")); - REQUIRE(parse_helper("Vertical{Button{\"amool\",\"bmpp\",Animated}}")); + REQUIRE(parse_helper("Vertical{YellowLight Button{\"amool\",\"bmpp\",Animated}}")); REQUIRE(parse_helper("Vertical{Button{\"amool\",\"bmpp\"}}")); - REQUIRE(parse_helper("Vertical{str x Button{\"amool\",System(\"ls\"), x}}")); + REQUIRE(parse_helper("Vertical{str x Blue Button{\"amool\",System(\"ls\"), x}}")); REQUIRE(parse_helper("Horizontal{Button{\"amool\",\"bmpp\",Ascii}}")); - REQUIRE(parse_helper("Horizontal{Button{\"amool\",\"bmpp\",Simple}}")); + REQUIRE(parse_helper("Horizontal{Cyan Button{\"amool\",\"bmpp\",Simple}}")); REQUIRE(parse_helper("Horizontal{Button{\"amool\",\"bmpp\",Animated}}")); - REQUIRE(parse_helper("Horizontal{Button{\"amool\",\"bmpp\"}}")); + REQUIRE(parse_helper("Horizontal{CyanLight Button{\"amool\",\"bmpp\"}}")); REQUIRE(parse_helper( "Horizontal{str y Button{\"amool\",System(\"mkdir dir1\"), y}}")); - REQUIRE(parse_helper("Vertical{int x Slider{\"amool\", x, 5, 100, 1}}")); + REQUIRE(parse_helper("Vertical{int x Black Slider{\"amool\", x, 5, 100, 1}}")); REQUIRE(parse_helper("Horizontal{int y Slider{\"amool\", y, 5, 100, 1}}")); REQUIRE(parse_helper( - "Horizontal{ Button{ \"amool\" , " + "Horizontal{ White Button{ \"amool\" , " "\"bmpp\" , Simple } }")); REQUIRE( parse_helper("Vertical{ Button{ \"amool\" , " "\"bmpp\" , Simple } }")); REQUIRE(parse_helper( - "Vertical{int y Dropdown{[\"Physics\", \"Maths\", \"Chemistry\", " + "Vertical{int y Magenta Dropdown{[\"Physics\", \"Maths\", \"Chemistry\", " " \"Biology\",], y}}")); - REQUIRE(parse_helper("Horizontal{int z Menu{[\"Physics\", \"Maths\", " + REQUIRE(parse_helper("Horizontal{int z Default Menu{[\"Physics\", \"Maths\", " "\"Chemistry\", \"Biology\",], z}}")); REQUIRE(parse_helper("Vertical{int opt Toggle{[\"Opt1\", \"Opt2\",], opt}}")); - REQUIRE(parse_helper("Horizontal{int a Toggle{[\"Opt1\", \"Opt2\",], a}}")); + REQUIRE(parse_helper("Horizontal{int a MagentaLight Toggle{[\"Opt1\", \"Opt2\",], a}}")); REQUIRE(parse_helper("Vertical{int b Toggle{[\"Opt1\", \"Opt2\",], b}}")); - REQUIRE(parse_helper("Horizontal{int x_ Toggle{[\"Opt1\", \"Opt2\",], x_}}")); + REQUIRE(parse_helper("Horizontal{int x_ GrayDark Toggle{[\"Opt1\", \"Opt2\",], x_}}")); // expect fail REQUIRE(!parse_helper("\"amool\"{Button{\"amool\",\"bmpp\",\"cmqq\"}}")); - REQUIRE(!parse_helper("\"amool\"{Button{\"amool\",\"bmpp\",Ascii}}")); + REQUIRE(!parse_helper("\"amool\"{\"Red\" Button{\"amool\",\"bmpp\",Ascii}}")); REQUIRE(!parse_helper("\"amool\"{_Button{\"amool\",\"bmpp\",Ascii}")); REQUIRE(!parse_helper("Vertical{_Button{\"amool\",\"bmpp\",Ascii}_}")); REQUIRE(!parse_helper("Horizontal{Button{\"amool\",system(\"ls\")}}")); @@ -67,66 +67,68 @@ TEST_CASE("Parse Simple") { TEST_CASE("Parse Complex") { REQUIRE(parse_helper("Vertical{\ - Button{\"amool\",\"bmpp\",Simple} \ + BlueLight Button{\"amool\",\"bmpp\",Simple} \ Button{\"amool\",\"bmpp\",Ascii} \ Horizontal{\ - Button{\"amool\",\"bmpp\",Animated} \ + Red Button{\"amool\",\"bmpp\",Animated} \ Button{\"amool\",System(\"mkdir dir1\")}} \ }")); REQUIRE(parse_helper("Vertical{\ str z\ - Button{\"amool\",\"bmpp\", Ascii}\ + Blue Button{\"amool\",\"bmpp\", Ascii}\ Button{\"amool\",System(\"ls\"), Animated, z} \ Horizontal{\ int x \ int y \ - Slider{\"amool\", x, 1, 100, 10} \ + Magenta Slider{\"amool\", x, 1, 100, 10} \ Slider{\"amool\", y, 1, 200, 100}} \ }")); REQUIRE(parse_helper("Vertical{\ - Button{\"amool\",\"bmpp\",Ascii}\ + str x \ + Button{\"amool\",\"bmpp\", Ascii, x}\ }")); REQUIRE(parse_helper("Horizontal{\ - Button{\"amool\",\"bmpp\",Ascii}\ + Yellow Button{\"amool\",\"bmpp\",Ascii}\ }")); } TEST_CASE("Parse Multiple Components in any order") { REQUIRE(parse_helper("Horizontal{\ int a\ - Slider{\"amool\", a, 1, 100, 1} \ + Default Slider{\"amool\", a, 1, 100, 1} \ Button{\"amool\" , \"bmpp\", Animated} \ }")); REQUIRE(parse_helper("Vertical{\ int a\ - Dropdown{[\"Physics\", \"Maths\", \"Chemistry\", \"Biology\",], a} \ - Button{\"amool\" , \"bmpp\", Animated} \ + Red Dropdown{[\"Physics\", \"Maths\", \"Chemistry\", \"Biology\",], a} \ + str x\ + Magenta Button{\"amool\" , \"bmpp\", Animated, x} \ }")); REQUIRE(parse_helper("Vertical{\ int a = 20\ Slider{\"amool\" ,a, 1, 100, 1} \ Button{\"amool\" , System(\"bmpp\"), Ascii} \ int b = 0\ - Menu{[\"Physics\", \"Maths\", \"Chemistry\", \"Biology\",], b} \ + Black Menu{[\"Physics\", \"Maths\", \"Chemistry\", \"Biology\",], HorizontalAnimated, b} \ }")); } TEST_CASE("Parse Recursive") { // expect pass REQUIRE(parse_helper("Vertical{\ - Button{\"amool\",\"bmpp\", Animated} \ + YellowLight Button{\"amool\",\"bmpp\", Animated} \ Button{\"amool\",\"bmpp\", Simple} \ str x\ Button{\"amool\",System(\"mkdir dir1\"), x} \ Horizontal{\ int a = 40\ - Slider{\"amool\", a, 1, 100, 10} \ + Blue Slider{\"amool\", a, 1, 100, 10} \ int b = 10\ Slider{\"amool\", b, 1, 200, 100} \ int m = 0\ - Menu{[\"Physics\", \"Maths\", \"Chemistry\", \"Biology\",], m} \ + RedLight Menu{[\"Physics\", \"Maths\", \"Chemistry\", \"Biology\",], m} \ Vertical{\ Button{\"amool\",\"bmpp\", Ascii} \ Button{\"amool\",System(\"ls\"), Animated} \ @@ -136,14 +138,14 @@ TEST_CASE("Parse Recursive") { // expect fail REQUIRE(!parse_helper("Vertical{\ - Button{\"amool\",\"bmpp\",Ascii \ + red Button{\"amool\",\"bmpp\",Ascii \ Button{\"amool\",\"bmpp\",\"cmqq\"} \ }\ }")); REQUIRE(!parse_helper("Horizontal{\ Button{\"amool\",\"bmpp\" Animated \ - Button{\"amool\",\"bmpp\" Ascii} \ + blue Button{\"amool\",\"bmpp\" Ascii} \ }\ }")); From e2332d1d25a5385cdd82b447db3fcfe65eee5552 Mon Sep 17 00:00:00 2001 From: "Vedant R. Nimje" Date: Sun, 10 Sep 2023 23:02:20 +0530 Subject: [PATCH 2/2] Updated Output video link, to reflect new changes --- README.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/README.md b/README.md index 2f2ac8d..fc38620 100644 --- a/README.md +++ b/README.md @@ -48,8 +48,7 @@ Vertical{ ### Output -https://github.com/vrnimje/quick-ftxui/assets/103848930/0bc3b98d-a85f-415f-b002-9f15894a9ce2 - +https://github.com/vrnimje/quick-ftxui/assets/103848930/c0d92edb-79fe-434d-9d72-0a577f617ed5 ## Features * #### Supports majority of FTXUI components, listed below: