Dar formato al código
This commit is contained in:
		@@ -4,7 +4,8 @@ set(CMAKE_BUILD_TYPE Debug)
 | 
				
			|||||||
set(CMAKE_CXX_STANDARD 17)
 | 
					set(CMAKE_CXX_STANDARD 17)
 | 
				
			||||||
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
 | 
					set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
project("StressUI"
 | 
					project(
 | 
				
			||||||
 | 
					  "StressUI"
 | 
				
			||||||
  LANGUAGES CXX
 | 
					  LANGUAGES CXX
 | 
				
			||||||
  VERSION 0.2
 | 
					  VERSION 0.2
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,11 +1,12 @@
 | 
				
			|||||||
#include "config.hpp"
 | 
					#include "config.hpp"
 | 
				
			||||||
#include <fstream>
 | 
					#include <fstream>
 | 
				
			||||||
#include <string>
 | 
					 | 
				
			||||||
#include <sstream>
 | 
					#include <sstream>
 | 
				
			||||||
 | 
					#include <string>
 | 
				
			||||||
#ifndef __CONFIG_FILE_HPP_
 | 
					#ifndef __CONFIG_FILE_HPP_
 | 
				
			||||||
#define __CONFIG_FILE_HPP_
 | 
					#define __CONFIG_FILE_HPP_
 | 
				
			||||||
namespace cf {
 | 
					namespace cf {
 | 
				
			||||||
    const std::string g_configFile = std::string(getenv("HOME")) + "/.config/stressUI.cfg";
 | 
					const std::string g_configFile =
 | 
				
			||||||
 | 
					    std::string(getenv("HOME")) + "/.config/stressUI.cfg";
 | 
				
			||||||
Config openConfig();
 | 
					Config openConfig();
 | 
				
			||||||
void closeConfig(Config *config);
 | 
					void closeConfig(Config *config);
 | 
				
			||||||
std::string getLine(std::ifstream *file);
 | 
					std::string getLine(std::ifstream *file);
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -5,7 +5,8 @@
 | 
				
			|||||||
namespace en {
 | 
					namespace en {
 | 
				
			||||||
const extern std::string noColor = "The terminal doesn't support colors";
 | 
					const extern std::string noColor = "The terminal doesn't support colors";
 | 
				
			||||||
const extern std::string errorGenerico_1 = "How do you get here?";
 | 
					const extern std::string errorGenerico_1 = "How do you get here?";
 | 
				
			||||||
    const extern std::string errorGenerico_2 = "Just in case we drop you on the main menu";
 | 
					const extern std::string errorGenerico_2 =
 | 
				
			||||||
 | 
					    "Just in case we drop you on the main menu";
 | 
				
			||||||
const extern std::string menuPrincipal = "Main Menu";
 | 
					const extern std::string menuPrincipal = "Main Menu";
 | 
				
			||||||
const extern std::string menuPrincipal_1 = "- Start Stress Test";
 | 
					const extern std::string menuPrincipal_1 = "- Start Stress Test";
 | 
				
			||||||
const extern std::string menuPrincipal_2 = "- Configurate";
 | 
					const extern std::string menuPrincipal_2 = "- Configurate";
 | 
				
			||||||
@@ -23,7 +24,8 @@ namespace en{
 | 
				
			|||||||
const extern std::string confHilosError = "Must introduce a number";
 | 
					const extern std::string confHilosError = "Must introduce a number";
 | 
				
			||||||
const extern std::string confTiempoError = "The time format must be HH:mm:ss";
 | 
					const extern std::string confTiempoError = "The time format must be HH:mm:ss";
 | 
				
			||||||
const extern std::string confArchText_1 = "Autogenerated file by Stress_UI";
 | 
					const extern std::string confArchText_1 = "Autogenerated file by Stress_UI";
 | 
				
			||||||
    const extern std::string confArchText_2 = "Do not edit manually without knowing what you do";
 | 
					const extern std::string confArchText_2 =
 | 
				
			||||||
}
 | 
					    "Do not edit manually without knowing what you do";
 | 
				
			||||||
 | 
					} // namespace en
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#endif // __EN_HPP_
 | 
					#endif // __EN_HPP_
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -5,7 +5,8 @@
 | 
				
			|||||||
namespace es {
 | 
					namespace es {
 | 
				
			||||||
const extern std::string noColor = "El terminal no soporta colores";
 | 
					const extern std::string noColor = "El terminal no soporta colores";
 | 
				
			||||||
const extern std::string errorGenerico_1 = "¿Como has llegado aquí?";
 | 
					const extern std::string errorGenerico_1 = "¿Como has llegado aquí?";
 | 
				
			||||||
    const extern std::string errorGenerico_2 = "Por si acaso vamos al menú principal";
 | 
					const extern std::string errorGenerico_2 =
 | 
				
			||||||
 | 
					    "Por si acaso vamos al menú principal";
 | 
				
			||||||
const extern std::string menuPrincipal = "Menú Principal";
 | 
					const extern std::string menuPrincipal = "Menú Principal";
 | 
				
			||||||
const extern std::string menuPrincipal_1 = "- Iniciar Stress Test";
 | 
					const extern std::string menuPrincipal_1 = "- Iniciar Stress Test";
 | 
				
			||||||
const extern std::string menuPrincipal_2 = "- Configurar";
 | 
					const extern std::string menuPrincipal_2 = "- Configurar";
 | 
				
			||||||
@@ -21,9 +22,11 @@ namespace es{
 | 
				
			|||||||
const extern std::string confHilosInput = "- Número de hilos\t> ";
 | 
					const extern std::string confHilosInput = "- Número de hilos\t> ";
 | 
				
			||||||
const extern std::string confTiempoInput = "- Tiempo de ejecución\t> ";
 | 
					const extern std::string confTiempoInput = "- Tiempo de ejecución\t> ";
 | 
				
			||||||
const extern std::string confHilosError = "Se debe introducir un número";
 | 
					const extern std::string confHilosError = "Se debe introducir un número";
 | 
				
			||||||
    const extern std::string confTiempoError = "El formato del tiempo debe ser HH:mm:ss";
 | 
					const extern std::string confTiempoError =
 | 
				
			||||||
 | 
					    "El formato del tiempo debe ser HH:mm:ss";
 | 
				
			||||||
const extern std::string confArchText_1 = "Archivo autogenerado por Stress_UI";
 | 
					const extern std::string confArchText_1 = "Archivo autogenerado por Stress_UI";
 | 
				
			||||||
    const extern std::string confArchText_2 = "No editar manualmente sin saber lo que se hace";
 | 
					const extern std::string confArchText_2 =
 | 
				
			||||||
}
 | 
					    "No editar manualmente sin saber lo que se hace";
 | 
				
			||||||
 | 
					} // namespace es
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#endif // __ES_HPP_
 | 
					#endif // __ES_HPP_
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -21,9 +21,11 @@ namespace gl{
 | 
				
			|||||||
const extern std::string confHilosInput = "- Número de fíos\t> ";
 | 
					const extern std::string confHilosInput = "- Número de fíos\t> ";
 | 
				
			||||||
const extern std::string confTiempoInput = "- Tempo de execución\t> ";
 | 
					const extern std::string confTiempoInput = "- Tempo de execución\t> ";
 | 
				
			||||||
const extern std::string confHilosError = "Debese introducir un número";
 | 
					const extern std::string confHilosError = "Debese introducir un número";
 | 
				
			||||||
    const extern std::string confTiempoError = "O formato do tempo debe ser HH:mm:ss";
 | 
					const extern std::string confTiempoError =
 | 
				
			||||||
 | 
					    "O formato do tempo debe ser HH:mm:ss";
 | 
				
			||||||
const extern std::string confArchText_1 = "Arquivo autoxenerado por Stress_UI";
 | 
					const extern std::string confArchText_1 = "Arquivo autoxenerado por Stress_UI";
 | 
				
			||||||
    const extern std::string confArchText_2 = "Non editar manualmente sin saber o que se fai";
 | 
					const extern std::string confArchText_2 =
 | 
				
			||||||
}
 | 
					    "Non editar manualmente sin saber o que se fai";
 | 
				
			||||||
 | 
					} // namespace gl
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#endif // __GL_HPP_
 | 
					#endif // __GL_HPP_
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -26,6 +26,6 @@ namespace txt{
 | 
				
			|||||||
extern std::string g_confArchText_2;
 | 
					extern std::string g_confArchText_2;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void inicializarIdioma(std::string idioma);
 | 
					void inicializarIdioma(std::string idioma);
 | 
				
			||||||
}
 | 
					} // namespace txt
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#endif // __TEXTOS_HPP_
 | 
					#endif // __TEXTOS_HPP_
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -12,9 +12,20 @@ namespace ui {
 | 
				
			|||||||
int8_t initUI(const int8_t *menu_principal, const int8_t *menu_error);
 | 
					int8_t initUI(const int8_t *menu_principal, const int8_t *menu_error);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void closeUI();
 | 
					void closeUI();
 | 
				
			||||||
    std::vector<std::string> showCentralInputBox(std::vector<std::string> *textos, const int8_t *num_box, std::vector<std::string> *elems, const int8_t *color_error);
 | 
					std::vector<std::string> showCentralInputBox(std::vector<std::string> *textos,
 | 
				
			||||||
    std::vector<std::string> showCentralInputBox(std::vector<std::string> *textos, const int8_t *num_box, std::vector<std::string> *elems, long title_size, const int8_t *color_error);
 | 
					                                             const int8_t *num_box,
 | 
				
			||||||
    void showCenterMensaje(std::vector<std::string> *mensaje, const int8_t *menu_color);
 | 
					                                             std::vector<std::string> *elems,
 | 
				
			||||||
 | 
					                                             const int8_t *color_error);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					std::vector<std::string> showCentralInputBox(std::vector<std::string> *textos,
 | 
				
			||||||
 | 
					                                             const int8_t *num_box,
 | 
				
			||||||
 | 
					                                             std::vector<std::string> *elems,
 | 
				
			||||||
 | 
					                                             long title_size,
 | 
				
			||||||
 | 
					                                             const int8_t *color_error);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void showCenterMensaje(std::vector<std::string> *mensaje,
 | 
				
			||||||
 | 
					                       const int8_t *menu_color);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void showTopTitle(const std::vector<std::string> *titulo);
 | 
					void showTopTitle(const std::vector<std::string> *titulo);
 | 
				
			||||||
} // namespace ui
 | 
					} // namespace ui
 | 
				
			||||||
#endif // __UI_HPP_
 | 
					#endif // __UI_HPP_
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -9,18 +9,11 @@ Config::Config(int8_t numHilos, std::string tiempo) {
 | 
				
			|||||||
//   delete numHilos;
 | 
					//   delete numHilos;
 | 
				
			||||||
//   delete tiempo;
 | 
					//   delete tiempo;
 | 
				
			||||||
// }
 | 
					// }
 | 
				
			||||||
int8_t Config::getNumHilos() {
 | 
					 | 
				
			||||||
  return numHilos;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
std::string Config::getTiempo() {
 | 
					int8_t Config::getNumHilos() { return numHilos; }
 | 
				
			||||||
  return tiempo;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
void Config::setNumHilos(int8_t numHilos) {
 | 
					std::string Config::getTiempo() { return tiempo; }
 | 
				
			||||||
  Config::numHilos = numHilos;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
void Config::setTiempo(std::string tiempo) {
 | 
					void Config::setNumHilos(int8_t numHilos) { Config::numHilos = numHilos; }
 | 
				
			||||||
  Config::tiempo = tiempo;
 | 
					
 | 
				
			||||||
}
 | 
					void Config::setTiempo(std::string tiempo) { Config::tiempo = tiempo; }
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										74
									
								
								src/main.cpp
									
									
									
									
									
								
							
							
						
						
									
										74
									
								
								src/main.cpp
									
									
									
									
									
								
							@@ -1,8 +1,8 @@
 | 
				
			|||||||
 | 
					#include "configFile.hpp"
 | 
				
			||||||
 | 
					#include "textos.hpp"
 | 
				
			||||||
 | 
					#include "ui.hpp"
 | 
				
			||||||
#include <locale.h>
 | 
					#include <locale.h>
 | 
				
			||||||
#include <thread>
 | 
					#include <thread>
 | 
				
			||||||
#include "configFile.hpp"
 | 
					 | 
				
			||||||
#include "ui.hpp"
 | 
					 | 
				
			||||||
#include "textos.hpp"
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
using namespace std;
 | 
					using namespace std;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -23,22 +23,28 @@ const int8_t MENU_TITULO = 9;
 | 
				
			|||||||
const int8_t PRIMER_INICIO = 10;
 | 
					const int8_t PRIMER_INICIO = 10;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const vector<string> TITULO_PRINCIPAL = {
 | 
					const vector<string> TITULO_PRINCIPAL = {
 | 
				
			||||||
    "____   ___  __  __ _____ ____   ___  ______   __  ____  _____ ______     _______ ____ ",
 | 
					    "____   ___  __  __ _____ ____   ___  ______   __  ____  _____ ______     "
 | 
				
			||||||
    "/ ___| / _ \\|  \\/  | ____| __ ) / _ \\|  _ \\ \\ / / / ___|| ____|  _ \\ \\   / / ____|  _ \\ ",
 | 
					    "_______ ____ ",
 | 
				
			||||||
    "\\___ \\| | | | |\\/| |  _| |  _ \\| | | | | | \\ V /  \\___ \\|  _| | |_) \\ \\ / /|  _| | |_) |",
 | 
					    "/ ___| / _ \\|  \\/  | ____| __ ) / _ \\|  _ \\ \\ / / / ___|| ____|  _ "
 | 
				
			||||||
    " ___) | |_| | |  | | |___| |_) | |_| | |_| || |    ___) | |___|  _ < \\ V / | |___|  _ < ",
 | 
					    "\\ \\   / / ____|  _ \\ ",
 | 
				
			||||||
    "|____/ \\___/|_|  |_|_____|____/ \\___/|____/ |_|   |____/|_____|_| \\_\\ \\_/  |_____|_| \\_\\",
 | 
					    "\\___ \\| | | | |\\/| |  _| |  _ \\| | | | | | \\ V /  \\___ \\|  _| | "
 | 
				
			||||||
 | 
					    "|_) \\ \\ / /|  _| | |_) |",
 | 
				
			||||||
 | 
					    " ___) | |_| | |  | | |___| |_) | |_| | |_| || |    ___) | |___|  _ < \\ V "
 | 
				
			||||||
 | 
					    "/ | |___|  _ < ",
 | 
				
			||||||
 | 
					    "|____/ \\___/|_|  |_|_____|____/ \\___/|____/ |_|   |____/|_____|_| \\_\\ "
 | 
				
			||||||
 | 
					    "\\_/  |_____|_| \\_\\",
 | 
				
			||||||
    "",
 | 
					    "",
 | 
				
			||||||
    "_______________________________________________________________________",
 | 
					    "_______________________________________________________________________",
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void userInterface(const int8_t *menu, Config *config);
 | 
					void userInterface(const int8_t *menu, Config *config);
 | 
				
			||||||
void userInterface(const int8_t *menu, vector<string> *mensaje, Config *config);
 | 
					void userInterface(const int8_t *menu, vector<string> *mensaje, Config *config);
 | 
				
			||||||
void showMenu(vector<string> *menu_elems, const int8_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 int8_t *num_menu, Config *config);
 | 
					              vector<string> *mensaje, Config *config);
 | 
				
			||||||
 | 
					void showMenu(vector<string> *menu_elems, const int8_t *num_menu,
 | 
				
			||||||
 | 
					              Config *config);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int main(int argc, char *argv[]) {
 | 
					int main(int argc, char *argv[]) {
 | 
				
			||||||
 | 
					 | 
				
			||||||
  txt::inicializarIdioma(setlocale(LC_ALL, ""));
 | 
					  txt::inicializarIdioma(setlocale(LC_ALL, ""));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  if (ui::initUI(&MENU_PRINCIPAL, &MENU_ERROR) != 0) {
 | 
					  if (ui::initUI(&MENU_PRINCIPAL, &MENU_ERROR) != 0) {
 | 
				
			||||||
@@ -62,11 +68,13 @@ void userInterface(const int8_t *menu, Config *config) {
 | 
				
			|||||||
  userInterface(menu, &dummy, config);
 | 
					  userInterface(menu, &dummy, config);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void userInterface(const int8_t *num_menu, vector<string> *mensaje, Config *config) {
 | 
					void userInterface(const int8_t *num_menu, vector<string> *mensaje,
 | 
				
			||||||
 | 
					                   Config *config) {
 | 
				
			||||||
  switch (*num_menu) {
 | 
					  switch (*num_menu) {
 | 
				
			||||||
  case CONFIGURAR_MENU_PRINCIPAL:
 | 
					  case CONFIGURAR_MENU_PRINCIPAL:
 | 
				
			||||||
  case MENU_PRINCIPAL: {
 | 
					  case MENU_PRINCIPAL: {
 | 
				
			||||||
      vector<string> elem_menu = {txt::g_menuPrincipal_1, txt::g_menuPrincipal_2, txt::g_menuPrincipal_3};
 | 
					    vector<string> elem_menu = {txt::g_menuPrincipal_1, txt::g_menuPrincipal_2,
 | 
				
			||||||
 | 
					                                txt::g_menuPrincipal_3};
 | 
				
			||||||
    showMenu(&elem_menu, &MENU_PRINCIPAL, mensaje, config);
 | 
					    showMenu(&elem_menu, &MENU_PRINCIPAL, mensaje, config);
 | 
				
			||||||
    break;
 | 
					    break;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
@@ -74,13 +82,16 @@ void userInterface(const int8_t *num_menu, vector<string> *mensaje, Config *conf
 | 
				
			|||||||
    /*TODO
 | 
					    /*TODO
 | 
				
			||||||
     *Lleva al menú principal
 | 
					     *Lleva al menú principal
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
      vector<string> elem_menu = {txt::g_menuPrincipal_1, txt::g_menuPrincipal_2, txt::g_menuPrincipal_3};
 | 
					    vector<string> elem_menu = {txt::g_menuPrincipal_1, txt::g_menuPrincipal_2,
 | 
				
			||||||
 | 
					                                txt::g_menuPrincipal_3};
 | 
				
			||||||
    showMenu(&elem_menu, &MENU_PRINCIPAL, mensaje, config);
 | 
					    showMenu(&elem_menu, &MENU_PRINCIPAL, mensaje, config);
 | 
				
			||||||
    break;
 | 
					    break;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  case MENU_CONFIGURACION: {
 | 
					  case MENU_CONFIGURACION: {
 | 
				
			||||||
      vector<string> elem_menu = {txt::g_menuConfigurar_1, txt::g_menuConfigurar_2, txt::g_menuConfigurar_3, txt::g_menuConfigurar_4};
 | 
					    vector<string> elem_menu = {
 | 
				
			||||||
 | 
					        txt::g_menuConfigurar_1, txt::g_menuConfigurar_2,
 | 
				
			||||||
 | 
					        txt::g_menuConfigurar_3, txt::g_menuConfigurar_4};
 | 
				
			||||||
    showMenu(&elem_menu, num_menu, mensaje, config);
 | 
					    showMenu(&elem_menu, num_menu, mensaje, config);
 | 
				
			||||||
    break;
 | 
					    break;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
@@ -91,7 +102,9 @@ void userInterface(const int8_t *num_menu, vector<string> *mensaje, Config *conf
 | 
				
			|||||||
    vector<string> textos_init = {txt::g_confTodo + cf::g_configFile, "", ""};
 | 
					    vector<string> textos_init = {txt::g_confTodo + cf::g_configFile, "", ""};
 | 
				
			||||||
    vector<string> elemens = {txt::g_confHilosInput, txt::g_confTiempoInput};
 | 
					    vector<string> elemens = {txt::g_confHilosInput, txt::g_confTiempoInput};
 | 
				
			||||||
    ui::showTopTitle(&TITULO_PRINCIPAL);
 | 
					    ui::showTopTitle(&TITULO_PRINCIPAL);
 | 
				
			||||||
      vector<string> entrada = ui::showCentralInputBox(&textos_init, &CONFIGURAR_TODO, &elemens, TITULO_PRINCIPAL.size(), &MENU_ERROR);
 | 
					    vector<string> entrada =
 | 
				
			||||||
 | 
					        ui::showCentralInputBox(&textos_init, &CONFIGURAR_TODO, &elemens,
 | 
				
			||||||
 | 
					                                TITULO_PRINCIPAL.size(), &MENU_ERROR);
 | 
				
			||||||
    Config config2 = Config(atoi(entrada[0].c_str()), entrada[1]);
 | 
					    Config config2 = Config(atoi(entrada[0].c_str()), entrada[1]);
 | 
				
			||||||
    config = &config2;
 | 
					    config = &config2;
 | 
				
			||||||
    cf::saveConfig(config);
 | 
					    cf::saveConfig(config);
 | 
				
			||||||
@@ -100,9 +113,12 @@ void userInterface(const int8_t *num_menu, vector<string> *mensaje, Config *conf
 | 
				
			|||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  case CONFIGURAR_HILOS: {
 | 
					  case CONFIGURAR_HILOS: {
 | 
				
			||||||
      vector<string> textos_init = {txt::g_confHilos + to_string(config->getNumHilos()), "", ""};
 | 
					    vector<string> textos_init = {
 | 
				
			||||||
 | 
					        txt::g_confHilos + to_string(config->getNumHilos()), "", ""};
 | 
				
			||||||
    vector<string> elemens = {txt::g_confHilosInput};
 | 
					    vector<string> elemens = {txt::g_confHilosInput};
 | 
				
			||||||
      vector<string> entrada = ui::showCentralInputBox(&textos_init, &CONFIGURAR_TODO, &elemens, TITULO_PRINCIPAL.size(), &MENU_ERROR);
 | 
					    vector<string> entrada =
 | 
				
			||||||
 | 
					        ui::showCentralInputBox(&textos_init, &CONFIGURAR_TODO, &elemens,
 | 
				
			||||||
 | 
					                                TITULO_PRINCIPAL.size(), &MENU_ERROR);
 | 
				
			||||||
    config->setNumHilos(atoi(entrada[0].c_str()));
 | 
					    config->setNumHilos(atoi(entrada[0].c_str()));
 | 
				
			||||||
    cf::saveConfig(config);
 | 
					    cf::saveConfig(config);
 | 
				
			||||||
    userInterface(&MENU_CONFIGURACION, mensaje, config);
 | 
					    userInterface(&MENU_CONFIGURACION, mensaje, config);
 | 
				
			||||||
@@ -110,9 +126,12 @@ void userInterface(const int8_t *num_menu, vector<string> *mensaje, Config *conf
 | 
				
			|||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  case CONFIGURAR_TIEMPO: {
 | 
					  case CONFIGURAR_TIEMPO: {
 | 
				
			||||||
      vector<string> textos_init = {txt::g_confTiempo + config->getTiempo(), "", ""};
 | 
					    vector<string> textos_init = {txt::g_confTiempo + config->getTiempo(), "",
 | 
				
			||||||
 | 
					                                  ""};
 | 
				
			||||||
    vector<string> elemens = {txt::g_confTiempoInput};
 | 
					    vector<string> elemens = {txt::g_confTiempoInput};
 | 
				
			||||||
      vector<string> entrada = ui::showCentralInputBox(&textos_init, &CONFIGURAR_TODO, &elemens, TITULO_PRINCIPAL.size(), &MENU_ERROR);
 | 
					    vector<string> entrada =
 | 
				
			||||||
 | 
					        ui::showCentralInputBox(&textos_init, &CONFIGURAR_TODO, &elemens,
 | 
				
			||||||
 | 
					                                TITULO_PRINCIPAL.size(), &MENU_ERROR);
 | 
				
			||||||
    config->setTiempo(entrada[0]);
 | 
					    config->setTiempo(entrada[0]);
 | 
				
			||||||
    cf::saveConfig(config);
 | 
					    cf::saveConfig(config);
 | 
				
			||||||
    userInterface(&MENU_CONFIGURACION, mensaje, config);
 | 
					    userInterface(&MENU_CONFIGURACION, mensaje, config);
 | 
				
			||||||
@@ -123,7 +142,8 @@ void userInterface(const int8_t *num_menu, vector<string> *mensaje, Config *conf
 | 
				
			|||||||
    /*TODO
 | 
					    /*TODO
 | 
				
			||||||
     *Lleva al menú principal
 | 
					     *Lleva al menú principal
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
      vector<string> elem_menu = {txt::g_menuPrincipal_1, txt::g_menuPrincipal_2, txt::g_menuPrincipal_3};
 | 
					    vector<string> elem_menu = {txt::g_menuPrincipal_1, txt::g_menuPrincipal_2,
 | 
				
			||||||
 | 
					                                txt::g_menuPrincipal_3};
 | 
				
			||||||
    showMenu(&elem_menu, &MENU_PRINCIPAL, mensaje, config);
 | 
					    showMenu(&elem_menu, &MENU_PRINCIPAL, mensaje, config);
 | 
				
			||||||
    break;
 | 
					    break;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
@@ -141,7 +161,8 @@ void userInterface(const int8_t *num_menu, vector<string> *mensaje, Config *conf
 | 
				
			|||||||
  }
 | 
					  }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void showMenu(vector<string> *menu_elems, const int8_t *num_menu, vector<string> *mensaje, Config *config) {
 | 
					void showMenu(vector<string> *menu_elems, const int8_t *num_menu,
 | 
				
			||||||
 | 
					              vector<string> *mensaje, Config *config) {
 | 
				
			||||||
  clear();
 | 
					  clear();
 | 
				
			||||||
  if (ui::g_mensaje) {
 | 
					  if (ui::g_mensaje) {
 | 
				
			||||||
    ui::showCenterMensaje(mensaje, &MENU_ERROR);
 | 
					    ui::showCenterMensaje(mensaje, &MENU_ERROR);
 | 
				
			||||||
@@ -149,11 +170,13 @@ void showMenu(vector<string> *menu_elems, const int8_t *num_menu, vector<string>
 | 
				
			|||||||
  showMenu(menu_elems, num_menu, config);
 | 
					  showMenu(menu_elems, num_menu, config);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void showMenu(vector<string> *menu_elems, const int8_t *num_menu, Config *config) {
 | 
					void showMenu(vector<string> *menu_elems, const int8_t *num_menu,
 | 
				
			||||||
 | 
					              Config *config) {
 | 
				
			||||||
  size_t height = menu_elems->size();
 | 
					  size_t height = menu_elems->size();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  attron(COLOR_PAIR(MENU_PRINCIPAL));
 | 
					  attron(COLOR_PAIR(MENU_PRINCIPAL));
 | 
				
			||||||
  WINDOW *menuwin = newwin(height + 2, ui::g_menuWith, TITULO_PRINCIPAL.size() + 4, 2);
 | 
					  WINDOW *menuwin =
 | 
				
			||||||
 | 
					      newwin(height + 2, ui::g_menuWith, TITULO_PRINCIPAL.size() + 4, 2);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  box(menuwin, 0, 0);
 | 
					  box(menuwin, 0, 0);
 | 
				
			||||||
  refresh();
 | 
					  refresh();
 | 
				
			||||||
@@ -186,7 +209,8 @@ void showMenu(vector<string> *menu_elems, const int8_t *num_menu, Config *config
 | 
				
			|||||||
      }
 | 
					      }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      if (menu_elems->at(i).length() < (ui::g_menuWith - 4)) {
 | 
					      if (menu_elems->at(i).length() < (ui::g_menuWith - 4)) {
 | 
				
			||||||
        for (int j = menu_elems->at(i).length(); j < (ui::g_menuWith - 4); j++) {
 | 
					        for (int j = menu_elems->at(i).length(); j < (ui::g_menuWith - 4);
 | 
				
			||||||
 | 
					             j++) {
 | 
				
			||||||
          menu_elems->at(i).append(" ");
 | 
					          menu_elems->at(i).append(" ");
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,7 +1,7 @@
 | 
				
			|||||||
#include "textos.hpp"
 | 
					#include "textos.hpp"
 | 
				
			||||||
 | 
					#include "idiomas/en.hpp"
 | 
				
			||||||
#include "idiomas/es.hpp"
 | 
					#include "idiomas/es.hpp"
 | 
				
			||||||
#include "idiomas/gl.hpp"
 | 
					#include "idiomas/gl.hpp"
 | 
				
			||||||
#include "idiomas/en.hpp"
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
std::string txt::g_noColor;
 | 
					std::string txt::g_noColor;
 | 
				
			||||||
std::string txt::g_errorGenerico_1;
 | 
					std::string txt::g_errorGenerico_1;
 | 
				
			||||||
@@ -27,7 +27,6 @@ std::string txt::g_confArchText_2;
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
void txt::inicializarIdioma(std::string idioma) {
 | 
					void txt::inicializarIdioma(std::string idioma) {
 | 
				
			||||||
  idioma = idioma.substr(0, idioma.find("_"));
 | 
					  idioma = idioma.substr(0, idioma.find("_"));
 | 
				
			||||||
 | 
					 | 
				
			||||||
  if (idioma == "gl") {
 | 
					  if (idioma == "gl") {
 | 
				
			||||||
    using namespace gl;
 | 
					    using namespace gl;
 | 
				
			||||||
    txt::g_noColor = noColor;
 | 
					    txt::g_noColor = noColor;
 | 
				
			||||||
@@ -121,5 +120,4 @@ void txt::inicializarIdioma(std::string idioma){
 | 
				
			|||||||
    txt::g_confArchText_1 = confArchText_1;
 | 
					    txt::g_confArchText_1 = confArchText_1;
 | 
				
			||||||
    txt::g_confArchText_2 = confArchText_2;
 | 
					    txt::g_confArchText_2 = confArchText_2;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										25
									
								
								src/ui.cpp
									
									
									
									
									
								
							
							
						
						
									
										25
									
								
								src/ui.cpp
									
									
									
									
									
								
							@@ -51,11 +51,17 @@ void ui::showCenterMensaje(vector<string> *mensaje, const int8_t *menu_color) {
 | 
				
			|||||||
  g_mensaje = false;
 | 
					  g_mensaje = false;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
vector<string> ui::showCentralInputBox(std::vector<std::string> *textos, const int8_t *num_box, std::vector<std::string> *elems, const int8_t *color_error) {
 | 
					vector<string> ui::showCentralInputBox(std::vector<std::string> *textos,
 | 
				
			||||||
 | 
					                                       const int8_t *num_box,
 | 
				
			||||||
 | 
					                                       std::vector<std::string> *elems,
 | 
				
			||||||
 | 
					                                       const int8_t *color_error) {
 | 
				
			||||||
  return ui::showCentralInputBox(textos, num_box, elems, 0, color_error);
 | 
					  return ui::showCentralInputBox(textos, num_box, elems, 0, color_error);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
vector<string> ui::showCentralInputBox(vector<string> *textos, const int8_t *num_box, vector<string> *elems, long title_size, const int8_t *color_error) {
 | 
					vector<string> ui::showCentralInputBox(vector<string> *textos,
 | 
				
			||||||
 | 
					                                       const int8_t *num_box,
 | 
				
			||||||
 | 
					                                       vector<string> *elems, long title_size,
 | 
				
			||||||
 | 
					                                       const int8_t *color_error) {
 | 
				
			||||||
  vector<string> entrada;
 | 
					  vector<string> entrada;
 | 
				
			||||||
  int start_ver_window = 1;
 | 
					  int start_ver_window = 1;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -64,7 +70,8 @@ vector<string> ui::showCentralInputBox(vector<string> *textos, const int8_t *num
 | 
				
			|||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  int height = ui::g_maxLines - (title_size + 4) - 1;
 | 
					  int height = ui::g_maxLines - (title_size + 4) - 1;
 | 
				
			||||||
  WINDOW *centralBOX = newwin(height, ui::g_maxCols - ui::g_menuWith - 4, start_ver_window, ui::g_menuWith + 2);
 | 
					  WINDOW *centralBOX = newwin(height, ui::g_maxCols - ui::g_menuWith - 4,
 | 
				
			||||||
 | 
					                              start_ver_window, ui::g_menuWith + 2);
 | 
				
			||||||
  box(centralBOX, 0, 0);
 | 
					  box(centralBOX, 0, 0);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  for (int i = 0; i < textos->size(); i++) {
 | 
					  for (int i = 0; i < textos->size(); i++) {
 | 
				
			||||||
@@ -90,17 +97,20 @@ vector<string> ui::showCentralInputBox(vector<string> *textos, const int8_t *num
 | 
				
			|||||||
      } else {
 | 
					      } else {
 | 
				
			||||||
        mvwprintw(centralBOX, i * 2 + 1 + textos->size(), 1, cleaner.c_str());
 | 
					        mvwprintw(centralBOX, i * 2 + 1 + textos->size(), 1, cleaner.c_str());
 | 
				
			||||||
        wattron(centralBOX, COLOR_PAIR(*color_error));
 | 
					        wattron(centralBOX, COLOR_PAIR(*color_error));
 | 
				
			||||||
        mvwprintw(centralBOX, i * 2 + textos->size(), 1, txt::g_confHilosError.c_str());
 | 
					        mvwprintw(centralBOX, i * 2 + textos->size(), 1,
 | 
				
			||||||
 | 
					                  txt::g_confHilosError.c_str());
 | 
				
			||||||
        wattroff(centralBOX, COLOR_PAIR(*color_error));
 | 
					        wattroff(centralBOX, COLOR_PAIR(*color_error));
 | 
				
			||||||
        i--;
 | 
					        i--;
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
    } else if (elems->at(i) == txt::g_confTiempoInput) {
 | 
					    } else if (elems->at(i) == txt::g_confTiempoInput) {
 | 
				
			||||||
      if(regex_match(input,regex("^([0-1]?[0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9]$"))){
 | 
					      if (regex_match(input,
 | 
				
			||||||
 | 
					                      regex("^([0-1]?[0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9]$"))) {
 | 
				
			||||||
        entrada.push_back(input);
 | 
					        entrada.push_back(input);
 | 
				
			||||||
      } else {
 | 
					      } else {
 | 
				
			||||||
        mvwprintw(centralBOX, i * 2 + 1 + textos->size(), 1, cleaner.c_str());
 | 
					        mvwprintw(centralBOX, i * 2 + 1 + textos->size(), 1, cleaner.c_str());
 | 
				
			||||||
        wattron(centralBOX, COLOR_PAIR(*color_error));
 | 
					        wattron(centralBOX, COLOR_PAIR(*color_error));
 | 
				
			||||||
        mvwprintw(centralBOX, i * 2 + textos->size(), 1, txt::g_confTiempoError.c_str());
 | 
					        mvwprintw(centralBOX, i * 2 + textos->size(), 1,
 | 
				
			||||||
 | 
					                  txt::g_confTiempoError.c_str());
 | 
				
			||||||
        wattroff(centralBOX, COLOR_PAIR(*color_error));
 | 
					        wattroff(centralBOX, COLOR_PAIR(*color_error));
 | 
				
			||||||
        i--;
 | 
					        i--;
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
@@ -119,7 +129,8 @@ void ui::showTopTitle(const vector<string> *titulo) {
 | 
				
			|||||||
  attron(A_BOLD);
 | 
					  attron(A_BOLD);
 | 
				
			||||||
  box(topTitleWin, 0, 0);
 | 
					  box(topTitleWin, 0, 0);
 | 
				
			||||||
  for (int i = 0; i < height; i++) {
 | 
					  for (int i = 0; i < height; i++) {
 | 
				
			||||||
    mvwprintw(topTitleWin, i + 1, (g_maxCols - 4 - titulo->at(i).length()) / 2, titulo->at(i).c_str());
 | 
					    mvwprintw(topTitleWin, i + 1, (g_maxCols - 4 - titulo->at(i).length()) / 2,
 | 
				
			||||||
 | 
					              titulo->at(i).c_str());
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  attroff(A_BOLD);
 | 
					  attroff(A_BOLD);
 | 
				
			||||||
  wrefresh(topTitleWin);
 | 
					  wrefresh(topTitleWin);
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user