display text on sub-windows
This commit is contained in:
parent
9322ea65a7
commit
4c6aa1f19c
|
@ -8,7 +8,7 @@
|
||||||
#include "../../include/reHDD.h"
|
#include "../../include/reHDD.h"
|
||||||
|
|
||||||
|
|
||||||
TUI::TUI(void){
|
TUI::TUI(void) {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -35,20 +35,29 @@ void TUI::initTUI()
|
||||||
clear();
|
clear();
|
||||||
curs_set(0);
|
curs_set(0);
|
||||||
init_color(COLOR_GRAY, 173, 170, 173);
|
init_color(COLOR_GRAY, 173, 170, 173);
|
||||||
|
|
||||||
|
|
||||||
|
init_pair(COLOR_AREA_STDSCR,COLOR_WHITE, COLOR_BLUE);
|
||||||
|
wbkgd(stdscr, COLOR_PAIR(COLOR_AREA_STDSCR));
|
||||||
|
|
||||||
|
int stdscrX, stdscrY;
|
||||||
|
getmaxyx(stdscr, stdscrY, stdscrX);
|
||||||
|
mvprintw(0, 2, "reHDD - HDD refurbishing tool - Licensed under GPL 3.0 X:%d Y:%d",stdscrX,stdscrY);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TUI::updateTUI(vector <Drive>* pvecDrives) {
|
void TUI::updateTUI(vector <Drive>* pvecDrives) {
|
||||||
|
|
||||||
|
|
||||||
werase(stdscr);
|
//werase(stdscr);
|
||||||
|
|
||||||
int stdscrX, stdscrY;
|
int stdscrX, stdscrY;
|
||||||
getmaxyx(stdscr, stdscrY, stdscrX);
|
getmaxyx(stdscr, stdscrY, stdscrX);
|
||||||
|
|
||||||
init_pair(COLOR_AREA_STDSCR,COLOR_WHITE, COLOR_BLUE);
|
init_pair(COLOR_AREA_STDSCR,COLOR_WHITE, COLOR_BLUE);
|
||||||
wbkgd(stdscr, COLOR_PAIR(COLOR_AREA_STDSCR));
|
wbkgd(stdscr, COLOR_PAIR(COLOR_AREA_STDSCR));
|
||||||
|
|
||||||
mvprintw(0, 2, "reHDD - HDD refurbishing tool - Licensed under GPL 3.0 X:%d Y:%d",stdscrX,stdscrY);
|
// mvprintw(0, 2, "reHDD - HDD refurbishing tool - Licensed under GPL 3.0 X:%d Y:%d",stdscrX,stdscrY);
|
||||||
|
|
||||||
refresh();
|
refresh();
|
||||||
|
|
||||||
|
@ -61,7 +70,7 @@ void TUI::updateTUI(vector <Drive>* pvecDrives) {
|
||||||
vWinDriveEntries.clear();
|
vWinDriveEntries.clear();
|
||||||
|
|
||||||
|
|
||||||
int i = 0;
|
// int i = 0;
|
||||||
|
|
||||||
vector <Drive>::iterator it;
|
vector <Drive>::iterator it;
|
||||||
for (it = pvecDrives->begin(); it != pvecDrives->end(); ++it)
|
for (it = pvecDrives->begin(); it != pvecDrives->end(); ++it)
|
||||||
|
@ -71,17 +80,14 @@ int i = 0;
|
||||||
string sModelName = it->getModelName();
|
string sModelName = it->getModelName();
|
||||||
string sCapacity = it->sCapacityToText();
|
string sCapacity = it->sCapacityToText();
|
||||||
|
|
||||||
|
WINDOW * tmp = createEntryWindow( ((int)(stdscrX/3) - 2), 5, 3, (5* (it - pvecDrives->begin()) )+3, sModelFamily, sModelName, sCapacity);
|
||||||
|
|
||||||
// WINDOW * tmp = createEntryWindow( ((int)(stdscrX/3) - 2), 5, 3, (5* (it - pvecDrives->begin()) )+3, sModelFamily, sModelName, sCapacity);
|
// WINDOW * tmp = createEntryWindow( ((int)(stdscrX/3) - 2), 5, 3, (5* (i) )+3, sModelFamily, sModelName, sCapacity);
|
||||||
|
|
||||||
|
// vWinDriveEntries.push_back(tmp);
|
||||||
WINDOW * tmp = createEntryWindow( ((int)(stdscrX/3) - 2), 5, 3, (5* (i) )+3, sModelFamily, sModelName, sCapacity);
|
|
||||||
|
|
||||||
// vWinDriveEntries.push_back(tmp);
|
|
||||||
wrefresh(tmp);
|
wrefresh(tmp);
|
||||||
|
|
||||||
i++;
|
// i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -107,20 +113,23 @@ WINDOW* TUI::createOverViewWindow( int iXSize, int iYSize) {
|
||||||
wbkgd(newWindow, COLOR_PAIR(COLOR_AREA_OVERVIEW));
|
wbkgd(newWindow, COLOR_PAIR(COLOR_AREA_OVERVIEW));
|
||||||
box(newWindow, ACS_VLINE, ACS_HLINE);
|
box(newWindow, ACS_VLINE, ACS_HLINE);
|
||||||
|
|
||||||
|
|
||||||
time_t rawtime;
|
time_t rawtime;
|
||||||
struct tm * timeinfo;
|
struct tm * timeinfo;
|
||||||
char buffer[80];
|
char buffer[80];
|
||||||
|
|
||||||
time (&rawtime);
|
time (&rawtime);
|
||||||
timeinfo = localtime(&rawtime);
|
timeinfo = localtime(&rawtime);
|
||||||
|
|
||||||
strftime(buffer,sizeof(buffer),"%d-%m-%Y %H:%M:%S",timeinfo);
|
strftime(buffer,sizeof(buffer),"%d-%m-%Y %H:%M:%S",timeinfo);
|
||||||
std::string str(buffer);
|
std::string str(buffer);
|
||||||
|
|
||||||
|
|
||||||
centerTitle(newWindow, str.c_str());
|
centerTitle(newWindow, str.c_str());
|
||||||
|
|
||||||
|
//mvwaddstr(newWindow, 2, 3, "Drücke eine Taste");
|
||||||
|
|
||||||
|
//refresh();
|
||||||
|
|
||||||
return newWindow;
|
return newWindow;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -133,8 +142,6 @@ WINDOW* TUI::createDetailViewWindow( int iXSize, int iYSize, int iXStart) {
|
||||||
box(newWindow, ACS_VLINE, ACS_HLINE);
|
box(newWindow, ACS_VLINE, ACS_HLINE);
|
||||||
centerTitle(newWindow, "Selected Drive: xyz");
|
centerTitle(newWindow, "Selected Drive: xyz");
|
||||||
|
|
||||||
// mvaddstr(iXStart+1, 5, "Test");
|
|
||||||
|
|
||||||
return newWindow;
|
return newWindow;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -146,17 +153,12 @@ WINDOW* TUI::createEntryWindow(int iXSize, int iYSize, int iXStart, int iYStart,
|
||||||
box(newWindow, ACS_VLINE, ACS_HLINE);
|
box(newWindow, ACS_VLINE, ACS_HLINE);
|
||||||
|
|
||||||
attron(COLOR_PAIR(COLOR_AREA_ENTRY));
|
attron(COLOR_PAIR(COLOR_AREA_ENTRY));
|
||||||
mvaddstr(iYStart+1, 5, "Test");
|
|
||||||
|
mvwaddstr(newWindow,1, 1, sModelFamily.c_str());
|
||||||
|
mvwaddstr(newWindow,2, 1, sModelName.c_str());
|
||||||
|
mvwaddstr(newWindow,3, 1, sCapacity.c_str());
|
||||||
|
|
||||||
//addstr("test");
|
// refresh();
|
||||||
|
|
||||||
|
|
||||||
//cout << "X: " << sModelFamily << endl;
|
|
||||||
|
|
||||||
// mvaddstr(iYStart+2, 5, sModelName.c_str());
|
|
||||||
//mvaddstr(iYStart+3, 5, sCapacity.c_str());
|
|
||||||
|
|
||||||
refresh();
|
|
||||||
|
|
||||||
return newWindow;
|
return newWindow;
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,13 +46,13 @@ uint32_t Drive::getPowerCycles(void)
|
||||||
return u32PowerCycles;
|
return u32PowerCycles;
|
||||||
}
|
}
|
||||||
|
|
||||||
string Drive::sCapacityToText(){
|
string Drive::sCapacityToText() {
|
||||||
if(getCapacity() <= (999*1000000000U)){
|
if(getCapacity() <= (999*1000000000U)) {
|
||||||
// Less or even 999 GB --> GB
|
// Less or even 999 GB --> GB
|
||||||
return to_string(getCapacity() / 1000000000U) + " GB";
|
return to_string(getCapacity() / 1000000000U) + " GB";
|
||||||
}
|
}
|
||||||
else{
|
else {
|
||||||
// More 999 GB --> TB
|
// More 999 GB --> TB
|
||||||
return to_string(getCapacity() / 1000000000000U) + " TB";
|
return to_string(getCapacity() / 1000000000000U) + " TB";
|
||||||
}
|
}
|
||||||
return "ERROR";
|
return "ERROR";
|
||||||
|
|
|
@ -30,7 +30,7 @@ reHDD::reHDD(void)
|
||||||
{
|
{
|
||||||
cout << "created app" << endl;
|
cout << "created app" << endl;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -80,7 +80,7 @@ void reHDD::app_logic(void)
|
||||||
|
|
||||||
void reHDD::ThreadScannDevices() {
|
void reHDD::ThreadScannDevices() {
|
||||||
while(true) {
|
while(true) {
|
||||||
// cout << "Thread" << endl;
|
// cout << "Thread" << endl;
|
||||||
mxScannDrives.lock();
|
mxScannDrives.lock();
|
||||||
vecNewDrives.clear();
|
vecNewDrives.clear();
|
||||||
searchDrives(&vecNewDrives); //search for new drives and store them in list
|
searchDrives(&vecNewDrives); //search for new drives and store them in list
|
||||||
|
@ -110,7 +110,7 @@ void reHDD::filterNewDrives(vector <Drive>* pvecOldDrives, vector <Drive>* pvecN
|
||||||
}
|
}
|
||||||
|
|
||||||
if(bOldDriveIsOffline == true) {
|
if(bOldDriveIsOffline == true) {
|
||||||
cout << "offline drive found: " << itOld->getPath() << endl;
|
//cout << "offline drive found: " << itOld->getPath() << endl;
|
||||||
//TODO kill wipe thread
|
//TODO kill wipe thread
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -130,7 +130,7 @@ void reHDD::filterNewDrives(vector <Drive>* pvecOldDrives, vector <Drive>* pvecN
|
||||||
*/
|
*/
|
||||||
void reHDD::searchDrives(vector <Drive>* pvecDrives)
|
void reHDD::searchDrives(vector <Drive>* pvecDrives)
|
||||||
{
|
{
|
||||||
// cout << "search drives ..." << endl;
|
// cout << "search drives ..." << endl;
|
||||||
char * cLine = NULL;
|
char * cLine = NULL;
|
||||||
size_t len = 0;
|
size_t len = 0;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue