Get Screen Dimensions #1047
-
I tried doing this: auto screen = ScreenInteractive::Fullscreen();
FileLogger fl("logs.txt");
fl << "screen dimx: " << screen.dimx() << " screen dimy: " << screen.dimy() << std::endl; but it prints out
Am I using this incorrectly? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
When I use it in this context it works properly: auto component = Container::Vertical({
Renderer([&] {
fl << "inside: screen dimx: " << screen.dimx() << " screen dimy: " << screen.dimy() << std::endl; inside: screen dimx: 167 screen dimy: 44 I'm not exactly sure what initializes these values but I guess trying to check the value before you do anything graphical might not be the best idea. |
Beta Was this translation helpful? Give feedback.
-
Hello @cuppajoeman The dimensions reported are the one from the last drawing. If you haven't drawn something 0x0 will be reported. The dimension depends on the terminal screen dimensions, the component dimension and the ftxui::Screen config. That's why it requires drawing the component first to report the size. To access the terminal dimension directly, you can use |
Beta Was this translation helpful? Give feedback.
Hello @cuppajoeman
The dimensions reported are the one from the last drawing. If you haven't drawn something 0x0 will be reported.
The dimension depends on the terminal screen dimensions, the component dimension and the ftxui::Screen config. That's why it requires drawing the component first to report the size.
To access the terminal dimension directly, you can use
ftxui::Terminal::Size()
instead.