You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I might be doing something completely wrong but I am breaking my brain on this for a while now.
I'm trying to create a single full-screen canvas so that I could draw into it at any point in the terminal. I expect that when I create a ftxui::ScreenInteractive::Fullscreen() interactive screen, it should initialize its size to the full size of the terminal, which, I believe it doesn't. Then, when I create a canvas it is initialized to an even smaller size, so that I can effectively draw in only part of the screen.
It feels like the task should be fairly simple, so I wonder what I might be doing wrong here. The code I use to test this out is below:
#include<ftxui/component/screen_interactive.hpp>
#include<ftxui/screen/string.hpp>
#include<string>
#include"ftxui/component/component.hpp"
#include"ftxui/component/event.hpp"
#include"ftxui/component/loop.hpp"
#include"ftxui/dom/elements.hpp"
#include"ftxui/screen/color.hpp"namespace {
const ftxui::Color kYellowishColor = ftxui::Color::RGB(255, 200, 100);
}
intmain() {
auto screen = ftxui::ScreenInteractive::Fullscreen();
int x{};
int y{};
auto component = ftxui::Renderer([&] {
auto c = ftxui::Canvas{screen.dimx(), screen.dimy()};
c.DrawBlock(x, y, true, kYellowishColor);
c.DrawBlock(x + 1, y, true, kYellowishColor);
returnftxui::vbox(
{ftxui::hbox({ftxui::text("canvas: " + std::to_string(screen.dimx()) +
"" + std::to_string(screen.dimy())),
ftxui::separator(),
ftxui::text("pos: " + std::to_string(x) + "" +
std::to_string(y))}),
ftxui::canvas(std::move(c))});
});
component |= ftxui::CatchEvent([&](ftxui::Event event) {
if (event.is_character()) {
if (event.character()[0] == 'q') { screen.Exit(); }
}
if (event == ftxui::Event::ArrowRight) { x += 2; }
if (event == ftxui::Event::ArrowLeft) { x -= 2; }
if (event == ftxui::Event::ArrowDown) { y++; }
if (event == ftxui::Event::ArrowUp) { y--; }
returntrue;
});
ftxui::Loop loop{&screen, component};
while (!loop.HasQuitted()) {
loop.RunOnce();
std::this_thread::sleep_for(std::chrono::milliseconds(10));
}
return EXIT_SUCCESS;
}
The text was updated successfully, but these errors were encountered:
niosus
changed the title
ftxui::ScreenInteractive::Fullscreen and ftxui::Canvas do not render a full screen canvasftxui::Canvas is not full screen when using ScreenInteractiveFeb 3, 2025
niosus
changed the title
ftxui::Canvas is not full screen when using ScreenInteractiveCanvas is not full screen when using ScreenInteractiveFeb 3, 2025
I might be doing something completely wrong but I am breaking my brain on this for a while now.
I'm trying to create a single full-screen canvas so that I could draw into it at any point in the terminal. I expect that when I create a
ftxui::ScreenInteractive::Fullscreen()
interactive screen, it should initialize its size to the full size of the terminal, which, I believe it doesn't. Then, when I create acanvas
it is initialized to an even smaller size, so that I can effectively draw in only part of the screen.It feels like the task should be fairly simple, so I wonder what I might be doing wrong here. The code I use to test this out is below:
The text was updated successfully, but these errors were encountered: