summaryrefslogtreecommitdiffstats
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
parent87db37966a8969a931fd49ebc2f9709bd27290d9 (diff)
Logic to retain screen and other changes
* Retain htop screen after quitting * Pass additional flag to CRT_init()
-rw-r--r--CRT.c20
-rw-r--r--CRT.h2
-rw-r--r--CommandLine.c2
3 files changed, 21 insertions, 3 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();
diff --git a/CRT.h b/CRT.h
index ae78c9c5..f5fd9452 100644
--- a/CRT.h
+++ b/CRT.h
@@ -197,7 +197,7 @@ void CRT_setMouse(bool enabled);
#define CRT_setMouse(enabled)
#endif
-void CRT_init(const Settings* settings, bool allowUnicode);
+void CRT_init(const Settings* settings, bool allowUnicode, bool retainScreenOnExit);
void CRT_done(void);
diff --git a/CommandLine.c b/CommandLine.c
index 0f168fb0..3d1f953f 100644
--- a/CommandLine.c
+++ b/CommandLine.c
@@ -376,7 +376,7 @@ int CommandLine_run(int argc, char** argv) {
}
host->iterationsRemaining = flags.iterationsRemaining;
- CRT_init(settings, flags.allowUnicode);
+ CRT_init(settings, flags.allowUnicode, flags.iterationsRemaining != -1);
MainPanel* panel = MainPanel_new();
ProcessList_setPanel(pl, (Panel*) panel);

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