ArthurSonzogni / FTXUI

:computer: C++ Functional Terminal User Interface. :heart:
MIT License
7.02k stars 427 forks source link

Creating a table with 2 columns #912

Closed sdmg15 closed 3 months ago

sdmg15 commented 3 months ago

The basic examples given in https://github.com/arthursonzogni/ftxui/blob/cdf28903a7781f97ba94d30b79c3a4b0c97ccce7/include/ftxui/dom/table.hpp Doesn't work.

Both of constructors of the class Table seems to be viable and thus causing two matches.

ArthurSonzogni commented 3 months ago

Thanks for reporting this.

What doesn't work? Would you like to author the PR updating the documentation?

sdmg15 commented 3 months ago

So you can see what goes wrong here https://godbolt.org/z/Kvfnn3jeo.

If we're to update the doc, it will become more verbose

auto table = Table(
    std::vector<std::vector<std::string>>{
        {"X", "Y"}
    }
);

Or either using string literals suffix to disambiguate.

using namespace std::literals;
auto table = Table(
   {
        {"X"s, "Y"}
    }
);

Let me know what you think is best, I'll work on that.

ArthurSonzogni commented 3 months ago

I am surprise you couldn't use the same as in the example: https://github.com/ArthurSonzogni/FTXUI/blob/547d9278d8416d92dd8e7d7e1e1bf7b84ca6fbb1/examples/dom/table.cpp#L17

Doesn't it work?

sdmg15 commented 3 months ago

What you just linked works. It's "edge case" I'd say. Please check the godbolt link.
When you try to create a table 2x2 or 1x1 that's when you'll face the error.

ArthurSonzogni commented 3 months ago

Thanks!

I believe I fixed the issue you are experiencing. Could you please confirm this fully fix it from your side?

sdmg15 commented 3 months ago

Looks solved, thanks for the great library and support.

I'd like to open a PR to add https://github.com/sdmg15/cryptofetch to the list of projects using FTXUI :)

ArthurSonzogni commented 3 months ago

You are welcome! Thanks for reporting this!