diff options
author | Sahil Siddiq <icegambit91@gmail.com> | 2023-05-22 11:09:11 +0530 |
---|---|---|
committer | BenBE <BenBE@geshi.org> | 2023-05-22 12:07:16 +0200 |
commit | dc883b2910f1feea7806fa5109916f9e1ae0d030 (patch) | |
tree | 5c8f0f0c6d654db44c8ca5a429e3a0d52c3b0956 /CRT.c | |
parent | 87db37966a8969a931fd49ebc2f9709bd27290d9 (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.c | 20 |
1 files changed, 19 insertions, 1 deletions
@@ -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(); |