fix: ScreenInteractive::FixedSize screen stomps on the history terminal output

This commit is contained in:
Zane Zhou 2025-06-19 17:22:07 +08:00
parent 6440a88dc6
commit 67bf515553
2 changed files with 23 additions and 17 deletions

View File

@ -107,9 +107,12 @@ class ScreenInteractive : public Screen {
}; };
Dimension dimension_ = Dimension::Fixed; Dimension dimension_ = Dimension::Fixed;
bool use_alternative_screen_ = false; bool use_alternative_screen_ = false;
ScreenInteractive(int dimx,
ScreenInteractive(Dimension dimension,
bool use_alternative_screen);
ScreenInteractive(Dimension dimension,
int dimx,
int dimy, int dimy,
Dimension dimension,
bool use_alternative_screen); bool use_alternative_screen);
bool track_mouse_ = true; bool track_mouse_ = true;
@ -126,6 +129,8 @@ 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

@ -346,22 +346,31 @@ void AnimationListener(std::atomic<bool>* quit, Sender<Task> out) {
} // namespace } // namespace
ScreenInteractive::ScreenInteractive(int dimx, ScreenInteractive::ScreenInteractive(Dimension dimension,
int dimy,
Dimension dimension,
bool use_alternative_screen) bool use_alternative_screen)
: Screen(dimx, dimy), : Screen(0, 0),
dimension_(dimension), dimension_(dimension),
use_alternative_screen_(use_alternative_screen) { use_alternative_screen_(use_alternative_screen) {
task_receiver_ = MakeReceiver<Task>(); task_receiver_ = MakeReceiver<Task>();
} }
ScreenInteractive::ScreenInteractive(Dimension dimension,
int dimx,
int dimy,
bool use_alternative_screen)
: Screen(0, 0),
dimension_(dimension),
fixed_dimx_(dimx), fixed_dimy_(dimy),
use_alternative_screen_(use_alternative_screen) {
task_receiver_ = MakeReceiver<Task>();
}
// static // static
ScreenInteractive ScreenInteractive::FixedSize(int dimx, int dimy) { ScreenInteractive ScreenInteractive::FixedSize(int dimx, int dimy) {
return { return {
Dimension::Fixed,
dimx, dimx,
dimy, dimy,
Dimension::Fixed,
false, false,
}; };
} }
@ -380,8 +389,6 @@ ScreenInteractive ScreenInteractive::Fullscreen() {
// static // static
ScreenInteractive ScreenInteractive::FullscreenPrimaryScreen() { ScreenInteractive ScreenInteractive::FullscreenPrimaryScreen() {
return { return {
0,
0,
Dimension::Fullscreen, Dimension::Fullscreen,
false, false,
}; };
@ -392,8 +399,6 @@ ScreenInteractive ScreenInteractive::FullscreenPrimaryScreen() {
// static // static
ScreenInteractive ScreenInteractive::FullscreenAlternateScreen() { ScreenInteractive ScreenInteractive::FullscreenAlternateScreen() {
return { return {
0,
0,
Dimension::Fullscreen, Dimension::Fullscreen,
true, true,
}; };
@ -402,8 +407,6 @@ ScreenInteractive ScreenInteractive::FullscreenAlternateScreen() {
// static // static
ScreenInteractive ScreenInteractive::TerminalOutput() { ScreenInteractive ScreenInteractive::TerminalOutput() {
return { return {
0,
0,
Dimension::TerminalOutput, Dimension::TerminalOutput,
false, false,
}; };
@ -412,8 +415,6 @@ ScreenInteractive ScreenInteractive::TerminalOutput() {
// static // static
ScreenInteractive ScreenInteractive::FitComponent() { ScreenInteractive ScreenInteractive::FitComponent() {
return { return {
0,
0,
Dimension::FitComponent, Dimension::FitComponent,
false, false,
}; };
@ -904,8 +905,8 @@ void ScreenInteractive::Draw(Component component) {
document->ComputeRequirement(); document->ComputeRequirement();
switch (dimension_) { switch (dimension_) {
case Dimension::Fixed: case Dimension::Fixed:
dimx = dimx_; dimx = fixed_dimx_;
dimy = dimy_; dimy = fixed_dimy_;
break; break;
case Dimension::TerminalOutput: case Dimension::TerminalOutput:
dimx = terminal.dimx; dimx = terminal.dimx;