diff --git a/Info.h b/Info.h index e35d4b3..46cddb6 100644 --- a/Info.h +++ b/Info.h @@ -1,23 +1,23 @@ #ifndef _INFO_H #define _INFO_H -#define VERSION "1.3" - +#define VERSION "1.0.4" +#define APPNAME "ServiceControl" #define ABOUT_INFO "\n\ - ServiceControl 1.3 \n\ + " APPNAME " " VERSION " \n\ \n\ Navigation keys: \n\ - Up - move cursor up | Down - move cursor down \n\ - right - move cursor right | left - move cursor left \n\ - PgUp - move page up | PgDown - move page down \n\ - / - for search | ? - for this help \n\ + Up - move cursor up | Down - move cursor down \n\ + right - move cursor right | left - move cursor left \n\ + PgUp - move page up | PgDown - move page down \n\ + / - for search | ? - for this help \n\ Action keys: \n\ - Space - anwählen/abwählen | F10 - exit \n\ - F1 - start/stop unit | F2 - reload/update \n\ - F3 - enabled unit | F4 - disabled unit \n\ - F5 - unmasked unit | F6 - masked unit \n\ + Space - anwählen/abwählen | F10 - exit | ESC - Close info/help\n\ + F1 - start/stop unit | F2 - reload/update | TAB - switch Menu/ \n\ + F3 - enabled unit | F4 - disabled unit | Servicelist/ \n\ + F5 - unmasked unit | F6 - masked unit | Search \n\ ---------------------------------------------------------------------------\n\ License: GPLv3 (c) Anthony Olszynski \n\ " -#endif +#endif //_INFO_H diff --git a/MenuClass.cpp b/MenuClass.cpp deleted file mode 100644 index 527d374..0000000 --- a/MenuClass.cpp +++ /dev/null @@ -1,566 +0,0 @@ -#include -#include -#include -#include -#include - -using namespace std; - -extern class TaskClass * TaskPtr; -//extern class MenuClass * MenuPtr; -extern class ServiceClass * ServicePtr; -extern class WinClass * WinPtr; -extern class ServiceTableClass * TablePtr; - -void MenuClass::Hauptmenu(void) { - MENEU.HMID = 0; - MENEU.HMName = string("HAUPTMENÜ"); - MENEU.HMItem = static_cast(calloc(5, sizeof(ITEM *))); - MENEU.HMItem[0] = new_item(" Datei", MENEU.HMName.c_str()); - MENEU.HMItem[1] = new_item("DaemonType", MENEU.HMName.c_str()); - MENEU.HMItem[2] = new_item("Systemctl", MENEU.HMName.c_str()); - MENEU.HMItem[3] = new_item("Info", MENEU.HMName.c_str()); - MENEU.HMItem[4] = nullptr; - MENEU.HMMenu = new_menu(MENEU.HMItem); - MENEU.HMWin = newwin(1, WinPtr->WinSize->WCX()-26, 0, 0); - set_menu_win (MENEU.HMMenu, MENEU.HMWin); - set_menu_sub(MENEU.HMMenu, MENEU.HMWin); - //############################################################### - //set_menu_sub(MENEU.UME.UMEMenu, MENEU.HMWin); - //############################################################### - set_menu_spacing(MENEU.HMMenu, 1, 0, 0); - set_menu_format(MENEU.HMMenu, 0, 5); - menu_opts_off(MENEU.HMMenu, O_SHOWDESC); - menu_opts_off(MENEU.HMMenu, O_NONCYCLIC); - wbkgd(MENEU.HMWin, COLOR_PAIR(HMcolor.HaMeFe_HG)|A_BOLD); - //set_item_fore(MENEU.HMItem[1], COLOR_PAIR(12)|A_REVERSE|A_BOLD); - set_menu_fore(MENEU.HMMenu, COLOR_PAIR(HMcolor.HaMe_FG)|A_REVERSE|A_BOLD); - set_menu_back(MENEU.HMMenu, COLOR_PAIR(HMcolor.HaMe_HG));//|A_BOLD); - set_menu_grey(MENEU.HMMenu, COLOR_PAIR(HMcolor.HaMe_grey)|A_BOLD); - set_menu_mark(MENEU.HMMenu,""); - post_menu(MENEU.HMMenu); -} /* Hauptmenü */ - -void MenuClass::Datei_menu(void) { - MENEU.UME.UMID = 1; - MENEU.UME.UMEName = string("Datei"); - MENEU.UME.UMEWin = newwin(6, 15, 1, 0); - wbkgd(MENEU.UME.UMEWin,COLOR_PAIR(HMcolor.UMeFe_HG)); - box(MENEU.UME.UMEWin, 0, 0); - MENEU.UME.UMEItem = static_cast(calloc(7, sizeof(ITEM *))); - MENEU.UME.UMEItem[0] = new_item("Man Systemctl", MENEU.UME.UMEName.c_str()); - MENEU.UME.UMEItem[1] = new_item("Einstellung", MENEU.UME.UMEName.c_str()); - MENEU.UME.UMEItem[2] = new_item("Remotectl", MENEU.UME.UMEName.c_str()); - MENEU.UME.UMEItem[3] = new_item("Beenden", MENEU.UME.UMEName.c_str()); - MENEU.UME.UMEItem[4] = nullptr; - MENEU.UME.UMEMenu = new_menu(MENEU.UME.UMEItem); - set_menu_win(MENEU.UME.UMEMenu, MENEU.UME.UMEWin); - set_menu_sub (MENEU.UME.UMEMenu, derwin(MENEU.UME.UMEWin, 0, 0, 1, 1)); - set_menu_spacing(MENEU.UME.UMEMenu, 0,0,0); - set_menu_format(MENEU.UME.UMEMenu, 5, 0); - menu_opts_off(MENEU.UME.UMEMenu, O_SHOWDESC); - menu_opts_off(MENEU.UME.UMEMenu, O_NONCYCLIC); - //set_menu_fore(MENEU.UME.UMEMenu, COLOR_PAIR(12)|A_REVERSE|A_BOLD); - set_menu_fore(MENEU.UME.UMEMenu, COLOR_PAIR(HMcolor.UMeFe_FG)|A_REVERSE|A_BOLD); - set_menu_back(MENEU.UME.UMEMenu, COLOR_PAIR(HMcolor.UMeFe_HG));//|A_BOLD); - set_menu_grey(MENEU.UME.UMEMenu, COLOR_PAIR(HMcolor.HaMe_grey)|A_BOLD); - set_menu_mark(MENEU.UME.UMEMenu,""); - set_current_item(MENEU.UME.UMEMenu, MENEU.UME.UMEItem[0]); - post_menu(MENEU.UME.UMEMenu); -} /* Datei Menü */ - -void MenuClass::DaemonType_menu(void) { - MENEU.UME.UMID = 2; - MENEU.UME.UMEName = string("DaemonType"); - MENEU.UME.UMEWin = newwin(12, 10, 1, 11); - box(MENEU.UME.UMEWin, 0, 0); - MENEU.UME.UMEItem = static_cast(calloc(11, sizeof(ITEM *))); - MENEU.UME.UMEItem[0] = new_item("Device", MENEU.UME.UMEName.c_str()); - MENEU.UME.UMEItem[1] = new_item("Mount", MENEU.UME.UMEName.c_str()); - MENEU.UME.UMEItem[2] = new_item("Path", MENEU.UME.UMEName.c_str()); - MENEU.UME.UMEItem[3] = new_item("Service", MENEU.UME.UMEName.c_str()); - MENEU.UME.UMEItem[4] = new_item("Scope", MENEU.UME.UMEName.c_str()); - MENEU.UME.UMEItem[5] = new_item("Slice", MENEU.UME.UMEName.c_str()); - MENEU.UME.UMEItem[6] = new_item("Socket", MENEU.UME.UMEName.c_str()); - MENEU.UME.UMEItem[7] = new_item("Swap", MENEU.UME.UMEName.c_str()); - MENEU.UME.UMEItem[8] = new_item("Target", MENEU.UME.UMEName.c_str()); - MENEU.UME.UMEItem[9] = new_item("Timer", MENEU.UME.UMEName.c_str()); - MENEU.UME.UMEItem[10] = nullptr; - MENEU.UME.UMEMenu = new_menu(MENEU.UME.UMEItem); - set_menu_win (MENEU.UME.UMEMenu, MENEU.UME.UMEWin); - set_menu_sub(MENEU.UME.UMEMenu, derwin(MENEU.UME.UMEWin,0,0,1,1)); - set_menu_spacing(MENEU.UME.UMEMenu, 0, 0, 1); - set_menu_format(MENEU.UME.UMEMenu, 11, 0); - menu_opts_off(MENEU.UME.UMEMenu, O_SHOWDESC); - menu_opts_off(MENEU.UME.UMEMenu, O_NONCYCLIC); - wbkgd(MENEU.UME.UMEWin,COLOR_PAIR(HMcolor.UMeFe_HG)); - set_menu_fore(MENEU.UME.UMEMenu, COLOR_PAIR(HMcolor.UMeFe_FG)|A_REVERSE|A_BOLD); - set_menu_back(MENEU.UME.UMEMenu, COLOR_PAIR(HMcolor.UMeFe_HG));//|A_BOLD); - set_menu_grey(MENEU.UME.UMEMenu, COLOR_PAIR(HMcolor.HaMe_grey)|A_BOLD); - set_menu_mark(MENEU.UME.UMEMenu,""); - set_current_item(MENEU.UME.UMEMenu, MENEU.UME.UMEItem[0]); - post_menu(MENEU.UME.UMEMenu); - -} /* System Untermenü */ - -void MenuClass::Systemctl_menu(void) { - MENEU.UME.UMID = 3; - MENEU.UME.UMEName = string("Systemctl"); - MENEU.UME.UMEWin = newwin(12, 18, 1, 22); - box(MENEU.UME.UMEWin, 0, 0); - MENEU.UME.UMEItem = static_cast(calloc(11, sizeof(ITEM *))); - MENEU.UME.UMEItem[0] = new_item("START", "F1"); - MENEU.UME.UMEItem[1] = new_item("STOP", "F1"); - MENEU.UME.UMEItem[2] = new_item("STATUS", "F3"); - MENEU.UME.UMEItem[3] = new_item("ENABLE", "F2"); - MENEU.UME.UMEItem[4] = new_item("DISABLE", "F2"); - MENEU.UME.UMEItem[5] = new_item("MASK", "F4"); - MENEU.UME.UMEItem[6] = new_item("UNMASK", "F4"); - MENEU.UME.UMEItem[7] = new_item("RESTART", "F5"); - MENEU.UME.UMEItem[8] = new_item("RELOAD", "F6"); - MENEU.UME.UMEItem[9] = new_item("Reload-daemon", "F7"); - MENEU.UME.UMEItem[10] = nullptr; - MENEU.UME.UMEMenu = new_menu(MENEU.UME.UMEItem); - set_menu_win (MENEU.UME.UMEMenu, MENEU.UME.UMEWin); - set_menu_sub(MENEU.UME.UMEMenu, derwin(MENEU.UME.UMEWin,0,0,1,1)); - set_menu_spacing(MENEU.UME.UMEMenu, 1, 0, 0); - set_menu_format(MENEU.UME.UMEMenu, 11, 0); - menu_opts_on(MENEU.UME.UMEMenu, O_SHOWDESC); - menu_opts_off(MENEU.UME.UMEMenu, O_NONCYCLIC); - wbkgd(MENEU.UME.UMEWin,COLOR_PAIR(HMcolor.UMeFe_HG)); - set_menu_fore(MENEU.UME.UMEMenu, COLOR_PAIR(HMcolor.UMeFe_FG)|A_REVERSE|A_BOLD); - set_menu_back(MENEU.UME.UMEMenu, COLOR_PAIR(HMcolor.UMeFe_HG));//|A_BOLD); - set_menu_grey(MENEU.UME.UMEMenu, COLOR_PAIR(HMcolor.HaMe_grey)|A_BOLD); - set_menu_mark(MENEU.UME.UMEMenu,""); - set_current_item(MENEU.UME.UMEMenu, MENEU.UME.UMEItem[0]); - post_menu(MENEU.UME.UMEMenu); -} /* Server Untermenü */ - -void MenuClass::Info_menu(void) { - MENEU.UME.UMID = 4; - MENEU.UME.UMEName = string("Info"); - MENEU.UME.UMEWin = newwin(5, 12, 1, 33); - wbkgd(MENEU.UME.UMEWin,COLOR_PAIR(HMcolor.UMeFe_HG)); - box(MENEU.UME.UMEWin,0,0); - //MENEU.UME.UMEItem = (ITEM **)calloc(4, sizeof(ITEM *)); - MENEU.UME.UMEItem = static_cast(calloc(4, sizeof(ITEM *))); - MENEU.UME.UMEItem[0] = new_item("journalctl", MENEU.UME.UMEName.c_str()); - MENEU.UME.UMEItem[1] = new_item("E-Mail", MENEU.UME.UMEName.c_str()); - MENEU.UME.UMEItem[2] = new_item("Beenden", MENEU.UME.UMEName.c_str()); - MENEU.UME.UMEItem[3] = nullptr; - MENEU.UME.UMEMenu = new_menu(MENEU.UME.UMEItem); - set_menu_win(MENEU.UME.UMEMenu, MENEU.UME.UMEWin); - set_menu_sub (MENEU.UME.UMEMenu, derwin(MENEU.UME.UMEWin, 0, 0, 1, 1)); - set_menu_spacing(MENEU.UME.UMEMenu, 0,0,0); - set_menu_format(MENEU.UME.UMEMenu, 5, 0); - menu_opts_off(MENEU.UME.UMEMenu, O_SHOWDESC); - menu_opts_off(MENEU.UME.UMEMenu, O_NONCYCLIC); - //set_menu_fore(MENEU.UME.UMEMenu, COLOR_PAIR(12)|A_REVERSE|A_BOLD); - set_menu_fore(MENEU.UME.UMEMenu, COLOR_PAIR(HMcolor.UMeFe_FG)|A_REVERSE|A_BOLD); - set_menu_back(MENEU.UME.UMEMenu, COLOR_PAIR(HMcolor.UMeFe_HG));//|A_BOLD); - set_menu_grey(MENEU.UME.UMEMenu, COLOR_PAIR(HMcolor.HaMe_grey)|A_BOLD); - set_menu_mark(MENEU.UME.UMEMenu,""); - set_current_item(MENEU.UME.UMEMenu, MENEU.UME.UMEItem[0]); - post_menu(MENEU.UME.UMEMenu); -} /* Info Menü */ - -WINDOW *MenuClass::tmpWi(string name, int id) { - if ((strcmp(name.c_str(),"Datei")==0) || (id==0)){ - Datei_menu(); - HMTMPWIN = MENEU.UME.UMEWin; - HMTMPMENU = MENEU.UME.UMEMenu; - }else if ((strcmp(name.c_str(),"DaemonType")==0) || (id==1)){ - DaemonType_menu(); - HMTMPWIN = MENEU.UME.UMEWin; - HMTMPMENU = MENEU.UME.UMEMenu; - }else if ((strcmp(name.c_str(),"Systemctl")==0) || (id==2)){ - Systemctl_menu(); - HMTMPWIN = MENEU.UME.UMEWin; - HMTMPMENU = MENEU.UME.UMEMenu; - }else if ((strcmp(name.c_str(),"Info")==0) || (id==4)){ - Info_menu(); - HMTMPWIN = MENEU.UME.UMEWin; - HMTMPMENU = MENEU.UME.UMEMenu; - } - return HMTMPWIN; -} - -void MenuClass::fensterwahl(string wahl) { - string menupoint = ServicePtr->AktivName; //item_name(current_item(LiMENU.LMenu)); - string befehl; - if (wahl.compare(" Datei") == 0) { - Datei_menu(); - }else if (wahl.compare("Systemctl") == 0) { - Systemctl_menu(); - }else if (wahl.compare("DaemonType") == 0) { - DaemonType_menu(); - }else if (wahl.compare("Systemctl") == 0) { - Info_menu(); - }else if (wahl.compare("Service") == 0) { - ServicePtr->start = 0; - ServicePtr->selected = 0; - ServicePtr->systemctlwahl = "service"; - ServicePtr->ServiceListFill(); - }else if (wahl.compare("Swap") == 0) { - ServicePtr->start = 0; - ServicePtr->selected = 0; - ServicePtr->systemctlwahl = "swap"; - ServicePtr->ServiceListFill(); - }else if (wahl.compare("Timer") == 0) { - ServicePtr->start = 0; - ServicePtr->selected = 0; - ServicePtr->systemctlwahl = "timer"; - ServicePtr->ServiceListFill(); - }else if (wahl.compare("Device") == 0) { - ServicePtr->start = 0; - ServicePtr->selected = 0; - ServicePtr->systemctlwahl = "device"; - ServicePtr->ServiceListFill(); - }else if (wahl.compare("Mount") == 0) { - ServicePtr->start = 0; - ServicePtr->selected = 0; - ServicePtr->systemctlwahl = "mount"; - ServicePtr->ServiceListFill(); - }else if (wahl.compare("Path") == 0) { - ServicePtr->start = 0; - ServicePtr->selected = 0; - ServicePtr->systemctlwahl = "path"; - ServicePtr->ServiceListFill(); - }else if (wahl.compare("Target") == 0) { - ServicePtr->start = 0; - ServicePtr->selected = 0; - ServicePtr->systemctlwahl = "target"; - ServicePtr->ServiceListFill(); - }else if (wahl.compare("Socket") == 0) { - ServicePtr->start = 0; - ServicePtr->selected = 0; - ServicePtr->systemctlwahl = "socket"; - ServicePtr->ServiceListFill(); - }else if (wahl.compare("Slice") == 0) { - ServicePtr->start = 0; - ServicePtr->selected = 0; - ServicePtr->systemctlwahl = "slice"; - ServicePtr->ServiceListFill(); - }else if (wahl.compare("Scope") == 0) { - ServicePtr->start = 0; - ServicePtr->selected = 0; - ServicePtr->systemctlwahl = "scope"; - ServicePtr->ServiceListFill(); - }else if (wahl.compare("Man Page")==0){ - exit(EXIT_SUCCESS); - //DATEIMANPAGE::Start_ManP(); - }else if (wahl.compare("Befehle")==0){ - exit(EXIT_SUCCESS); - //DATEIBEFEHLE::befehle_main(); - }else if (wahl.compare("Einstellung")==0){ - exit(EXIT_SUCCESS); - //einDa(); - }else if (wahl.compare("Beenden")==0){ - exit(EXIT_SUCCESS); - }else if (wahl.compare("START") == 0) { - pos_menu_cursor(LiMENU.LMenu); - befehl = "systemctl start " + menupoint + " --now"; - TaskPtr->TERM_AUSGABE(befehl); - ServicePtr->ServiceListFill(); - }else if (wahl.compare("STOP") == 0) { - pos_menu_cursor(LiMENU.LMenu); - befehl = "systemctl stop " + menupoint + " --now"; - TaskPtr->TERM_AUSGABE(befehl); - ServicePtr->ServiceListFill(); - }else if (wahl.compare("RELOAD") == 0) { - pos_menu_cursor(LiMENU.LMenu); - befehl = "systemctl reload " + menupoint + " --now"; - TaskPtr->TERM_AUSGABE(befehl); - ServicePtr->ServiceListFill(); - }else if (wahl.compare("RESTART") == 0) { - pos_menu_cursor(LiMENU.LMenu); - befehl = "systemctl restart " + menupoint + " --now"; - TaskPtr->TERM_AUSGABE(befehl); - ServicePtr->ServiceListFill(); - }else if (wahl.compare("ENABLE") == 0) { - pos_menu_cursor(LiMENU.LMenu); - befehl = "systemctl enable " + menupoint; - TaskPtr->TERM_AUSGABE(befehl); - ServicePtr->ServiceListFill(); - }else if (wahl.compare("DISABLE") == 0) { - pos_menu_cursor(LiMENU.LMenu); - befehl = "systemctl disable " + menupoint; - TaskPtr->TERM_AUSGABE(befehl); - ServicePtr->ServiceListFill(); - }else if (wahl.compare("STATUS") == 0) { - pos_menu_cursor(LiMENU.LMenu); - befehl = "systemctl status " + menupoint; - ServicePtr->Statusabfrage(TaskPtr->TERM_AUSGABE(befehl)); - }else if (wahl.compare("UNMASK") == 0) { - pos_menu_cursor(LiMENU.LMenu); - befehl = "systemctl unmask " + menupoint; - TaskPtr->TERM_AUSGABE(befehl); - ServicePtr->ServiceListFill(); - }else if (wahl.compare("MASK") == 0) { - pos_menu_cursor(LiMENU.LMenu); - befehl = "systemctl mask " + menupoint; - TaskPtr->TERM_AUSGABE(befehl); - ServicePtr->ServiceListFill(); - }else if (wahl.compare("journalctl") == 0) { - befehl = "journalctl -b -u " + menupoint; - ServicePtr->Statusabfrage(TaskPtr->TERM_AUSGABE(befehl)); - } -} - -void MenuClass::QUIT(void){ - try { - //###############--Hauptmenu--############################################### - int E = item_count(MENEU.HMMenu); - unpost_menu(MENEU.HMMenu); - SAFE_DELETE(MENEU.HMMenu); - SAFE_DELETE_ARRAY(MENEU.HMItem); - wborder(MENEU.HMWin, ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '); - touchline(MENEU.HMWin,0,E+1); - delwin(MENEU.HMWin); - endwin(); - //###############--Untermenu--############################################### - E = item_count(MENEU.UME.UMEMenu); - unpost_menu(MENEU.UME.UMEMenu); - SAFE_DELETE(MENEU.UME.UMEMenu); - SAFE_DELETE_ARRAY(MENEU.UME.UMEItem); - wborder(MENEU.UME.UMEWin, ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '); - touchline(MENEU.UME.UMEWin,0,E+1); - delwin(MENEU.UME.UMEWin); - endwin(); - - refresh(); - redrawwin(TaskPtr->ClearWindow(WinPtr->START.TMPWin2)); - wrefresh(TaskPtr->ClearWindow(WinPtr->START.TMPWin2)); - - } catch (const NCursesException *e) { - endwin(); - std::cerr << string(e->classname()) << std::endl; - //res = e.errorno; - } catch (const NCursesException &e) { - endwin(); - std::cerr << e.message << std::endl; - //res = e.errorno; - } catch (const std::exception &e) { - endwin(); - std::cerr << "Exception: " << e.what() << std::endl; - //res = EXIT_FAILURE; - } -} - -void MenuClass::MenuStart(void){ - try { - set_current_item(MENEU.HMMenu, MENEU.HMItem[MeInAl]); - HMTMPWIN = tmpWi(item_name(current_item(MENEU.HMMenu)),item_index(current_item(MENEU.HMMenu))); - string tmpMeNa = string(item_name(current_item(MENEU.HMMenu))); - string MeAuWa = ""; - // std::string PATTER = ""; - ServicePtr->TableMoveRow(); - int tabkey = 1; - int key; - while ((key=wgetch(stdscr)) != KEY_F(10)) { - switch(tabkey){ - case 1:{ // MainWindow ListMenu - switch (key) { -// case '/':{ -// ServicePtr->searchInput(); -// break;} - case '?':{ - ServicePtr->Statusabfrage(ABOUT_INFO); - break;} - case KEY_RESIZE:{ - resize(); - break;} - case KEY_DOWN:{ - //menu_driver(LiMENU.LMenu, REQ_DOWN_ITEM); - ServicePtr->tabledriver(ServicePtr->ServiceList,REQ_DOWN_ITEM); - ServicePtr->TableMoveRow(); - break; } - case KEY_UP:{ - //menu_driver(LiMENU.LMenu, REQ_UP_ITEM); - ServicePtr->tabledriver(ServicePtr->ServiceList,REQ_UP_ITEM); - ServicePtr->TableMoveRow(); - break; } - case KEY_NPAGE:{ - //menu_driver(LiMENU.LMenu, REQ_UP_ITEM); - ServicePtr->tabledriver(ServicePtr->ServiceList,REQ_SCR_DPAGE); - ServicePtr->TableMoveRow(); - break; } - case KEY_PPAGE:{ - //menu_driver(LiMENU.LMenu, REQ_UP_ITEM); - ServicePtr->tabledriver(ServicePtr->ServiceList,REQ_SCR_UPAGE); - ServicePtr->TableMoveRow(); - break; } - case KEY_END:{ - //menu_driver(LiMENU.LMenu, REQ_UP_ITEM); - ServicePtr->tabledriver(ServicePtr->ServiceList,REQ_LAST_ITEM); - ServicePtr->TableMoveRow(); - break; } - case KEY_HOME:{ - //menu_driver(LiMENU.LMenu, REQ_UP_ITEM); - ServicePtr->start = 0; - ServicePtr->selected = 0; - ServicePtr->tabledriver(ServicePtr->ServiceList,REQ_FIRST_ITEM); - ServicePtr->TableMoveRow(); - break; } - case 0x09: { - tabkey = TaskPtr->ZahlenWerk(1,"++",2); - HMTMPWIN = tmpWi("Datei",0); - redrawwin(TaskPtr->ClearWindow(MENEU.UME.UMEWin)); - wrefresh(TaskPtr->ClearWindow(MENEU.UME.UMEWin)); - break; } - case KEY_BTAB:{ - tabkey = TaskPtr->ZahlenWerk(1,"--",2); - HMTMPWIN = tmpWi("Datei",0); - redrawwin(TaskPtr->ClearWindow(MENEU.UME.UMEWin)); - wrefresh(TaskPtr->ClearWindow(MENEU.UME.UMEWin)); - break; } - case KEY_BACKSPACE:{ - //menu_driver(LiMENU.LMenu, REQ_BACK_PATTERN); - ServicePtr->tabledriver(ServicePtr->ServiceList,REQ_BACK_PATTERN); - break; } - case 10:{ - //string menupoint = item_name(current_item(LiMENU.LMenu)); - string menupoint = ServicePtr->AktivName; - string befehl; - befehl = "systemctl status " + menupoint; - //pos_menu_cursor(LiMENU.LMenu); - ServicePtr->Statusabfrage(TaskPtr->TERM_AUSGABE(befehl)); - break; } - case 32:{ - ServicePtr->tabledriver(ServicePtr->ServiceList, REQ_TOGGLE_ITEM); - //menu_driver(LiMENU.LMenu, REQ_TOGGLE_ITEM); - break; } - default:{ - if (key > 10 && key < 128) { - sprintf(ServicePtr->searchString,"%c",key); - PATTER.append(string(ServicePtr->searchString)); - mvwaddnstr(WinPtr->START.TMPWin4, 4, 33, PATTER.c_str(),-1); - ServicePtr->tabledriver(ServicePtr->ServiceList,REQ_NEXT_MATCH); - // sprintf(searchString,"%c",key); - } - break; } - } - if (tabkey==1) { - ServicePtr->INFOWINDOW(ServicePtr->AktivName); - //ServicePtr->INFOWINDOW(item_name(current_item(LiMENU.LMenu))); - refresh(); - touchwin(TaskPtr->ClearWindow(WinPtr->START.TMPWin2)); - wrefresh(TaskPtr->ClearWindow(WinPtr->START.TMPWin2)); - touchwin(TaskPtr->ClearWindow(WinPtr->START.TMPWin4)); - wrefresh(TaskPtr->ClearWindow(WinPtr->START.TMPWin4)); - prefresh(LiMENU.LMWin, 0, 0, 2, 1, WinPtr->WinSize->HRY_TmpWinReal(WinPtr->START.TMPWin2)+1, WinPtr->WinSize->WCX_TmpWinReal(WinPtr->START.TMPWin2));// -2 - } else if (tabkey==2) { - refresh(); - wrefresh(TaskPtr->ClearWindow(MENEU.HMWin)); - redrawwin(TaskPtr->ClearWindow(MENEU.UME.UMEWin)); - wrefresh(TaskPtr->ClearWindow(MENEU.UME.UMEWin)); - } - break; } // MainWindow ListMenu - case 2:{ //Hauptmenu - switch(key){ -// case '/':{ -// ServicePtr->searchInput(); -// //ServicePtr->inputFor = INPUT_FOR_SEARCH; -// break;} - case '?':{ - ServicePtr->Statusabfrage(ABOUT_INFO); - break;} - case KEY_RESIZE:{ - resize(); - break;} - case KEY_DOWN:{ - menu_driver(MENEU.UME.UMEMenu, REQ_DOWN_ITEM); - break; } - case KEY_UP:{ - menu_driver(MENEU.UME.UMEMenu, REQ_UP_ITEM); - break; } - case KEY_RIGHT:{ - MenuClass::MENEU.LoescheUME(); - menu_driver(MENEU.HMMenu, REQ_RIGHT_ITEM); - tmpMeNa = string(item_name(current_item(MENEU.HMMenu))); - HMTMPWIN = tmpWi(item_name(current_item(MENEU.HMMenu)), item_index(current_item(MENEU.HMMenu))); - break; } - case KEY_LEFT:{ - MenuClass::MENEU.LoescheUME(); // delete before menu drive - menu_driver(MENEU.HMMenu, REQ_LEFT_ITEM); - tmpMeNa = string(item_name(current_item(MENEU.HMMenu))); - HMTMPWIN = tmpWi(item_name(current_item(MENEU.HMMenu)), item_index(current_item(MENEU.HMMenu))); - break; } - case 0x09:{ - tabkey = TaskPtr->ZahlenWerk(2,"++",2); - set_current_item(MENEU.HMMenu, MENEU.HMItem[0]); - MenuClass::MENEU.LoescheUME(); - wrefresh(TaskPtr->ClearWindow(MENEU.HMWin)); - break; } - case KEY_BTAB:{ - tabkey = TaskPtr->ZahlenWerk(2,"--",2); - set_current_item(MENEU.HMMenu, MENEU.HMItem[0]); - MenuClass::MENEU.LoescheUME(); - wrefresh(TaskPtr->ClearWindow(MENEU.HMWin)); - break;} - case 10:{ - MeInAl = item_index(current_item(MENEU.HMMenu)); - fensterwahl(item_name(current_item(MENEU.UME.UMEMenu))); - tabkey = TaskPtr->ZahlenWerk(2,"++",2); - set_current_item(MENEU.HMMenu, MENEU.HMItem[0]); - MenuClass::MENEU.LoescheUME(); - wrefresh(TaskPtr->ClearWindow(MENEU.HMWin)); - break; } - } - if (tabkey==2) { - refresh(); - redrawwin(TaskPtr->ClearWindow(WinPtr->START.TMPWin2)); - wrefresh(TaskPtr->ClearWindow(WinPtr->START.TMPWin2)); - prefresh(LiMENU.LMWin, 0, 0, 2, 1, WinPtr->WinSize->HRY_TmpWinReal(WinPtr->START.TMPWin2)+1, WinPtr->WinSize->WCX_TmpWinReal(WinPtr->START.TMPWin2)); - wrefresh(TaskPtr->ClearWindow(MENEU.HMWin)); - redrawwin(TaskPtr->ClearWindow(MENEU.UME.UMEWin)); - wrefresh(TaskPtr->ClearWindow(MENEU.UME.UMEWin)); - } else if(tabkey==1){ - MenuClass::MENEU.LoescheUME(); - refresh(); - redrawwin(TaskPtr->ClearWindow(WinPtr->START.TMPWin2)); - wrefresh(TaskPtr->ClearWindow(WinPtr->START.TMPWin2)); - prefresh(LiMENU.LMWin, 0, 0, 2, 1, WinPtr->WinSize->HRY_TmpWinReal(WinPtr->START.TMPWin2)+1, WinPtr->WinSize->WCX_TmpWinReal(WinPtr->START.TMPWin2)); - } - break;} // Hauptmenu - } - } - - ServicePtr->ENDE_NEW(); - - if (LiMENU.LMItem){unpost_menu(LiMENU.LMenu);SAFE_DELETE(LiMENU.LMItem);SAFE_DELETE_ARRAY(LiMENU.LMItem);} - // int n_choices, i; - // n_choices = ARRAY_SIZE(LiMENU.LMItem); - // unpost_menu(LiMENU.LMenu); - // for(i = 0; i < n_choices; ++i) - // free_item(LiMENU.LMItem[i]); - // free_menu(LiMENU.LMenu); - endwin(); - - } catch (const NCursesException *e) { - endwin(); - std::cerr << e->message << std::endl; - cout << e->errorno; - } catch (const NCursesException &e) { - endwin(); - std::cerr << e.message << std::endl; - cout << e.errorno; - } catch (const std::exception &e) { - endwin(); - std::cerr << "Exception: " << e.what() << std::endl; - cout << EXIT_FAILURE; - } -} - -void MenuClass::resize(){ - WinPtr->WinSize->WCX(); // = 80; - WinPtr->WinSize->HRY(); // = 24; -} - -MenuClass::MenuClass(){ - -} - -MenuClass::~MenuClass(){ - -} diff --git a/MenuClass.h b/MenuClass.h deleted file mode 100644 index fa7d9b6..0000000 --- a/MenuClass.h +++ /dev/null @@ -1,106 +0,0 @@ -#ifndef MENUCLASS_H -#define MENUCLASS_H - -#include - -//-------Color-Hauptmenue------------------------ -struct MenuColor { - int HaMeFe_HG {78}; //Fenster_Background - int HaMe_FG {78}; //Hauptmenue_Foreground - int HaMe_HG {78}; //Hauptmenue_Background - int HaMe_grey {04}; //Hauptmenue_inaktive - int UMeFe_HG {87}; //Fenster_Untermenue - int UMeFe_FG {87}; //Fenster_Untermenue -}; -//-------Color-InApp-Menues---------------------- -struct InAppColor { - int IlMeFe_HG = 78; //Fenster_Background - int IlMe_FG = 71; //InnLineMenue_Foreground - int IlMe_HG = 18; //InnLineMenue_Background - int IlMe_grey = 18; //InnLineMenue_inaktive - int IlUMeFe_HG = 87;//Fenster_Untermenue -}; - -struct HAUPTMENU { - int HMID; - std::string HMName; - WINDOW *HMWin {nullptr}; - MENU *HMMenu {nullptr}; - ITEM **HMItem {nullptr}; - //############################################### - struct UNTERMENU { - int UMID; - std::string UMEName; - WINDOW *UMEWin {nullptr}; - MENU *UMEMenu {nullptr}; - ITEM **UMEItem {nullptr}; - }UME; - void LoescheUME(){ - int E = item_count(UME.UMEMenu); - unpost_menu(UME.UMEMenu); - SAFE_DELETE(UME.UMEMenu) - SAFE_DELETE_ARRAY(UME.UMEItem) - wborder(UME.UMEWin, ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '); - touchline(UME.UMEWin,0,E+1); - delwin(UME.UMEWin); - endwin(); - refresh(); - } -}; - -struct LISTMENU { - int LMID; - std::string LMName; - WINDOW *LMWin {nullptr}; - MENU *LMenu {nullptr}; - ITEM **LMItem {nullptr}; -}; - -struct APPMENU { - WINDOW *AppWin1 {nullptr}; - MENU *AppMenu1 {nullptr}; - ITEM **AppItem1 {nullptr}; - WINDOW *AppWin2 {nullptr}; - MENU *AppMenu2 {nullptr}; - ITEM **AppItem2 {nullptr}; -}; - -class MenuClass -{ -public: - //############################variablen######### - HAUPTMENU MENEU; - int MeInAl; - WINDOW *HMTMPWIN; - MENU *HMTMPMENU; - //##########MENÜ################################ - LISTMENU LiMENU; - int LiMeInAl; - WINDOW *LiTMPWIN; - MENU *LiTMPMENU; - //############################################## - LISTMENU NEW_UNIT_MENU; - int NEW_UNIT_MeInAl; - WINDOW *NEW_UNIT_TMPWIN; - MENU *NEW_UNIT_TMPMENU; - //############################################## - APPMENU InAppMenu; - MenuColor HMcolor; - InAppColor IAcolor; - std::string PATTER = ""; - void Hauptmenu(void); - void Datei_menu(void); - void DaemonType_menu(void); - void Systemctl_menu(void); - void Info_menu(void); - MENU *tmpMe(std::string name, int id); - WINDOW *tmpWi(std::string name, int id); - void fensterwahl(std::string wahl); - void QUIT(void); - void MenuStart(void); - void resize(); - MenuClass(); - ~MenuClass(); -}; - -#endif // MENUCLASS_H diff --git a/MenuWinClass.cpp b/MenuWinClass.cpp new file mode 100644 index 0000000..15b5aa6 --- /dev/null +++ b/MenuWinClass.cpp @@ -0,0 +1,899 @@ + #include + +using namespace std; + +TaskClass *TaskClass_MWC = new TaskClass(); +ServiceClass *ServiceClass_MWC = new ServiceClass(); +MenuWinClass *MenuWinClass_MWC = new MenuWinClass(); + +FENSTER MenuWinClass::START; +HAUPTMENU MenuWinClass::TOPMENU; +WINDOW* MenuWinClass::TMPWIN; +MENU* MenuWinClass::TMPMENU; +int MenuWinClass::MeInAl = 0; +INAPPMENU MenuWinClass::SERVICEMENU; +int MenuWinClass::LiMeInAl; +WINDOW* MenuWinClass::LiTMPWIN; +MENU* MenuWinClass::LiTMPMENU; +string MenuWinClass::PATTERN; +ServiceClass ServiceClass; +vector ServiceList; +int MenuWinClass::TabKey = 1; + +WinID& operator++(WinID& WID, int) { + return WID = (WID == WinID::ENDWIN) ? WinID::MAINWIN : static_cast(static_cast(WID) + 1); +}; +WinID& operator--(WinID& WID, int) { + return WID = (WID == WinID::ENDWIN) ? WinID::MAINWIN : static_cast(static_cast(WID) - 1); +}; +ostream& operator<<(ostream& WID, WinID e) { + static const vector EnumString = {"MENUWIN", "MAINWIN", "TERMWIN", "LISTPAD", "DESCWIN", "ENDWIN"}; + return WID << EnumString[static_cast(e)]; +}; +MenuID& operator++(MenuID& MID, int) { + return MID = (MID == MenuID::ENDMENU) ? MenuID::MAINMENU : static_cast(static_cast(MID) + 1); +}; +MenuID& operator--(MenuID& MID, int) { + return MID = (MID == MenuID::ENDMENU) ? MenuID::MAINMENU : static_cast(static_cast(MID) - 1); +}; +ostream& operator<<(ostream& MID, MenuID e) { + static const vector EnumString = {"DATEIMENU", "DAEMONMENU", "SYSTEMCTLMENU", "INFOMENU", "MAINMENU", "ENDMENU"}; + return MID << EnumString[static_cast(e)]; +}; + +MenuWinClass::MenuWinClass() { + START.WinSize.RAND = 1; + START.WinSize.h = 1; //rand + START.WinSize.w = 1; + START.WCX(); // = 80; + START.HRY(); // = 24; + START.WinSize.WCX(); // = 80; + START.WinSize.HRY(); // = 24; + START.WinSize.WCX_Real(); + START.WinSize.HRY_Real(); + START.WinSize.WCX_Center(); + START.WinSize.HRY_Center(); + START.WinSize.WCX_TmpWin(stdscr); + START.WinSize.HRY_TmpWin(stdscr); + START.WinSize.WCX_TmpWinReal(stdscr); + START.WinSize.HRY_TmpWinReal(stdscr); + START.WinSize.WCX_TmpWinCenter(stdscr); + START.WinSize.HRY_TmpWinCenter(stdscr); +} +void MenuWinClass::StartWin() { + setlocale(LC_CTYPE, "de_DE.UTF-8"); + setlocale(LC_ALL, "de_DE.UTF-8"); + initscr(); + if (has_colors() == FALSE) { endwin(); cout << "Your terminal does not support color\n" << endl; exit(1);} + start_color(); + cbreak(); + noecho(); + curs_set(false); + keypad(stdscr, true); + MenuWinClass::AppColor(); +} +void MenuWinClass::StopWin() { + endwin(); +} +void MenuWinClass::AppColor() { + start_color(); + short MY_MARIN_BLUE = 240, MY_LIGHT_BLUE = 250, MY_DARK_BLACK = 0, MY_LIGHT_WHITE = 100; + short R = 0, G = 0, B = 0; + init_color(MY_MARIN_BLUE, R, G, static_cast(300)); + init_color(MY_LIGHT_BLUE, R, G, static_cast(850)); + init_color(MY_DARK_BLACK, R, G, B); + init_color(MY_LIGHT_WHITE, 1000, 1000, 1000); + /* 0 black, 1 red, 2 green, 3 yellow, 4 blue, 5 magenta, 6 cyan, 7 white, 8 marin blue, 9 light blue */ + /* hintergrund Schwarz */ + init_pair(00, MY_DARK_BLACK, MY_DARK_BLACK); + init_pair(10, COLOR_RED, MY_DARK_BLACK); + init_pair(20, COLOR_GREEN, MY_DARK_BLACK); + init_pair(30, COLOR_YELLOW, MY_DARK_BLACK); + init_pair(40, COLOR_BLUE, MY_DARK_BLACK); + init_pair(50, COLOR_MAGENTA, MY_DARK_BLACK); + init_pair(60, COLOR_CYAN, MY_DARK_BLACK); + init_pair(70, MY_LIGHT_WHITE, MY_DARK_BLACK); + init_pair(80, MY_MARIN_BLUE, MY_DARK_BLACK); + init_pair(90, MY_LIGHT_BLUE, MY_DARK_BLACK); + /* hintergrund Rot */ + init_pair(01, MY_DARK_BLACK, COLOR_RED); + init_pair(11, COLOR_RED, COLOR_RED); + init_pair(21, COLOR_GREEN, COLOR_RED); + init_pair(31, COLOR_YELLOW, COLOR_RED); + init_pair(41, COLOR_BLUE, COLOR_RED); + init_pair(51, COLOR_MAGENTA, COLOR_RED); + init_pair(61, COLOR_CYAN, COLOR_RED); + init_pair(71, MY_LIGHT_WHITE, COLOR_RED); + init_pair(81, MY_MARIN_BLUE, COLOR_RED); + init_pair(91, MY_LIGHT_BLUE, COLOR_RED); + /* hintergrund Gruen */ + init_pair(02, MY_DARK_BLACK, COLOR_GREEN); + init_pair(12, COLOR_RED, COLOR_GREEN); + init_pair(22, COLOR_GREEN, COLOR_GREEN); + init_pair(32, COLOR_YELLOW, COLOR_GREEN); + init_pair(42, COLOR_BLUE, COLOR_GREEN); + init_pair(52, COLOR_MAGENTA, COLOR_GREEN); + init_pair(62, COLOR_CYAN, COLOR_GREEN); + init_pair(72, MY_LIGHT_WHITE, COLOR_GREEN); + init_pair(82, MY_MARIN_BLUE, COLOR_GREEN); + init_pair(92, MY_LIGHT_BLUE, COLOR_GREEN); + /* hintergrund Gelb */ + init_pair(03, MY_DARK_BLACK, COLOR_YELLOW); + init_pair(13, COLOR_RED, COLOR_YELLOW); + init_pair(23, COLOR_GREEN, COLOR_YELLOW); + init_pair(33, COLOR_YELLOW, COLOR_YELLOW); + init_pair(43, COLOR_BLUE, COLOR_YELLOW); + init_pair(53, COLOR_MAGENTA, COLOR_YELLOW); + init_pair(63, COLOR_CYAN, COLOR_YELLOW); + init_pair(73, MY_LIGHT_WHITE, COLOR_YELLOW); + init_pair(83, MY_MARIN_BLUE, COLOR_YELLOW); + init_pair(93, MY_LIGHT_BLUE, COLOR_YELLOW); + /* hintergrund Blau */ + init_pair(04, MY_DARK_BLACK, COLOR_BLUE); + init_pair(14, COLOR_RED, COLOR_BLUE); + init_pair(24, COLOR_GREEN, COLOR_BLUE); + init_pair(34, COLOR_YELLOW, COLOR_BLUE); + init_pair(44, COLOR_BLUE, COLOR_BLUE); + init_pair(54, COLOR_MAGENTA, COLOR_BLUE); + init_pair(64, COLOR_CYAN, COLOR_BLUE); + init_pair(74, MY_LIGHT_WHITE, COLOR_BLUE); + init_pair(84, MY_MARIN_BLUE, COLOR_BLUE); + /* hintergrund Magenta */ + init_pair(05, MY_DARK_BLACK, COLOR_MAGENTA); + init_pair(15, COLOR_RED, COLOR_MAGENTA); + init_pair(25, COLOR_GREEN, COLOR_MAGENTA); + init_pair(35, COLOR_YELLOW, COLOR_MAGENTA); + init_pair(45, COLOR_BLUE, COLOR_MAGENTA); + init_pair(55, COLOR_MAGENTA, COLOR_MAGENTA); + init_pair(65, COLOR_CYAN, COLOR_MAGENTA); + init_pair(75, MY_LIGHT_WHITE, COLOR_MAGENTA); + /* hintergrund Cyan */ + init_pair(06, MY_DARK_BLACK, COLOR_CYAN); + init_pair(16, COLOR_RED, COLOR_CYAN); + init_pair(26, COLOR_GREEN, COLOR_CYAN); + init_pair(36, COLOR_YELLOW, COLOR_CYAN); + init_pair(46, COLOR_BLUE, COLOR_CYAN); + init_pair(56, COLOR_MAGENTA, COLOR_CYAN); + init_pair(66, COLOR_CYAN, COLOR_CYAN); + init_pair(76, MY_LIGHT_WHITE, COLOR_CYAN); + init_pair(86, MY_MARIN_BLUE, COLOR_CYAN); + init_pair(96, MY_LIGHT_BLUE, COLOR_CYAN); + /* hintergrund White */ + init_pair(07, MY_DARK_BLACK, MY_LIGHT_WHITE); + init_pair(17, COLOR_RED, MY_LIGHT_WHITE); + init_pair(27, COLOR_GREEN, MY_LIGHT_WHITE); + init_pair(37, COLOR_YELLOW, MY_LIGHT_WHITE); + init_pair(47, COLOR_BLUE, MY_LIGHT_WHITE); + init_pair(57, COLOR_MAGENTA, MY_LIGHT_WHITE); + init_pair(67, COLOR_CYAN, MY_LIGHT_WHITE); + init_pair(77, MY_LIGHT_WHITE, MY_LIGHT_WHITE); + init_pair(87, MY_MARIN_BLUE, MY_LIGHT_WHITE); + init_pair(97, MY_LIGHT_BLUE, MY_LIGHT_WHITE); + /* hintergrund Marin Blau */ + init_pair(8, MY_DARK_BLACK, MY_MARIN_BLUE); + init_pair(18, COLOR_RED, MY_MARIN_BLUE); + init_pair(28, COLOR_GREEN, MY_MARIN_BLUE); + init_pair(38, COLOR_YELLOW, MY_MARIN_BLUE); + init_pair(48, COLOR_BLUE, MY_MARIN_BLUE); + init_pair(58, COLOR_MAGENTA, MY_MARIN_BLUE); + init_pair(68, COLOR_CYAN, MY_MARIN_BLUE); + init_pair(78, MY_LIGHT_WHITE, MY_MARIN_BLUE); + init_pair(88, MY_MARIN_BLUE, MY_MARIN_BLUE); + init_pair(98, MY_LIGHT_BLUE, MY_MARIN_BLUE); + /* hintergrund Light Blue */ + init_pair(9, MY_DARK_BLACK, MY_LIGHT_BLUE); + init_pair(19, COLOR_RED, MY_LIGHT_BLUE); + init_pair(29, COLOR_GREEN, MY_LIGHT_BLUE); + init_pair(39, COLOR_YELLOW, MY_LIGHT_BLUE); + init_pair(49, COLOR_BLUE, MY_LIGHT_BLUE); + init_pair(59, COLOR_MAGENTA, MY_LIGHT_BLUE); + init_pair(69, COLOR_CYAN, MY_LIGHT_BLUE); + init_pair(79, MY_LIGHT_WHITE, MY_LIGHT_BLUE); + init_pair(89, MY_MARIN_BLUE, MY_LIGHT_BLUE); + init_pair(99, MY_LIGHT_BLUE, MY_LIGHT_BLUE); +} /*---------Programm_Farben------------------------*/ +void MenuWinClass::SetWinSize() { + MenuWinClass::START.WCX(); + MenuWinClass::START.HRY(); + MenuWinClass::START.HRYw1(); + MenuWinClass::START.WCXw1(); + MenuWinClass::START.HRYw2(); + MenuWinClass::START.WCXw2(); + MenuWinClass::START.HRYw3(); + MenuWinClass::START.WCXw3(); + MenuWinClass::START.HRYw4(); + MenuWinClass::START.WCXw4(); + MenuWinClass::START.HRYw5(); + MenuWinClass::START.WCXw5(); + MenuWinClass::START.HRYtime(); + MenuWinClass::START.WCXtime(); + MenuWinClass::START.TMPWin1 = newwin(MenuWinClass::START.HRYw1(), MenuWinClass::START.WCXw1(), 0, 0); + MenuWinClass::START.TMPWin2 = newwin(MenuWinClass::START.HRYw2(), MenuWinClass::START.WCXw2(), 1, 0); + MenuWinClass::START.TMPWin3 = newwin(MenuWinClass::START.HRYw3(), MenuWinClass::START.WCXw3(), (MenuWinClass::START.HRYw1() + MenuWinClass::START.HRYw2()), 0); + MenuWinClass::START.TMPWin4 = newpad(MenuWinClass::START.HRYw4(), MenuWinClass::START.WCXw4()); + //MenuWinClass::START.TMPWin5 = newpad(MenuWinClass::START.HRYw5(), MenuWinClass::START.WCXw5()); + MenuWinClass::START.TMPWin5 = newwin(MenuWinClass::START.HRYw5(), MenuWinClass::START.WCXw5(), (MenuWinClass::START.HRYw1() + MenuWinClass::START.HRYw2())+ 1, 33); +} /*---------Fenster_Size_Setzen--------------------*/ +void MenuWinClass::CreateWin(WINDOW* win, WinID WID) { + switch (WID) { + case MENUWIN: { /*TMPWin1*/ + MenuWinClass::Hauptmenu(); + wbkgd(win, COLOR_PAIR(MenuWinClass::START.WinColor.BK_MENUWIN)); + break; + } + case MAINWIN: { /*TMPWin2*/ + box(win, 0, 0); + wbkgd(win, COLOR_PAIR(MenuWinClass::START.WinColor.BK_MAINWIN)); + wsetscrreg(win, 0, MenuWinClass::START.HRYw2() - 2); + scrollok(win, true); + break; + } + case INFOWIN: { /*TMPWin3*/ + box(win, 0, 0); + wbkgd(win, COLOR_PAIR(MenuWinClass::START.WinColor.BK_INFOWIN)); + wattr_on(win, COLOR_PAIR(MenuWinClass::START.WinColor.BK_INFOWIN) | A_BOLD, nullptr); + mvwaddnstr(win, MenuWinClass::START.HRYw3() -1, MenuWinClass::START.WCXw3() - 14, "[ EXIT F10 ]", -1); //12+2 + mvwaddnstr(win, MenuWinClass::START.HRYw3() -1, MenuWinClass::START.WCXw3() - 26, "[ MENÜ TAB ]", -1); //11+2 + wattr_off(win, COLOR_PAIR(MenuWinClass::START.WinColor.BK_INFOWIN) | A_BOLD, nullptr); + break; + } + case LISTPAD: { /*TMPWin4*/ + wbkgd(win, COLOR_PAIR(MenuWinClass::START.WinColor.BK_LISTPAD)); + win = derwin(MenuWinClass::START.TMPWin2, MenuWinClass::START.HRYw4(), MenuWinClass::START.WCXw4(), 1, 1); + break; + } + case DESCWIN: { /*TMPWin5*/ + //win = derwin(MenuWinClass::START.TMPWin3, MenuWinClass::START.HRYw5(), MenuWinClass::START.WCXw5(), 1, 33); + wbkgd(win, COLOR_PAIR(MenuWinClass::START.WinColor.BK_DESCWIN)); + break; + } + case TIMEWIN: { /*TimeWin*/ + wbkgd(win, COLOR_PAIR(MenuWinClass::START.WinColor.BK_TIMEWIN)); + win = derwin(MenuWinClass::START.TMPWin1, 1, 20, 0, MenuWinClass::START.WCX() - 20); + break; + } + case ENDWIN: { break; } + default: { break; } + } + refresh(); + wrefresh(win); +} /*---------Fenster_Erzeugen-----------------------*/ +void MenuWinClass::ResizeHandler(int signal) { + UNUSED(signal); + StopWin(); + StartWin(); + SetWinSize(); + MenuWinClass::CreateWin(MenuWinClass::START.TMPWin1, MENUWIN); + MenuWinClass::CreateWin(MenuWinClass::START.TMPWin2, MAINWIN); + MenuWinClass::CreateWin(MenuWinClass::START.TMPWin3, INFOWIN); + MenuWinClass::CreateWin(MenuWinClass::START.TMPWin4, LISTPAD); + MenuWinClass::CreateWin(MenuWinClass::START.TMPWin5, DESCWIN); +} /*---------Resize_Fenster_neu_Erzeugen----------------*/ +void MenuWinClass::ScrollPad(WINDOW* SubWin, int StartY, int StartX, int Height, int Width, int PadHeight) { + int Choice = 0, Key = 0; + keypad(SubWin, true); + refresh(); + int cols = 0; + while (Choice == 0) { + prefresh(SubWin, cols, 0, StartY, StartX, Height, Width); + Key = wgetch(SubWin); + switch (Key) { + case KEY_UP: { + if (cols <= 0) { continue; } + cols--; + break; + } + case KEY_DOWN: { + if (cols + Height + 1 >= PadHeight) { continue; } + cols++; + break; + } + case KEY_PPAGE: { /* Page Up */ + if (cols <= 0) { continue; } + cols -= Height; + if (cols < 0) { cols = 0; } + break; + } + case KEY_NPAGE: { /* Page Down */ + if (cols + Height + 1 >= PadHeight) { continue; } + cols += Height; + if (cols + Height + 1 > PadHeight) { cols = PadHeight - Height - 1; } + break; + } + case KEY_HOME: { + cols = 0; + break; + } + case KEY_END: { + cols = PadHeight - Height - 1; + break; + } + case 10: { /* Enter */ + Choice = 1; + break; + } + } + refresh(); + } + delwin(SubWin); +} +void MenuWinClass::printInMiddle(WINDOW *win, int starty, int startx, int width, char *string, chtype color, char *sp) { + int x, y; + unsigned long length; + float temp; + + if(win == nullptr) + win = stdscr; + getyx(win, y, x); + if(startx != 0) + x = startx; + if(starty != 0) + y = starty; + if(width == 0) + width = 80; + + length = strlen(string); + temp = (width - static_cast(length))/ 2; + x = startx + static_cast(temp); + wattron(win, color); + + if (sp) { + for (int i = startx; i < width; i++) { + mvwprintw(win, y, i, "%c", sp); + } + } + + mvwprintw(win, y, x, "%s", string); + wattroff(win, color); +} +void MenuWinClass::FensterDraw() { + ServiceClass_MWC->INFOWINDOW(""); + ServiceClass_MWC->ServiceListFill(); + MenuWinClass::CreateWin(MenuWinClass::START.TMPWin1, MENUWIN); + MenuWinClass::CreateWin(MenuWinClass::START.TMPWin2, MAINWIN); + MenuWinClass::CreateWin(MenuWinClass::START.TMPWin3, INFOWIN); + MenuWinClass::CreateWin(MenuWinClass::START.TMPWin4, LISTPAD); + MenuWinClass::CreateWin(MenuWinClass::START.TMPWin5, DESCWIN); +} +void MenuWinClass::Hauptmenu(void) { + MenuWinClass::TOPMENU.MID = MAINMENU; + MenuWinClass::TOPMENU.HMName = string("HAUPTMENÜ"); + MenuWinClass::TOPMENU.HMItem = static_cast(calloc(5, sizeof(ITEM*))); + MenuWinClass::TOPMENU.HMItem[0] = new_item(" Datei", MenuWinClass::TOPMENU.HMName.c_str()); + MenuWinClass::TOPMENU.HMItem[1] = new_item("DaemonType", MenuWinClass::TOPMENU.HMName.c_str()); + MenuWinClass::TOPMENU.HMItem[2] = new_item("Systemctl", MenuWinClass::TOPMENU.HMName.c_str()); + MenuWinClass::TOPMENU.HMItem[3] = new_item("Info", MenuWinClass::TOPMENU.HMName.c_str()); + MenuWinClass::TOPMENU.HMItem[4] = nullptr; + MenuWinClass::TOPMENU.HMMenu = new_menu(MenuWinClass::TOPMENU.HMItem); + MenuWinClass::START.TMPWin1 = newwin(MenuWinClass::START.HRYw1(), MenuWinClass::START.WCXw1(), 0, 0); + set_menu_win(MenuWinClass::TOPMENU.HMMenu, MenuWinClass::START.TMPWin1); + set_menu_sub(MenuWinClass::TOPMENU.HMMenu, MenuWinClass::START.TMPWin1); + //############################################################### + //set_menu_sub(TOPMENU.UME.UMEMenu, MenuWinClass::START.TMPWin1); + //############################################################### + set_menu_spacing(MenuWinClass::TOPMENU.HMMenu, 1, 0, 0); + set_menu_format(MenuWinClass::TOPMENU.HMMenu, 0, 5); + menu_opts_off(MenuWinClass::TOPMENU.HMMenu, O_SHOWDESC); + menu_opts_off(MenuWinClass::TOPMENU.HMMenu, O_NONCYCLIC); + wbkgd(MenuWinClass::START.TMPWin1, COLOR_PAIR(MenuWinClass::TOPMENU.MenuColor.BK_MAINMENU)); + set_menu_fore(MenuWinClass::TOPMENU.HMMenu, COLOR_PAIR(MenuWinClass::TOPMENU.MenuColor.BK_AKTIVHAME) | A_BOLD); + set_menu_back(MenuWinClass::TOPMENU.HMMenu, COLOR_PAIR(MenuWinClass::TOPMENU.MenuColor.BK_MAINMENU)); + set_menu_grey(MenuWinClass::TOPMENU.HMMenu, COLOR_PAIR(MenuWinClass::TOPMENU.MenuColor.BK_UNUSEDHM)); + set_menu_mark(MenuWinClass::TOPMENU.HMMenu, ""); + post_menu(MenuWinClass::TOPMENU.HMMenu); +} /* Hauptmenü */ +void MenuWinClass::DateiMenu(void) { + TOPMENU.UME.UMID = 1; + TOPMENU.UME.UMEName = string("Datei"); + TOPMENU.UME.UMEWin = newwin(6, 15, 1, 0); + wbkgd(TOPMENU.UME.UMEWin, COLOR_PAIR(TOPMENU.MenuColor.BK_UNTERMENU)); + box(TOPMENU.UME.UMEWin, 0, 0); + TOPMENU.UME.UMEItem = static_cast(calloc(7, sizeof(ITEM*))); + TOPMENU.UME.UMEItem[0] = new_item("Man Systemctl", TOPMENU.UME.UMEName.c_str()); + TOPMENU.UME.UMEItem[1] = new_item("Einstellung", TOPMENU.UME.UMEName.c_str()); + TOPMENU.UME.UMEItem[2] = new_item("Remotectl", TOPMENU.UME.UMEName.c_str()); + TOPMENU.UME.UMEItem[3] = new_item("Beenden", TOPMENU.UME.UMEName.c_str()); + TOPMENU.UME.UMEItem[4] = nullptr; + TOPMENU.UME.UMEMenu = new_menu(TOPMENU.UME.UMEItem); + set_menu_win(TOPMENU.UME.UMEMenu, TOPMENU.UME.UMEWin); + set_menu_sub(TOPMENU.UME.UMEMenu, derwin(TOPMENU.UME.UMEWin, 0, 0, 1, 1)); + set_menu_spacing(TOPMENU.UME.UMEMenu, 0, 0, 0); + set_menu_format(TOPMENU.UME.UMEMenu, 5, 0); + menu_opts_off(TOPMENU.UME.UMEMenu, O_SHOWDESC); + menu_opts_off(TOPMENU.UME.UMEMenu, O_NONCYCLIC); + set_menu_fore(TOPMENU.UME.UMEMenu, COLOR_PAIR(TOPMENU.MenuColor.BK_AKTIVUNME)|A_REVERSE|A_BOLD); + set_menu_back(TOPMENU.UME.UMEMenu, COLOR_PAIR(TOPMENU.MenuColor.BK_UNTERMENU)); + set_menu_grey(TOPMENU.UME.UMEMenu, COLOR_PAIR(TOPMENU.MenuColor.BK_UNUSEDUM)|A_BOLD); + set_menu_mark(TOPMENU.UME.UMEMenu, ""); + set_current_item(TOPMENU.UME.UMEMenu, TOPMENU.UME.UMEItem[0]); + post_menu(TOPMENU.UME.UMEMenu); +} /* Datei Untermenü */ +void MenuWinClass::DaemonTypeMenu(void) { + TOPMENU.UME.UMID = 2; + TOPMENU.UME.UMEName = string("DaemonType"); + TOPMENU.UME.UMEWin = newwin(12, 10, 1, 11); + box(TOPMENU.UME.UMEWin, 0, 0); + TOPMENU.UME.UMEItem = static_cast(calloc(11, sizeof(ITEM*))); + TOPMENU.UME.UMEItem[0] = new_item("Device", TOPMENU.UME.UMEName.c_str()); + TOPMENU.UME.UMEItem[1] = new_item("Mount", TOPMENU.UME.UMEName.c_str()); + TOPMENU.UME.UMEItem[2] = new_item("Path", TOPMENU.UME.UMEName.c_str()); + TOPMENU.UME.UMEItem[3] = new_item("Service", TOPMENU.UME.UMEName.c_str()); + TOPMENU.UME.UMEItem[4] = new_item("Scope", TOPMENU.UME.UMEName.c_str()); + TOPMENU.UME.UMEItem[5] = new_item("Slice", TOPMENU.UME.UMEName.c_str()); + TOPMENU.UME.UMEItem[6] = new_item("Socket", TOPMENU.UME.UMEName.c_str()); + TOPMENU.UME.UMEItem[7] = new_item("Swap", TOPMENU.UME.UMEName.c_str()); + TOPMENU.UME.UMEItem[8] = new_item("Target", TOPMENU.UME.UMEName.c_str()); + TOPMENU.UME.UMEItem[9] = new_item("Timer", TOPMENU.UME.UMEName.c_str()); + TOPMENU.UME.UMEItem[10] = nullptr; + TOPMENU.UME.UMEMenu = new_menu(TOPMENU.UME.UMEItem); + set_menu_win(TOPMENU.UME.UMEMenu, TOPMENU.UME.UMEWin); + set_menu_sub(TOPMENU.UME.UMEMenu, derwin(TOPMENU.UME.UMEWin, 0, 0, 1, 1)); + set_menu_spacing(TOPMENU.UME.UMEMenu, 0, 0, 1); + set_menu_format(TOPMENU.UME.UMEMenu, 11, 0); + menu_opts_off(TOPMENU.UME.UMEMenu, O_SHOWDESC); + menu_opts_off(TOPMENU.UME.UMEMenu, O_NONCYCLIC); + wbkgd(TOPMENU.UME.UMEWin, COLOR_PAIR(TOPMENU.MenuColor.BK_UNTERMENU)); + set_menu_fore(TOPMENU.UME.UMEMenu, COLOR_PAIR(TOPMENU.MenuColor.BK_AKTIVUNME)|A_REVERSE|A_BOLD); + set_menu_back(TOPMENU.UME.UMEMenu, COLOR_PAIR(TOPMENU.MenuColor.BK_UNTERMENU)); + set_menu_grey(TOPMENU.UME.UMEMenu, COLOR_PAIR(TOPMENU.MenuColor.BK_UNUSEDUM)|A_BOLD); + set_menu_mark(TOPMENU.UME.UMEMenu, ""); + set_current_item(TOPMENU.UME.UMEMenu, TOPMENU.UME.UMEItem[0]); + post_menu(TOPMENU.UME.UMEMenu); +} /* DaemonType Untermenü */ +void MenuWinClass::SystemctlMenu(void) { + TOPMENU.UME.UMID = 3; + TOPMENU.UME.UMEName = string("Systemctl"); + TOPMENU.UME.UMEWin = newwin(12, 18, 1, 22); + box(TOPMENU.UME.UMEWin, 0, 0); + TOPMENU.UME.UMEItem = static_cast(calloc(11, sizeof(ITEM*))); + TOPMENU.UME.UMEItem[0] = new_item("START", "F1"); + TOPMENU.UME.UMEItem[1] = new_item("STOP", "F1"); + TOPMENU.UME.UMEItem[2] = new_item("STATUS", "F3"); + TOPMENU.UME.UMEItem[3] = new_item("ENABLE", "F2"); + TOPMENU.UME.UMEItem[4] = new_item("DISABLE", "F2"); + TOPMENU.UME.UMEItem[5] = new_item("MASK", "F4"); + TOPMENU.UME.UMEItem[6] = new_item("UNMASK", "F4"); + TOPMENU.UME.UMEItem[7] = new_item("RESTART", "F5"); + TOPMENU.UME.UMEItem[8] = new_item("RELOAD", "F6"); + TOPMENU.UME.UMEItem[9] = new_item("Reload-daemon", "F7"); + TOPMENU.UME.UMEItem[10] = nullptr; + TOPMENU.UME.UMEMenu = new_menu(TOPMENU.UME.UMEItem); + set_menu_win(TOPMENU.UME.UMEMenu, TOPMENU.UME.UMEWin); + set_menu_sub(TOPMENU.UME.UMEMenu, derwin(TOPMENU.UME.UMEWin, 0, 0, 1, 1)); + set_menu_spacing(TOPMENU.UME.UMEMenu, 1, 0, 0); + set_menu_format(TOPMENU.UME.UMEMenu, 11, 0); + menu_opts_on(TOPMENU.UME.UMEMenu, O_SHOWDESC); + menu_opts_off(TOPMENU.UME.UMEMenu, O_NONCYCLIC); + wbkgd(TOPMENU.UME.UMEWin, COLOR_PAIR(TOPMENU.MenuColor.BK_UNTERMENU)); + set_menu_fore(TOPMENU.UME.UMEMenu, COLOR_PAIR(TOPMENU.MenuColor.BK_AKTIVUNME)|A_REVERSE|A_BOLD); + set_menu_back(TOPMENU.UME.UMEMenu, COLOR_PAIR(TOPMENU.MenuColor.BK_UNTERMENU)); + set_menu_grey(TOPMENU.UME.UMEMenu, COLOR_PAIR(TOPMENU.MenuColor.BK_UNUSEDUM)|A_BOLD); + set_menu_mark(TOPMENU.UME.UMEMenu, ""); + set_current_item(TOPMENU.UME.UMEMenu, TOPMENU.UME.UMEItem[0]); + post_menu(TOPMENU.UME.UMEMenu); +} /* Systemctl Untermenü */ +void MenuWinClass::InfoMenu(void) { + TOPMENU.UME.UMID = 4; + TOPMENU.UME.UMEName = string("Info"); + TOPMENU.UME.UMEWin = newwin(5, 12, 1, 33); + wbkgd(TOPMENU.UME.UMEWin, COLOR_PAIR(TOPMENU.MenuColor.BK_UNTERMENU)); + box(TOPMENU.UME.UMEWin, 0, 0); + TOPMENU.UME.UMEItem = static_cast(calloc(4, sizeof(ITEM*))); + TOPMENU.UME.UMEItem[0] = new_item("journalctl", TOPMENU.UME.UMEName.c_str()); + TOPMENU.UME.UMEItem[1] = new_item("E-Mail", TOPMENU.UME.UMEName.c_str()); + TOPMENU.UME.UMEItem[2] = new_item("Beenden", TOPMENU.UME.UMEName.c_str()); + TOPMENU.UME.UMEItem[3] = nullptr; + TOPMENU.UME.UMEMenu = new_menu(TOPMENU.UME.UMEItem); + set_menu_win(TOPMENU.UME.UMEMenu, TOPMENU.UME.UMEWin); + set_menu_sub(TOPMENU.UME.UMEMenu, derwin(TOPMENU.UME.UMEWin, 0, 0, 1, 1)); + set_menu_spacing(TOPMENU.UME.UMEMenu, 0, 0, 0); + set_menu_format(TOPMENU.UME.UMEMenu, 5, 0); + menu_opts_off(TOPMENU.UME.UMEMenu, O_SHOWDESC); + menu_opts_off(TOPMENU.UME.UMEMenu, O_NONCYCLIC); + set_menu_fore(TOPMENU.UME.UMEMenu, COLOR_PAIR(TOPMENU.MenuColor.BK_AKTIVUNME)|A_REVERSE|A_BOLD); + set_menu_back(TOPMENU.UME.UMEMenu, COLOR_PAIR(TOPMENU.MenuColor.BK_UNTERMENU)); + set_menu_grey(TOPMENU.UME.UMEMenu, COLOR_PAIR(TOPMENU.MenuColor.BK_UNUSEDUM)|A_BOLD); + set_menu_mark(TOPMENU.UME.UMEMenu, ""); + set_current_item(TOPMENU.UME.UMEMenu, TOPMENU.UME.UMEItem[0]); + post_menu(TOPMENU.UME.UMEMenu); +} /* Info Untermenü */ +WINDOW* MenuWinClass::TempWin(string Name, MenuID MID) { + if ((Name.compare(" Datei") == 0) || (MID == DATEIMENU)) { + //MenuWinClass::CreateMenu(MenuWinClass::TOPMENU.UME.UMEWin, MenuWinClass::TOPMENU.UME.UMEMenu, DATEIMENU, "DATEIMENU"); + MenuWinClass::DateiMenu(); + MenuWinClass::TMPWIN = MenuWinClass::TOPMENU.UME.UMEWin; + MenuWinClass::TMPMENU = MenuWinClass::TOPMENU.UME.UMEMenu; + } else if ((Name.compare("DaemonType") == 0) || (MID == DAEMONMENU)) { + //MenuWinClass::CreateMenu(MenuWinClass::TOPMENU.UME.UMEWin, MenuWinClass::TOPMENU.UME.UMEMenu, SYSTEMMENU, "SYSTEMMENU"); + MenuWinClass::DaemonTypeMenu(); + MenuWinClass::TMPWIN = MenuWinClass::TOPMENU.UME.UMEWin; + MenuWinClass::TMPMENU = MenuWinClass::TOPMENU.UME.UMEMenu; + } else if ((Name.compare("Systemctl") == 0) || (MID == SYSTEMCTLMENU)) { + //MenuWinClass::CreateMenu(MenuWinClass::TOPMENU.UME.UMEWin, MenuWinClass::TOPMENU.UME.UMEMenu, SERVERMENU, "SERVERMENU"); + MenuWinClass::SystemctlMenu(); + MenuWinClass::TMPWIN = MenuWinClass::TOPMENU.UME.UMEWin; + MenuWinClass::TMPMENU = MenuWinClass::TOPMENU.UME.UMEMenu; + } else if ((Name.compare("Info") == 0) || (MID == INFOMENU)) { + //MenuWinClass::CreateMenu(MenuWinClass::TOPMENU.UME.UMEWin, MenuWinClass::TOPMENU.UME.UMEMenu, SOFTWAREMENU, "SOFTWAREMENU"); + MenuWinClass::InfoMenu(); + MenuWinClass::TMPWIN = MenuWinClass::TOPMENU.UME.UMEWin; + MenuWinClass::TMPMENU = MenuWinClass::TOPMENU.UME.UMEMenu; + } + return MenuWinClass::TMPWIN; +} /* Menü und Win Neuzuordnen */ +void MenuWinClass::StartMenuAuswahl(string wahl) { + string menupoint = MenuWinClass::SERVICEMENU.AktivName; + string befehl; + if (wahl.compare(" Datei") == 0) { + DateiMenu(); + } else if (wahl.compare("Systemctl") == 0) { + SystemctlMenu(); + } else if (wahl.compare("DaemonType") == 0) { + DaemonTypeMenu(); + } else if (wahl.compare("Systemctl") == 0) { + InfoMenu(); + } else if (wahl.compare("Service") == 0) { + ServiceClass_MWC->start = 0; + ServiceClass_MWC->selected = 0; + ServiceClass_MWC->systemctlwahl = "service"; + ServiceClass_MWC->ServiceListFill(); + } else if (wahl.compare("Swap") == 0) { + ServiceClass_MWC->start = 0; + ServiceClass_MWC->selected = 0; + ServiceClass_MWC->systemctlwahl = "swap"; + ServiceClass_MWC->ServiceListFill(); + } else if (wahl.compare("Timer") == 0) { + ServiceClass_MWC->start = 0; + ServiceClass_MWC->selected = 0; + ServiceClass_MWC->systemctlwahl = "timer"; + ServiceClass_MWC->ServiceListFill(); + } else if (wahl.compare("Device") == 0) { + ServiceClass_MWC->start = 0; + ServiceClass_MWC->selected = 0; + ServiceClass_MWC->systemctlwahl = "device"; + ServiceClass_MWC->ServiceListFill(); + } else if (wahl.compare("Mount") == 0) { + ServiceClass_MWC->start = 0; + ServiceClass_MWC->selected = 0; + ServiceClass_MWC->systemctlwahl = "mount"; + ServiceClass_MWC->ServiceListFill(); + } else if (wahl.compare("Path") == 0) { + ServiceClass_MWC->start = 0; + ServiceClass_MWC->selected = 0; + ServiceClass_MWC->systemctlwahl = "path"; + ServiceClass_MWC->ServiceListFill(); + } else if (wahl.compare("Target") == 0) { + ServiceClass_MWC->start = 0; + ServiceClass_MWC->selected = 0; + ServiceClass_MWC->systemctlwahl = "target"; + ServiceClass_MWC->ServiceListFill(); + } else if (wahl.compare("Socket") == 0) { + ServiceClass_MWC->start = 0; + ServiceClass_MWC->selected = 0; + ServiceClass_MWC->systemctlwahl = "socket"; + ServiceClass_MWC->ServiceListFill(); + } else if (wahl.compare("Slice") == 0) { + ServiceClass_MWC->start = 0; + ServiceClass_MWC->selected = 0; + ServiceClass_MWC->systemctlwahl = "slice"; + ServiceClass_MWC->ServiceListFill(); + } else if (wahl.compare("Scope") == 0) { + ServiceClass_MWC->start = 0; + ServiceClass_MWC->selected = 0; + ServiceClass_MWC->systemctlwahl = "scope"; + ServiceClass_MWC->ServiceListFill(); + } else if (wahl.compare("Man Page") == 0) { + exit(EXIT_SUCCESS); + //DATEIMANPAGE::Start_ManP(); + } else if (wahl.compare("Befehle") == 0) { + exit(EXIT_SUCCESS); + //DATEIBEFEHLE::befehle_main(); + } else if (wahl.compare("Einstellung") == 0) { + exit(EXIT_SUCCESS); + //einDa(); + } else if (wahl.compare("Beenden") == 0) { + exit(EXIT_SUCCESS); + } else if (wahl.compare("START") == 0) { + pos_menu_cursor(MenuWinClass::SERVICEMENU.LMenu); + befehl = "systemctl start " + menupoint + " --now"; + TaskClass_MWC->TERM_AUSGABE(befehl); + ServiceClass_MWC->ServiceListFill(); + } else if (wahl.compare("STOP") == 0) { + pos_menu_cursor(MenuWinClass::SERVICEMENU.LMenu); + befehl = "systemctl stop " + menupoint + " --now"; + TaskClass_MWC->TERM_AUSGABE(befehl); + ServiceClass_MWC->ServiceListFill(); + } else if (wahl.compare("RELOAD") == 0) { + pos_menu_cursor(MenuWinClass::SERVICEMENU.LMenu); + befehl = "systemctl reload " + menupoint + " --now"; + TaskClass_MWC->TERM_AUSGABE(befehl); + ServiceClass_MWC->ServiceListFill(); + } else if (wahl.compare("RESTART") == 0) { + pos_menu_cursor(MenuWinClass::SERVICEMENU.LMenu); + befehl = "systemctl restart " + menupoint + " --now"; + TaskClass_MWC->TERM_AUSGABE(befehl); + ServiceClass_MWC->ServiceListFill(); + } else if (wahl.compare("ENABLE") == 0) { + pos_menu_cursor(MenuWinClass::SERVICEMENU.LMenu); + befehl = "systemctl enable " + menupoint; + TaskClass_MWC->TERM_AUSGABE(befehl); + ServiceClass_MWC->ServiceListFill(); + } else if (wahl.compare("DISABLE") == 0) { + pos_menu_cursor(MenuWinClass::SERVICEMENU.LMenu); + befehl = "systemctl disable " + menupoint; + TaskClass_MWC->TERM_AUSGABE(befehl); + ServiceClass_MWC->ServiceListFill(); + } else if (wahl.compare("STATUS") == 0) { + pos_menu_cursor(MenuWinClass::SERVICEMENU.LMenu); + befehl = "systemctl status " + menupoint; + ServiceClass_MWC->Statusabfrage(TaskClass_MWC->TERM_AUSGABE(befehl)); + } else if (wahl.compare("UNMASK") == 0) { + pos_menu_cursor(MenuWinClass::SERVICEMENU.LMenu); + befehl = "systemctl unmask " + menupoint; + TaskClass_MWC->TERM_AUSGABE(befehl); + ServiceClass_MWC->ServiceListFill(); + } else if (wahl.compare("MASK") == 0) { + pos_menu_cursor(MenuWinClass::SERVICEMENU.LMenu); + befehl = "systemctl mask " + menupoint; + TaskClass_MWC->TERM_AUSGABE(befehl); + ServiceClass_MWC->ServiceListFill(); + } else if (wahl.compare("journalctl") == 0) { + befehl = "journalctl -b -u " + menupoint; + ServiceClass_MWC->Statusabfrage(TaskClass_MWC->TERM_AUSGABE(befehl)); + } +} /* MenüPoint to command */ +void MenuWinClass::RefreshWindows(){ + refresh(); + wrefresh(MenuWinClass::START.TMPWin1); + redrawwin(MenuWinClass::START.TMPWin2); + wrefresh(MenuWinClass::START.TMPWin2); + touchwin(MenuWinClass::START.TMPWin2); + redrawwin(MenuWinClass::START.TMPWin3); + wrefresh(MenuWinClass::START.TMPWin3); + touchwin(MenuWinClass::START.TMPWin3); + prefresh(MenuWinClass::START.TMPWin4, 0, 0, 2, 1, MenuWinClass::START.HRYw4() + 1, MenuWinClass::START.WCXw4()); + //prefresh(MenuWinClass::START.TMPWin5, 0, 0, MenuWinClass::START.HRY()-4, + // MenuWinClass::START.WCX()-46, MenuWinClass::START.HRYw5(), MenuWinClass::START.WCXw5()); + wrefresh(MenuWinClass::START.TMPWin5); +} + +int MenuWinClass::MenuStart(int Key) { +//try { + set_current_item(MenuWinClass::TOPMENU.HMMenu, MenuWinClass::TOPMENU.HMItem[MenuWinClass::MeInAl]); + TMPWIN = TempWin(item_name(current_item(MenuWinClass::TOPMENU.HMMenu)), (MenuID)item_index(current_item(MenuWinClass::TOPMENU.HMMenu))); + string tmpMeNa = string(item_name(current_item(MenuWinClass::TOPMENU.HMMenu))); + string MeAuWa = ""; + ServiceClass_MWC->TableMoveRow(); + while ((Key = wgetch(stdscr)) != KEY_F(10)) { + switch (MenuWinClass::TabKey) { + case 1: { + switch (Key) { + case '?': { ServiceClass_MWC->Statusabfrage(ABOUT_INFO); break; } + case 27: { + MenuWinClass_MWC->TabKey = TaskClass_MWC->ZahlenWerk(1, "++", 3); + set_current_item(MenuWinClass::TOPMENU.HMMenu, MenuWinClass::TOPMENU.HMItem[0]); + MenuWinClass::TOPMENU.LoescheUME(); + wrefresh(MenuWinClass::START.TMPWin1); + break; + } + case KEY_DOWN: { + ServiceClass_MWC->TableDriver(ServiceClass_MWC->ServiceList, REQ_DOWN_ITEM); + ServiceClass_MWC->TableMoveRow(); + break; + } + case KEY_UP: { + ServiceClass_MWC->TableDriver(ServiceClass_MWC->ServiceList, REQ_UP_ITEM); + ServiceClass_MWC->TableMoveRow(); + break; + } + case KEY_NPAGE: { + ServiceClass_MWC->TableDriver(ServiceClass_MWC->ServiceList, REQ_SCR_DPAGE); + ServiceClass_MWC->TableMoveRow(); + break; + } + case KEY_PPAGE: { + ServiceClass_MWC->TableDriver(ServiceClass_MWC->ServiceList, REQ_SCR_UPAGE); + ServiceClass_MWC->TableMoveRow(); + break; + } + case KEY_END: { + ServiceClass_MWC->TableDriver(ServiceClass_MWC->ServiceList, REQ_LAST_ITEM); + ServiceClass_MWC->TableMoveRow(); + break; + } + case KEY_HOME: { + ServiceClass_MWC->start = 0; + ServiceClass_MWC->selected = 0; + ServiceClass_MWC->TableDriver(ServiceClass_MWC->ServiceList, REQ_FIRST_ITEM); + ServiceClass_MWC->TableMoveRow(); + break; + } + case 0x09: { + MenuWinClass_MWC->TabKey = TaskClass_MWC->ZahlenWerk(1, "++", 3); + TMPWIN = TempWin("Datei", DATEIMENU); + redrawwin(MenuWinClass::TOPMENU.UME.UMEWin); + wrefresh(MenuWinClass::TOPMENU.UME.UMEWin); + break; + } + case KEY_BTAB: { + MenuWinClass_MWC->TabKey = TaskClass_MWC->ZahlenWerk(1, "--", 3); + TMPWIN = TempWin("Datei", DATEIMENU); + redrawwin(MenuWinClass::TOPMENU.UME.UMEWin); + wrefresh(MenuWinClass::TOPMENU.UME.UMEWin); + break; + } + case KEY_BACKSPACE: { ServiceClass_MWC->TableDriver(ServiceClass_MWC->ServiceList, REQ_BACK_PATTERN); break; } + case 10: { + string menupoint = MenuWinClass::SERVICEMENU.AktivName; + string befehl = "systemctl status " + menupoint; + ServiceClass_MWC->Statusabfrage(TaskClass_MWC->TERM_AUSGABE(befehl)); + break; } + case 32: { ServiceClass_MWC->TableDriver(ServiceClass_MWC->ServiceList, REQ_TOGGLE_ITEM); break; } + default: { if (Key > 10 && Key < 128) { + //ServiceClass_MWC->TableDriver(ServiceClass_MWC->ServiceList, REQ_NEXT_MATCH); + } + break;} + } + if (MenuWinClass_MWC->TabKey == 1) { + curs_set(false); + ServiceClass_MWC->INFOWINDOW(MenuWinClass::SERVICEMENU.AktivName); + MenuWinClass::TOPMENU.LoescheUME(); + MenuWinClass::RefreshWindows(); + } else if (MenuWinClass_MWC->TabKey == 2) { + curs_set(false); + MenuWinClass::RefreshWindows(); + wrefresh(MenuWinClass::START.TMPWin1); + redrawwin(MenuWinClass::TOPMENU.UME.UMEWin); + wrefresh(MenuWinClass::TOPMENU.UME.UMEWin); + } else if (MenuWinClass_MWC->TabKey == 3) { + curs_set(true); + mvwaddnstr(MenuWinClass::START.TMPWin3, 4, 33, MenuWinClass::PATTERN.c_str(), -1); + MenuWinClass::RefreshWindows(); + } + break; + } /* MainWindow ListMenu */ + case 2: { + switch (Key) { + case '?': { ServiceClass_MWC->Statusabfrage(ABOUT_INFO); break; } + case 27: { + MenuWinClass_MWC->TabKey = TaskClass_MWC->ZahlenWerk(2, "++", 3); + set_current_item(MenuWinClass::TOPMENU.HMMenu, MenuWinClass::TOPMENU.HMItem[0]); + MenuWinClass::TOPMENU.LoescheUME(); + wrefresh(MenuWinClass::START.TMPWin1); + break; + } + case KEY_DOWN: { menu_driver(TOPMENU.UME.UMEMenu, REQ_DOWN_ITEM); break; } + case KEY_UP: { menu_driver(TOPMENU.UME.UMEMenu, REQ_UP_ITEM); break; } + case KEY_RIGHT: { + MenuWinClass::TOPMENU.LoescheUME(); + menu_driver(MenuWinClass::TOPMENU.HMMenu, REQ_RIGHT_ITEM); + tmpMeNa = string(item_name(current_item(MenuWinClass::TOPMENU.HMMenu))); + TMPWIN = TempWin(item_name(current_item(MenuWinClass::TOPMENU.HMMenu)), (MenuID)item_index(current_item(MenuWinClass::TOPMENU.HMMenu))); + break; + } + case KEY_LEFT: { + MenuWinClass::TOPMENU.LoescheUME(); // delete before menu drive + menu_driver(MenuWinClass::TOPMENU.HMMenu, REQ_LEFT_ITEM); + tmpMeNa = string(item_name(current_item(MenuWinClass::TOPMENU.HMMenu))); + TMPWIN = TempWin(item_name(current_item(MenuWinClass::TOPMENU.HMMenu)), (MenuID)item_index(current_item(MenuWinClass::TOPMENU.HMMenu))); + break; + } + case 0x09: { + MenuWinClass_MWC->TabKey = TaskClass_MWC->ZahlenWerk(2, "++", 3); + set_current_item(MenuWinClass::TOPMENU.HMMenu, MenuWinClass::TOPMENU.HMItem[0]); + MenuWinClass::TOPMENU.LoescheUME(); + wrefresh(MenuWinClass::START.TMPWin1); + break; + } + case KEY_BTAB: { + MenuWinClass_MWC->TabKey = TaskClass_MWC->ZahlenWerk(2, "--", 3); + set_current_item(MenuWinClass::TOPMENU.HMMenu, MenuWinClass::TOPMENU.HMItem[0]); + MenuWinClass::TOPMENU.LoescheUME(); + wrefresh(MenuWinClass::START.TMPWin1); + break; + } + case 10: { + MenuWinClass::MeInAl = item_index(current_item(MenuWinClass::TOPMENU.HMMenu)); + StartMenuAuswahl(item_name(current_item(MenuWinClass::TOPMENU.UME.UMEMenu))); + MenuWinClass_MWC->TabKey = TaskClass_MWC->ZahlenWerk(2, "++", 2); + set_current_item(MenuWinClass::TOPMENU.HMMenu, MenuWinClass::TOPMENU.HMItem[0]); + MenuWinClass::TOPMENU.LoescheUME(); + wrefresh(MenuWinClass::START.TMPWin1); + break; } + } + if (MenuWinClass_MWC->TabKey == 1) { + curs_set(false); + ServiceClass_MWC->INFOWINDOW(MenuWinClass::SERVICEMENU.AktivName); + MenuWinClass::TOPMENU.LoescheUME(); + MenuWinClass::RefreshWindows(); + } else if (MenuWinClass_MWC->TabKey == 2) { + curs_set(false); + MenuWinClass::RefreshWindows(); + wrefresh(MenuWinClass::START.TMPWin1); + redrawwin(MenuWinClass::TOPMENU.UME.UMEWin); + wrefresh(MenuWinClass::TOPMENU.UME.UMEWin); + } else if (MenuWinClass_MWC->TabKey == 3) { + curs_set(true); + mvwaddnstr(MenuWinClass::START.TMPWin3, 4, 33, MenuWinClass::PATTERN.c_str(), -1); + MenuWinClass::RefreshWindows(); + } + break; + } /* Hauptmenu */ + case 3:{ + int y,x; + getyx(MenuWinClass::START.TMPWin3, y, x); + int curposi = (x - 33); + switch (Key) { + case '?':{ ServiceClass_MWC->Statusabfrage(ABOUT_INFO); break; } + case 27:{ break; } + case 127: + case KEY_BACKSPACE:{ + MenuWinClass::PATTERN = ServiceClass_MWC->SearchDriver(REQ_DEL_BACKSPACE, MenuWinClass::START.TMPWin3, Key, MenuWinClass::PATTERN, curposi); + break; } + case KEY_DC:{ + MenuWinClass::PATTERN = ServiceClass_MWC->SearchDriver(REQ_DEL_DC, MenuWinClass::START.TMPWin3, Key, MenuWinClass::PATTERN, curposi); + break; } + case KEY_RIGHT:{ + MenuWinClass::PATTERN = ServiceClass_MWC->SearchDriver(REQ_RIGHT, MenuWinClass::START.TMPWin3, Key, MenuWinClass::PATTERN, curposi); + break; } + case KEY_LEFT:{ + MenuWinClass::PATTERN = ServiceClass_MWC->SearchDriver(REQ_LEFT, MenuWinClass::START.TMPWin3, Key, MenuWinClass::PATTERN, curposi); + break; } + case 0x09: { + MenuWinClass_MWC->TabKey = TaskClass_MWC->ZahlenWerk(3, "++", 3); + set_current_item(MenuWinClass::TOPMENU.HMMenu, MenuWinClass::TOPMENU.HMItem[0]); + MenuWinClass::TOPMENU.LoescheUME(); + wrefresh(MenuWinClass::START.TMPWin1); + break; + } + case KEY_BTAB: { + MenuWinClass_MWC->TabKey = TaskClass_MWC->ZahlenWerk(3, "--", 3); + set_current_item(MenuWinClass::TOPMENU.HMMenu, MenuWinClass::TOPMENU.HMItem[0]); + MenuWinClass::TOPMENU.LoescheUME(); + wrefresh(MenuWinClass::START.TMPWin1); + break; + } + case KEY_ENTER: + case 10:{ break; } + default:{ + if (Key > 10 && Key < 128) { + MenuWinClass::PATTERN = ServiceClass_MWC->SearchDriver(REQ_INS_DEFAULT, MenuWinClass::START.TMPWin3, Key, MenuWinClass::PATTERN, curposi); + //ServiceClass_MWC->TableDriver(ServiceClass_MWC->ServiceList, REQ_NEXT_MATCH); + } + break; } + } + if (MenuWinClass_MWC->TabKey == 1) { + curs_set(false); + ServiceClass_MWC->INFOWINDOW(MenuWinClass::SERVICEMENU.AktivName); + MenuWinClass::TOPMENU.LoescheUME(); + MenuWinClass::RefreshWindows(); + } else if (MenuWinClass_MWC->TabKey == 2) { + curs_set(false); + MenuWinClass::RefreshWindows(); + wrefresh(MenuWinClass::START.TMPWin1); + redrawwin(MenuWinClass::TOPMENU.UME.UMEWin); + wrefresh(MenuWinClass::TOPMENU.UME.UMEWin); + } else if (MenuWinClass_MWC->TabKey == 3) { + curs_set(true); + MenuWinClass::RefreshWindows(); + } + break; + }/* search at tmpwin3 */ + } + if (Key == KEY_F(10)) { break; } + } + return Key; +// } catch (const NCursesException* e) { endwin(); std::cerr << e->message << std::endl; cout << e->errorno; return -1; +// } catch (const NCursesException& e) { endwin(); std::cerr << e.message << std::endl; cout << e.errorno; return -1; +// } catch (const std::exception& e) { endwin(); std::cerr << "Exception: " << e.what() << std::endl; cout << EXIT_FAILURE; return -1; } +} /* Menü surf funktion */ + +MenuWinClass::~MenuWinClass(){ + if (MenuWinClass::START.TMPWin1) {werase(MenuWinClass::START.TMPWin1); delwin(MenuWinClass::START.TMPWin1); endwin();} + if (MenuWinClass::START.TMPWin2) {werase(MenuWinClass::START.TMPWin2); delwin(MenuWinClass::START.TMPWin2); endwin();} + if (MenuWinClass::START.TMPWin3) {werase(MenuWinClass::START.TMPWin3); delwin(MenuWinClass::START.TMPWin3); endwin();} + if (MenuWinClass::START.TMPWin4) {werase(MenuWinClass::START.TMPWin4); delwin(MenuWinClass::START.TMPWin4); endwin();} + if (MenuWinClass::START.TMPWin5) {werase(MenuWinClass::START.TMPWin5); delwin(MenuWinClass::START.TMPWin5); endwin();} +} + + diff --git a/MenuWinClass.h b/MenuWinClass.h new file mode 100644 index 0000000..20a6e63 --- /dev/null +++ b/MenuWinClass.h @@ -0,0 +1,205 @@ +#ifndef MENUWINCLASS_H +#define MENUWINCLASS_H + +#include +#include +#include + +using namespace std; + +enum WinID { MENUWIN = 0, MAINWIN = 1, INFOWIN = 2, LISTPAD = 3, DESCWIN = 4, TIMEWIN = 5, ENDWIN = 6 }; +enum MenuID { DATEIMENU = 0, DAEMONMENU = 1, SYSTEMCTLMENU = 2, INFOMENU = 3, MAINMENU = 4, ENDMENU = 5 }; + +struct FENSTER { + int FEID {0}; + string FENAME {""}; + int BorderWeight {1}; + int BorderHeight {1}; + int WCX() {return static_cast(roundf(getmaxx(stdscr)));}; /* W=weight C=column X=x achse */ + int HRY() {return static_cast(roundf(getmaxy(stdscr)));}; /* H=height R=row Y=y achse */ + int HRYw1() {return static_cast(roundf(1));}; + int WCXw1() {return static_cast(roundf(WCX()));}; + WinID TMPWin1ID {MENUWIN}; + WINDOW *TMPWin1 = newwin(HRYw1(), WCXw1(), 0, 0); + int HRYw2() {return static_cast(roundf(HRY() - (HRYw1() + HRYw3())));}; + int WCXw2() {return static_cast(roundf(WCX()));}; + WinID TMPWin2ID {MAINWIN}; + WINDOW *TMPWin2 = newwin(HRYw2(), WCXw2(), 1, 0); + int HRYw3() {return static_cast(roundf(6));}; + int WCXw3() {return static_cast(roundf(WCX()));}; + WinID TMPWin3ID {INFOWIN}; + WINDOW *TMPWin3 = newwin(HRYw3(), WCXw3(), (HRYw1() + HRYw2()), 0); + int HRYw4() {return static_cast(roundf(HRYw2() - ((BorderWeight * 2))));}; + int WCXw4() {return static_cast(roundf(WCXw2() - (BorderWeight * 2)));}; + WinID TMPWin4ID {LISTPAD}; + WINDOW *TMPWin4 = newpad(HRYw4(), WCXw4()); + int HRYw5() {return static_cast(roundf(HRYw3() - ((BorderWeight * 2) + 1)));}; + int WCXw5() {return static_cast(roundf(WCXw3() - ((BorderWeight * 2) + 32)));}; + WinID TMPWin5ID {DESCWIN}; + WINDOW *TMPWin5 = newpad(HRYw5(), WCXw5()); + int HRYtime() {return static_cast(roundf(1));}; + int WCXtime() {return static_cast(roundf(20));}; + WinID TimeWinID {TIMEWIN}; + WINDOW *TimeWin = newwin(HRYtime(), WCXtime(), 0, (WCX() - 20)); + int TMPWinHigh {0}; + FORM *TMPForm1 {nullptr}; + FIELD **TMPField1 {nullptr}; + struct WinSize { + int RAND = 1; + int w {1}; + int h {1}; + int WCX(){return static_cast(roundf(getmaxx(stdscr)));}; + int HRY(){return static_cast(roundf(getmaxy(stdscr)));}; + int WCX_Real(){return static_cast(roundf(WCX() - (2 * RAND)));} + int HRY_Real(){return static_cast(roundf(HRY() - (2 * RAND)));} + int WCX_Center(){return static_cast(roundf(WCX() / 2));}; + int HRY_Center(){return static_cast(roundf(HRY() / 2));}; + int WCX_TmpWin(WINDOW * tmpwin){return static_cast(roundf(getmaxx(tmpwin)));}; + int HRY_TmpWin(WINDOW * tmpwin){return static_cast(roundf(getmaxy(tmpwin)));}; + int WCX_TmpWinReal(WINDOW * tmpwin){return static_cast(roundf(getmaxx(tmpwin) - (2 * RAND)));}; + int HRY_TmpWinReal(WINDOW * tmpwin){return static_cast(roundf(getmaxy(tmpwin) - (2 * RAND)));}; + int WCX_TmpWinCenter(WINDOW * tmpwin){return static_cast(roundf(getmaxx(tmpwin) / 2));}; + int HRY_TmpWinCenter(WINDOW * tmpwin){return static_cast(roundf(getmaxy(tmpwin) / 2));}; + unsigned long WinHalfDurch(WINDOW * tmpwin, int TeilDurch){return static_cast(roundf(WCX_TmpWinCenter(tmpwin) / TeilDurch));}; + } WinSize; + struct WinColor { + int BK_MENUWIN = 78; // 78 Text=MY_LIGHT_WHITE, Bk=MY_MARIN_BLUE + int BK_MAINWIN = 78; // 87 Text=MY_MARIN_BLUE, Bk=MY_LIGHT_WHITE + int BK_INFOWIN = 78; + int BK_LISTPAD = 78; + int BK_DESCWIN = 78; + int BK_TIMEWIN = 70; + int BK_HELPWIN = 74; + int WinBk_Main = 78; //Fenster_Background + int WinFo_Main = 78; //Fenster_Foreground + int WinBk_Info = 78; //info fenster_Background + int WinFo_Info = 78; //info fenster foreground + int WinBk_Help = 74; //help fenster Background + int WinFo_Help = 74; //help fenster foreground + } WinColor; + void delwinow(WINDOW *tmpwin){ + if(tmpwin){ + int mx,my,bx,by; + getbegyx(tmpwin,by,bx); + getmaxyx(tmpwin,my,mx); + touchwin(tmpwin); + wborder(tmpwin, ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '); + touchline(tmpwin,bx,mx); + delwin(tmpwin); + endwin(); + tmpwin=nullptr; + } + } + /* void delmenu(WINDOW *tmpwin, MENU *tmpmenu, ITEM **tmpitem){ + if (tmpmenu){ + int E = item_count(tmpmenu); + unpost_menu(tmpmenu); + SAFE_DELETE(tmpmenu); + SAFE_DELETE_ARRAY(tmpitem); + wborder(tmpwin, ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '); + touchline(tmpwin,0,E+1); + delwin(tmpwin); + endwin(); + } + }*/ + void delform(WINDOW *tmpwin, FORM *tmpform, FIELD **tmpfield){ + if (tmpform){ + int mx,my,bx,by; + getbegyx(tmpwin,by,bx); + getmaxyx(tmpwin,my,mx); + unpost_form(tmpform); + SAFE_DELETE(tmpform); + SAFE_DELETE_ARRAY(tmpfield); + wborder(tmpwin, ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '); + touchline(tmpwin,bx,mx); + delwin(tmpwin); + endwin(); + } + } +}; +struct HAUPTMENU { + MenuID MID; + string HMName; + MENU *HMMenu {nullptr}; + ITEM **HMItem {nullptr}; + //############################################### + struct UNTERMENU { + int UMID; + string UMEName; + WINDOW *UMEWin; + MENU *UMEMenu; + ITEM **UMEItem; + }UME; + struct MenuColor { + int BK_MAINMENU = 78; // 78 Text=MY_LIGHT_WHITE, Bk=MY_MARIN_BLUE + int BK_UNTERMENU = 78; // 87 Text=MY_MARIN_BLUE, Bk=MY_LIGHT_WHITE + int BK_AKTIVHAME = 18; + int BK_AKTIVUNME = 18; + int BK_UNUSEDHM = 78; + int BK_UNUSEDUM = 78; + } MenuColor; + void LoescheUME(){ + int E = item_count(UME.UMEMenu); + unpost_menu(UME.UMEMenu); + SAFE_DELETE(UME.UMEMenu); + SAFE_DELETE_ARRAY(UME.UMEItem); + wborder(UME.UMEWin, ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '); + touchline(UME.UMEWin,0,E+1); + delwin(UME.UMEWin); + endwin(); + refresh(); + } +}; +struct INAPPMENU { + friend class MenuWinClass; + int LMID; + std::string LMName; + MENU* LMenu {nullptr}; + ITEM** LMItem {nullptr}; + string AktivName = ""; + +}; + +class MenuWinClass: public INAPPMENU { +public: + /*################################################*/ + static FENSTER START; + static HAUPTMENU TOPMENU; + static int MeInAl; + static WINDOW *TMPWIN; + static MENU *TMPMENU; + static INAPPMENU SERVICEMENU; + static int LiMeInAl; + static WINDOW* LiTMPWIN; + static MENU* LiTMPMENU; + static string PATTERN; + static int TabKey;// {1}; + /*#############_WINDOW_###########################*/ + static void StartWin(); + static void StopWin(); + static void SetWinSize(); + static void AppColor(); + static void CreateWin(WINDOW *win, WinID WID); + void FensterDraw(); + static void ResizeHandler(int signal); + void ScrollPad(WINDOW *SubWin, int StartY, int StartX, int Height, int Width, int PadHeight); + void printInMiddle(WINDOW *win, int starty, int startx, int width, char *text, chtype color, char *sp); + /*#############_MENÜ_#############################*/ + static void Hauptmenu(void); + static void DateiMenu(void); + static void DaemonTypeMenu(void); + static void SystemctlMenu(void); + static void InfoMenu(void); + static WINDOW* TempWin(string Name, MenuID MID); + static void StartMenuAuswahl(string wahl); + static void RefreshWindows(); + static int MenuStart(int Key); + /*#############_Constructor/De_###################*/ + MenuWinClass(); + ~MenuWinClass(); + /*################################################*/ +}; + + + +#endif // MENUWINCLASS_H diff --git a/README.md b/README.md index bc22572..d77b537 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,14 @@ # ServiceControl -systemctl is the basic. ServiceControl this is a Qt creator project! +chkservice is the basis for ServiceControl. -also download Qt Creator. +This is a Qt Creator project! -This is a Qt Creator Projekt for run you musst set two options. +Also download Qt Creator. -That is the clock jump of my development and also consists of parts of this preliminary work. +You need to set two options before you can begin. + +That is the clock leap in my development and also consists of parts of this preliminary work. chkservice can be installed on Ubuntu with: @@ -18,21 +20,22 @@ https://github.com/hflautert/chkservices https://github.com/linuxenko/chkservice -![ServiceControl](https://github.com/fett-tony/ServiceControl/blob/main/Screenshot/ServiceControll-v1.0.2.png) +![ServiceControl](https://github.com/fett-tony/ServiceControl/blob/ServiceControl_v1.0.4/Screenshot/ServiceControl_v1.0.4.png) +![ServiceControl](https://github.com/fett-tony/ServiceControl/blob/ServiceControl_v1.0.4/Screenshot/ServiceControl_v1.0.4_2.png) -# 1. the first option is shadowbuild muss off. +# 1. The first option is Shadowbuild Must Off. -this is while this projekt have own options into the pro file and work with a special folder set. +This has to be done because this project has a special folder system for the build. ![ShadowBuild](https://github.com/fett-tony/NcursesWindowTemplate/blob/main/README/ShadowBuild.png) -# 2. the second option for debugger +# 2. The second option is for the debugger when you need to work with threads or pthread you must set SIGSTOP options off. for running with thread or pthread option -you musst set "handle SIGSTOP pass nostop noprint" into the Debugger option for "Locals & Expressions". +you must set "handle SIGSTOP pass nostop noprint" into the Debugger option for "Locals & Expressions". > TOOLS -> Options -> Debugger -> Locals & Expressions -> Debugging Helper Customization @@ -41,8 +44,3 @@ you musst set "handle SIGSTOP pass nostop noprint" into the Debugger option for ![Debugging_Helper_Customization](https://github.com/fett-tony/NcursesWindowTemplate/blob/main/README/Debugging_Helper_Customization.png) - -![ServiceControl](https://github.com/fett-tony/ServiceControl/blob/main/Screenshot/ServiceControl-1.png) -![ServiceControl](https://github.com/fett-tony/ServiceControl/blob/main/Screenshot/ServiceControl-2.png) -![ServiceControl](https://github.com/fett-tony/ServiceControl/blob/main/Screenshot/ServiceControl-3.png) -![ServiceControl](https://github.com/fett-tony/ServiceControl/blob/main/Screenshot/ServiceControll-branch.png) diff --git a/Screenshot/ServiceControl_v1.0.4.png b/Screenshot/ServiceControl_v1.0.4.png new file mode 100644 index 0000000..28f3995 Binary files /dev/null and b/Screenshot/ServiceControl_v1.0.4.png differ diff --git a/Screenshot/ServiceControl_v1.0.4_2.png b/Screenshot/ServiceControl_v1.0.4_2.png new file mode 100644 index 0000000..4900d4f Binary files /dev/null and b/Screenshot/ServiceControl_v1.0.4_2.png differ diff --git a/ServiceClass.cpp b/ServiceClass.cpp index efc11bc..ed8ccca 100644 --- a/ServiceClass.cpp +++ b/ServiceClass.cpp @@ -1,22 +1,18 @@ -#include -#include -#include -#include -#include +#include using namespace std; -extern class TaskClass * TaskPtr; -extern class MenuClass * MenuPtr; -//extern class ServiceClass * ServicePtr; -extern class WinClass * WinPtr; +TaskClass *TaskClass_SC = new TaskClass(); +//MenuClass *MenuPtr_SC = new MenuClass(); +ServiceClass *ServiceClass_SC = new ServiceClass(); +//WinClass *WinPtr_SC = new WinClass(); +MenuWinClass *MenuWinClass_SC = new MenuWinClass(); int X = 0; - +/*##################################################################################*/ void ServiceClass::ServiceListFill() { - //string tmpSystemd = TaskPtr->TERM_AUSGABE("systemctl --all | egrep 'timer|target|swap|socket|service|slice|scope|path|mount|device' | awk '{$1=$1};1' | sed 's/● //g'"); - string tmpService = TaskPtr->TERM_AUSGABE("systemctl list-unit-files -t "+ systemctlwahl +" | grep '."+ systemctlwahl +"' | awk '{$1=$1};1' | sort"); - string tmpServiceInfo = TaskPtr->TERM_AUSGABE("systemctl --all --type="+ systemctlwahl +" | grep '."+ systemctlwahl +"' | awk '{$1=$1};1' | sed 's/● //g' | sort"); + string tmpService = TaskClass_SC->TERM_AUSGABE("systemctl list-unit-files -t "+ systemctlwahl +" | grep '."+ systemctlwahl +"' | awk '{$1=$1};1' | sort"); + string tmpServiceInfo = TaskClass_SC->TERM_AUSGABE("systemctl --all --type="+ systemctlwahl +" | grep '."+ systemctlwahl +"' | awk '{$1=$1};1' | sed 's/● //g' | sort"); string tmpstr1,tmpstr2; std::vector tmpaa,tmpbb; ServiceList.clear(); @@ -27,18 +23,18 @@ void ServiceClass::ServiceListFill() { if (filestream) { while (getline(filestream,tmpstr1)){ tmpaa.push_back(string()); - tmpaa = TaskPtr->StringTeiler(tmpstr1,' '); + tmpaa = TaskClass_SC->StringTeiler(tmpstr1,' '); ServiceList.push_back(SERVICES()); ServiceList[X].SID = static_cast(X); ServiceList[X].Name = tmpaa[0]; ServiceList[X].Status = tmpaa[1]; - ServiceList[X].Target = systemctlwahl; //ServiceList[X].Name.substr(ServiceList[X].Name.find(".")+1,ServiceList[X].Name.length()); + ServiceList[X].Target = systemctlwahl; X++; tmpaa.clear(); vector().swap(tmpaa); } } else { - mvwaddnstr(WinPtr->START.TMPWin3, 5, 5, "failed to open or read" ,-1); + mvwaddnstr(MenuWinClass::START.TMPWin3, 5, 5, "failed to open or read" ,-1); } X = 0; @@ -46,7 +42,7 @@ void ServiceClass::ServiceListFill() { if (filestream2) { while (getline(filestream2,tmpstr2)){ tmpbb.push_back(string()); - tmpbb = TaskPtr->StringTeiler(tmpstr2,' '); + tmpbb = TaskClass_SC->StringTeiler(tmpstr2,' '); for(unsigned long Z = 0; Z < static_cast(ServiceList.size()); Z++) { if (ServiceList[Z].Name.compare(tmpbb[0].c_str())==0) { ServiceList.push_back(SERVICES()); @@ -68,173 +64,168 @@ void ServiceClass::ServiceListFill() { vector().swap(tmpbb); } } else { - mvwaddnstr(WinPtr->START.TMPWin3, 5, 5, "failed to open or read" ,-1); + mvwaddnstr(MenuWinClass::START.TMPWin3, 5, 5, "failed to open or read" ,-1); } SetStateOption(); // ServiceListe(); } - void ServiceClass::ServiceListe(){ - if (MenuPtr->LiMENU.LMItem){unpost_menu(MenuPtr->LiMENU.LMenu);SAFE_DELETE(MenuPtr->LiMENU.LMItem);SAFE_DELETE_ARRAY(MenuPtr->LiMENU.LMItem);} - if (MenuPtr->LiMENU.LMWin){werase(MenuPtr->LiMENU.LMWin);delwin(MenuPtr->LiMENU.LMWin);endwin();} + if (MenuWinClass_SC->SERVICEMENU.LMItem){unpost_menu(MenuWinClass_SC->SERVICEMENU.LMenu);SAFE_DELETE(MenuWinClass_SC->SERVICEMENU.LMItem);SAFE_DELETE_ARRAY(MenuWinClass_SC->SERVICEMENU.LMItem);} + if (MenuWinClass::START.TMPWin4){werase(MenuWinClass::START.TMPWin4);delwin(MenuWinClass::START.TMPWin4);endwin();} int mrows = 0; int mcols = 0; unsigned long count = ServiceList.size(); - MenuPtr->LiMENU.LMItem = static_cast(calloc(count, sizeof(ITEM *))); + MenuWinClass_SC->SERVICEMENU.LMItem = static_cast(calloc(count, sizeof(ITEM *))); for (unsigned long i = 0; i < (count-2); i++) { - MenuPtr->LiMENU.LMItem[i] = new_item(ServiceList[i].Name.c_str(), ServiceList[i].Status.c_str()); + MenuWinClass_SC->SERVICEMENU.LMItem[i] = new_item(ServiceList[i].Name.c_str(), ServiceList[i].Status.c_str()); } - MenuPtr->LiMENU.LMItem[count-1] = nullptr; - MenuPtr->LiMENU.LMenu = new_menu(MenuPtr->LiMENU.LMItem); - scale_menu(MenuPtr->LiMENU.LMenu, &mrows, &mcols); - MenuPtr->LiMENU.LMWin = newpad(TaskPtr->WinFullSize(WinPtr->START.TMPWin2,static_cast(count),"H"), TaskPtr->WinFullSize(WinPtr->START.TMPWin2,mcols,"W")); - wbkgd(MenuPtr->LiMENU.LMWin, COLOR_PAIR(WinPtr->WindowColor.FeBk_Main)); - set_menu_win(MenuPtr->LiMENU.LMenu, MenuPtr->LiMENU.LMWin); - set_menu_sub(MenuPtr->LiMENU.LMenu, MenuPtr->LiMENU.LMWin); - set_menu_format(MenuPtr->LiMENU.LMenu, WinPtr->WinSize->HRY()-9, 1); //-3 - set_menu_spacing(MenuPtr->LiMENU.LMenu, 0, 0, 0); - menu_opts_off(MenuPtr->LiMENU.LMenu, O_SELECTABLE); - menu_opts_on(MenuPtr->LiMENU.LMenu, O_NONCYCLIC); - set_menu_fore(MenuPtr->LiMENU.LMenu, COLOR_PAIR(20)|A_BOLD|A_REVERSE); - set_menu_back(MenuPtr->LiMENU.LMenu, COLOR_PAIR(78)|A_BOLD); - set_menu_grey(MenuPtr->LiMENU.LMenu, COLOR_PAIR(30)); - set_menu_mark(MenuPtr->LiMENU.LMenu, ""); - post_menu(MenuPtr->LiMENU.LMenu); + MenuWinClass_SC->SERVICEMENU.LMItem[count-1] = nullptr; + MenuWinClass_SC->SERVICEMENU.LMenu = new_menu(MenuWinClass_SC->SERVICEMENU.LMItem); + scale_menu(MenuWinClass_SC->SERVICEMENU.LMenu, &mrows, &mcols); + MenuWinClass::START.TMPWin4 = newpad(TaskClass_SC->WinFullSize(MenuWinClass::START.TMPWin2,static_cast(count),"H"), TaskClass_SC->WinFullSize(MenuWinClass::START.TMPWin2,mcols,"W")); + wbkgd(MenuWinClass::START.TMPWin4, COLOR_PAIR(MenuWinClass::START.WinColor.BK_LISTPAD)); + set_menu_win(MenuWinClass_SC->SERVICEMENU.LMenu, MenuWinClass::START.TMPWin4); + set_menu_sub(MenuWinClass_SC->SERVICEMENU.LMenu, MenuWinClass::START.TMPWin4); + set_menu_format(MenuWinClass_SC->SERVICEMENU.LMenu, MenuWinClass_SC->START.HRY()-9, 1); //-3 + set_menu_spacing(MenuWinClass_SC->SERVICEMENU.LMenu, 0, 0, 0); + menu_opts_off(MenuWinClass_SC->SERVICEMENU.LMenu, O_SELECTABLE); + menu_opts_on(MenuWinClass_SC->SERVICEMENU.LMenu, O_NONCYCLIC); + set_menu_fore(MenuWinClass_SC->SERVICEMENU.LMenu, COLOR_PAIR(20)|A_BOLD|A_REVERSE); + set_menu_back(MenuWinClass_SC->SERVICEMENU.LMenu, COLOR_PAIR(78)|A_BOLD); + set_menu_grey(MenuWinClass_SC->SERVICEMENU.LMenu, COLOR_PAIR(30)); + set_menu_mark(MenuWinClass_SC->SERVICEMENU.LMenu, ""); + post_menu(MenuWinClass_SC->SERVICEMENU.LMenu); } - void ServiceClass::INFOWINDOW(string Name){ - werase(WinPtr->START.TMPWin5); - wattr_on(WinPtr->START.TMPWin4, COLOR_PAIR(WinPtr->WindowColor.FeFo_Info)|A_BOLD,nullptr); - mvwaddnstr(WinPtr->START.TMPWin4, 1, 1, "STATE: " ,-1); - mvwaddnstr(WinPtr->START.TMPWin4, 2, 1, "LOAD: " ,-1); - mvwaddnstr(WinPtr->START.TMPWin4, 3, 1, "AKTIVE: " ,-1); //9 - mvwaddnstr(WinPtr->START.TMPWin4, 4, 1, "SUB: " ,-1); - mvwaddnstr(WinPtr->START.TMPWin4, 1, 26, "DESC:" ,-1); - mvwaddnstr(WinPtr->START.TMPWin4, 4, 26, "Suche:" ,-1); - //mvwaddnstr(WinPtr->START.TMPWin4, 6, 1, " " ,-1); - wattr_off(WinPtr->START.TMPWin4, COLOR_PAIR(WinPtr->WindowColor.FeFo_Info)|A_BOLD,nullptr); + werase(MenuWinClass::START.TMPWin5); + wattr_on(MenuWinClass::START.TMPWin3, COLOR_PAIR(MenuWinClass::START.WinColor.BK_INFOWIN)|A_BOLD,nullptr); + mvwaddnstr(MenuWinClass::START.TMPWin3, 1, 1, "STATE: " ,-1); + mvwaddnstr(MenuWinClass::START.TMPWin3, 2, 1, "LOAD: " ,-1); + mvwaddnstr(MenuWinClass::START.TMPWin3, 3, 1, "AKTIVE: " ,-1); //9 + mvwaddnstr(MenuWinClass::START.TMPWin3, 4, 1, "SUB: " ,-1); + mvwaddnstr(MenuWinClass::START.TMPWin3, 1, 26, "DESC:" ,-1); + mvwaddnstr(MenuWinClass::START.TMPWin3, 4, 26, "Suche:" ,-1); + //mvwaddnstr(MenuWinClass::START.TMPWin3, 6, 1, " " ,-1); + wattr_off(MenuWinClass::START.TMPWin3, COLOR_PAIR(MenuWinClass::START.WinColor.BK_INFOWIN)|A_BOLD,nullptr); for (unsigned long X = 0; X < static_cast(ServiceList.size());X++){ if (ServiceList[X].Name.compare(Name)==0) { switch (ServiceList[X].state) { case UNIT_STATE_ENABLED: - wattr_on(WinPtr->START.TMPWin4, COLOR_PAIR(StateColor.Green)|A_BOLD,nullptr); - mvwaddnstr(WinPtr->START.TMPWin4, 1, 9, ServiceList[X].Status.c_str() ,-1); - wattr_off(WinPtr->START.TMPWin4, COLOR_PAIR(StateColor.Green)|A_BOLD,nullptr); + wattr_on(MenuWinClass::START.TMPWin3, COLOR_PAIR(StateColor.Green)|A_BOLD,nullptr); + mvwaddnstr(MenuWinClass::START.TMPWin3, 1, 9, ServiceList[X].Status.c_str() ,-1); + wattr_off(MenuWinClass::START.TMPWin3, COLOR_PAIR(StateColor.Green)|A_BOLD,nullptr); break; case UNIT_STATE_BAD: case UNIT_STATE_DISABLED: - wattr_on(WinPtr->START.TMPWin4, COLOR_PAIR(StateColor.Red)|A_BOLD,nullptr); - mvwaddnstr(WinPtr->START.TMPWin4, 1, 9, ServiceList[X].Status.c_str() ,-1); - wattr_off(WinPtr->START.TMPWin4, COLOR_PAIR(StateColor.Red)|A_BOLD,nullptr); + wattr_on(MenuWinClass::START.TMPWin3, COLOR_PAIR(StateColor.Red)|A_BOLD,nullptr); + mvwaddnstr(MenuWinClass::START.TMPWin3, 1, 9, ServiceList[X].Status.c_str() ,-1); + wattr_off(MenuWinClass::START.TMPWin3, COLOR_PAIR(StateColor.Red)|A_BOLD,nullptr); break; case UNIT_STATE_STATIC: case UNIT_STATE_MASKED: case UNIT_STATE_GENERATED: - wattr_on(WinPtr->START.TMPWin4, COLOR_PAIR(StateColor.Yellow)|A_BOLD,nullptr); - mvwaddnstr(WinPtr->START.TMPWin4, 1, 9, ServiceList[X].Status.c_str() ,-1); - wattr_off(WinPtr->START.TMPWin4, COLOR_PAIR(StateColor.Yellow)|A_BOLD,nullptr); + wattr_on(MenuWinClass::START.TMPWin3, COLOR_PAIR(StateColor.Yellow)|A_BOLD,nullptr); + mvwaddnstr(MenuWinClass::START.TMPWin3, 1, 9, ServiceList[X].Status.c_str() ,-1); + wattr_off(MenuWinClass::START.TMPWin3, COLOR_PAIR(StateColor.Yellow)|A_BOLD,nullptr); break; case UNIT_STATE_TMP: default: - wattr_on(WinPtr->START.TMPWin4, COLOR_PAIR(StateColor.White)|A_BOLD,nullptr); - mvwaddnstr(WinPtr->START.TMPWin4, 1, 9, ServiceList[X].Status.c_str() ,-1); - wattr_off(WinPtr->START.TMPWin4, COLOR_PAIR(StateColor.White)|A_BOLD,nullptr); + wattr_on(MenuWinClass::START.TMPWin3, COLOR_PAIR(StateColor.White)|A_BOLD,nullptr); + mvwaddnstr(MenuWinClass::START.TMPWin3, 1, 9, ServiceList[X].Status.c_str() ,-1); + wattr_off(MenuWinClass::START.TMPWin3, COLOR_PAIR(StateColor.White)|A_BOLD,nullptr); break; } // ende status switch switch (ServiceList[X].load) { case UNIT_LOADSTATE_LOADED: - wattr_on(WinPtr->START.TMPWin4, COLOR_PAIR(StateColor.Green)|A_BOLD,nullptr); - mvwaddnstr(WinPtr->START.TMPWin4, 2, 9, ServiceList[X].Load.c_str() ,-1); - wattr_off(WinPtr->START.TMPWin4, COLOR_PAIR(StateColor.Green)|A_BOLD,nullptr); + wattr_on(MenuWinClass::START.TMPWin3, COLOR_PAIR(StateColor.Green)|A_BOLD,nullptr); + mvwaddnstr(MenuWinClass::START.TMPWin3, 2, 9, ServiceList[X].Load.c_str() ,-1); + wattr_off(MenuWinClass::START.TMPWin3, COLOR_PAIR(StateColor.Green)|A_BOLD,nullptr); break; case UNIT_LOADSTATE_NOTFOUND: case UNIT_LOADSTATE_UNLOAD: - wattr_on(WinPtr->START.TMPWin4, COLOR_PAIR(StateColor.Red)|A_BOLD,nullptr); - mvwaddnstr(WinPtr->START.TMPWin4, 2, 9, ServiceList[X].Load.c_str() ,-1); - wattr_off(WinPtr->START.TMPWin4, COLOR_PAIR(StateColor.Red)|A_BOLD,nullptr); + wattr_on(MenuWinClass::START.TMPWin3, COLOR_PAIR(StateColor.Red)|A_BOLD,nullptr); + mvwaddnstr(MenuWinClass::START.TMPWin3, 2, 9, ServiceList[X].Load.c_str() ,-1); + wattr_off(MenuWinClass::START.TMPWin3, COLOR_PAIR(StateColor.Red)|A_BOLD,nullptr); break; default: - wattr_on(WinPtr->START.TMPWin4, COLOR_PAIR(StateColor.White)|A_BOLD,nullptr); - mvwaddnstr(WinPtr->START.TMPWin4, 2, 9, ServiceList[X].Load.c_str() ,-1); - wattr_off(WinPtr->START.TMPWin4, COLOR_PAIR(StateColor.White)|A_BOLD,nullptr); + wattr_on(MenuWinClass::START.TMPWin3, COLOR_PAIR(StateColor.White)|A_BOLD,nullptr); + mvwaddnstr(MenuWinClass::START.TMPWin3, 2, 9, ServiceList[X].Load.c_str() ,-1); + wattr_off(MenuWinClass::START.TMPWin3, COLOR_PAIR(StateColor.White)|A_BOLD,nullptr); break; } // ende load switch switch (ServiceList[X].active) { case UNIT_ACTIVESTATE_ACTIVE: - wattr_on(WinPtr->START.TMPWin4, COLOR_PAIR(StateColor.Green)|A_BOLD,nullptr); - mvwaddnstr(WinPtr->START.TMPWin4, 3, 9, ServiceList[X].Active.c_str() ,-1); - wattr_off(WinPtr->START.TMPWin4, COLOR_PAIR(StateColor.Green)|A_BOLD,nullptr); + wattr_on(MenuWinClass::START.TMPWin3, COLOR_PAIR(StateColor.Green)|A_BOLD,nullptr); + mvwaddnstr(MenuWinClass::START.TMPWin3, 3, 9, ServiceList[X].Active.c_str() ,-1); + wattr_off(MenuWinClass::START.TMPWin3, COLOR_PAIR(StateColor.Green)|A_BOLD,nullptr); break; case UNIT_ACTIVESTATE_INACTIVE: - wattr_on(WinPtr->START.TMPWin4, COLOR_PAIR(StateColor.Red)|A_BOLD,nullptr); - mvwaddnstr(WinPtr->START.TMPWin4, 3, 9, ServiceList[X].Active.c_str() ,-1); - wattr_off(WinPtr->START.TMPWin4, COLOR_PAIR(StateColor.Red)|A_BOLD,nullptr); + wattr_on(MenuWinClass::START.TMPWin3, COLOR_PAIR(StateColor.Red)|A_BOLD,nullptr); + mvwaddnstr(MenuWinClass::START.TMPWin3, 3, 9, ServiceList[X].Active.c_str() ,-1); + wattr_off(MenuWinClass::START.TMPWin3, COLOR_PAIR(StateColor.Red)|A_BOLD,nullptr); break; default: - wattr_on(WinPtr->START.TMPWin4, COLOR_PAIR(StateColor.White)|A_BOLD,nullptr); - mvwaddnstr(WinPtr->START.TMPWin4, 3, 9, ServiceList[X].Active.c_str() ,-1); - wattr_off(WinPtr->START.TMPWin4, COLOR_PAIR(StateColor.White)|A_BOLD,nullptr); + wattr_on(MenuWinClass::START.TMPWin3, COLOR_PAIR(StateColor.White)|A_BOLD,nullptr); + mvwaddnstr(MenuWinClass::START.TMPWin3, 3, 9, ServiceList[X].Active.c_str() ,-1); + wattr_off(MenuWinClass::START.TMPWin3, COLOR_PAIR(StateColor.White)|A_BOLD,nullptr); break; } switch (ServiceList[X].substate) { case UNIT_SUBSTATE_RUNNING: - wattr_on(WinPtr->START.TMPWin4, COLOR_PAIR(StateColor.Green)|A_BOLD,nullptr); - mvwaddnstr(WinPtr->START.TMPWin4, 4, 9, ServiceList[X].SubStatus.c_str() ,-1); - wattr_off(WinPtr->START.TMPWin4, COLOR_PAIR(StateColor.Green)|A_BOLD,nullptr); + wattr_on(MenuWinClass::START.TMPWin3, COLOR_PAIR(StateColor.Green)|A_BOLD,nullptr); + mvwaddnstr(MenuWinClass::START.TMPWin3, 4, 9, ServiceList[X].SubStatus.c_str() ,-1); + wattr_off(MenuWinClass::START.TMPWin3, COLOR_PAIR(StateColor.Green)|A_BOLD,nullptr); break; case UNIT_SUBSTATE_CONNECTED: - wattr_on(WinPtr->START.TMPWin4, COLOR_PAIR(StateColor.Yellow)|A_BOLD,nullptr); - mvwaddnstr(WinPtr->START.TMPWin4, 4, 9, ServiceList[X].SubStatus.c_str() ,-1); - wattr_off(WinPtr->START.TMPWin4, COLOR_PAIR(StateColor.Yellow)|A_BOLD,nullptr); + wattr_on(MenuWinClass::START.TMPWin3, COLOR_PAIR(StateColor.Yellow)|A_BOLD,nullptr); + mvwaddnstr(MenuWinClass::START.TMPWin3, 4, 9, ServiceList[X].SubStatus.c_str() ,-1); + wattr_off(MenuWinClass::START.TMPWin3, COLOR_PAIR(StateColor.Yellow)|A_BOLD,nullptr); case UNIT_SUBSTATE_INVALID: case UNIT_SUBSTATE_EXITED: case UNIT_SUBSTATE_DEAD: - wattr_on(WinPtr->START.TMPWin4, COLOR_PAIR(StateColor.Red)|A_BOLD,nullptr); - mvwaddnstr(WinPtr->START.TMPWin4, 4, 9, ServiceList[X].SubStatus.c_str() ,-1); - wattr_off(WinPtr->START.TMPWin4, COLOR_PAIR(StateColor.Red)|A_BOLD,nullptr); + wattr_on(MenuWinClass::START.TMPWin3, COLOR_PAIR(StateColor.Red)|A_BOLD,nullptr); + mvwaddnstr(MenuWinClass::START.TMPWin3, 4, 9, ServiceList[X].SubStatus.c_str() ,-1); + wattr_off(MenuWinClass::START.TMPWin3, COLOR_PAIR(StateColor.Red)|A_BOLD,nullptr); break; default: - wattr_on(WinPtr->START.TMPWin4, COLOR_PAIR(StateColor.White)|A_BOLD,nullptr); - mvwaddnstr(WinPtr->START.TMPWin4, 4, 9, ServiceList[X].SubStatus.c_str() ,-1); - wattr_off(WinPtr->START.TMPWin4, COLOR_PAIR(StateColor.White)|A_BOLD,nullptr); + wattr_on(MenuWinClass::START.TMPWin3, COLOR_PAIR(StateColor.White)|A_BOLD,nullptr); + mvwaddnstr(MenuWinClass::START.TMPWin3, 4, 9, ServiceList[X].SubStatus.c_str() ,-1); + wattr_off(MenuWinClass::START.TMPWin3, COLOR_PAIR(StateColor.White)|A_BOLD,nullptr); break; } - wattr_on(WinPtr->START.TMPWin5, COLOR_PAIR(30)|A_BOLD,nullptr); - mvwaddnstr(WinPtr->START.TMPWin5, 0, 0, ServiceList[X].Description.c_str() ,-1); - wattr_off(WinPtr->START.TMPWin5, COLOR_PAIR(30)|A_BOLD,nullptr); + //wattr_on(MenuWinClass::START.TMPWin5, COLOR_PAIR(78)|A_BOLD,nullptr); + mvwaddnstr(MenuWinClass::START.TMPWin5, 0, 0, ServiceList[X].Description.c_str() ,-1); + //wattr_off(MenuWinClass::START.TMPWin5, COLOR_PAIR(78)|A_BOLD,nullptr); } } } - void ServiceClass::Statusabfrage(string ausgabestatus) { int hoehe; - int rowy = WinPtr->WinSize->HRY()-4; - int ROWS = 0; - int keytab; - - STATUSWIN = newwin(WinPtr->WinSize->HRY()-2, WinPtr->WinSize->WCX()-2, 1, 1); - wbkgd(STATUSWIN, COLOR_PAIR(WinPtr->WindowColor.FeBk_Help)|A_BOLD); + int rowy = MenuWinClass_SC->START.HRY()-4; + int ROWS = 0; int Key; + STATUSWIN = newwin(MenuWinClass_SC->START.HRY()-2, MenuWinClass_SC->START.WCX()-2, 1, 1); + wbkgd(STATUSWIN, COLOR_PAIR(MenuWinClass::START.WinColor.WinBk_Help)|A_BOLD); box(STATUSWIN, 0,0); - hoehe = TaskPtr->Zeilen(ausgabestatus.c_str(),WinPtr->WinSize->WCX()-4); - STATUSINFO = newpad(hoehe, WinPtr->WinSize->WCX()-4); - wbkgd(STATUSINFO, COLOR_PAIR(WinPtr->WindowColor.FeBk_Help)|A_BOLD); - STATUSINFO = derwin(STATUSWIN, WinPtr->WinSize->HRY()-4, WinPtr->WinSize->WCX()-4, 1, 1); - wattr_on(STATUSINFO, COLOR_PAIR(WinPtr->WindowColor.FeFo_Help)|A_BOLD,nullptr); + hoehe = TaskClass_SC->Zeilen(ausgabestatus.c_str(),MenuWinClass_SC->START.WCX()-4); + STATUSINFO = newpad(hoehe, MenuWinClass_SC->START.WCX()-4); + wbkgd(STATUSINFO, COLOR_PAIR(MenuWinClass::START.WinColor.WinBk_Help)|A_BOLD); + STATUSINFO = derwin(STATUSWIN, MenuWinClass_SC->START.HRY()-4, MenuWinClass_SC->START.WCX()-4, 1, 1); + wattr_on(STATUSINFO, COLOR_PAIR(MenuWinClass::START.WinColor.WinFo_Help)|A_BOLD,nullptr); mvwaddnstr(STATUSINFO, 0, 0, ausgabestatus.c_str(),-1); - wattr_off(STATUSINFO, COLOR_PAIR(WinPtr->WindowColor.FeFo_Info)|A_BOLD,nullptr); + wattr_off(STATUSINFO, COLOR_PAIR(MenuWinClass::START.WinColor.WinFo_Info)|A_BOLD,nullptr); wattr_on(STATUSWIN, COLOR_PAIR(70)|A_BOLD,nullptr); - mvwaddnstr(STATUSWIN, WinPtr->WinSize->HRY() -3, WinPtr->WinSize->WCX()-15, "[ EXIT F10 ]" ,-1); + mvwaddnstr(STATUSWIN, MenuWinClass_SC->START.HRY() -3, MenuWinClass_SC->START.WCX()-15, "[ EXIT ESC ]" ,-1); wattr_off(STATUSWIN, COLOR_PAIR(70)|A_BOLD,nullptr); wrefresh(STATUSWIN); touchwin(STATUSWIN); - prefresh(STATUSINFO, 0, 0, 0, 0, WinPtr->WinSize->HRY() -4, WinPtr->WinSize->WCX()-4); + prefresh(STATUSINFO, 0, 0, 0, 0, MenuWinClass_SC->START.HRY() -4, MenuWinClass_SC->START.WCX()-4); - while ((keytab=getch()) != KEY_F(10)) { - switch (keytab) { + while ((Key=getch()) != 27) { + switch (Key) { case KEY_DOWN:{ if ((ROWS + rowy +1) >= hoehe){ ROWS = hoehe; @@ -250,71 +241,46 @@ void ServiceClass::Statusabfrage(string ausgabestatus) { } break;} default:{ - break; } } refresh(); touchwin(STATUSWIN); - prefresh(STATUSINFO, ROWS, 0, 0, 0, WinPtr->WinSize->HRY() -4, WinPtr->WinSize->WCX()-4); + prefresh(STATUSINFO, ROWS, 0, 0, 0, MenuWinClass_SC->START.HRY() -4, MenuWinClass_SC->START.WCX()-4); } if (STATUSINFO){werase(STATUSINFO);delwin(STATUSINFO);} if (STATUSWIN){werase(STATUSWIN);delwin(STATUSWIN);} - redrawwin(TaskPtr->ClearWindow(WinPtr->START.TMPWin2)); - wrefresh(TaskPtr->ClearWindow(WinPtr->START.TMPWin2)); - prefresh(MenuPtr->LiMENU.LMWin, 0, 0, 2, 1, WinPtr->WinSize->HRY()-8, WinPtr->WinSize->WCX()-2); + redrawwin(TaskClass_SC->ClearWindow(MenuWinClass::START.TMPWin2)); + wrefresh(TaskClass_SC->ClearWindow(MenuWinClass::START.TMPWin2)); + redrawwin(TaskClass_SC->ClearWindow(MenuWinClass::START.TMPWin3)); + wrefresh(TaskClass_SC->ClearWindow(MenuWinClass::START.TMPWin3)); + prefresh(MenuWinClass_SC->START.TMPWin4, 0, 0, 2, 1, MenuWinClass_SC->START.HRYw4() + 1, MenuWinClass_SC->START.WCXw4()); + prefresh(MenuWinClass_SC->START.TMPWin5, 0, 0, MenuWinClass_SC->START.HRY()-4, MenuWinClass_SC->START.WCX()-46, MenuWinClass_SC->START.HRYw5(), MenuWinClass_SC->START.WCXw5()); } - -void ServiceClass::ENDE_NEW() { - try { - ServiceList.clear(); - //vector().swap(MenuPtr->ServiceList); - vector(ServiceList).swap (ServiceList); - clear(); - //###############--Hauptmenu--############################################### - int E = item_count(MenuPtr->MENEU.HMMenu); - unpost_menu(MenuPtr->MENEU.HMMenu); - SAFE_DELETE(MenuPtr->MENEU.HMMenu); - SAFE_DELETE_ARRAY(MenuPtr->MENEU.HMItem); - wborder(MenuPtr->MENEU.HMWin, ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '); - touchline(MenuPtr->MENEU.HMWin,0,E+1); - delwin(MenuPtr->MENEU.HMWin); - endwin(); - //###############--Untermenu--############################################### - E = item_count(MenuPtr->MENEU.UME.UMEMenu); - unpost_menu(MenuPtr->MENEU.UME.UMEMenu); - SAFE_DELETE(MenuPtr->MENEU.UME.UMEMenu); - SAFE_DELETE_ARRAY(MenuPtr->MENEU.UME.UMEItem); - wborder(MenuPtr->MENEU.UME.UMEWin, ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '); - touchline(MenuPtr->MENEU.UME.UMEWin,0,E+1); - delwin(MenuPtr->MENEU.UME.UMEWin); - endwin(); - - refresh(); - redrawwin(TaskPtr->ClearWindow(WinPtr->START.TMPWin3)); - wrefresh(TaskPtr->ClearWindow(WinPtr->START.TMPWin3)); - } catch (const NCursesException *e) { - endwin(); - std::cerr << e->message << std::endl; - cout << e->errorno; - } catch (const NCursesException &e) { - endwin(); - std::cerr << e.message << std::endl; - cout << e.errorno; - } catch (const std::exception &e) { - endwin(); - std::cerr << "Exception: " << e.what() << std::endl; - cout << EXIT_FAILURE; - } +void ServiceClass::ENDE() { +// try { + if (MenuWinClass::START.TimeWin) {werase(MenuWinClass::START.TimeWin); delwin(MenuWinClass::START.TimeWin); endwin();} + if (MenuWinClass::SERVICEMENU.LMItem) {unpost_menu(MenuWinClass::SERVICEMENU.LMenu); SAFE_DELETE(MenuWinClass::SERVICEMENU.LMItem); SAFE_DELETE_ARRAY(MenuWinClass::SERVICEMENU.LMItem);} + if (MenuWinClass::TOPMENU.UME.UMEItem) { unpost_menu(MenuWinClass::TOPMENU.UME.UMEMenu); SAFE_DELETE(MenuWinClass::TOPMENU.UME.UMEItem); SAFE_DELETE_ARRAY(MenuWinClass::TOPMENU.UME.UMEItem);} + if (MenuWinClass::TOPMENU.HMItem) { unpost_menu(MenuWinClass::TOPMENU.HMMenu); SAFE_DELETE(MenuWinClass::TOPMENU.HMItem); SAFE_DELETE_ARRAY(MenuWinClass::TOPMENU.HMItem);} + if (MenuWinClass::START.TMPWin5) {werase(MenuWinClass::START.TMPWin5); delwin(MenuWinClass::START.TMPWin5); endwin();} + if (MenuWinClass::START.TMPWin4) {werase(MenuWinClass::START.TMPWin4); delwin(MenuWinClass::START.TMPWin4); endwin();} + if (MenuWinClass::START.TMPWin3) {werase(MenuWinClass::START.TMPWin3); delwin(MenuWinClass::START.TMPWin3); endwin();} + if (MenuWinClass::START.TMPWin2) {werase(MenuWinClass::START.TMPWin2); delwin(MenuWinClass::START.TMPWin2); endwin();} + if (MenuWinClass::START.TMPWin1) {werase(MenuWinClass::START.TMPWin1); delwin(MenuWinClass::START.TMPWin1); endwin();} + werase(stdscr); + ServiceList.clear(); + vector(ServiceList).swap (ServiceList); + clear(); +// } catch (const NCursesException *e) { endwin(); std::cerr << e->message << std::endl; cout << e->errorno; +// } catch (const NCursesException &e) { endwin(); std::cerr << e.message << std::endl; cout << e.errorno; +// } catch (const std::exception &e) { endwin(); std::cerr << "Exception: " << e.what() << std::endl; cout << EXIT_FAILURE; } } - -//################################################################################## +/*##################################################################################*/ // new Systemd bestandteile - void ServiceClass::SetStateOption() { //SERVICES unit // pushitem //vector().swap(ServiceList); //UnitItem *item = new UnitItem(); //string name(unit->id); - //item->Name = name; //item->target = name.substr(name.find_last_of('.') + 1, name.length()); //item->description = string(unit->description == nullptr ? "" : unit->description); @@ -386,195 +352,192 @@ void ServiceClass::SetStateOption() { //SERVICES unit // pushitem // items.push_back(item); BuildWin(); }; - void ServiceClass::BuildWin() { - if (MenuPtr->LiMENU.LMItem){unpost_menu(MenuPtr->LiMENU.LMenu);SAFE_DELETE(MenuPtr->LiMENU.LMItem);SAFE_DELETE_ARRAY(MenuPtr->LiMENU.LMItem);} - if (MenuPtr->LiMENU.LMWin){werase(MenuPtr->LiMENU.LMWin);delwin(MenuPtr->LiMENU.LMWin);endwin();} + if (MenuWinClass_SC->SERVICEMENU.LMItem){unpost_menu(MenuWinClass_SC->SERVICEMENU.LMenu);SAFE_DELETE(MenuWinClass_SC->SERVICEMENU.LMItem);SAFE_DELETE_ARRAY(MenuWinClass_SC->SERVICEMENU.LMItem);} + if (MenuWinClass_SC->START.TMPWin4){werase(MenuWinClass_SC->START.TMPWin4);delwin(MenuWinClass_SC->START.TMPWin4);endwin();} StateColor.Green = 28; StateColor.Yellow = 38; StateColor.Red = 18; StateColor.White = 78; unsigned long count = ServiceList.size(); - MenuPtr->LiMENU.LMWin = newpad(static_cast(count), WinPtr->WinSize->WCX_TmpWinReal(WinPtr->START.TMPWin2)); - wbkgd(MenuPtr->LiMENU.LMWin, COLOR_PAIR(WinPtr->WindowColor.FeBk_Main)); + MenuWinClass_SC->START.TMPWin4 = newpad(static_cast(count), MenuWinClass_SC->START.WinSize.WCX_TmpWinReal(MenuWinClass::START.TMPWin2)); + wbkgd(MenuWinClass_SC->START.TMPWin4, COLOR_PAIR(MenuWinClass::START.WinColor.BK_LISTPAD)); for (unsigned long i = 0; i < ServiceList.size(); i++) { TableDraw(ServiceList[i], static_cast(i)); //TableMoveRow(); } } - void ServiceClass::TableMoveRow() { //drawUnits if (ServiceList.empty()) { // updateUnits(); ServiceListFill(); } // const int oneX = unit->sub & A_COLOR; - for (int i = 0; i < WinPtr->WinSize->HRY_TmpWinReal(WinPtr->START.TMPWin2); i++) { - if ((i + start) > static_cast(ServiceList.size() - 1)) { + for (int i = 0; i < MenuWinClass_SC->START.HRYw4(); i++) { + if ((i + ServiceClass::start) > static_cast(ServiceList.size() - 1)) { break; } SERVICES unit = ServiceList[static_cast(start + i)]; if (i == selected) { StateColor.SetSignalColor(17, 37, 27, 87); - AktivName=ServiceList[static_cast(start + selected)].Name; - wattron(MenuPtr->LiMENU.LMWin, COLOR_PAIR(87)|A_BOLD); + MenuWinClass::SERVICEMENU.AktivName = ServiceList[static_cast(start + selected)].Name; + wattron(MenuWinClass_SC->START.TMPWin4, COLOR_PAIR(87)|A_BOLD); } TableDraw(unit, i); - wattroff(MenuPtr->LiMENU.LMWin, COLOR_PAIR(87)|A_BOLD); + wattroff(MenuWinClass_SC->START.TMPWin4, COLOR_PAIR(87)|A_BOLD); StateColor.SetSignalColor(18, 38, 28, 78); } /* if (inputFor == INPUT_FOR_LIST) { // drawInfo(); // } else { // drawSearch(); - // } -// refresh(); - wrefresh(TaskPtr->ClearWindow(MenuPtr->LiMENU.LMWin));*/ + // }*/ refresh(); - touchwin(TaskPtr->ClearWindow(WinPtr->START.TMPWin2)); - wrefresh(TaskPtr->ClearWindow(WinPtr->START.TMPWin2)); - prefresh(MenuPtr->LiMENU.LMWin, 0, 0, 2, 1, WinPtr->WinSize->HRY_TmpWinReal(WinPtr->START.TMPWin2)+1, WinPtr->WinSize->WCX_TmpWinReal(WinPtr->START.TMPWin2));// -2 + touchwin(TaskClass_SC->ClearWindow(MenuWinClass::START.TMPWin2)); + wrefresh(TaskClass_SC->ClearWindow(MenuWinClass::START.TMPWin2)); + touchwin(TaskClass_SC->ClearWindow(MenuWinClass::START.TMPWin3)); + wrefresh(TaskClass_SC->ClearWindow(MenuWinClass::START.TMPWin3)); + prefresh(MenuWinClass::START.TMPWin4, 0, 0, 2, 1, MenuWinClass::START.HRYw4() + 1, MenuWinClass::START.WCXw4()); + prefresh(MenuWinClass::START.TMPWin5, 0, 0, MenuWinClass::START.HRY() - 4, MenuWinClass::START.WCX() - 46, MenuWinClass::START.HRYw5(), MenuWinClass::START.WCXw5()); } - void ServiceClass::TableDraw(SERVICES unit, int y) { if (unit.Target.compare(systemctlwahl)==0) { //unit.SID = unit.SID++; - if (unit.Name.size() < static_cast(WinPtr->WinSize->WCX_TmpWinCenter(WinPtr->START.TMPWin2))) { - unit.Name.resize(WinPtr->WinSize->WCX_TmpWinCenter(WinPtr->START.TMPWin2), ' '); + if (unit.Name.size() < static_cast(MenuWinClass_SC->START.WinSize.WCX_TmpWinCenter(MenuWinClass_SC->START.TMPWin2))) { + unit.Name.resize(MenuWinClass_SC->START.WinSize.WCX_TmpWinCenter(MenuWinClass_SC->START.TMPWin2), ' '); }else { - unit.Name.resize(WinPtr->WinSize->WCX_TmpWinCenter(WinPtr->START.TMPWin2)); + unit.Name.resize(MenuWinClass_SC->START.WinSize.WCX_TmpWinCenter(MenuWinClass_SC->START.TMPWin2)); } - if (unit.Status.size() <= WinPtr->WinSize->WinHalfDurch(WinPtr->START.TMPWin2, 4)) { - unit.Status.resize(WinPtr->WinSize->WinHalfDurch(WinPtr->START.TMPWin2, 4), ' '); + if (unit.Status.size() <= MenuWinClass_SC->START.WinSize.WinHalfDurch(MenuWinClass_SC->START.TMPWin2, 4)) { + unit.Status.resize(MenuWinClass_SC->START.WinSize.WinHalfDurch(MenuWinClass_SC->START.TMPWin2, 4), ' '); }else { - unit.Status.resize(WinPtr->WinSize->WinHalfDurch(WinPtr->START.TMPWin2, 4)); + unit.Status.resize(MenuWinClass_SC->START.WinSize.WinHalfDurch(MenuWinClass_SC->START.TMPWin2, 4)); } - if (unit.SubStatus.size() <= WinPtr->WinSize->WinHalfDurch(WinPtr->START.TMPWin2, 4) ) { - unit.SubStatus.resize(WinPtr->WinSize->WinHalfDurch(WinPtr->START.TMPWin2, 4), ' '); + if (unit.SubStatus.size() <= MenuWinClass_SC->START.WinSize.WinHalfDurch(MenuWinClass_SC->START.TMPWin2, 4) ) { + unit.SubStatus.resize(MenuWinClass_SC->START.WinSize.WinHalfDurch(MenuWinClass_SC->START.TMPWin2, 4), ' '); } else { - unit.SubStatus.resize(WinPtr->WinSize->WinHalfDurch(WinPtr->START.TMPWin2, 4)); + unit.SubStatus.resize(MenuWinClass_SC->START.WinSize.WinHalfDurch(MenuWinClass_SC->START.TMPWin2, 4)); } - if (unit.Active.size() <= WinPtr->WinSize->WinHalfDurch(WinPtr->START.TMPWin2, 4) ) { - unit.Active.resize(WinPtr->WinSize->WinHalfDurch(WinPtr->START.TMPWin2, 4), ' '); + if (unit.Active.size() <= MenuWinClass_SC->START.WinSize.WinHalfDurch(MenuWinClass_SC->START.TMPWin2, 4) ) { + unit.Active.resize(MenuWinClass_SC->START.WinSize.WinHalfDurch(MenuWinClass_SC->START.TMPWin2, 4), ' '); }else { - unit.Active.resize(WinPtr->WinSize->WinHalfDurch(WinPtr->START.TMPWin2, 4)); + unit.Active.resize(MenuWinClass_SC->START.WinSize.WinHalfDurch(MenuWinClass_SC->START.TMPWin2, 4)); } - if (unit.Load.size() <= WinPtr->WinSize->WinHalfDurch(WinPtr->START.TMPWin2, 4) ) { - unit.Load.resize(WinPtr->WinSize->WinHalfDurch(WinPtr->START.TMPWin2, 4), ' '); + if (unit.Load.size() <= MenuWinClass_SC->START.WinSize.WinHalfDurch(MenuWinClass_SC->START.TMPWin2, 4) ) { + unit.Load.resize(MenuWinClass_SC->START.WinSize.WinHalfDurch(MenuWinClass_SC->START.TMPWin2, 4), ' '); }else { - unit.Load.resize(WinPtr->WinSize->WinHalfDurch(WinPtr->START.TMPWin2, 4)); + unit.Load.resize(MenuWinClass_SC->START.WinSize.WinHalfDurch(MenuWinClass_SC->START.TMPWin2, 4)); } std::string name(unit.Name); - wattron(MenuPtr->LiMENU.LMWin, COLOR_PAIR(StateColor.White)|A_BOLD); - mvwprintw(MenuPtr->LiMENU.LMWin, y, WinPtr->WinSize->RAND-1, "%s", name.c_str()); - wattroff(MenuPtr->LiMENU.LMWin, COLOR_PAIR(StateColor.White)|A_BOLD); + wattron(MenuWinClass::START.TMPWin4, COLOR_PAIR(StateColor.White)|A_BOLD); + mvwprintw(MenuWinClass::START.TMPWin4, y, MenuWinClass_SC->START.WinSize.RAND-1, "%s", name.c_str()); + wattroff(MenuWinClass::START.TMPWin4, COLOR_PAIR(StateColor.White)|A_BOLD); switch (unit.state) { case UNIT_STATE_ENABLED: - wattron(MenuPtr->LiMENU.LMWin, COLOR_PAIR(StateColor.Green)|A_BOLD); - mvwaddnstr(MenuPtr->LiMENU.LMWin, y, WinPtr->WinSize->WCX_TmpWinCenter(WinPtr->START.TMPWin2)+1, unit.Status.c_str(), -1); - //mvwprintw(MenuPtr->LiMENU.LMWin, y, WinPtr->WinSize->WCX_TmpWinCenter(WinPtr->START.TMPWin2)+1, "%s ", unit.Status.c_str()); - wattroff(MenuPtr->LiMENU.LMWin, COLOR_PAIR(StateColor.Green)|A_BOLD); + wattron(MenuWinClass::START.TMPWin4, COLOR_PAIR(StateColor.Green)|A_BOLD); + mvwaddnstr(MenuWinClass::START.TMPWin4, y, MenuWinClass_SC->START.WinSize.WCX_TmpWinCenter(MenuWinClass_SC->START.TMPWin2)+1, unit.Status.c_str(), -1); + //mvwprintw(MenuWinClass::START.TMPWin4, y, MenuWinClass_SC->START.WinSize.WCX_TmpWinCenter(MenuWinClass_SC->START.TMPWin2)+1, "%s ", unit.Status.c_str()); + wattroff(MenuWinClass::START.TMPWin4, COLOR_PAIR(StateColor.Green)|A_BOLD); break; case UNIT_STATE_BAD: case UNIT_STATE_DISABLED: - wattron(MenuPtr->LiMENU.LMWin, COLOR_PAIR(StateColor.Red)|A_BOLD); - mvwaddnstr(MenuPtr->LiMENU.LMWin, y, WinPtr->WinSize->WCX_TmpWinCenter(WinPtr->START.TMPWin2)+1, unit.Status.c_str(), -1); - //mvwprintw(MenuPtr->LiMENU.LMWin, y, WinPtr->WinSize->WCX_TmpWinCenter(WinPtr->START.TMPWin2)+1, "%s ", unit.Status.c_str()); - wattroff(MenuPtr->LiMENU.LMWin, COLOR_PAIR(StateColor.Red)|A_BOLD); + wattron(MenuWinClass::START.TMPWin4, COLOR_PAIR(StateColor.Red)|A_BOLD); + mvwaddnstr(MenuWinClass::START.TMPWin4, y, MenuWinClass_SC->START.WinSize.WCX_TmpWinCenter(MenuWinClass_SC->START.TMPWin2)+1, unit.Status.c_str(), -1); + //mvwprintw(MenuWinClass::START.TMPWin4, y, MenuWinClass_SC->START.WinSize.WCX_TmpWinCenter(MenuWinClass_SC->START.TMPWin2)+1, "%s ", unit.Status.c_str()); + wattroff(MenuWinClass::START.TMPWin4, COLOR_PAIR(StateColor.Red)|A_BOLD); break; case UNIT_STATE_STATIC: case UNIT_STATE_MASKED: case UNIT_STATE_GENERATED: - wattron(MenuPtr->LiMENU.LMWin, COLOR_PAIR(StateColor.Yellow)|A_BOLD); - mvwaddnstr(MenuPtr->LiMENU.LMWin, y, WinPtr->WinSize->WCX_TmpWinCenter(WinPtr->START.TMPWin2)+1, unit.Status.c_str(), -1); - //mvwprintw(MenuPtr->LiMENU.LMWin, y, WinPtr->WinSize->WCX_TmpWinCenter(WinPtr->START.TMPWin2)+1, "%s ", unit.Status.c_str()); - wattroff(MenuPtr->LiMENU.LMWin, COLOR_PAIR(StateColor.Yellow)|A_BOLD); + wattron(MenuWinClass::START.TMPWin4, COLOR_PAIR(StateColor.Yellow)|A_BOLD); + mvwaddnstr(MenuWinClass::START.TMPWin4, y, MenuWinClass_SC->START.WinSize.WCX_TmpWinCenter(MenuWinClass_SC->START.TMPWin2)+1, unit.Status.c_str(), -1); + //mvwprintw(MenuWinClass::START.TMPWin4, y, MenuWinClass_SC->START.WinSize.WCX_TmpWinCenter(MenuWinClass_SC->START.TMPWin2)+1, "%s ", unit.Status.c_str()); + wattroff(MenuWinClass::START.TMPWin4, COLOR_PAIR(StateColor.Yellow)|A_BOLD); break; case UNIT_STATE_TMP: default: - wattron(MenuPtr->LiMENU.LMWin, COLOR_PAIR(StateColor.White)|A_BOLD); - mvwaddnstr(MenuPtr->LiMENU.LMWin, y, WinPtr->WinSize->WCX_TmpWinCenter(WinPtr->START.TMPWin2)+1, unit.Status.c_str(), -1); - //mvwprintw(MenuPtr->LiMENU.LMWin, y, WinPtr->WinSize->WCX_TmpWinCenter(WinPtr->START.TMPWin2)+1, "%9s", unit.Status.c_str()); - wattroff(MenuPtr->LiMENU.LMWin, COLOR_PAIR(StateColor.White)|A_BOLD); + wattron(MenuWinClass::START.TMPWin4, COLOR_PAIR(StateColor.White)|A_BOLD); + mvwaddnstr(MenuWinClass::START.TMPWin4, y, MenuWinClass_SC->START.WinSize.WCX_TmpWinCenter(MenuWinClass_SC->START.TMPWin2)+1, unit.Status.c_str(), -1); + //mvwprintw(MenuWinClass::START.TMPWin4, y, MenuWinClass_SC->START.WinSize.WCX_TmpWinCenter(MenuWinClass_SC->START.TMPWin2)+1, "%9s", unit.Status.c_str()); + wattroff(MenuWinClass::START.TMPWin4, COLOR_PAIR(StateColor.White)|A_BOLD); break; } switch (unit.load) { case UNIT_LOADSTATE_LOADED: - wattron(MenuPtr->LiMENU.LMWin, COLOR_PAIR(StateColor.Green)|A_BOLD); - mvwaddnstr(MenuPtr->LiMENU.LMWin, y, WinPtr->WinSize->WCX_TmpWinCenter(WinPtr->START.TMPWin2) +11, unit.Load.c_str(), -1); - //mvwprintw(MenuPtr->LiMENU.LMWin, y, WinPtr->WinSize->WCX() - 11, unit.LoadStatus.c_str()); - wattroff(MenuPtr->LiMENU.LMWin, COLOR_PAIR(StateColor.Green)|A_BOLD); + wattron(MenuWinClass::START.TMPWin4, COLOR_PAIR(StateColor.Green)|A_BOLD); + mvwaddnstr(MenuWinClass::START.TMPWin4, y, MenuWinClass_SC->START.WinSize.WCX_TmpWinCenter(MenuWinClass_SC->START.TMPWin2) +11, unit.Load.c_str(), -1); + //mvwprintw(MenuWinClass::START.TMPWin4, y, MenuWinClass_SC->START.WinSize.WCX() - 11, unit.LoadStatus.c_str()); + wattroff(MenuWinClass::START.TMPWin4, COLOR_PAIR(StateColor.Green)|A_BOLD); break; case UNIT_LOADSTATE_NOTFOUND: case UNIT_LOADSTATE_UNLOAD: - wattron(MenuPtr->LiMENU.LMWin, COLOR_PAIR(StateColor.Red)|A_BOLD); - mvwaddnstr(MenuPtr->LiMENU.LMWin, y, WinPtr->WinSize->WCX_TmpWinCenter(WinPtr->START.TMPWin2) +11, unit.Load.c_str(), -1); - //mvwprintw(MenuPtr->LiMENU.LMWin, y, WinPtr->WinSize->WCX()- 11, unit.LoadStatus.c_str()); - wattroff(MenuPtr->LiMENU.LMWin, COLOR_PAIR(StateColor.Red)|A_BOLD); + wattron(MenuWinClass::START.TMPWin4, COLOR_PAIR(StateColor.Red)|A_BOLD); + mvwaddnstr(MenuWinClass::START.TMPWin4, y, MenuWinClass_SC->START.WinSize.WCX_TmpWinCenter(MenuWinClass_SC->START.TMPWin2) +11, unit.Load.c_str(), -1); + //mvwprintw(MenuWinClass::START.TMPWin4, y, MenuWinClass_SC->START.WinSize.WCX()- 11, unit.LoadStatus.c_str()); + wattroff(MenuWinClass::START.TMPWin4, COLOR_PAIR(StateColor.Red)|A_BOLD); break; default: - wattron(MenuPtr->LiMENU.LMWin, COLOR_PAIR(StateColor.White)|A_BOLD); - mvwaddnstr(MenuPtr->LiMENU.LMWin, y, WinPtr->WinSize->WCX_TmpWinCenter(WinPtr->START.TMPWin2) +11, unit.Load.c_str(), -1); - //mvwprintw(MenuPtr->LiMENU.LMWin, y, WinPtr->WinSize->WCX() - 11, unit.LoadStatus.c_str()); // 3 jetzt 9 - wattroff(MenuPtr->LiMENU.LMWin, COLOR_PAIR(StateColor.White)|A_BOLD); + wattron(MenuWinClass::START.TMPWin4, COLOR_PAIR(StateColor.White)|A_BOLD); + mvwaddnstr(MenuWinClass::START.TMPWin4, y, MenuWinClass_SC->START.WinSize.WCX_TmpWinCenter(MenuWinClass_SC->START.TMPWin2) +11, unit.Load.c_str(), -1); + //mvwprintw(MenuWinClass::START.TMPWin4, y, MenuWinClass_SC->START.WinSize.WCX() - 11, unit.LoadStatus.c_str()); // 3 jetzt 9 + wattroff(MenuWinClass::START.TMPWin4, COLOR_PAIR(StateColor.White)|A_BOLD); break; } switch (unit.active) { case UNIT_ACTIVESTATE_ACTIVE: - wattron(MenuPtr->LiMENU.LMWin, COLOR_PAIR(StateColor.Green)|A_BOLD); - mvwaddnstr(MenuPtr->LiMENU.LMWin, y, WinPtr->WinSize->WCX_TmpWinCenter(WinPtr->START.TMPWin2) +21, unit.Active.c_str(), -1); - //mvwprintw(MenuPtr->LiMENU.LMWin, y, WinPtr->WinSize->WCX()- 21, unit.ActiveStatus.c_str()); - wattroff(MenuPtr->LiMENU.LMWin, COLOR_PAIR(StateColor.Green)|A_BOLD); + wattron(MenuWinClass::START.TMPWin4, COLOR_PAIR(StateColor.Green)|A_BOLD); + mvwaddnstr(MenuWinClass::START.TMPWin4, y, MenuWinClass_SC->START.WinSize.WCX_TmpWinCenter(MenuWinClass_SC->START.TMPWin2) +21, unit.Active.c_str(), -1); + //mvwprintw(MenuWinClass::START.TMPWin4, y, MenuWinClass_SC->START.WinSize.WCX()- 21, unit.ActiveStatus.c_str()); + wattroff(MenuWinClass::START.TMPWin4, COLOR_PAIR(StateColor.Green)|A_BOLD); break; case UNIT_ACTIVESTATE_INACTIVE: - wattron(MenuPtr->LiMENU.LMWin, COLOR_PAIR(StateColor.Red)|A_BOLD); - mvwaddnstr(MenuPtr->LiMENU.LMWin, y, WinPtr->WinSize->WCX_TmpWinCenter(WinPtr->START.TMPWin2) +21, unit.Active.c_str(), -1); - //mvwprintw(MenuPtr->LiMENU.LMWin, y, WinPtr->WinSize->WCX()- 21, unit.ActiveStatus.c_str()); - wattroff(MenuPtr->LiMENU.LMWin, COLOR_PAIR(StateColor.Red)|A_BOLD); + wattron(MenuWinClass::START.TMPWin4, COLOR_PAIR(StateColor.Red)|A_BOLD); + mvwaddnstr(MenuWinClass::START.TMPWin4, y, MenuWinClass_SC->START.WinSize.WCX_TmpWinCenter(MenuWinClass_SC->START.TMPWin2) +21, unit.Active.c_str(), -1); + //mvwprintw(MenuWinClass::START.TMPWin4, y, MenuWinClass_SC->START.WinSize.WCX()- 21, unit.ActiveStatus.c_str()); + wattroff(MenuWinClass::START.TMPWin4, COLOR_PAIR(StateColor.Red)|A_BOLD); break; default: - wattron(MenuPtr->LiMENU.LMWin, COLOR_PAIR(StateColor.White)|A_BOLD); - mvwaddnstr(MenuPtr->LiMENU.LMWin, y, WinPtr->WinSize->WCX_TmpWinCenter(WinPtr->START.TMPWin2) +21, unit.Active.c_str(), -1); - //mvwprintw(MenuPtr->LiMENU.LMWin, y, WinPtr->WinSize->WCX() - 11, unit.LoadStatus.c_str()); // 3 jetzt 9 - wattroff(MenuPtr->LiMENU.LMWin, COLOR_PAIR(StateColor.White)|A_BOLD); + wattron(MenuWinClass::START.TMPWin4, COLOR_PAIR(StateColor.White)|A_BOLD); + mvwaddnstr(MenuWinClass::START.TMPWin4, y, MenuWinClass_SC->START.WinSize.WCX_TmpWinCenter(MenuWinClass_SC->START.TMPWin2) +21, unit.Active.c_str(), -1); + //mvwprintw(MenuWinClass::START.TMPWin4, y, MenuWinClass_SC->START.WinSize.WCX() - 11, unit.LoadStatus.c_str()); // 3 jetzt 9 + wattroff(MenuWinClass::START.TMPWin4, COLOR_PAIR(StateColor.White)|A_BOLD); break; } switch (unit.substate) { case UNIT_SUBSTATE_RUNNING: - wattron(MenuPtr->LiMENU.LMWin, COLOR_PAIR(StateColor.Green)|A_BOLD); - mvwaddnstr(MenuPtr->LiMENU.LMWin, y, WinPtr->WinSize->WCX_TmpWinCenter(WinPtr->START.TMPWin2) +31, unit.SubStatus.c_str(), -1); - //mvwprintw(MenuPtr->LiMENU.LMWin, y, WinPtr->WinSize->WCX_TmpWinCenter(WinPtr->START.TMPWin2)+11, "%10s", unit.SubStatus.c_str()); - wattroff(MenuPtr->LiMENU.LMWin, COLOR_PAIR(StateColor.Green)|A_BOLD); + wattron(MenuWinClass::START.TMPWin4, COLOR_PAIR(StateColor.Green)|A_BOLD); + mvwaddnstr(MenuWinClass::START.TMPWin4, y, MenuWinClass_SC->START.WinSize.WCX_TmpWinCenter(MenuWinClass_SC->START.TMPWin2) +31, unit.SubStatus.c_str(), -1); + //mvwprintw(MenuWinClass::START.TMPWin4, y, MenuWinClass_SC->START.WinSize.WCX_TmpWinCenter(MenuWinClass_SC->START.TMPWin2)+11, "%10s", unit.SubStatus.c_str()); + wattroff(MenuWinClass::START.TMPWin4, COLOR_PAIR(StateColor.Green)|A_BOLD); break; case UNIT_SUBSTATE_CONNECTED: - wattron(MenuPtr->LiMENU.LMWin, COLOR_PAIR(StateColor.Yellow)|A_BOLD); - mvwaddnstr(MenuPtr->LiMENU.LMWin, y, WinPtr->WinSize->WCX_TmpWinCenter(WinPtr->START.TMPWin2) +31, unit.SubStatus.c_str(), -1); - //mvwprintw(MenuPtr->LiMENU.LMWin, y, WinPtr->WinSize->WCX_TmpWinCenter(WinPtr->START.TMPWin2)+11, "%10s", unit.SubStatus.c_str()); - wattroff(MenuPtr->LiMENU.LMWin, COLOR_PAIR(StateColor.Yellow)|A_BOLD); + wattron(MenuWinClass::START.TMPWin4, COLOR_PAIR(StateColor.Yellow)|A_BOLD); + mvwaddnstr(MenuWinClass::START.TMPWin4, y, MenuWinClass_SC->START.WinSize.WCX_TmpWinCenter(MenuWinClass_SC->START.TMPWin2) +31, unit.SubStatus.c_str(), -1); + //mvwprintw(MenuWinClass::START.TMPWin4, y, MenuWinClass_SC->START.WinSize.WCX_TmpWinCenter(MenuWinClass_SC->START.TMPWin2)+11, "%10s", unit.SubStatus.c_str()); + wattroff(MenuWinClass::START.TMPWin4, COLOR_PAIR(StateColor.Yellow)|A_BOLD); case UNIT_SUBSTATE_INVALID: case UNIT_SUBSTATE_EXITED: case UNIT_SUBSTATE_DEAD: - wattron(MenuPtr->LiMENU.LMWin, COLOR_PAIR(StateColor.Red)|A_BOLD); - mvwaddnstr(MenuPtr->LiMENU.LMWin, y, WinPtr->WinSize->WCX_TmpWinCenter(WinPtr->START.TMPWin2) +31, unit.SubStatus.c_str(), -1); - //mvwprintw(MenuPtr->LiMENU.LMWin, y, WinPtr->WinSize->WCX_TmpWinCenter(WinPtr->START.TMPWin2)+11, "%10s", unit.SubStatus.c_str()); - wattroff(MenuPtr->LiMENU.LMWin, COLOR_PAIR(StateColor.Red)|A_BOLD); + wattron(MenuWinClass::START.TMPWin4, COLOR_PAIR(StateColor.Red)|A_BOLD); + mvwaddnstr(MenuWinClass::START.TMPWin4, y, MenuWinClass_SC->START.WinSize.WCX_TmpWinCenter(MenuWinClass_SC->START.TMPWin2) +31, unit.SubStatus.c_str(), -1); + //mvwprintw(MenuWinClass::START.TMPWin4, y, MenuWinClass_SC->START.WinSize.WCX_TmpWinCenter(MenuWinClass_SC->START.TMPWin2)+11, "%10s", unit.SubStatus.c_str()); + wattroff(MenuWinClass::START.TMPWin4, COLOR_PAIR(StateColor.Red)|A_BOLD); break; default: - wattron(MenuPtr->LiMENU.LMWin, COLOR_PAIR(StateColor.White)|A_BOLD); - mvwaddnstr(MenuPtr->LiMENU.LMWin, y, WinPtr->WinSize->WCX_TmpWinCenter(WinPtr->START.TMPWin2) +31, unit.SubStatus.c_str(), -1); - //mvwprintw(MenuPtr->LiMENU.LMWin, y, WinPtr->WinSize->WCX_TmpWinCenter(WinPtr->START.TMPWin2)+11, "%10s", unit.SubStatus.c_str()); // 3 jetzt 9 - wattroff(MenuPtr->LiMENU.LMWin, COLOR_PAIR(StateColor.White)|A_BOLD); + wattron(MenuWinClass::START.TMPWin4, COLOR_PAIR(StateColor.White)|A_BOLD); + mvwaddnstr(MenuWinClass::START.TMPWin4, y, MenuWinClass_SC->START.WinSize.WCX_TmpWinCenter(MenuWinClass_SC->START.TMPWin2) +31, unit.SubStatus.c_str(), -1); + //mvwprintw(MenuWinClass::START.TMPWin4, y, MenuWinClass_SC->START.WinSize.WCX_TmpWinCenter(MenuWinClass_SC->START.TMPWin2)+11, "%10s", unit.SubStatus.c_str()); // 3 jetzt 9 + wattroff(MenuWinClass::START.TMPWin4, COLOR_PAIR(StateColor.White)|A_BOLD); break; } } } - -void ServiceClass::tabledriver(std::vector SRVLIST,int key){ - int ps = WinPtr->WinSize->HRY_TmpWinReal(WinPtr->START.TMPWin2)-1; +void ServiceClass::TableDriver(std::vector SRVLIST,int key){ + int ps = MenuWinClass_SC->START.HRYw4()-1; switch(key){ case REQ_LEFT_ITEM:{ break;} @@ -587,7 +550,7 @@ void ServiceClass::tabledriver(std::vector SRVLIST,int key){ selected--; } if (SRVLIST[static_cast(start + selected)].Name.empty()) { - ServiceClass::tabledriver(SRVLIST,REQ_UP_ITEM); + ServiceClass::TableDriver(SRVLIST,REQ_UP_ITEM); } break;} case REQ_DOWN_ITEM:{ @@ -606,7 +569,7 @@ void ServiceClass::tabledriver(std::vector SRVLIST,int key){ selected = ps; } if (SRVLIST[static_cast(start + selected)].Name.empty()) { - ServiceClass::tabledriver(SRVLIST,REQ_DOWN_ITEM); + ServiceClass::TableDriver(SRVLIST,REQ_DOWN_ITEM); } break;} case REQ_SCR_ULINE:{ @@ -622,7 +585,7 @@ void ServiceClass::tabledriver(std::vector SRVLIST,int key){ selected = 0; } if (SRVLIST[static_cast(start + selected)].Name.empty()) { - ServiceClass::tabledriver(SRVLIST,REQ_UP_ITEM); + ServiceClass::TableDriver(SRVLIST,REQ_UP_ITEM); } break;} case REQ_SCR_DPAGE:{ @@ -635,7 +598,7 @@ void ServiceClass::tabledriver(std::vector SRVLIST,int key){ selected = ps; } if (SRVLIST[static_cast(start + selected)].Name.empty()) { - ServiceClass::tabledriver(SRVLIST,REQ_DOWN_ITEM); + ServiceClass::TableDriver(SRVLIST,REQ_DOWN_ITEM); } break;} case REQ_FIRST_ITEM:{ @@ -645,7 +608,7 @@ void ServiceClass::tabledriver(std::vector SRVLIST,int key){ selected--; } if (SRVLIST[static_cast(start + selected)].Name.empty()) { - ServiceClass::tabledriver(SRVLIST,REQ_UP_ITEM); + ServiceClass::TableDriver(SRVLIST,REQ_UP_ITEM); } break;} case REQ_LAST_ITEM:{ @@ -653,7 +616,7 @@ void ServiceClass::tabledriver(std::vector SRVLIST,int key){ start = max - ps; selected = ps; if (SRVLIST[static_cast(start + selected)].Name.empty()) { - ServiceClass::tabledriver(SRVLIST,REQ_UP_ITEM); + ServiceClass::TableDriver(SRVLIST,REQ_UP_ITEM); } break;} case REQ_NEXT_ITEM:{ @@ -663,7 +626,7 @@ void ServiceClass::tabledriver(std::vector SRVLIST,int key){ selected--; } if (SRVLIST[static_cast(start + selected)].Name.empty()) { - ServiceClass::tabledriver(SRVLIST,REQ_UP_ITEM); + ServiceClass::TableDriver(SRVLIST,REQ_UP_ITEM); } break;} case REQ_PREV_ITEM:{ @@ -683,7 +646,7 @@ void ServiceClass::tabledriver(std::vector SRVLIST,int key){ selected = ps; } if (SRVLIST[static_cast(start + selected)].Name.empty()) { - ServiceClass::tabledriver(SRVLIST,REQ_DOWN_ITEM); + ServiceClass::TableDriver(SRVLIST,REQ_DOWN_ITEM); } break;} case REQ_TOGGLE_ITEM:{ @@ -691,15 +654,15 @@ void ServiceClass::tabledriver(std::vector SRVLIST,int key){ case REQ_CLEAR_PATTERN:{ break;} case REQ_BACK_PATTERN:{ - if (MenuPtr->PATTER.size()>0) {MenuPtr->PATTER.pop_back(); MenuPtr->PATTER.shrink_to_fit();}; - mvwaddnstr(WinPtr->START.TMPWin4, 4, 33, " ",-1); - mvwaddnstr(WinPtr->START.TMPWin4, 4, 33, MenuPtr->PATTER.c_str(),-1); + if (MenuWinClass_SC->PATTERN.size()>0) {MenuWinClass_SC->PATTERN.pop_back(); MenuWinClass_SC->PATTERN.shrink_to_fit();}; + mvwaddnstr(MenuWinClass::START.TMPWin3, 4, 33, " ",-1); + mvwaddnstr(MenuWinClass::START.TMPWin3, 4, 33, MenuWinClass_SC->PATTERN.c_str(),-1); break;} case REQ_NEXT_MATCH:{ int position = 0; for (auto unit : ServiceList) { if (!unit.Name.empty()) { - if (unit.Name.rfind(MenuPtr->PATTER.c_str()) != std::string::npos) { + if (unit.Name.rfind(MenuWinClass_SC->PATTERN.c_str()) != std::string::npos) { lastFound = position; moveTo(position); } position++; @@ -708,83 +671,135 @@ void ServiceClass::tabledriver(std::vector SRVLIST,int key){ } } if (lastFound == 0) { - MenuPtr->PATTER.clear(); + MenuWinClass_SC->PATTERN.clear(); return; } lastFound = 0; - tabledriver(ServiceList,REQ_NEXT_MATCH); + TableDriver(ServiceList,REQ_NEXT_MATCH); break;} case REQ_PREV_MATCH:{ break;} } } - void ServiceClass::searchInput() { int key; while ((key=wgetch(stdscr)) != KEY_F(10)) { switch(key) { case 27:{ // ESC - MenuPtr->PATTER.clear(); - mvwaddnstr(WinPtr->START.TMPWin4, 4, 33, " ",-1); + MenuWinClass_SC->PATTERN.clear(); + mvwaddnstr(MenuWinClass::START.TMPWin3, 4, 33, " ",-1); break;} - //case KEY_ENTER: // Ctrl-M + case KEY_ENTER: // Ctrl-M case 10: {// Enter - tabledriver(ServiceList,REQ_NEXT_MATCH); + TableDriver(ServiceList,REQ_NEXT_MATCH); break;} case KEY_BACKSPACE:{ - if (MenuPtr->PATTER.size()>0) {MenuPtr->PATTER.pop_back(); MenuPtr->PATTER.shrink_to_fit();}; - mvwaddnstr(WinPtr->START.TMPWin4, 4, 33, " ",-1); - mvwaddnstr(WinPtr->START.TMPWin4, 4, 33, MenuPtr->PATTER.c_str(),-1); - tabledriver(ServiceList,REQ_NEXT_MATCH); + if (MenuWinClass_SC->PATTERN.size()>0) {MenuWinClass_SC->PATTERN.pop_back(); MenuWinClass_SC->PATTERN.shrink_to_fit();}; + mvwaddnstr(MenuWinClass::START.TMPWin3, 4, 33, " ",-1); + mvwaddnstr(MenuWinClass::START.TMPWin3, 4, 33, MenuWinClass_SC->PATTERN.c_str(),-1); + TableDriver(ServiceList,REQ_NEXT_MATCH); break;} default:{ if (key > 10 && key < 128) { sprintf(searchString,"%c",key); - MenuPtr->PATTER.append(string(searchString)); - mvwaddnstr(WinPtr->START.TMPWin4, 4, 33, MenuPtr->PATTER.c_str(),-1); - tabledriver(ServiceList,REQ_NEXT_MATCH); + MenuWinClass_SC->PATTERN.append(string(searchString)); + mvwaddnstr(MenuWinClass::START.TMPWin3, 4, 33, MenuWinClass_SC->PATTERN.c_str(),-1); + TableDriver(ServiceList,REQ_NEXT_MATCH); } break;} } refresh(); - touchwin(TaskPtr->ClearWindow(WinPtr->START.TMPWin2)); - wrefresh(TaskPtr->ClearWindow(WinPtr->START.TMPWin2)); - touchwin(TaskPtr->ClearWindow(WinPtr->START.TMPWin4)); - wrefresh(TaskPtr->ClearWindow(WinPtr->START.TMPWin4)); - prefresh(MenuPtr->LiMENU.LMWin, 0, 0, 2, 1, - WinPtr->WinSize->HRY_TmpWinReal(WinPtr->START.TMPWin2)+1, - WinPtr->WinSize->WCX_TmpWinReal(WinPtr->START.TMPWin2)); + touchwin(TaskClass_SC->ClearWindow(MenuWinClass::START.TMPWin2)); + wrefresh(TaskClass_SC->ClearWindow(MenuWinClass::START.TMPWin2)); + touchwin(TaskClass_SC->ClearWindow(MenuWinClass::START.TMPWin3)); + wrefresh(TaskClass_SC->ClearWindow(MenuWinClass::START.TMPWin3)); + prefresh(MenuWinClass::START.TMPWin4, 0, 0, 2, 1, MenuWinClass::START.HRYw4() + 1, MenuWinClass::START.WCXw4()); + prefresh(MenuWinClass::START.TMPWin5, 0, 0, MenuWinClass::START.HRY()-4, MenuWinClass::START.WCX()-46, MenuWinClass::START.HRYw5(), MenuWinClass::START.WCXw5()); } } - void ServiceClass::drawSearch() { /* * Lets indicate it is a search input */ char text[BUFSIZ] = ""; if (lastFound == 0) { sprintf(searchString,"%s",text); - MenuPtr->PATTER.append(string(searchString)); + MenuWinClass_SC->PATTERN.append(string(searchString)); //sprintf(text, "%s%s", text, searchString); } /* * Draw it using any visible, light color */ //drawStatus(1, text, 0); - mvwaddnstr(WinPtr->START.TMPWin4, 4, 33, MenuPtr->PATTER.c_str(),-1); + mvwaddnstr(MenuWinClass::START.TMPWin3, 4, 33, MenuWinClass_SC->PATTERN.c_str(),-1); } - void ServiceClass::moveTo(int position) { start = selected = 0; for (int i = 0; i < position; i++) { - tabledriver(ServiceList,REQ_UP_ITEM); + TableDriver(ServiceList,REQ_UP_ITEM); } } +string ServiceClass::SearchDriver(SeaReq drv, WINDOW *Win, int Key, string Search, int Posi) { + static const int Start = 33; + int hry, wcx; + getyx(Win, hry, wcx); + int MaxSearchTextLaenge = (MenuWinClass::START.WCX() - (Start + MenuWinClass::START.BorderWeight)); + int Laenge = Search.length(); + int AbsolPosi; + AbsolPosi = (Start + Posi); + char TmpKey[BUFSIZE] = ""; + sprintf(TmpKey, "%c", Key); + string dummi; + dummi.assign(MaxSearchTextLaenge,' '); + switch (drv) { + case REQ_DEL_BACKSPACE:{ + if ((wcx > Start) && (wcx <= (Start + Laenge))) { + Search.erase(Posi-1, 1); + mvwaddnstr(Win, 4, Start, dummi.c_str(), -1); + mvwaddnstr(Win, 4, Start, Search.c_str(), -1); + wmove(Win, 4, AbsolPosi - 1); + } + break; } + case REQ_DEL_DC:{ + if ((wcx > Start) && (wcx < (Start + Laenge))) { + Search.erase(Posi+1, 1); + mvwaddnstr(Win, 4, Start, dummi.c_str(), -1); + mvwaddnstr(Win, 4, Start, Search.c_str(), -1); + wmove(Win, 4, AbsolPosi - 1); + } + break; } + case REQ_RIGHT:{ + if ((wcx > Start) && (wcx <= (Start + Laenge))) { + //if ((Posi != 0) || ((Posi-1) <= Laenge)) { + int cursorbewegen = AbsolPosi +1; + wmove(Win, 4, cursorbewegen); + } + break; } + case REQ_LEFT:{ + if ((wcx > Start) && (wcx <= (Start + Laenge))) { + //if ((Posi != 0) || ((Posi-1) <= Laenge)) { + int cursorbewegen = AbsolPosi -1; + wmove(Win, 4, cursorbewegen); + } + break; } + case REQ_INS_DEFAULT:{ + if (Key > 10 && Key < 128) { + if (Posi < Laenge) { + Search.insert(Posi, string(TmpKey)); + mvwaddnstr(Win, 4, Start, Search.c_str(), -1); + wmove(Win, 4, (Start + Posi)); + } else { + Search.append(string(TmpKey)); + mvwaddnstr(Win, 4, Start, Search.c_str(), -1); + } + }; + break;} + } + wrefresh(Win); + return Search; +} +/*##################################################################################*/ ServiceClass::ServiceClass(){ systemctlwahl = "service"; } - ServiceClass::~ServiceClass(){ } - - - - +/*##################################################################################*/ diff --git a/ServiceClass.h b/ServiceClass.h index e219ca1..914b2e8 100644 --- a/ServiceClass.h +++ b/ServiceClass.h @@ -1,7 +1,9 @@ #ifndef SERVICECLASS_H #define SERVICECLASS_H -#include +#include +#include +#include //enum _INPUT_FOR { // INPUT_FOR_LIST, @@ -11,6 +13,7 @@ #define ERR_PREFIX "Failed: " #define SYSV_INSTALL_EXEC "/lib/systemd/systemd-sysv-install" +enum SeaReq { REQ_RIGHT, REQ_LEFT, REQ_DEL_DC, REQ_DEL_BACKSPACE, REQ_INS_DEFAULT}; enum { UNIT_STATE_DISABLED = 0x01, UNIT_STATE_ENABLED = 0x02, @@ -31,7 +34,6 @@ enum { UNIT_ACTIVESTATE_ACTIVE = 0x11, UNIT_ACTIVESTATE_INACTIVE = 0x12 }; - enum STATE_FLAGS { STATE_FLAGS_ENABLE, STATE_FLAGS_DISABLE, @@ -43,10 +45,10 @@ struct SignalColor { int Yellow {38}; //Warn or fails int Green {28}; //infoS int White {78}; //all all right - void SetSignalColor(int RED = 18, int YELLOW = 38, int GREEN = 28, int WHITE = 78){Red = RED; Yellow = YELLOW; Green = GREEN; White = WHITE;}; + void SetSignalColor(int RED = 18, int YELLOW = 38, int GREEN = 28, int WHITE = 78) {Red = RED; Yellow = YELLOW; Green = GREEN; White = WHITE;}; }; -typedef struct SERVICES SERVICES; +//typedef struct SERVICES SERVICES; struct SERVICES { int SID; std::string Name; @@ -61,50 +63,42 @@ struct SERVICES { std::string Active; int substate; std::string SubStatus; - SERVICES* next; }; - -class ServiceClass -{ +class ServiceClass { public: - ServiceClass(); - ~ServiceClass(); - WINDOW *STATUSWIN; - WINDOW *STATUSINFO; - WINDOW *ServiceInfo; - std::string systemctlwahl; - void ServiceFensterDesign(); - void ServiceListFill(); - void ServiceListe(); - void INFOWINDOW(std::string Name); - void Statusabfrage(std::string ausgabestatus); - void ENDE_NEW(); - int StartServiceControll(); - //##########MENÜ################################ - std::vector ServiceList; - WINDOW *ListMenuPanel; - MENU *ListMenu; - ITEM **ListMenuItem; - //##################################################### + /*#####################################################*/ + vector ServiceList; + WINDOW *STATUSWIN; + WINDOW *STATUSINFO; + string systemctlwahl; + /*#####################################################*/ SignalColor StateColor; char searchString[BUFSIZ] = ""; unsigned char inputFor = 0; int lastFound = 0; - int selected = 0; - int start = 0; - //unsigned long selected = 0; - //unsigned long start = 0; - std::string AktivName {""}; - void tabledriver(std::vector SRVLIST,int key); - void SetStateOption(); //SERVICES unit - void TableDraw(SERVICES unit, int y); - void TableMoveRow(); + int selected = 0; + int start = 0; + string AktivName {""}; + /*#####################################################*/ + void ServiceListFill(); + void ServiceListe(); + void INFOWINDOW(string Name); + void Statusabfrage(string ausgabestatus); + void ENDE(); + /*#####################################################*/ + void SetStateOption(); /*SERVICES unit*/ void BuildWin(); + void TableMoveRow(); + void TableDraw(SERVICES unit, int y); + void TableDriver(vector SRVLIST, int key); + void moveTo(int position); void searchInput(); void drawSearch(); - void moveTo(int position); - + string SearchDriver(SeaReq drv, WINDOW *Win, int Key, string Search, int Posi); + /*#####################################################*/ + ServiceClass(); + ~ServiceClass(); }; diff --git a/ServiceControl.pro b/ServiceControl.pro index 9a1eda1..a5c39c2 100644 --- a/ServiceControl.pro +++ b/ServiceControl.pro @@ -1,66 +1,101 @@ TEMPLATE = app -CONFIG += console c++11 +CONFIG += console c++17 CONFIG -= app_bundle CONFIG -= qt -########################################################################### -# # -# Meine einstellung immer ohne shadow build in QT creator!!! # -# Start # -########################################################################### - -CONFIG(debug, debug|release) { +############################################################################ +## Meine einstellung immer ohne shadow build in QT creator!!! # +############################################################################ +PROGRAMMNAME = ServiceControl +TARGET = bin/$$PROGRAMMNAME +VERSION = v1.0.4 +QMAKE_TARGET_PRODUCT = "$${PROGRAMMNAME}" +QMAKE_TARGET_COMPANY = "HOMELAND" +QMAKE_TARGET_COPYRIGHT = "Copyright (c) by Aktony" +DEFINES += APP_VERSION=\"\\\"$${VERSION}\\\"\" \ + APP_PRODUCT=\"\\\"$${QMAKE_TARGET_PRODUCT}\\\"\" \ + APP_COMPANY=\"\\\"$${QMAKE_TARGET_COMPANY}\\\"\" \ + APP_COPYRIGHT=\"\\\"$${QMAKE_TARGET_COPYRIGHT}\\\"\" +#unix:!macx:QMAKE_DEL_FILE = rm -f +#unix:!macx:QMAKE_DEL_DIR = rm -rf +#unix:!macx:OUT_PWD = "$$PWD/Build_$$VERSION" +DESTDIR = "$$PWD/Build_$$VERSION/debug/$$PROGRAMMNAME" +############################################################################ +#__________________release and debug_______________________________________# +############################################################################ +CONFIG(debug, debug|release) { DEFINES += DEBUG_MODE - DESTDIR = "$$PWD/Build/debug" - MAKEFILE = Makefile.debug } -else:CONFIG(release, debug|release) { + DESTDIR = "$$PWD/Build_$$VERSION/debug/$$PROGRAMMNAME" + QMAKE_MAKEFILE = Makefile.debug + MAKEFILE = Makefile.debug +} else:CONFIG(release, debug|release) { DEFINES += RELEASE_MODE - DESTDIR = "$$PWD/Build/release" - MAKEFILE = Makefile.release } -else:CONFIG(force_debug_info) { + DESTDIR = "$$PWD/Build_$$VERSION/release/$$PROGRAMMNAME" + QMAKE_MAKEFILE = Makefile.release + MAKEFILE = Makefile.release +} else:CONFIG(force_debug_info) { DEFINES += PROFILE_MODE - DESTDIR = "$$PWD/Build/profile" - MAKEFILE = Makefile.profile } -else { - DEFINES += PROFILE_MODE - DESTDIR = "$$PWD/Build/profile" - MAKEFILE = Makefile.profile } + DESTDIR = "$$PWD/Build_$$VERSION/profile/$$PROGRAMMNAME" + QMAKE_MAKEFILE = Makefile.profile + MAKEFILE = Makefile.profile +} else { + DEFINES += DEBUG_MODE + DESTDIR = "$$PWD/Build_$$VERSION/debug/$$PROGRAMMNAME" + QMAKE_MAKEFILE = Makefile.debug + MAKEFILE = Makefile.debug +} -RCC_DIR = "$$PWD/Build/RCCFiles" -UI_DIR = "$$PWD/Build/UICFiles" -MOC_DIR = "$$PWD/Build/MOCFiles" -OBJECTS_DIR = "$$PWD/Build/ObjFiles" +RCC_DIR = "$$PWD/Build_$$VERSION/RCCFiles" +UI_DIR = "$$PWD/Build_$$VERSION/UICFiles" +MOC_DIR = "$$PWD/Build_$$VERSION/MOCFiles" +OBJECTS_DIR = "$$PWD/Build_$$VERSION/ObjFiles" -# Copy files to build directory -#copydata0.commands = $(COPY_DIR) $$PWD/config/config.txt $$DESTDIR -#copydata1.commands = $(COPY_DIR) $$PWD/config/SystemMan.db $$DESTDIR -#first.depends = $(first) copydata0 copydata1 +message($$_PRO_FILE_ " - Profile!") +message($$_PRO_FILE_PWD_ " - Profile dir!") +message($$DESTDIR " - Destdir Name!") +message($$MAKEFILE " - Makefile Name!") +message($$OUT_PWD " - out_pwd dir!") +message($$QMAKE_MAKEFILE " - Qmakefile Name!") +############################################################################ +#__________________Copy files to build directory___________________________# +############################################################################ +#copydata0.commands = $(DEL_DIR) $$DESTDIR/config +#copydata1.commands = $(COPY_FILE) $$PWD/lib/libLogWriter.a $$DESTDIR/lib/libLogWriter.a +#copydata2.commands = $(COPY_FILE) $$PWD/lib/libUserGroupList.a $$DESTDIR/lib/libUserGroupList.a +#first.depends = $(first) copydata0 copydata1 copydata2 #export(first.depends) #export(copydata0.commands) #export(copydata1.commands) -#QMAKE_EXTRA_TARGETS += first copydata0 copydata1 - -#QFile DbFile; -#QString DatabaseDataStoragePath = QStandardPaths::writableLocation(QStandardPaths::StandardLocation::AppDataLocation); -#DbFile.setFileName("assets:/MyDatabase.sqlite"); -#DbFile.copy(DatabaseDataStoragePath + "/MyDatabase.sqlite") -#QFile::setPermissions(DatabaseDataStoragePath + "/MyDatabase.sqlite", QFile::WriteOwner | QFile::ReadOwner); - -unix:!macx: LIBS += -Wall -lncursesw -lmenuw -lformw -lpanelw -pthread -lsystemd -lncurses++w -lmenu -ldbus-c++-1 +#export(copydata2.commands) +#QMAKE_EXTRA_TARGETS += first copydata0 copydata1 copydata2 +unix:!macx: LIBS += -lncurses++w -Wall -lncursesw -lmenuw -lmenu -lformw -lpanelw -pthread -lreadline -Wreturn-type -lstdc++fs -lsystemd +#-lpam -lpam_misc -lxcb +#unix:!macx:LIBS_PRIVATE += $$DESTDIR/lib/libUserGroupList.a +#unix:!macx:LIBS_PRIVATE += $$DESTDIR/lib/libLogWriter.a +#unix:!macx: LIBS += -L$$DESTDIR/lib/ -lLogWriter -lUserGroupList +#$$DESTDIR/lib/libconfigator.a $$DESTDIR/lib/libdragonfail.a $$DESTDIR/lib/libtermbox.a $$DESTDIR/lib/libtestoasterror.a +#unix:!macx: LIBS += -L$$DESTDIR/lib/ -largoat -lconfigator -ldragonfail -ltermbox -ltestoasterror ########################################################################### # Ende !!! # ########################################################################### SOURCES += \ - MenuClass.cpp \ +# MenuClass.cpp \ +# WinClass.cpp \ + MenuWinClass.cpp \ ServiceClass.cpp \ Start.cpp \ - TaskClass.cpp \ - WinClass.cpp + TaskClass.cpp + HEADERS += \ Info.h \ - MenuClass.h \ +# WinClass.h \ +# MenuClass.h \ + MenuWinClass.h \ ServiceClass.h \ - TaskClass.h \ - WinClass.h + TaskClass.h + +DISTFILES += \ + zeug.txt + diff --git a/Start.cpp b/Start.cpp index e75a1e0..f7249fd 100644 --- a/Start.cpp +++ b/Start.cpp @@ -1,117 +1,59 @@ -#include -#include -#include -#include -#include +#include +//#include +//#include +#include +#include +#include using namespace std; -WinClass * WinPtr = new WinClass(); -TaskClass * TaskPtr = new TaskClass(); -MenuClass * MenuPtr = new MenuClass(); -ServiceClass * ServicePtr = new ServiceClass(); +TaskClass * TaskClassS = new TaskClass(); +ServiceClass * ServiceClassS = new ServiceClass(); +MenuWinClass *MenuWinClassS = new MenuWinClass(); -void WinClass::StartWin() { - setlocale(LC_CTYPE,"de_DE.UTF-8"); - setlocale(LC_ALL,"de_DE.UTF-8"); - initscr(); - if (has_colors()==FALSE) { endwin(); printf("Your terminal does not support color\n"); exit(1);} - start_color(); - cbreak(); - noecho(); - curs_set(false); - keypad(stdscr, true); - //raw(); - //(void) nonl(); - //clear(); - //syncok(stdscr,true); - //getmaxyx(stdscr,WinSize->HRY,WinSize->WCX); - WinPtr->AppColor(); - //WinPtr->SetSize(); -} - -void WinClass::StopWin() { - delete TaskPtr; - delete MenuPtr; - delete ServicePtr; - delete WinPtr; - endwin(); - //exit(EXIT_SUCCESS); -} - -void WinClass::printInMiddle(WINDOW *win, int starty, int startx, int width, char *string, chtype color, char *sp) { - int x, y; - unsigned long length; - float temp; - - if(win == nullptr) - win = stdscr; - getyx(win, y, x); - if(startx != 0) - x = startx; - if(starty != 0) - y = starty; - if(width == 0) - width = 80; - - length = strlen(string); - temp = (width - static_cast(length))/ 2; - x = startx + static_cast(temp); - wattron(win, color); - - if (sp) { - for (int i = startx; i < width; i++) { - mvwprintw(win, y, i, "%c", sp); - } - } - - mvwprintw(win, y, x, "%s", string); - wattroff(win, color); -} - -int main (int ac, char **av) { - try { - if (ac > 1) { - fprintf(stdout, ABOUT_INFO, VERSION); +int main (int argc, char* argv[]) { +//try { + if (argc > 1) { + if (string(argv[1]).compare("-h")) { + cout << ABOUT_INFO << " " << VERSION << endl; return 0; + exit(EXIT_SUCCESS); + } else { + //fn = string(argv[1]); + //ed = Editor(fn); } - werase(stdscr); - WinPtr->StartWin(); - WinPtr->FensterDraw(); - - //-------------_DatumUhrZeit_datumuhrzeit_----------------------------------------------- - std::thread worker(&TaskClass::process_signal, std::ref(TaskPtr), "DateTime"); - worker.detach(); - - refresh(); - wrefresh(TaskPtr->ClearWindow(WinPtr->START.TMPWin1)); - touchwin(TaskPtr->ClearWindow(WinPtr->START.TMPWin1)); - redrawwin(TaskPtr->ClearWindow(WinPtr->START.TMPWin2)); - wrefresh(TaskPtr->ClearWindow(WinPtr->START.TMPWin2)); - wrefresh(TaskPtr->ClearWindow(WinPtr->START.TMPWin4)); - touchwin(TaskPtr->ClearWindow(WinPtr->START.TMPWin4)); - wrefresh(TaskPtr->ClearWindow(WinPtr->START.TMPWin5)); - prefresh(MenuPtr->LiMENU.LMWin, 0, 0, 2, 1, WinPtr->WinSize->HRY_TmpWinReal(WinPtr->START.TMPWin2)+1, WinPtr->WinSize->WCX_TmpWinReal(WinPtr->START.TMPWin2)); - redrawwin(TaskPtr->ClearWindow(MenuPtr->MENEU.HMWin)); - wrefresh(TaskPtr->ClearWindow(MenuPtr->MENEU.HMWin)); - - MenuPtr->MenuStart(); - WinPtr->StopWin(); - - } catch (const NCursesException *e) { - endwin(); - std::cerr << e->message << std::endl; - cout << e->errorno; - } catch (const NCursesException &e) { - endwin(); - std::cerr << e.message << std::endl; - cout << e.errorno; - } catch (const std::exception &e) { - endwin(); - std::cerr << "Exception: " << e.what() << std::endl; - cout << EXIT_FAILURE; } -} - - + int Key = 0; + werase(stdscr); + MenuWinClassS->StartWin(); + signal(SIGWINCH, MenuWinClass::ResizeHandler); + //-------------_DatumUhrZeit_datumuhrzeit_----------------------------------------------- + //std::thread worker(&TaskClass::process_signal, std::ref(TaskPtr), "DateTime"); + //worker.detach(); + MenuWinClass::SetWinSize(); + MenuWinClassS->FensterDraw(); + + refresh(); + wrefresh(TaskClassS->ClearWindow(MenuWinClass::START.TMPWin1)); + touchwin(TaskClassS->ClearWindow(MenuWinClass::START.TMPWin1)); + redrawwin(TaskClassS->ClearWindow(MenuWinClass::START.TMPWin2)); + wrefresh(TaskClassS->ClearWindow(MenuWinClass::START.TMPWin2)); + touchwin(TaskClassS->ClearWindow(MenuWinClass::START.TMPWin2)); + wrefresh(TaskClassS->ClearWindow(MenuWinClass::START.TMPWin3)); + touchwin(TaskClassS->ClearWindow(MenuWinClass::START.TMPWin3)); + prefresh(MenuWinClass::START.TMPWin4, 0, 0, 2, 1, MenuWinClass::START.HRYw4() + 1, MenuWinClass::START.WCXw4()); + prefresh(MenuWinClass::START.TMPWin5, 0, 0, MenuWinClass::START.HRY()-4, + MenuWinClass::START.WCX()-46, MenuWinClass::START.HRYw5(), MenuWinClass::START.WCXw5()); + redrawwin(TaskClassS->ClearWindow(MenuWinClass::START.TMPWin1)); + wrefresh(TaskClassS->ClearWindow(MenuWinClass::START.TMPWin1)); + + do { Key = MenuWinClass::MenuStart(Key); if (Key == KEY_F(10)) { break; } } while ((Key = getch()) != KEY_F(10)); + + ServiceClassS->ENDE(); + MenuWinClassS->StopWin(); + +// } catch (const NCursesException *e) { endwin(); std::cerr << e->message << std::endl; cout << e->errorno; +// } catch (const NCursesException &e) { endwin(); std::cerr << e.message << std::endl; cout << e.errorno; +// } catch (const std::exception &e) { endwin(); std::cerr << "Exception: " << e.what() << std::endl; cout << EXIT_FAILURE; } +} diff --git a/TaskClass.cpp b/TaskClass.cpp index f91d261..4d72df4 100644 --- a/TaskClass.cpp +++ b/TaskClass.cpp @@ -1,125 +1,68 @@ -#include -#include -#include -#include -#include +#include +//#include +//#include +#include +#include +#include using namespace std; -//extern class TaskClass * TaskPtr; -extern class MenuClass * MenuPtr; -extern class ServiceClass * ServicePtr; -extern class WinClass * WinPtr; -extern class ServiceTableClass * TablePtr; -volatile int signal_flag; +TaskClass *TaskClass_TC = new TaskClass(); +//MenuClass *MenuPtr_TC = new MenuClass(); +ServiceClass *ServiceClass_TC = new ServiceClass(); +//WinClass *WinPtr_TC = new WinClass(); +MenuWinClass *MenuWinClass_TC = new MenuWinClass(); -//#################################################################### -//eigenes zählwerk um von forn an fangen zu können -//aktuelle zahl, string ob + oder -, maximale höchste zahl +volatile int signal_flag; +/*##########################################################################*/ int TaskClass::ZahlenWerk(int zahlen, string i, int max) { int tmp = 0; - if (strcmp(i.c_str(),"++")==0){ - if(zahlen>=max){ + if (strcmp(i.c_str(), "++") == 0) { + if (zahlen >= max) { tmp = 1; - }else if(zahlen==0){ + } else if (zahlen == 0) { tmp = 1; - }else if (zahlen>0){ + } else if (zahlen > 0) { tmp = ++zahlen; - }else if (zahlen1){ + } else if (zahlen > 1) { tmp = --zahlen; - }else if(zahlen<=max){ + } else if (zahlen <= max) { tmp = --zahlen; } - }else{ + } else { tmp = 1; } return tmp; } - -int TaskClass::ZahlenBerechnen(int posa, RANGE range, string wahl) { - int tmp; - if (wahl.compare("+") == 0){ - posa++; - }else if (wahl.compare("-") == 0){ - posa--; - } - - if (posa >= range.min && posa <= range.max){ - tmp = ((posa - range.min) + range.min); - }else if (posa >= range.min && posa > range.max){ - tmp = (posa - range.max);// + range.min; - while(tmp > range.max){ - tmp = (tmp - range.max);// + range.min; - } - }else if (posa < range.min && posa <= range.max){ - tmp = range.max + posa; - while(tmp < range.min){ - if(tmp == 0){tmp = range.max;} - else{tmp = range.max + tmp;} - } - }else if (posa == 0){ - tmp = range.max; - }else{tmp = posa;} - - return tmp; -} - -int TaskClass::RangeZahlenWerk(int mina, int posa, int maxa, string wahl){ - vector list; - int included; - RANGE range; - - range.min = mina; - range.max = maxa; - range.count(); - range.range = 1; - list.push_back(range); - - do { - included = TaskClass::ZahlenBerechnen(posa, range, wahl); - }while (included > range.max); - return included; -} - -int TaskClass::Zeilen(string data, int maxbreite){ +int TaskClass::Zeilen(string data, int maxbreite) { int rownr = 0; double zeiBr = (data.length() / static_cast(maxbreite)); int zeiBr2; stringstream datast(data); string line; - for (rownr = 0; std::getline(datast, line); ++rownr){} + for (rownr = 0; std::getline(datast, line); ++rownr) {} zeiBr2 = static_cast(ceil(zeiBr)); return (rownr + zeiBr2); } - std::vector TaskClass::StringTeiler(const std::string& str, char delimiter) { std::istringstream is(str); std::vector result; - for(std::string cur; std::getline(is, cur, delimiter); result.push_back(cur)); + for (std::string cur; std::getline(is, cur, delimiter); result.push_back(cur)); return result; } -//########################################################################## -//void TaskClass::centerplace(int hoehe, int weite) { -// // WinPtr->halb_XC = static_cast(roundf(WinPtr->WinSize.WCX/2)); -// // WinPtr->halb_YR = static_cast(roundf(WinPtr->WinSize.HRY/2)); -// WinPtr->WinSize->Center_HRY = static_cast(roundf(WinPtr->WinSize->halb_HRY() - (hoehe/2))); -// WinPtr->WinSize->Center_WCX = static_cast(roundf(WinPtr->WinSize->halb_WCX() - (weite/2))); -//} - string TaskClass::TERM_AUSGABE(string cmd) { //cmd = "systemctl list-unit-files -t service | grep '.service' | awk '{$1=$1};1' | sort"; string data; - FILE * stream; + FILE* stream; char buffer[BUFSIZE]; - cmd.append(" 2>/dev/null"); //2>&1 stream = popen(cmd.c_str(), "r"); if (stream) { @@ -133,130 +76,31 @@ string TaskClass::TERM_AUSGABE(string cmd) { memset(buffer, 0, BUFSIZE); return data; } - -WINDOW *TaskClass::ClearWindow(WINDOW *TEMPWINDOW) { - clearok(TEMPWINDOW,true); +WINDOW* TaskClass::ClearWindow(WINDOW* TEMPWINDOW) { + clearok(TEMPWINDOW, true); return TEMPWINDOW; } - -void TaskClass::ClearScreen() { - if (!cur_term) { - int result; - setupterm( nullptr, STDOUT_FILENO, &result ); - if (result <= 0) return; - } - putp(tigetstr("clear")); -} - -//NO_RETURN -void TaskClass::TermQuit(int sig) { - UNUSED(sig); - TaskClass::ConfigDateiList.clear(); - vector().swap(TaskClass::ConfigDateiList); - TaskClass::DeletAllWin("Ende"); - clear(); - raise(SIGTERM); - exit(EXIT_SUCCESS); -} - -void TaskClass::DeletAllWin(const char *name) { - try { - if (strcmp(name,"Ende")==0){ - if (WinPtr->START.TMPWin1){ - werase(WinPtr->START.TMPWin1); - delwin(WinPtr->START.TMPWin1); - endwin(); - } - if (WinPtr->START.TMPWin2){ - werase(WinPtr->START.TMPWin2); - delwin(WinPtr->START.TMPWin2); - endwin(); - } - if (WinPtr->START.TMPWin3){ - werase(WinPtr->START.TMPWin3); - delwin(WinPtr->START.TMPWin3); - endwin(); - } - if (WinPtr->START.TMPWin4){ - werase(WinPtr->START.TMPWin4); - delwin(WinPtr->START.TMPWin4); - endwin(); - } - if (WinPtr->START.TMPWin5){ - werase(WinPtr->START.TMPWin5); - delwin(WinPtr->START.TMPWin5); - endwin(); - } - endwin(); - } - } catch (const NCursesException *e) { - endwin(); - std::cerr << e->message << std::endl; - cout << e->errorno; - } catch (const NCursesException &e) { - endwin(); - std::cerr << e.message << std::endl; - cout << e.errorno; - } catch (const std::exception &e) { - endwin(); - std::cerr << "Exception: " << e.what() << std::endl; - cout << EXIT_FAILURE; - } -} - -//############################################################################# -int TaskClass::WinFullSize(WINDOW * TmpWin, int WHCRXY, string WorH){ - if (WorH.compare("W")==0) { - if (WinPtr->WinSize->WCX_TmpWinReal(TmpWin) <= WHCRXY) { +int TaskClass::WinFullSize(WINDOW* TmpWin, int WHCRXY, string WorH) { + if (WorH.compare("W") == 0) { + if (MenuWinClass_TC->START.WinSize.WCX_TmpWinReal(TmpWin) <= WHCRXY) { return WHCRXY; } else { - return WinPtr->WinSize->WCX_TmpWinReal(TmpWin); + return MenuWinClass_TC->START.WinSize.WCX_TmpWinReal(TmpWin); } - } else if (WorH.compare("H")==0) { - if (WinPtr->WinSize->HRY_TmpWinReal(TmpWin) <= WHCRXY) { + } else if (WorH.compare("H") == 0) { + if (MenuWinClass_TC->START.WinSize.HRY_TmpWinReal(TmpWin) <= WHCRXY) { return WHCRXY; } else { - return WinPtr->WinSize->HRY_TmpWinReal(TmpWin); + return MenuWinClass_TC->START.WinSize.HRY_TmpWinReal(TmpWin); } } } - -void TaskClass::set_flag(int signal) { - signal_flag = signal; +/*##########################################################################*/ +TaskClass::TaskClass() { + //TaskClass::DateTime.TIMEFIELD(MenuPtr->MENEU.HMWin,MenuWinClass_TC->WinSize.WCX); } - -void TaskClass::process_signal(std::string command) { - try { - while (signal_flag != SIGTERM) { - //MenuPtr->MENEU.HMWin - DateTime.TIMEFIELD(WinPtr->START.TimeWin,20); //WinPtr->WinSize->WCX_TmpWin(WinPtr->START.TimeWin)); - std::this_thread::sleep_for(std::chrono::milliseconds(1000)); - } - } catch (const std::exception &e) { - endwin(); - std::cerr << "Exception: " << e.what() << std::endl; - cout << EXIT_FAILURE; - } -} - -void TaskClass::Resize_Handler(int sig) { - try { - while (signal_flag != SIGTERM) { - WinPtr->ChangeSize(); - std::this_thread::sleep_for(std::chrono::milliseconds(1000)); - } - } catch (const std::exception &e) { - endwin(); - std::cerr << "Exception: " << e.what() << std::endl; - cout << EXIT_FAILURE; - } -} - -TaskClass::TaskClass(){ - //TaskClass::DateTime.TIMEFIELD(MenuPtr->MENEU.HMWin,WinPtr->WinSize.WCX); -} - -TaskClass::~TaskClass(){ +TaskClass::~TaskClass() { } +/*##########################################################################*/ diff --git a/TaskClass.h b/TaskClass.h index 0db78aa..1ec5fe9 100644 --- a/TaskClass.h +++ b/TaskClass.h @@ -7,59 +7,38 @@ #include #include #include -#include #include #include +#include +#include +#include #include +#include #include #include #include -#include #include -//thrade lib -#include -//thrade lib -#include -#include -#include -#include -#include -#include +#include #include #include -#include -#include -//#include -#include - -#ifdef __GNUC__ -#define NO_RETURN __attribute__((noreturn)) -#elif __MINGW32__ -#define NO_RETURN __attribute__((noreturn)) -#elif __clang__ -#define NO_RETURN __attribute__((noreturn)) -#elif _MSC_VER -#define NO_RETURN __declspec(noreturn) -#endif - -//#define CTRLD 4 -#define BUFSIZE 8192 -#define CLEARSCR system ( "clear" ) -#define UNUSED(x) (void) (x) -#define SAFE_DELETE(p) { if(p) { delete (p); (p) = nullptr; } } -#define SAFE_DELETE_ARRAY(p) { if(p) { delete[] (p); (p) = nullptr; } } -#define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0])) -#define SIZEOF(table) (sizeof(table) / sizeof(table[0])) +#include -#define RST "\x1B[0m": -#define KRED "\x1B[31m": +//#define CTRLD 4 +#define BUFSIZE 8192 +#define CLEARSCR system ( "clear" ) +#define UNUSED(x) (void) (x) +#define SAFE_DELETE(p) { if(p) { delete (p); (p) = nullptr; } } +#define SAFE_DELETE_ARRAY(p) { if(p) { delete[] (p); (p) = nullptr; } } +#define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0])) +#define SIZEOF(table) (sizeof(table) / sizeof(table[0])) +#define RST "\x1B[0m"; +#define KRED "\x1B[31m"; #define KGRN "\x1B[32m"; #define KYEL "\x1B[33m"; #define KBLU "\x1B[34m"; #define KMAG "\x1B[35m"; #define KCYN "\x1B[36m"; #define KWHT "\x1B[37m"; - #define FRED(x) KRED x RST; #define FGRN(x) KGRN x RST; #define FYEL(x) KYEL x RST; @@ -68,63 +47,39 @@ #define FCYN(x) KCYN x RST; #define FWHT(x) KWHT x RST; +using namespace std; + struct DatumUhrZeit { int n = 0; time_t Zeitstempel; - tm *UHRZEIT; + tm* UHRZEIT; char UHRZEITchar[19]; std::string UHRZEITstr; - void TIMEFIELD(WINDOW *TMPWin, int TMPmax_xc) { + void TIMEFIELD(WINDOW* TMPWin, int TMPmax_xc) { Zeitstempel = time(nullptr); UHRZEIT = localtime(&Zeitstempel); strftime(UHRZEITchar, size_t(UHRZEITchar), "%d.%m.%Y %T", UHRZEIT); UHRZEITstr = std::string(UHRZEITchar); - wattr_on(TMPWin, COLOR_PAIR(79)|A_STANDOUT|A_BOLD,nullptr);//|A_BOLD,0); + wattr_on(TMPWin, COLOR_PAIR(79) | A_STANDOUT | A_BOLD, nullptr); //|A_BOLD,0); mvwaddnstr(TMPWin, 0, 0, UHRZEITstr.c_str(), -1); - wattr_off(TMPWin, COLOR_PAIR(79)|A_STANDOUT|A_BOLD,nullptr);//|A_BOLD,0); + wattr_off(TMPWin, COLOR_PAIR(79) | A_STANDOUT | A_BOLD, nullptr); //|A_BOLD,0); refresh(); wrefresh(TMPWin); //TMPmax_xc-2 } }; - class TaskClass { -public: - DatumUhrZeit DateTime; - void set_flag(int signal); - void process_signal(std::string command); - void execute(std::string command); - static void Resize_Handler(int sig); - typedef struct { - int min; - int max; - int count(){return max - min;} - int range{1}; - } RANGE; - int ZahlenWerk(int zahlen, std::string i, int max); - int ZahlenBerechnen(int posa, RANGE range, std::string wahl); - int RangeZahlenWerk(int mina, int posa, int maxa, std::string wahl); - int Zeilen(std::string data, int maxbreite); - std::vector StringTeiler(const std::string& str, char delimiter); - //############################################################################## - std::string TERM_AUSGABE(std::string cmd); - //############################################################################## - void centerplace(int hoehe, int weite); - //############################################################################## - //--------------------Verlassen-und-Löschen------------------------------------- - void TermQuit(int); - WINDOW *ClearWindow(WINDOW *W); - void ClearScreen(); - void DeletAllWin(const char *namem); - int WinFullSize(WINDOW * TmpWin, int WHCRXY, std::string WorH); - //############################################################################## - std::string filename; - std::vector ConfigDateiList; - int CountConfigDatei; - //############################################################################### - + public: + /*##############################################################################*/ + int ZahlenWerk(int zahlen, std::string i, int max); + int Zeilen(std::string data, int maxbreite); + vector StringTeiler(const std::string& str, char delimiter); + string TERM_AUSGABE(std::string cmd); + WINDOW* ClearWindow(WINDOW* W); + int WinFullSize(WINDOW* TmpWin, int WHCRXY, std::string WorH); TaskClass(); ~TaskClass(); + /*##############################################################################*/ }; #endif // TASKCLASS_H diff --git a/WinClass.cpp b/WinClass.cpp deleted file mode 100644 index 8c9093a..0000000 --- a/WinClass.cpp +++ /dev/null @@ -1,267 +0,0 @@ -#include -#include -#include -#include -#include - -using namespace std; - -extern class TaskClass * TaskPtr; -extern class MenuClass * MenuPtr; -extern class ServiceClass * ServicePtr; -//extern class WinClass * WinPtr; -extern class ServiceTableClass * TablePtr; - -WinClass::WinClass() { - WinSize->RAND = 1; - WinSize->h = 1; //rand - WinSize->w = 1; - WinSize->WCX(); // = 80; - WinSize->HRY(); // = 24; - WinSize->WCX_Real(); - WinSize->HRY_Real(); - WinSize->WCX_Center(); - WinSize->HRY_Center(); - WinSize->WCX_TmpWin(stdscr); - WinSize->HRY_TmpWin(stdscr); - WinSize->WCX_TmpWinReal(stdscr); - WinSize->HRY_TmpWinReal(stdscr); - WinSize->WCX_TmpWinCenter(stdscr); - WinSize->HRY_TmpWinCenter(stdscr); -} - -void WinClass::AppColor() { - //start_color(); - short MY_MARIN_BLUE=240, MY_LIGHT_BLUE=250; - short R=0,G=0;//,B=0; - init_color(MY_MARIN_BLUE, R, G, static_cast(300)); - init_color(MY_LIGHT_BLUE, R, G, static_cast(850)); - // 0 black, 1 red, 2 green, 3 yellow, 4 blue, 5 magenta, - // 6 cyan, 7 white, 8 marin blue, 9 light blue - /* hintergrund Schwarz */ - init_pair(00, COLOR_BLACK, COLOR_BLACK); - init_pair(10, COLOR_RED, COLOR_BLACK); - init_pair(20, COLOR_GREEN, COLOR_BLACK); - init_pair(30, COLOR_YELLOW, COLOR_BLACK); - init_pair(40, COLOR_BLUE, COLOR_BLACK); - init_pair(50, COLOR_MAGENTA,COLOR_BLACK); - init_pair(60, COLOR_CYAN, COLOR_BLACK); - init_pair(70, COLOR_WHITE, COLOR_BLACK); - init_pair(80, MY_MARIN_BLUE,COLOR_BLACK); - init_pair(90, MY_LIGHT_BLUE,COLOR_BLACK); - /* hintergrund Rot */ - init_pair(01, COLOR_BLACK, COLOR_RED); - init_pair(11, COLOR_RED, COLOR_RED); - init_pair(21, COLOR_GREEN, COLOR_RED); - init_pair(31, COLOR_YELLOW, COLOR_RED); - init_pair(41, COLOR_BLUE, COLOR_RED); - init_pair(51, COLOR_MAGENTA,COLOR_RED); - init_pair(61, COLOR_CYAN, COLOR_RED); - init_pair(71, COLOR_WHITE, COLOR_RED); - init_pair(81, MY_MARIN_BLUE,COLOR_RED); - init_pair(91, MY_LIGHT_BLUE,COLOR_RED); - /* hintergrund Gruen */ - init_pair(02, COLOR_BLACK, COLOR_GREEN); - init_pair(12, COLOR_RED, COLOR_GREEN); - init_pair(22, COLOR_GREEN, COLOR_GREEN); - init_pair(32, COLOR_YELLOW, COLOR_GREEN); - init_pair(42, COLOR_BLUE, COLOR_GREEN); - init_pair(52, COLOR_MAGENTA,COLOR_GREEN); - init_pair(62, COLOR_CYAN, COLOR_GREEN); - init_pair(72, COLOR_WHITE, COLOR_GREEN); - init_pair(82, MY_MARIN_BLUE,COLOR_GREEN); - init_pair(92, MY_LIGHT_BLUE,COLOR_GREEN); - /* hintergrund Gelb */ - init_pair(03, COLOR_BLACK, COLOR_YELLOW); - init_pair(13, COLOR_RED, COLOR_YELLOW); - init_pair(23, COLOR_GREEN, COLOR_YELLOW); - init_pair(33, COLOR_YELLOW, COLOR_YELLOW); - init_pair(43, COLOR_BLUE, COLOR_YELLOW); - init_pair(53, COLOR_MAGENTA,COLOR_YELLOW); - init_pair(63, COLOR_CYAN, COLOR_YELLOW); - init_pair(73, COLOR_WHITE, COLOR_YELLOW); - init_pair(83, MY_MARIN_BLUE,COLOR_YELLOW); - init_pair(93, MY_LIGHT_BLUE,COLOR_YELLOW); - /* hintergrund Blau */ - init_pair(04, COLOR_BLACK, COLOR_BLUE); - init_pair(14, COLOR_RED, COLOR_BLUE); - init_pair(24, COLOR_GREEN, COLOR_BLUE); - init_pair(34, COLOR_YELLOW, COLOR_BLUE); - init_pair(44, COLOR_BLUE, COLOR_BLUE); - init_pair(54, COLOR_MAGENTA,COLOR_BLUE); - init_pair(64, COLOR_CYAN, COLOR_BLUE); - init_pair(74, COLOR_WHITE, COLOR_BLUE); - init_pair(84, MY_MARIN_BLUE,COLOR_BLUE); - /* hintergrund Magenta */ - init_pair(05, COLOR_BLACK, COLOR_MAGENTA); - init_pair(15, COLOR_RED, COLOR_MAGENTA); - init_pair(25, COLOR_GREEN, COLOR_MAGENTA); - init_pair(35, COLOR_YELLOW, COLOR_MAGENTA); - init_pair(45, COLOR_BLUE, COLOR_MAGENTA); - init_pair(55, COLOR_MAGENTA,COLOR_MAGENTA); - init_pair(65, COLOR_CYAN, COLOR_MAGENTA); - init_pair(75, COLOR_WHITE, COLOR_MAGENTA); - /* hintergrund Cyan */ - init_pair(06, COLOR_BLACK, COLOR_CYAN); - init_pair(16, COLOR_RED, COLOR_CYAN); - init_pair(26, COLOR_GREEN, COLOR_CYAN); - init_pair(36, COLOR_YELLOW, COLOR_CYAN); - init_pair(46, COLOR_BLUE, COLOR_CYAN); - init_pair(56, COLOR_MAGENTA,COLOR_CYAN); - init_pair(66, COLOR_CYAN, COLOR_CYAN); - init_pair(76, COLOR_WHITE, COLOR_CYAN); - init_pair(86, MY_MARIN_BLUE,COLOR_CYAN); - init_pair(96, MY_LIGHT_BLUE,COLOR_CYAN); - /* hintergrund White */ - init_pair(07, COLOR_BLACK, COLOR_WHITE); - init_pair(17, COLOR_RED, COLOR_WHITE); - init_pair(27, COLOR_GREEN, COLOR_WHITE); - init_pair(37, COLOR_YELLOW, COLOR_WHITE); - init_pair(47, COLOR_BLUE, COLOR_WHITE); - init_pair(57, COLOR_MAGENTA,COLOR_WHITE); - init_pair(67, COLOR_CYAN, COLOR_WHITE); - init_pair(77, COLOR_WHITE, COLOR_WHITE); - init_pair(87, MY_MARIN_BLUE,COLOR_WHITE); - init_pair(97, MY_LIGHT_BLUE,COLOR_WHITE); - /* hintergrund Marin Blau */ - init_pair(8, COLOR_BLACK, MY_MARIN_BLUE); - init_pair(18, COLOR_RED, MY_MARIN_BLUE); - init_pair(28, COLOR_GREEN, MY_MARIN_BLUE); - init_pair(38, COLOR_YELLOW, MY_MARIN_BLUE); - init_pair(48, COLOR_BLUE, MY_MARIN_BLUE); - init_pair(58, COLOR_MAGENTA,MY_MARIN_BLUE); - init_pair(68, COLOR_CYAN, MY_MARIN_BLUE); - init_pair(78, COLOR_WHITE, MY_MARIN_BLUE); - init_pair(88, MY_MARIN_BLUE,MY_MARIN_BLUE); - init_pair(98, MY_LIGHT_BLUE,MY_MARIN_BLUE); - /* hintergrund Light Blue */ - init_pair(9, COLOR_BLACK, MY_LIGHT_BLUE); - init_pair(19, COLOR_RED, MY_LIGHT_BLUE); - init_pair(29, COLOR_GREEN, MY_LIGHT_BLUE); - init_pair(39, COLOR_YELLOW, MY_LIGHT_BLUE); - init_pair(49, COLOR_BLUE, MY_LIGHT_BLUE); - init_pair(59, COLOR_MAGENTA,MY_LIGHT_BLUE); - init_pair(69, COLOR_CYAN, MY_LIGHT_BLUE); - init_pair(79, COLOR_WHITE, MY_LIGHT_BLUE); - init_pair(89, MY_MARIN_BLUE,MY_LIGHT_BLUE); - init_pair(99, MY_LIGHT_BLUE,MY_LIGHT_BLUE); - -} /*---------Programm_Farben------------------------*/ - -void WinClass::FensterDesign() { - if (MenuPtr->MENEU.HMWin) {werase(MenuPtr->MENEU.HMWin); delwin(MenuPtr->MENEU.HMWin); endwin();} - if (MenuPtr->LiMENU.LMWin) {werase(MenuPtr->LiMENU.LMWin); delwin(MenuPtr->LiMENU.LMWin); endwin();} - if (MenuPtr->NEW_UNIT_MENU.LMWin) {werase(MenuPtr->NEW_UNIT_MENU.LMWin); delwin(MenuPtr->NEW_UNIT_MENU.LMWin); endwin();} - if (START.TimeWin) {werase(START.TimeWin); delwin(START.TimeWin); endwin();} - if (START.TMPWin1) {werase(START.TMPWin1); delwin(START.TMPWin1); endwin();} - if (START.TMPWin2) {werase(START.TMPWin2); delwin(START.TMPWin2); endwin();} - if (START.TMPWin3) {werase(START.TMPWin3); delwin(START.TMPWin3); endwin();} - if (START.TMPWin4) {werase(START.TMPWin4); delwin(START.TMPWin4); endwin();} - if (START.TMPWin5) {werase(START.TMPWin5); delwin(START.TMPWin5); endwin();} - // - START.FEID = 0; - START.FENAME = string("VARSYSMAN"); - START.TimeWin = newwin(1, 20, 0, WinSize->WCX()-20); - START.TMPWin1 = newwin(1, WinSize->WCX(), 0, 0); - MenuPtr->MENEU.HMWin = derwin(START.TMPWin1, 1, WinSize->WCX()-20, 0, 0); - START.TimeWin = derwin(START.TMPWin1, 1, 20, 0, WinSize->WCX()-20); - wbkgd(START.TMPWin1, COLOR_PAIR(MenuPtr->HMcolor.HaMeFe_HG)); - // Hauptfenster TMPWin2 - START.TMPWin2 = newwin(WinSize->HRY() -7, WinSize->WCX(), 1, 0); //-1 -20 - wbkgd(START.TMPWin2, COLOR_PAIR(WindowColor.FeBk_Main)); - box(START.TMPWin2, 0,0); - // Listen Menü LMWin at the MainWindow as PAD - MenuPtr->LiMENU.LMWin = newpad(WinSize->HRY() -9, WinSize->WCX()-2); //-5 -20 - wbkgd(MenuPtr->LiMENU.LMWin, COLOR_PAIR(WindowColor.FeBk_Main)); - MenuPtr->LiMENU.LMWin = derwin(START.TMPWin2, WinSize->HRY_TmpWinReal(START.TMPWin2), WinSize->WCX_TmpWinReal(START.TMPWin2), 3, 2); //-4 -20 - //MenuPtr->NEW_UNIT_MENU.LMWin = derwin(START.TMPWin2, WinSize->HRY_REALMAINWIN(START.TMPWin2), WinSize->WCX_REALMAINWIN(START.TMPWin2), 3, 2); //-4 -20 - // Secondary Window on the bottom, hinweiss leiste unten TMPWin4 - START.TMPWin4 = newwin(WinSize->HRY() -18, WinSize->WCX(), WinSize->HRY()-6, 0);//-1 -60 1 -20 - box_set(START.TMPWin4, 0,0); - wbkgd(START.TMPWin4, COLOR_PAIR(WindowColor.FeBk_Info)); - wattr_on(START.TMPWin4, COLOR_PAIR(01)|A_BOLD,nullptr); - mvwaddnstr(START.TMPWin4, WinSize->HRY_TmpWin(START.TMPWin4) -1, WinSize->WCX_TmpWin(START.TMPWin4) -14, "[ EXIT F10 ]" ,-1); //12+2 - mvwaddnstr(START.TMPWin4, WinSize->HRY_TmpWin(START.TMPWin4) -1, WinSize->WCX_TmpWin(START.TMPWin4) -26, "[ MENÜ TAB ]" ,-1); //11+2 - wattr_off(START.TMPWin4, COLOR_PAIR(01)|A_BOLD,nullptr); - // Description fenster unten - START.TMPWin5 = newwin(3, WinSize->WCX() -33, WinSize->HRY()-5, WinSize->WCX() -48); - wbkgd(START.TMPWin5, COLOR_PAIR(WindowColor.FeFo_Info)|A_BOLD); //42 - START.TMPWin5 = derwin(START.TMPWin4, 3, WinSize->WCX() -33, 1, WinSize->WCX() -48); - //ServicePtr->ServiceListFill(); - // Service_Class.ServiceHauptMenu(); -} /*---------Fenster sub----------------------------*/ - -void WinClass::ScrollPad(WINDOW * SubWin, int StartY, int StartX, int Height, int Width, int PadHeight) { - int Choice = 0, Key = 0; - keypad(SubWin, true); - refresh(); - int cols = 0; - while (Choice == 0) { - prefresh(SubWin, cols,0,StartY,StartX,Height,Width); - Key = wgetch(SubWin); - switch(Key) - { - case KEY_UP: - { - if (cols <= 0) continue; - cols--; - break; - } - case KEY_DOWN: - { - if (cols+Height+1 >= PadHeight) continue; - cols++; - break; - } - case KEY_PPAGE: /* Page Up */ - { - if (cols <= 0) continue; - cols -= Height; - if (cols < 0) cols = 0; - break; - } - case KEY_NPAGE: /* Page Down */ - if (cols+Height+1 >= PadHeight) continue; - cols += Height; - if (cols+Height+1 > PadHeight) cols = PadHeight-Height-1; - break; - case KEY_HOME: - cols = 0; - break; - case KEY_END: - cols = PadHeight-Height-1; - break; - case 10: /* Enter */ - { - Choice = 1; - break; - } - } - refresh(); - } - delwin(SubWin); -} - -void WinClass::FensterDraw() { - FensterDesign(); - MenuPtr->Hauptmenu(); - ServicePtr->INFOWINDOW(""); - ServicePtr->ServiceListFill(); -} - -void WinClass::ChangeSize() { - StopWin(); - StartWin(); - FensterDraw(); -} - -//________________new_Systemd_________________ - -WinClass::~WinClass(){ - if (START.TMPWin1) {werase(START.TMPWin1); delwin(START.TMPWin1); endwin();} - if (START.TMPWin2) {werase(START.TMPWin2); delwin(START.TMPWin2); endwin();} - if (START.TMPWin3) {werase(START.TMPWin3); delwin(START.TMPWin3); endwin();} - if (START.TMPWin4) {werase(START.TMPWin4); delwin(START.TMPWin4); endwin();} - if (START.TMPWin5) {werase(START.TMPWin5); delwin(START.TMPWin5); endwin();} -}; - diff --git a/WinClass.h b/WinClass.h deleted file mode 100644 index b73af62..0000000 --- a/WinClass.h +++ /dev/null @@ -1,81 +0,0 @@ -#ifndef WINCLASS_H -#define WINCLASS_H - -#include - -struct FensterColor { - int FeBk_Main = 78; //Fenster_Background - int FeFo_Main = 78; //Fenster_Foreground - int FeBk_Info = 71; //info fenster_Background - int FeFo_Info = 71; //info fenster foreground - int FeBk_Help = 74; //help fenster Background - int FeFo_Help = 74; //help fenster foreground -}; - -typedef struct RECTANGLE { - int RAND = 1; - int WCX(){return static_cast(roundf(getmaxx(stdscr)));}; - int HRY(){return static_cast(roundf(getmaxy(stdscr)));}; - int WCX_Real(){return static_cast(roundf(WCX() - (2 * RAND)));} - int HRY_Real(){return static_cast(roundf(HRY() - (2 * RAND)));} - int WCX_Center(){return static_cast(roundf(WCX() / 2));}; - int HRY_Center(){return static_cast(roundf(HRY() / 2));}; - int WCX_TmpWin(WINDOW * tmpwin){return static_cast(roundf(getmaxx(tmpwin)));}; - int HRY_TmpWin(WINDOW * tmpwin){return static_cast(roundf(getmaxy(tmpwin)));}; - int WCX_TmpWinReal(WINDOW * tmpwin){return static_cast(roundf(getmaxx(tmpwin) - (2 * RAND)));}; - int HRY_TmpWinReal(WINDOW * tmpwin){return static_cast(roundf(getmaxy(tmpwin) - (2 * RAND)));}; - int WCX_TmpWinCenter(WINDOW * tmpwin){return static_cast(roundf(getmaxx(tmpwin) / 2));}; - int HRY_TmpWinCenter(WINDOW * tmpwin){return static_cast(roundf(getmaxy(tmpwin) / 2));}; - unsigned long WinHalfDurch(WINDOW * tmpwin, int TeilDurch){return static_cast(roundf(WCX_TmpWinCenter(tmpwin) / TeilDurch));}; - int w {1}; - int h {1}; -} RECTANGLE; - -struct FENSTER { - int FEID {0}; - std::string FENAME {""}; - WINDOW *TimeWin {nullptr}; - WINDOW *TMPWin1 {nullptr}; - WINDOW *TMPWin2 {nullptr}; - WINDOW *TMPWin3 {nullptr}; - WINDOW *TMPWin4 {nullptr}; - WINDOW *TMPWin5 {nullptr}; - int TMPWinHigh {0}; - void delwinow(WINDOW *tmpwin){ - if(tmpwin){ - int mx,my,bx,by; - getbegyx(tmpwin,by,bx); - getmaxyx(tmpwin,my,mx); - touchwin(tmpwin); - wborder(tmpwin, ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '); - touchline(tmpwin,bx,mx); - delwin(tmpwin); - endwin(); - tmpwin = nullptr; - } - } -}; - -class WinClass { -public: - RECTANGLE * WinSize = new RECTANGLE; - FENSTER START; - FensterColor WindowColor; - void StartWin(); - void StopWin(); - void SetSize(); - void AppColor(); - void FensterDesign(); - void ScrollPad(WINDOW * SubWin, int StartY, int StartX, int Height, int Width, int PadHeight); - void printInMiddle(WINDOW *win, int starty, int startx, int width, char *string, chtype color, char *sp); - void FensterDraw(); - void ChangeSize(); -//#########_ende_new_systemd________________ - WinClass(); - ~WinClass(); - -}; - - - -#endif // WINCLASS_H