1 Commits

Author SHA1 Message Date
9f6cfc17f8 Restore terminal state on termination 2025-07-24 18:55:49 +02:00
3 changed files with 16 additions and 3 deletions

View File

@ -51,6 +51,8 @@ public:
static enum UserInput readUserInput();
static void terminateTUI();
private:
static string sCpuUsage;
static string sRamUsage;
@ -80,4 +82,4 @@ private:
string formatSpeed(time_t u32ShredTimeDelta, unsigned long ulWrittenBytes);
static void vTruncateText(string *psText, uint16_t u16MaxLenght);
};
#endif // TUI_H_
#endif // TUI_H_

View File

@ -198,8 +198,9 @@ void reHDD::ThreadUserInput()
ui->updateTUI(&listDrives, u8SelectedEntry);
break;
case TUI::UserInput::Terminate:
cout << "Terminate" << endl;
// cout << "Terminate" << endl;
stopShredAllDrives(&listDrives);
ui->terminateTUI();
sleep(5); // sleep 5 sec
std::exit(1); // Terminates main, doesn't wait for threads
break;
@ -724,4 +725,4 @@ bool reHDD::getSystemDrive(string &systemDrive)
pclose(outputfileHwinfo);
return systemDriveFound;
}
}

View File

@ -63,6 +63,11 @@ void TUI::initTUI()
void TUI::updateTUI(list<Drive> *plistDrives, uint8_t u8SelectedEntry)
{
if (isendwin())
{
return;
}
mxUIrefresh.lock();
uint16_t u16StdscrX, u16StdscrY;
getmaxyx(stdscr, u16StdscrY, u16StdscrX);
@ -250,6 +255,11 @@ enum TUI::UserInput TUI::readUserInput()
return TUI::UserInput::Undefined;
}
void TUI::terminateTUI()
{
endwin();
}
void TUI::centerTitle(WINDOW *pwin, const char *title)
{
int x, maxX, stringSize;