summaryrefslogtreecommitdiffstats
path: root/CRT.c
diff options
context:
space:
mode:
authorSahil Siddiq <icegambit91@gmail.com>2023-05-22 11:09:11 +0530
committerBenBE <BenBE@geshi.org>2023-05-22 12:07:16 +0200
commitdc883b2910f1feea7806fa5109916f9e1ae0d030 (patch)
tree5c8f0f0c6d654db44c8ca5a429e3a0d52c3b0956 /CRT.c
parent87db37966a8969a931fd49ebc2f9709bd27290d9 (diff)
Logic to retain screen and other changes
* Retain htop screen after quitting * Pass additional flag to CRT_init()
Diffstat (limited to 'CRT.c')
-rw-r--r--CRT.c20
1 files changed, 19 insertions, 1 deletions
diff --git a/CRT.c b/CRT.c
index a82fc8c1..1846d4e5 100644
--- a/CRT.c
+++ b/CRT.c
@@ -21,6 +21,7 @@ in the source distribution for its full text.
#include "CommandLine.h"
#include "ProvideCurses.h"
+#include "ProvideTerm.h"
#include "XUtils.h"
#if !defined(NDEBUG) && defined(HAVE_MEMFD_CREATE)
@@ -793,6 +794,8 @@ static int CRT_colorSchemes[LAST_COLORSCHEME][LAST_COLORELEMENT] = {
[COLORSCHEME_BROKENGRAY] = { 0 } // dynamically generated.
};
+static bool CRT_retainScreenOnExit = false;
+
int CRT_scrollHAmount = 5;
int CRT_scrollWheelVAmount = 10;
@@ -951,8 +954,19 @@ void CRT_setMouse(bool enabled) {
}
#endif
-void CRT_init(const Settings* settings, bool allowUnicode) {
+void CRT_init(const Settings* settings, bool allowUnicode, bool retainScreenOnExit) {
initscr();
+
+ if (retainScreenOnExit) {
+ CRT_retainScreenOnExit = true;
+ refresh();
+ tputs(exit_ca_mode, 0, putchar);
+ tputs(clear_screen, 0, putchar);
+ fflush(stdout);
+ enter_ca_mode = 0;
+ exit_ca_mode = 0;
+ }
+
redirectStderr();
noecho();
CRT_crashSettings = settings;
@@ -1056,6 +1070,10 @@ void CRT_done(void) {
attroff(resetColor);
refresh();
+ if (CRT_retainScreenOnExit) {
+ mvcur(-1, -1, LINES - 1, 0);
+ }
+
curs_set(1);
endwin();

© 2014-2024 Faster IT GmbH | imprint | privacy policy