This commit is contained in:
ArthurSonzogni 2025-06-19 12:41:23 +02:00
parent 67bf515553
commit d86a08b8c9
No known key found for this signature in database
GPG Key ID: 41D98248C074CD6C
2 changed files with 15 additions and 23 deletions

View File

@ -105,15 +105,14 @@ class ScreenInteractive : public Screen {
Fullscreen, Fullscreen,
TerminalOutput, TerminalOutput,
}; };
Dimension dimension_ = Dimension::Fixed; const Dimension dimension_ = Dimension::Fixed;
bool use_alternative_screen_ = false; const int dimension_fixed_x_ = 0;
const int dimension_fixed_y_ = 0;
const bool use_alternative_screen_ = false;
ScreenInteractive(Dimension dimension, ScreenInteractive(Dimension dimension,
bool use_alternative_screen); bool use_alternative_screen);
ScreenInteractive(Dimension dimension, ScreenInteractive(int dimx, int dimy); // Dimension::Fixed constructor.
int dimx,
int dimy,
bool use_alternative_screen);
bool track_mouse_ = true; bool track_mouse_ = true;
@ -129,8 +128,6 @@ class ScreenInteractive : public Screen {
bool animation_requested_ = false; bool animation_requested_ = false;
animation::TimePoint previous_animation_time_; animation::TimePoint previous_animation_time_;
int fixed_dimx_ = 0;
int fixed_dimy_ = 0;
int cursor_x_ = 1; int cursor_x_ = 1;
int cursor_y_ = 1; int cursor_y_ = 1;

View File

@ -354,25 +354,16 @@ ScreenInteractive::ScreenInteractive(Dimension dimension,
task_receiver_ = MakeReceiver<Task>(); task_receiver_ = MakeReceiver<Task>();
} }
ScreenInteractive::ScreenInteractive(Dimension dimension, ScreenInteractive::ScreenInteractive(int dimx, int dimy)
int dimx,
int dimy,
bool use_alternative_screen)
: Screen(0, 0), : Screen(0, 0),
dimension_(dimension), dimension_fixed_x_(dimx),
fixed_dimx_(dimx), fixed_dimy_(dimy), dimension_fixed_y_(dimy) {
use_alternative_screen_(use_alternative_screen) {
task_receiver_ = MakeReceiver<Task>(); task_receiver_ = MakeReceiver<Task>();
} }
// static // static
ScreenInteractive ScreenInteractive::FixedSize(int dimx, int dimy) { ScreenInteractive ScreenInteractive::FixedSize(int dimx, int dimy) {
return { return { dimx, dimy };
Dimension::Fixed,
dimx,
dimy,
false,
};
} }
/// Create a ScreenInteractive taking the full terminal size. This is using the /// 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 // static
ScreenInteractive ScreenInteractive::TerminalOutput() { ScreenInteractive ScreenInteractive::TerminalOutput() {
return { return {
@ -412,6 +405,8 @@ ScreenInteractive ScreenInteractive::TerminalOutput() {
}; };
} }
/// Create a ScreenInteractive whose width and height match the component being
/// drawn.
// static // static
ScreenInteractive ScreenInteractive::FitComponent() { ScreenInteractive ScreenInteractive::FitComponent() {
return { return {
@ -905,8 +900,8 @@ void ScreenInteractive::Draw(Component component) {
document->ComputeRequirement(); document->ComputeRequirement();
switch (dimension_) { switch (dimension_) {
case Dimension::Fixed: case Dimension::Fixed:
dimx = fixed_dimx_; dimx = dimension_fixed_x_;
dimy = fixed_dimy_; dimy = dimension_fixed_y_;
break; break;
case Dimension::TerminalOutput: case Dimension::TerminalOutput:
dimx = terminal.dimx; dimx = terminal.dimx;