Optimizaciones menores y empezar implentacioń de CpuMon
Signed-off-by: somebody_master <somebody_master@somebodyserver.mooo.com>
This commit is contained in:
parent
c947f1fb38
commit
7c47fbc4fb
@ -9,22 +9,22 @@ extern int g_maxLines, g_maxCols, g_begCol, g_begLine, g_menuWith;
|
||||
// int8_t error;
|
||||
extern bool g_mensaje;
|
||||
|
||||
int8_t initUI(const int8_t *menu_principal, const int8_t *menu_error);
|
||||
uint8_t initUI(const uint8_t *menu_principal, const uint8_t *menu_error);
|
||||
|
||||
void closeUI();
|
||||
std::vector<std::string> showCentralInputBox(std::vector<std::string> *textos,
|
||||
const int8_t *num_box,
|
||||
const uint8_t *num_box,
|
||||
std::vector<std::string> *elems,
|
||||
const int8_t *color_error);
|
||||
const uint8_t *color_error);
|
||||
|
||||
std::vector<std::string> showCentralInputBox(std::vector<std::string> *textos,
|
||||
const int8_t *num_box,
|
||||
const uint8_t *num_box,
|
||||
std::vector<std::string> *elems,
|
||||
long title_size,
|
||||
const int8_t *color_error);
|
||||
const uint8_t *color_error);
|
||||
|
||||
void showCenterMensaje(std::vector<std::string> *mensaje,
|
||||
const int8_t *menu_color);
|
||||
const uint8_t *menu_color);
|
||||
|
||||
void showTopTitle(const std::vector<std::string> *titulo);
|
||||
} // namespace ui
|
||||
|
@ -2,4 +2,11 @@
|
||||
|
||||
CpuMon::CpuMon(int8_t num_hilos) { CpuMon::num_hilos = num_hilos; }
|
||||
|
||||
void CpuMon::iniciarCPU_MON() {}
|
||||
void CpuMon::iniciarCPU_MON() {
|
||||
int columnas = ui::g_maxCols / 2;
|
||||
int lineas = ui::g_maxLines;
|
||||
int num_sectores = 1;
|
||||
while (lineas < (CpuMon::num_hilos / num_sectores)) {
|
||||
num_sectores++;
|
||||
}
|
||||
}
|
||||
|
50
src/main.cpp
50
src/main.cpp
@ -8,20 +8,20 @@
|
||||
using namespace std;
|
||||
|
||||
// Constantes para el manejo de los diferentes menús
|
||||
const int8_t MENU_PRINCIPAL = 0;
|
||||
const int8_t MENU_INICIAR_STRESS = 1;
|
||||
const int8_t MENU_CONFIGURACION = 2;
|
||||
const int8_t SALIR = 3;
|
||||
const uint8_t MENU_PRINCIPAL = 0;
|
||||
const uint8_t MENU_INICIAR_STRESS = 1;
|
||||
const uint8_t MENU_CONFIGURACION = 2;
|
||||
const uint8_t SALIR = 3;
|
||||
|
||||
const int8_t CONFIGURAR_TODO = 4;
|
||||
const int8_t CONFIGURAR_HILOS = 5;
|
||||
const int8_t CONFIGURAR_TIEMPO = 6;
|
||||
const int8_t CONFIGURAR_MENU_PRINCIPAL = 7;
|
||||
const uint8_t CONFIGURAR_TODO = 4;
|
||||
const uint8_t CONFIGURAR_HILOS = 5;
|
||||
const uint8_t CONFIGURAR_TIEMPO = 6;
|
||||
const uint8_t CONFIGURAR_MENU_PRINCIPAL = 7;
|
||||
|
||||
const int8_t MENU_ERROR = 8;
|
||||
const int8_t MENU_TITULO = 9;
|
||||
const uint8_t MENU_ERROR = 8;
|
||||
const uint8_t MENU_TITULO = 9;
|
||||
|
||||
const int8_t PRIMER_INICIO = 10;
|
||||
const uint8_t PRIMER_INICIO = 10;
|
||||
|
||||
const vector<string> TITULO_PRINCIPAL = {
|
||||
"____ ___ __ __ _____ ____ ___ ______ __ ____ _____ ______ "
|
||||
@ -38,11 +38,12 @@ const vector<string> TITULO_PRINCIPAL = {
|
||||
"_______________________________________________________________________",
|
||||
};
|
||||
|
||||
void userInterface(const int8_t *menu, Config *config);
|
||||
void userInterface(const int8_t *menu, vector<string> *mensaje, Config *config);
|
||||
void showMenu(vector<string> *menu_elems, const int8_t *num_menu,
|
||||
void userInterface(const uint8_t *menu, Config *config);
|
||||
void userInterface(const uint8_t *menu, vector<string> *mensaje,
|
||||
Config *config);
|
||||
void showMenu(vector<string> *menu_elems, const uint8_t *num_menu,
|
||||
vector<string> *mensaje, Config *config);
|
||||
void showMenu(vector<string> *menu_elems, const int8_t *num_menu,
|
||||
void showMenu(vector<string> *menu_elems, const uint8_t *num_menu,
|
||||
Config *config);
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
@ -64,12 +65,12 @@ int main(int argc, char *argv[]) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
void userInterface(const int8_t *menu, Config *config) {
|
||||
void userInterface(const uint8_t *menu, Config *config) {
|
||||
vector<string> dummy = {""};
|
||||
userInterface(menu, &dummy, config);
|
||||
}
|
||||
|
||||
void userInterface(const int8_t *num_menu, vector<string> *mensaje,
|
||||
void userInterface(const uint8_t *num_menu, vector<string> *mensaje,
|
||||
Config *config) {
|
||||
switch (*num_menu) {
|
||||
case CONFIGURAR_MENU_PRINCIPAL:
|
||||
@ -83,6 +84,7 @@ void userInterface(const int8_t *num_menu, vector<string> *mensaje,
|
||||
/*TODO
|
||||
*Lleva al menú principal
|
||||
*/
|
||||
// CpuMon monitor = CpuMon(std::thread::hardware_concurrency());
|
||||
vector<string> elem_menu = {txt::g_menuPrincipal_1, txt::g_menuPrincipal_2,
|
||||
txt::g_menuPrincipal_3};
|
||||
showMenu(&elem_menu, &MENU_PRINCIPAL, mensaje, config);
|
||||
@ -162,7 +164,7 @@ void userInterface(const int8_t *num_menu, vector<string> *mensaje,
|
||||
}
|
||||
}
|
||||
|
||||
void showMenu(vector<string> *menu_elems, const int8_t *num_menu,
|
||||
void showMenu(vector<string> *menu_elems, const uint8_t *num_menu,
|
||||
vector<string> *mensaje, Config *config) {
|
||||
clear();
|
||||
if (ui::g_mensaje) {
|
||||
@ -171,7 +173,7 @@ void showMenu(vector<string> *menu_elems, const int8_t *num_menu,
|
||||
showMenu(menu_elems, num_menu, config);
|
||||
}
|
||||
|
||||
void showMenu(vector<string> *menu_elems, const int8_t *num_menu,
|
||||
void showMenu(vector<string> *menu_elems, const uint8_t *num_menu,
|
||||
Config *config) {
|
||||
size_t height = menu_elems->size();
|
||||
|
||||
@ -187,8 +189,8 @@ void showMenu(vector<string> *menu_elems, const int8_t *num_menu,
|
||||
|
||||
keypad(menuwin, true);
|
||||
|
||||
int choice = 0;
|
||||
int8_t highlight = 0;
|
||||
uint16_t choice = 0;
|
||||
uint8_t highlight = 0;
|
||||
|
||||
switch (*num_menu) {
|
||||
|
||||
@ -204,13 +206,13 @@ void showMenu(vector<string> *menu_elems, const int8_t *num_menu,
|
||||
}
|
||||
|
||||
while (true) {
|
||||
for (int i = 0; i < height; i++) {
|
||||
for (uint8_t i = 0; i < height; i++) {
|
||||
if (i == highlight) {
|
||||
wattron(menuwin, A_REVERSE);
|
||||
}
|
||||
|
||||
if (menu_elems->at(i).length() < (ui::g_menuWith - 4)) {
|
||||
for (int j = menu_elems->at(i).length(); j < (ui::g_menuWith - 4);
|
||||
for (uint8_t j = menu_elems->at(i).length(); j < (ui::g_menuWith - 4);
|
||||
j++) {
|
||||
menu_elems->at(i).append(" ");
|
||||
}
|
||||
@ -220,7 +222,7 @@ void showMenu(vector<string> *menu_elems, const int8_t *num_menu,
|
||||
// casos. De momento la mejor solución es leer la cadena cada dos
|
||||
// caracteres y ver si cuadra con alguna de las siguientes letras.
|
||||
|
||||
for (int j = 0; j < menu_elems->at(i).length(); j++) {
|
||||
for (uint8_t j = 0; j < menu_elems->at(i).length(); j++) {
|
||||
if (menu_elems->at(i).substr(j, 2).compare("á") == 0 |
|
||||
menu_elems->at(i).substr(j, 2).compare("é") == 0 |
|
||||
menu_elems->at(i).substr(j, 2).compare("í") == 0 |
|
||||
|
14
src/ui.cpp
14
src/ui.cpp
@ -12,7 +12,7 @@ int ui::g_begCol = 0;
|
||||
int ui::g_menuWith = 30;
|
||||
bool ui::g_mensaje = false;
|
||||
|
||||
int8_t ui::initUI(const int8_t *menu_principal, const int8_t *menu_error) {
|
||||
uint8_t ui::initUI(const uint8_t *menu_principal, const uint8_t *menu_error) {
|
||||
initscr();
|
||||
noecho();
|
||||
cbreak();
|
||||
@ -37,7 +37,7 @@ void ui::closeUI() {
|
||||
endwin();
|
||||
}
|
||||
|
||||
void ui::showCenterMensaje(vector<string> *mensaje, const int8_t *menu_color) {
|
||||
void ui::showCenterMensaje(vector<string> *mensaje, const uint8_t *menu_color) {
|
||||
int startLine = (g_maxLines - mensaje->size()) / 2;
|
||||
|
||||
attron(COLOR_PAIR(*menu_color));
|
||||
@ -52,18 +52,18 @@ void ui::showCenterMensaje(vector<string> *mensaje, const int8_t *menu_color) {
|
||||
}
|
||||
|
||||
vector<string> ui::showCentralInputBox(std::vector<std::string> *textos,
|
||||
const int8_t *num_box,
|
||||
const uint8_t *num_box,
|
||||
std::vector<std::string> *elems,
|
||||
const int8_t *color_error) {
|
||||
const uint8_t *color_error) {
|
||||
return ui::showCentralInputBox(textos, num_box, elems, 0, color_error);
|
||||
}
|
||||
|
||||
vector<string> ui::showCentralInputBox(vector<string> *textos,
|
||||
const int8_t *num_box,
|
||||
const uint8_t *num_box,
|
||||
vector<string> *elems, long title_size,
|
||||
const int8_t *color_error) {
|
||||
const uint8_t *color_error) {
|
||||
vector<string> entrada;
|
||||
int start_ver_window = 1;
|
||||
uint8_t start_ver_window = 1;
|
||||
|
||||
if (title_size != 0) {
|
||||
start_ver_window = title_size + 4;
|
||||
|
Loading…
x
Reference in New Issue
Block a user