forked from localhorst/reHDD
added user input via keys
This commit is contained in:
@ -34,31 +34,25 @@ void TUI::initTUI()
|
||||
}
|
||||
clear();
|
||||
curs_set(0);
|
||||
noecho();
|
||||
cbreak();
|
||||
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);
|
||||
mvprintw(0, 2, "reHDD - HDD refurbishing tool - GPL 3.0 ");
|
||||
|
||||
}
|
||||
|
||||
void TUI::updateTUI(vector <Drive>* pvecDrives) {
|
||||
|
||||
|
||||
//werase(stdscr);
|
||||
|
||||
int stdscrX, stdscrY;
|
||||
getmaxyx(stdscr, stdscrY, stdscrX);
|
||||
|
||||
init_pair(COLOR_AREA_STDSCR,COLOR_WHITE, COLOR_BLUE);
|
||||
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);
|
||||
|
||||
refresh();
|
||||
|
||||
overview=createOverViewWindow((int)(stdscrX/3), (stdscrY-15));
|
||||
@ -67,30 +61,48 @@ void TUI::updateTUI(vector <Drive>* pvecDrives) {
|
||||
detailview=createDetailViewWindow(((stdscrX)-(int)(stdscrX/3)-7), (stdscrY-3), (int)(stdscrX/3)+5);
|
||||
wrefresh(detailview);
|
||||
|
||||
vWinDriveEntries.clear();
|
||||
|
||||
|
||||
// int i = 0;
|
||||
|
||||
vector <Drive>::iterator it;
|
||||
for (it = pvecDrives->begin(); it != pvecDrives->end(); ++it)
|
||||
{
|
||||
|
||||
string sModelFamily = it->getModelFamily();
|
||||
string sModelName = it->getModelName();
|
||||
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* (i) )+3, sModelFamily, sModelName, sCapacity);
|
||||
|
||||
// vWinDriveEntries.push_back(tmp);
|
||||
WINDOW * tmp = createEntryWindow( ((int)(stdscrX/3) - 2), 5, 3, (5* (it - pvecDrives->begin()) )+3, sModelFamily, sModelName, sCapacity);
|
||||
wrefresh(tmp);
|
||||
|
||||
// i++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
enum TUI::UserInput TUI::readUserInput() {
|
||||
int ch = wgetch(stdscr);
|
||||
switch(ch)
|
||||
{
|
||||
case KEY_UP:
|
||||
return TUI::UserInput::UpKey;
|
||||
break;
|
||||
case KEY_DOWN:
|
||||
return TUI::UserInput::DownKey;
|
||||
break;
|
||||
case 10:
|
||||
return TUI::UserInput::Enter;
|
||||
break;
|
||||
case 27:
|
||||
return TUI::UserInput::ESC;
|
||||
break;
|
||||
case 'a':
|
||||
return TUI::UserInput::Abort;
|
||||
break;
|
||||
case 'd':
|
||||
return TUI::UserInput::Delete;
|
||||
break;
|
||||
case 's':
|
||||
return TUI::UserInput::Shred;
|
||||
break;
|
||||
default:
|
||||
return TUI::UserInput::Undefined;
|
||||
break;
|
||||
}
|
||||
return TUI::UserInput::Undefined;
|
||||
}
|
||||
|
||||
|
||||
@ -126,14 +138,10 @@ WINDOW* TUI::createOverViewWindow( int iXSize, int iYSize) {
|
||||
|
||||
centerTitle(newWindow, str.c_str());
|
||||
|
||||
//mvwaddstr(newWindow, 2, 3, "Drücke eine Taste");
|
||||
|
||||
//refresh();
|
||||
|
||||
keypad(newWindow, TRUE);
|
||||
return newWindow;
|
||||
}
|
||||
|
||||
|
||||
WINDOW* TUI::createDetailViewWindow( int iXSize, int iYSize, int iXStart) {
|
||||
WINDOW *newWindow;
|
||||
newWindow = newwin(iYSize, iXSize, 2, iXStart);
|
||||
@ -142,6 +150,7 @@ WINDOW* TUI::createDetailViewWindow( int iXSize, int iYSize, int iXStart) {
|
||||
box(newWindow, ACS_VLINE, ACS_HLINE);
|
||||
centerTitle(newWindow, "Selected Drive: xyz");
|
||||
|
||||
keypad(newWindow, TRUE);
|
||||
return newWindow;
|
||||
}
|
||||
|
||||
@ -153,12 +162,12 @@ WINDOW* TUI::createEntryWindow(int iXSize, int iYSize, int iXStart, int iYStart,
|
||||
box(newWindow, ACS_VLINE, ACS_HLINE);
|
||||
|
||||
attron(COLOR_PAIR(COLOR_AREA_ENTRY));
|
||||
|
||||
|
||||
mvwaddstr(newWindow,1, 1, sModelFamily.c_str());
|
||||
mvwaddstr(newWindow,2, 1, sModelName.c_str());
|
||||
mvwaddstr(newWindow,3, 1, sCapacity.c_str());
|
||||
|
||||
// refresh();
|
||||
keypad(newWindow, TRUE);
|
||||
|
||||
return newWindow;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user