diff --git a/include/ftxui/component/screen_interactive.hpp b/include/ftxui/component/screen_interactive.hpp index 8b90a2be..950b1931 100644 --- a/include/ftxui/component/screen_interactive.hpp +++ b/include/ftxui/component/screen_interactive.hpp @@ -105,15 +105,14 @@ class ScreenInteractive : public Screen { Fullscreen, TerminalOutput, }; - Dimension dimension_ = Dimension::Fixed; - bool use_alternative_screen_ = false; + const Dimension dimension_ = Dimension::Fixed; + const int dimension_fixed_x_ = 0; + const int dimension_fixed_y_ = 0; + const bool use_alternative_screen_ = false; ScreenInteractive(Dimension dimension, bool use_alternative_screen); - ScreenInteractive(Dimension dimension, - int dimx, - int dimy, - bool use_alternative_screen); + ScreenInteractive(int dimx, int dimy); // Dimension::Fixed constructor. bool track_mouse_ = true; @@ -129,8 +128,6 @@ class ScreenInteractive : public Screen { bool animation_requested_ = false; animation::TimePoint previous_animation_time_; - int fixed_dimx_ = 0; - int fixed_dimy_ = 0; int cursor_x_ = 1; int cursor_y_ = 1; diff --git a/src/ftxui/component/screen_interactive.cpp b/src/ftxui/component/screen_interactive.cpp index bce10aeb..deddc0c5 100644 --- a/src/ftxui/component/screen_interactive.cpp +++ b/src/ftxui/component/screen_interactive.cpp @@ -354,25 +354,16 @@ ScreenInteractive::ScreenInteractive(Dimension dimension, task_receiver_ = MakeReceiver(); } -ScreenInteractive::ScreenInteractive(Dimension dimension, - int dimx, - int dimy, - bool use_alternative_screen) +ScreenInteractive::ScreenInteractive(int dimx, int dimy) : Screen(0, 0), - dimension_(dimension), - fixed_dimx_(dimx), fixed_dimy_(dimy), - use_alternative_screen_(use_alternative_screen) { + dimension_fixed_x_(dimx), + dimension_fixed_y_(dimy) { task_receiver_ = MakeReceiver(); } // static ScreenInteractive ScreenInteractive::FixedSize(int dimx, int dimy) { - return { - Dimension::Fixed, - dimx, - dimy, - false, - }; + return { dimx, dimy }; } /// Create a ScreenInteractive taking the full terminal size. This is using the @@ -404,6 +395,8 @@ ScreenInteractive ScreenInteractive::FullscreenAlternateScreen() { }; } +/// Create a ScreenInteractive whose width match the terminal output width and +/// the height matches the component being drawn. // static ScreenInteractive ScreenInteractive::TerminalOutput() { return { @@ -412,6 +405,8 @@ ScreenInteractive ScreenInteractive::TerminalOutput() { }; } +/// Create a ScreenInteractive whose width and height match the component being +/// drawn. // static ScreenInteractive ScreenInteractive::FitComponent() { return { @@ -905,8 +900,8 @@ void ScreenInteractive::Draw(Component component) { document->ComputeRequirement(); switch (dimension_) { case Dimension::Fixed: - dimx = fixed_dimx_; - dimy = fixed_dimy_; + dimx = dimension_fixed_x_; + dimy = dimension_fixed_y_; break; case Dimension::TerminalOutput: dimx = terminal.dimx;