Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Should Table::SelectRectangle() wrap in the way it does? #806

Open
lukester1975 opened this issue Jan 9, 2024 · 1 comment
Open

Should Table::SelectRectangle() wrap in the way it does? #806

lukester1975 opened this issue Jan 9, 2024 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@lukester1975
Copy link

lukester1975 commented Jan 9, 2024

Hi

As subject - it leads to surprising (to me!) behaviour:

#include <ftxui/dom/table.hpp>
#include <ftxui/screen/screen.hpp>

#include <iostream>

void bad()
{
	auto table = ftxui::Table({ { "h1" }, { "h2" } });
	table.SelectAll().Decorate(ftxui::flex_grow);
	table.SelectRows(2, -1).DecorateAlternateRow(ftxui::bgcolor(ftxui::Color::Palette256::Grey30));

	auto document = table.Render();
	auto screen = ftxui::Screen::Create(ftxui::Dimension::Full(), ftxui::Dimension::Fit(document));

	ftxui::Render(screen, document);
	screen.Print();
}

void ok()
{
	auto table = ftxui::Table({ { "h1" }, { "h2" }, { "r1" }, { "r2" }, { "r3" } });
	table.SelectAll().Decorate(ftxui::flex_grow);
	table.SelectRows(2, -1).DecorateAlternateRow(ftxui::bgcolor(ftxui::Color::Palette256::Grey30));

	auto document = table.Render();
	auto screen = ftxui::Screen::Create(ftxui::Dimension::Full(), ftxui::Dimension::Fit(document));

	ftxui::Render(screen, document);
	screen.Print();
}

ftxui1

I.e. two header rows, then alternate background colours on data rows. In the first case, decorating row 2 -> end wraps back to 0, which I assume is unintentional?

It seems a shame to have to check that there are data rows before calling DecorateAlternateRow() so I did a quick hack fix here: lukester1975@0a19eba.

Thanks!

@ArthurSonzogni
Copy link
Owner

Yes, we should probably fix this.
Thanks for reporting it!

@ArthurSonzogni ArthurSonzogni self-assigned this Jan 10, 2024
@ArthurSonzogni ArthurSonzogni added the bug Something isn't working label Jan 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants