22#include < iostream>
33
44#include < docopt/docopt.h>
5+ #include < ftxui/component/captured_mouse.hpp> // for ftxui
6+ #include < ftxui/component/component.hpp> // for Slider
7+ #include < ftxui/component/screen_interactive.hpp> // for ScreenInteractive
58#include < spdlog/spdlog.h>
69
7- // This file will be generated automatically when you run the CMake configuration step.
8- // It creates a namespace called `myproject`.
9- // You can modify the source template at `configured_files/config.hpp.in`.
10+ // This file will be generated automatically when you run the CMake
11+ // configuration step. It creates a namespace called `myproject`. You can modify
12+ // the source template at `configured_files/config.hpp.in`.
1013#include < internal_use_only/config.hpp>
1114
1215static constexpr auto USAGE =
13- R"( Naval Fate.
16+ R"( intro
1417
1518 Usage:
16- naval_fate ship new <name>...
17- naval_fate ship <name> move <x> <y> [--speed=<kn>]
18- naval_fate ship shoot <x> <y>
19- naval_fate mine (set|remove) <x> <y> [--moored | --drifting]
20- naval_fate (-h | --help)
21- naval_fate --version
19+ intro
20+ intro (-h | --help)
21+ intro --version
2222 Options:
2323 -h --help Show this screen.
2424 --version Show version.
25- --speed=<kn> Speed in knots [default: 10].
26- --moored Moored (anchored) mine.
27- --drifting Drifting mine.
2825)" ;
2926
3027int main (int argc, const char **argv)
@@ -35,15 +32,56 @@ int main(int argc, const char **argv)
3532 true ,// show help if requested
3633 fmt::format (" {} {}" ,
3734 myproject::cmake::project_name,
38- myproject::cmake::project_version));// version string, acquired from config.hpp via CMake
35+ myproject::cmake::project_version));// version string, acquired
36+ // from config.hpp via CMake
3937
40- for (auto const &arg : args) { std::cout << arg.first << " =" << arg.second << ' \n ' ; }
38+ using namespace ftxui ;
39+ std::vector<std::string> toggle_1_entries = {
40+ " On" ,
41+ " Off" ,
42+ };
43+ std::vector<std::string> toggle_2_entries = {
44+ " Enabled" ,
45+ " Disabled" ,
46+ };
47+ std::vector<std::string> toggle_3_entries = {
48+ " 10€" ,
49+ " 0€" ,
50+ };
51+ std::vector<std::string> toggle_4_entries = {
52+ " Nothing" ,
53+ " One element" ,
54+ " Several elements" ,
55+ };
4156
57+ auto screen = ScreenInteractive::TerminalOutput ();
4258
43- // Use the default logger (stdout, multi-threaded, colored)
44- spdlog::info (" Hello, {}!" , " World" );
59+ int toggle_1_selected = 0 ;
60+ int toggle_2_selected = 0 ;
61+ int toggle_3_selected = 0 ;
62+ int toggle_4_selected = 0 ;
63+ Component toggle_1 = Toggle (&toggle_1_entries, &toggle_1_selected);
64+ Component toggle_2 = Toggle (&toggle_2_entries, &toggle_2_selected);
65+ Component toggle_3 = Toggle (&toggle_3_entries, &toggle_3_selected);
66+ Component toggle_4 = Toggle (&toggle_4_entries, &toggle_4_selected);
67+ auto quit_button = Button (" Save & Quit" , screen.ExitLoopClosure ());
68+
69+ auto container = Container::Vertical ({ toggle_1, toggle_2, toggle_3, toggle_4, quit_button });
70+
71+ auto renderer = Renderer (container, [&] {
72+ return vbox ({ text (" Choose your options:" ),
73+ text (" " ),
74+ hbox (text (" * Poweroff on startup : " ), toggle_1->Render ()),
75+ hbox (text (" * Out of process : " ), toggle_2->Render ()),
76+ hbox (text (" * Price of the information : " ), toggle_3->Render ()),
77+ hbox (text (" * Number of elements : " ), toggle_4->Render ()),
78+ text (" " ),
79+ hbox (toggle_1_selected == 0 ? color (Color::Green, quit_button->Render ())
80+ : color (Color::Blue, quit_button->Render ())) });
81+ });
82+
83+ screen.Loop (renderer);
4584
46- fmt::print (" Hello, from {}\n " , " {fmt}" );
4785 } catch (const std::exception &e) {
4886 fmt::print (" Unhandled exception in main: {}" , e.what ());
4987 }
0 commit comments