From 898b8d672ef2cea386048b79276db26867997bae Mon Sep 17 00:00:00 2001
From: Arthur Sonzogni <sonzogniarthur@gmail.com>
Date: Fri, 31 Mar 2023 17:44:01 +0200
Subject: [PATCH] Fix useless new line when using the alternative screen.
 (#610)

Fix:https://github.com/ArthurSonzogni/FTXUI/issues/609
---
 CHANGELOG.md                               | 1 +
 src/ftxui/component/screen_interactive.cpp | 6 +++++-
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index 39ef3c72..4dd1eb6f 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -7,6 +7,7 @@ current (development)
 ### Component
 - Feature: Support `ResizableSplit` with customizable separator.
 - Breaking: MenuDirection enum is renamed Direction
+- Fix: Remove useless new line when using an alternative screen.
 
 ### Dom
 - Feature: Add the dashed style for border and separator.
diff --git a/src/ftxui/component/screen_interactive.cpp b/src/ftxui/component/screen_interactive.cpp
index 9f4eba73..dfca52e4 100644
--- a/src/ftxui/component/screen_interactive.cpp
+++ b/src/ftxui/component/screen_interactive.cpp
@@ -460,9 +460,13 @@ void ScreenInteractive::PostMain() {
     g_active_screen->Install();
   } else {
     Uninstall();
+
+    std::cout << '\r';
     // On final exit, keep the current drawing and reset cursor position one
     // line after it.
-    std::cout << std::endl;
+    if (!use_alternative_screen_) {
+      std::cout << std::endl;
+    }
   }
 }
 
-- 
GitLab