Dar formato al código
This commit is contained in:
		@@ -4,10 +4,11 @@ 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
 | 
				
			||||||
  )
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
add_library(
 | 
					add_library(
 | 
				
			||||||
  ui
 | 
					  ui
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -2,11 +2,11 @@
 | 
				
			|||||||
#ifndef __CONFIG_HPP_
 | 
					#ifndef __CONFIG_HPP_
 | 
				
			||||||
#define __CONFIG_HPP_
 | 
					#define __CONFIG_HPP_
 | 
				
			||||||
class Config {
 | 
					class Config {
 | 
				
			||||||
  private:
 | 
					private:
 | 
				
			||||||
  int8_t numHilos;
 | 
					  int8_t numHilos;
 | 
				
			||||||
  std::string tiempo;
 | 
					  std::string tiempo;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  public:
 | 
					public:
 | 
				
			||||||
  Config(int8_t numHilos, std::string tiempo);
 | 
					  Config(int8_t numHilos, std::string tiempo);
 | 
				
			||||||
  int8_t getNumHilos();
 | 
					  int8_t getNumHilos();
 | 
				
			||||||
  std::string getTiempo();
 | 
					  std::string getTiempo();
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,15 +1,16 @@
 | 
				
			|||||||
#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 =
 | 
				
			||||||
    Config openConfig();
 | 
					    std::string(getenv("HOME")) + "/.config/stressUI.cfg";
 | 
				
			||||||
    void closeConfig(Config *config);
 | 
					Config openConfig();
 | 
				
			||||||
    std::string getLine(std::ifstream *file);
 | 
					void closeConfig(Config *config);
 | 
				
			||||||
    void saveConfig(Config *config);
 | 
					std::string getLine(std::ifstream *file);
 | 
				
			||||||
    void escribirText(std::ofstream *file, std::string *text, int numSpcs);
 | 
					void saveConfig(Config *config);
 | 
				
			||||||
 | 
					void escribirText(std::ofstream *file, std::string *text, int numSpcs);
 | 
				
			||||||
} // namespace cf
 | 
					} // namespace cf
 | 
				
			||||||
#endif // __CONFIG_FILE_HPP_
 | 
					#endif // __CONFIG_FILE_HPP_
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -2,28 +2,30 @@
 | 
				
			|||||||
#ifndef __EN_HPP_
 | 
					#ifndef __EN_HPP_
 | 
				
			||||||
#define __EN_HPP_
 | 
					#define __EN_HPP_
 | 
				
			||||||
 | 
					
 | 
				
			||||||
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 =
 | 
				
			||||||
    const extern std::string menuPrincipal = "Main Menu";
 | 
					    "Just in case we drop you on the main menu";
 | 
				
			||||||
    const extern std::string menuPrincipal_1 = "- Start Stress Test";
 | 
					const extern std::string menuPrincipal = "Main Menu";
 | 
				
			||||||
    const extern std::string menuPrincipal_2 = "- Configurate";
 | 
					const extern std::string menuPrincipal_1 = "- Start Stress Test";
 | 
				
			||||||
    const extern std::string menuPrincipal_3 = "- Exit";
 | 
					const extern std::string menuPrincipal_2 = "- Configurate";
 | 
				
			||||||
    const extern std::string menuConfigurar = "Configuration";
 | 
					const extern std::string menuPrincipal_3 = "- Exit";
 | 
				
			||||||
    const extern std::string menuConfigurar_1 = "- Configurate all";
 | 
					const extern std::string menuConfigurar = "Configuration";
 | 
				
			||||||
    const extern std::string menuConfigurar_2 = "- Number of threads";
 | 
					const extern std::string menuConfigurar_1 = "- Configurate all";
 | 
				
			||||||
    const extern std::string menuConfigurar_3 = "- Time";
 | 
					const extern std::string menuConfigurar_2 = "- Number of threads";
 | 
				
			||||||
    const extern std::string menuConfigurar_4 = "- Main Menu";
 | 
					const extern std::string menuConfigurar_3 = "- Time";
 | 
				
			||||||
    const extern std::string confTodo = "All the configuration will be write in ";
 | 
					const extern std::string menuConfigurar_4 = "- Main Menu";
 | 
				
			||||||
    const extern std::string confHilos = "Current number of threads > ";
 | 
					const extern std::string confTodo = "All the configuration will be write in ";
 | 
				
			||||||
    const extern std::string confTiempo = "Current execution time > ";
 | 
					const extern std::string confHilos = "Current number of threads > ";
 | 
				
			||||||
    const extern std::string confHilosInput = "- Number of threads\t> ";
 | 
					const extern std::string confTiempo = "Current execution time > ";
 | 
				
			||||||
    const extern std::string confTiempoInput = "- Execution time\t> ";
 | 
					const extern std::string confHilosInput = "- Number of threads\t> ";
 | 
				
			||||||
    const extern std::string confHilosError = "Must introduce a number";
 | 
					const extern std::string confTiempoInput = "- Execution time\t> ";
 | 
				
			||||||
    const extern std::string confTiempoError = "The time format must be HH:mm:ss";
 | 
					const extern std::string confHilosError = "Must introduce a number";
 | 
				
			||||||
    const extern std::string confArchText_1 = "Autogenerated file by Stress_UI";
 | 
					const extern std::string confTiempoError = "The time format must be HH:mm:ss";
 | 
				
			||||||
    const extern std::string confArchText_2 = "Do not edit manually without knowing what you do";
 | 
					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";
 | 
				
			||||||
 | 
					} // namespace en
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#endif // __EN_HPP_
 | 
					#endif // __EN_HPP_
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -2,28 +2,31 @@
 | 
				
			|||||||
#ifndef __ES_HPP_
 | 
					#ifndef __ES_HPP_
 | 
				
			||||||
#define __ES_HPP_
 | 
					#define __ES_HPP_
 | 
				
			||||||
 | 
					
 | 
				
			||||||
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 =
 | 
				
			||||||
    const extern std::string menuPrincipal = "Menú Principal";
 | 
					    "Por si acaso vamos al menú principal";
 | 
				
			||||||
    const extern std::string menuPrincipal_1 = "- Iniciar Stress Test";
 | 
					const extern std::string menuPrincipal = "Menú Principal";
 | 
				
			||||||
    const extern std::string menuPrincipal_2 = "- Configurar";
 | 
					const extern std::string menuPrincipal_1 = "- Iniciar Stress Test";
 | 
				
			||||||
    const extern std::string menuPrincipal_3 = "- Salir";
 | 
					const extern std::string menuPrincipal_2 = "- Configurar";
 | 
				
			||||||
    const extern std::string menuConfigurar = "Configuración";
 | 
					const extern std::string menuPrincipal_3 = "- Salir";
 | 
				
			||||||
    const extern std::string menuConfigurar_1 = "- Configurar todo";
 | 
					const extern std::string menuConfigurar = "Configuración";
 | 
				
			||||||
    const extern std::string menuConfigurar_2 = "- Número de hilos";
 | 
					const extern std::string menuConfigurar_1 = "- Configurar todo";
 | 
				
			||||||
    const extern std::string menuConfigurar_3 = "- Tiempo";
 | 
					const extern std::string menuConfigurar_2 = "- Número de hilos";
 | 
				
			||||||
    const extern std::string menuConfigurar_4 = "- Menú principal";
 | 
					const extern std::string menuConfigurar_3 = "- Tiempo";
 | 
				
			||||||
    const extern std::string confTodo = "Toda la configuración se escribirá en ";
 | 
					const extern std::string menuConfigurar_4 = "- Menú principal";
 | 
				
			||||||
    const extern std::string confHilos = "Número de hilos actuales > ";
 | 
					const extern std::string confTodo = "Toda la configuración se escribirá en ";
 | 
				
			||||||
    const extern std::string confTiempo = "Tiempo actual > ";
 | 
					const extern std::string confHilos = "Número de hilos actuales > ";
 | 
				
			||||||
    const extern std::string confHilosInput = "- Número de hilos\t> ";
 | 
					const extern std::string confTiempo = "Tiempo actual > ";
 | 
				
			||||||
    const extern std::string confTiempoInput = "- Tiempo de ejecución\t> ";
 | 
					const extern std::string confHilosInput = "- Número de hilos\t> ";
 | 
				
			||||||
    const extern std::string confHilosError = "Se debe introducir un número";
 | 
					const extern std::string confTiempoInput = "- Tiempo de ejecución\t> ";
 | 
				
			||||||
    const extern std::string confTiempoError = "El formato del tiempo debe ser HH:mm:ss";
 | 
					const extern std::string confHilosError = "Se debe introducir un número";
 | 
				
			||||||
    const extern std::string confArchText_1 = "Archivo autogenerado por Stress_UI";
 | 
					const extern std::string confTiempoError =
 | 
				
			||||||
    const extern std::string confArchText_2 = "No editar manualmente sin saber lo que se hace";
 | 
					    "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_2 =
 | 
				
			||||||
 | 
					    "No editar manualmente sin saber lo que se hace";
 | 
				
			||||||
 | 
					} // namespace es
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#endif // __ES_HPP_
 | 
					#endif // __ES_HPP_
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -2,28 +2,30 @@
 | 
				
			|||||||
#ifndef __GL_HPP_
 | 
					#ifndef __GL_HPP_
 | 
				
			||||||
#define __GL_HPP_
 | 
					#define __GL_HPP_
 | 
				
			||||||
 | 
					
 | 
				
			||||||
namespace gl{
 | 
					namespace gl {
 | 
				
			||||||
    const extern std::string noColor = "O terminal non soporta cores";
 | 
					const extern std::string noColor = "O terminal non soporta cores";
 | 
				
			||||||
    const extern std::string errorGenerico_1 = "Como chegaches aquí?";
 | 
					const extern std::string errorGenerico_1 = "Como chegaches aquí?";
 | 
				
			||||||
    const extern std::string errorGenerico_2 = "Por si acaso imos ó menú principal";
 | 
					const extern std::string errorGenerico_2 = "Por si acaso imos ó 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";
 | 
				
			||||||
    const extern std::string menuPrincipal_3 = "- Saír";
 | 
					const extern std::string menuPrincipal_3 = "- Saír";
 | 
				
			||||||
    const extern std::string menuConfigurar = "Configuración";
 | 
					const extern std::string menuConfigurar = "Configuración";
 | 
				
			||||||
    const extern std::string menuConfigurar_1 = "- Configurar todo";
 | 
					const extern std::string menuConfigurar_1 = "- Configurar todo";
 | 
				
			||||||
    const extern std::string menuConfigurar_2 = "- Número de fíos";
 | 
					const extern std::string menuConfigurar_2 = "- Número de fíos";
 | 
				
			||||||
    const extern std::string menuConfigurar_3 = "- Tempo";
 | 
					const extern std::string menuConfigurar_3 = "- Tempo";
 | 
				
			||||||
    const extern std::string menuConfigurar_4 = "- Menú principal";
 | 
					const extern std::string menuConfigurar_4 = "- Menú principal";
 | 
				
			||||||
    const extern std::string confTodo = "Toda a configuración escribirase en ";
 | 
					const extern std::string confTodo = "Toda a configuración escribirase en ";
 | 
				
			||||||
    const extern std::string confHilos = "Número de fíos actuáis > ";
 | 
					const extern std::string confHilos = "Número de fíos actuáis > ";
 | 
				
			||||||
    const extern std::string confTiempo = "Tempo de execución actual > ";
 | 
					const extern std::string confTiempo = "Tempo de execución actual > ";
 | 
				
			||||||
    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 =
 | 
				
			||||||
    const extern std::string confArchText_1 = "Arquivo autoxenerado por Stress_UI";
 | 
					    "O formato do tempo debe ser HH:mm:ss";
 | 
				
			||||||
    const extern std::string confArchText_2 = "Non editar manualmente sin saber o que se fai";
 | 
					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";
 | 
				
			||||||
 | 
					} // namespace gl
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#endif // __GL_HPP_
 | 
					#endif // __GL_HPP_
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -2,30 +2,30 @@
 | 
				
			|||||||
#ifndef __TEXTOS_HPP_
 | 
					#ifndef __TEXTOS_HPP_
 | 
				
			||||||
#define __TEXTOS_HPP_
 | 
					#define __TEXTOS_HPP_
 | 
				
			||||||
 | 
					
 | 
				
			||||||
namespace txt{
 | 
					namespace txt {
 | 
				
			||||||
    extern std::string g_noColor;
 | 
					extern std::string g_noColor;
 | 
				
			||||||
    extern std::string g_errorGenerico_1;
 | 
					extern std::string g_errorGenerico_1;
 | 
				
			||||||
    extern std::string g_errorGenerico_2;
 | 
					extern std::string g_errorGenerico_2;
 | 
				
			||||||
    extern std::string g_menuPrincipal;
 | 
					extern std::string g_menuPrincipal;
 | 
				
			||||||
    extern std::string g_menuPrincipal_1;
 | 
					extern std::string g_menuPrincipal_1;
 | 
				
			||||||
    extern std::string g_menuPrincipal_2;
 | 
					extern std::string g_menuPrincipal_2;
 | 
				
			||||||
    extern std::string g_menuPrincipal_3;
 | 
					extern std::string g_menuPrincipal_3;
 | 
				
			||||||
    extern std::string g_menuConfigurar;
 | 
					extern std::string g_menuConfigurar;
 | 
				
			||||||
    extern std::string g_menuConfigurar_1;
 | 
					extern std::string g_menuConfigurar_1;
 | 
				
			||||||
    extern std::string g_menuConfigurar_2;
 | 
					extern std::string g_menuConfigurar_2;
 | 
				
			||||||
    extern std::string g_menuConfigurar_3;
 | 
					extern std::string g_menuConfigurar_3;
 | 
				
			||||||
    extern std::string g_menuConfigurar_4;
 | 
					extern std::string g_menuConfigurar_4;
 | 
				
			||||||
    extern std::string g_confTodo;
 | 
					extern std::string g_confTodo;
 | 
				
			||||||
    extern std::string g_confHilos;
 | 
					extern std::string g_confHilos;
 | 
				
			||||||
    extern std::string g_confTiempo;
 | 
					extern std::string g_confTiempo;
 | 
				
			||||||
    extern std::string g_confHilosInput;
 | 
					extern std::string g_confHilosInput;
 | 
				
			||||||
    extern std::string g_confTiempoInput;
 | 
					extern std::string g_confTiempoInput;
 | 
				
			||||||
    extern std::string g_confHilosError;
 | 
					extern std::string g_confHilosError;
 | 
				
			||||||
    extern std::string g_confTiempoError;
 | 
					extern std::string g_confTiempoError;
 | 
				
			||||||
    extern std::string g_confArchText_1;
 | 
					extern std::string g_confArchText_1;
 | 
				
			||||||
    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_
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -5,16 +5,27 @@
 | 
				
			|||||||
#define __UI_HPP_
 | 
					#define __UI_HPP_
 | 
				
			||||||
 | 
					
 | 
				
			||||||
namespace ui {
 | 
					namespace ui {
 | 
				
			||||||
    extern int g_maxLines, g_maxCols, g_begCol, g_begLine, g_menuWith;
 | 
					extern int g_maxLines, g_maxCols, g_begCol, g_begLine, g_menuWith;
 | 
				
			||||||
    //int8_t error;
 | 
					// int8_t error;
 | 
				
			||||||
    extern bool g_mensaje;
 | 
					extern bool g_mensaje;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    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,
 | 
				
			||||||
    void showTopTitle(const std::vector<std::string> *titulo);
 | 
					                                             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);
 | 
				
			||||||
} // 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; }
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										76
									
								
								src/main.cpp
									
									
									
									
									
								
							
							
						
						
									
										76
									
								
								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;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
@@ -89,9 +100,11 @@ void userInterface(const int8_t *num_menu, vector<string> *mensaje, Config *conf
 | 
				
			|||||||
  case PRIMER_INICIO: {
 | 
					  case PRIMER_INICIO: {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    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;
 | 
				
			||||||
@@ -25,10 +25,9 @@ std::string txt::g_confTiempoError;
 | 
				
			|||||||
std::string txt::g_confArchText_1;
 | 
					std::string txt::g_confArchText_1;
 | 
				
			||||||
std::string txt::g_confArchText_2;
 | 
					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;
 | 
				
			||||||
    txt::g_errorGenerico_1 = errorGenerico_1;
 | 
					    txt::g_errorGenerico_1 = errorGenerico_1;
 | 
				
			||||||
@@ -51,7 +50,7 @@ void txt::inicializarIdioma(std::string idioma){
 | 
				
			|||||||
    txt::g_confTiempoError = confTiempoError;
 | 
					    txt::g_confTiempoError = confTiempoError;
 | 
				
			||||||
    txt::g_confArchText_1 = confArchText_1;
 | 
					    txt::g_confArchText_1 = confArchText_1;
 | 
				
			||||||
    txt::g_confArchText_2 = confArchText_2;
 | 
					    txt::g_confArchText_2 = confArchText_2;
 | 
				
			||||||
    }else if(idioma == "es"){
 | 
					  } else if (idioma == "es") {
 | 
				
			||||||
    using namespace es;
 | 
					    using namespace es;
 | 
				
			||||||
    txt::g_noColor = noColor;
 | 
					    txt::g_noColor = noColor;
 | 
				
			||||||
    txt::g_errorGenerico_1 = errorGenerico_1;
 | 
					    txt::g_errorGenerico_1 = errorGenerico_1;
 | 
				
			||||||
@@ -74,7 +73,7 @@ void txt::inicializarIdioma(std::string idioma){
 | 
				
			|||||||
    txt::g_confTiempoError = confTiempoError;
 | 
					    txt::g_confTiempoError = confTiempoError;
 | 
				
			||||||
    txt::g_confArchText_1 = confArchText_1;
 | 
					    txt::g_confArchText_1 = confArchText_1;
 | 
				
			||||||
    txt::g_confArchText_2 = confArchText_2;
 | 
					    txt::g_confArchText_2 = confArchText_2;
 | 
				
			||||||
    }else if(idioma == "en"){
 | 
					  } else if (idioma == "en") {
 | 
				
			||||||
    using namespace en;
 | 
					    using namespace en;
 | 
				
			||||||
    txt::g_noColor = noColor;
 | 
					    txt::g_noColor = noColor;
 | 
				
			||||||
    txt::g_errorGenerico_1 = errorGenerico_1;
 | 
					    txt::g_errorGenerico_1 = errorGenerico_1;
 | 
				
			||||||
@@ -97,7 +96,7 @@ void txt::inicializarIdioma(std::string idioma){
 | 
				
			|||||||
    txt::g_confTiempoError = confTiempoError;
 | 
					    txt::g_confTiempoError = confTiempoError;
 | 
				
			||||||
    txt::g_confArchText_1 = confArchText_1;
 | 
					    txt::g_confArchText_1 = confArchText_1;
 | 
				
			||||||
    txt::g_confArchText_2 = confArchText_2;
 | 
					    txt::g_confArchText_2 = confArchText_2;
 | 
				
			||||||
    }else{
 | 
					  } else {
 | 
				
			||||||
    using namespace en;
 | 
					    using namespace en;
 | 
				
			||||||
    txt::g_noColor = noColor;
 | 
					    txt::g_noColor = noColor;
 | 
				
			||||||
    txt::g_errorGenerico_1 = errorGenerico_1;
 | 
					    txt::g_errorGenerico_1 = errorGenerico_1;
 | 
				
			||||||
@@ -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;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										31
									
								
								src/ui.cpp
									
									
									
									
									
								
							
							
						
						
									
										31
									
								
								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++) {
 | 
				
			||||||
@@ -83,24 +90,27 @@ vector<string> ui::showCentralInputBox(vector<string> *textos, const int8_t *num
 | 
				
			|||||||
    mvwprintw(centralBOX, i * 2 + 1 + textos->size(), 1, elems->at(i).c_str());
 | 
					    mvwprintw(centralBOX, i * 2 + 1 + textos->size(), 1, elems->at(i).c_str());
 | 
				
			||||||
    wrefresh(centralBOX);
 | 
					    wrefresh(centralBOX);
 | 
				
			||||||
    wgetnstr(centralBOX, input, 10);
 | 
					    wgetnstr(centralBOX, input, 10);
 | 
				
			||||||
    if (elems->at(i) == txt::g_confHilosInput){
 | 
					    if (elems->at(i) == txt::g_confHilosInput) {
 | 
				
			||||||
      regex integer_expr("(\\+|-)?[[:digit:]]+");
 | 
					      regex integer_expr("(\\+|-)?[[:digit:]]+");
 | 
				
			||||||
      if(regex_match(input, integer_expr)){
 | 
					      if (regex_match(input, integer_expr)) {
 | 
				
			||||||
        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_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