21#include "../kernel.hpp"
26int findParameter(
const std::string& sCmd,
const std::string& sParam,
const char cFollowing);
189 std::fstream Settings_ini;
199 if (Settings_ini.fail())
202 Settings_ini.close();
208 Settings_ini <<
"# NUMERE-CONFIG-1x-SERIES\n";
209 Settings_ini <<
"# =======================\n";
210 Settings_ini <<
"# !!! DO NOT MODIFY THIS FILE UNLESS YOU KNOW THE CONSEQUENCES!!!\n#\n";
211 Settings_ini <<
"# This file contains the configuration of NumeRe. This configuration is incompatible\n";
212 Settings_ini <<
"# to versions prior to v 1.1.2.\n";
213 Settings_ini <<
"# If you experience issues resulting form erroneous configurations, you may delete\n";
214 Settings_ini <<
"# this and all other INI files in this directory. Delete also the numere.ini.back\n";
215 Settings_ini <<
"# file for a complete reset. All configuration values will of course get lost during\n";
216 Settings_ini <<
"# this process.\n#\n";
217 Settings_ini <<
"# (relative paths are anchored in NumeRe's root directory):" << std::endl;
225 if (iter->second.shallSave())
228 Settings_ini << iter->first +
"=";
231 switch (iter->second.getType())
234 Settings_ini << (iter->second.active() ?
"true" :
"false") << std::endl;
237 Settings_ini << iter->second.value() << std::endl;
240 Settings_ini <<
replaceExePath(iter->second.stringval()) << std::endl;
249 Settings_ini <<
"#\n# End of configuration file" << std::endl;
252 Settings_ini.close();
270 std::string
id = sSettings.substr(0, sSettings.find(
'='));
271 std::string value = sSettings.substr(sSettings.find(
'=')+1);
280 switch (iter->second.getType())
283 iter->second.active() = value ==
"true" ? true :
false;
286 iter->second.value() = (size_t)
StrToInt(value);
289 iter->second.stringval() = value;
313 std::string sSavePath = _sOption.substr(_sOption.find(
'=')+1);
316 if (sSavePath.length())
318 while (sSavePath.find(
'\\') != std::string::npos)
319 sSavePath[sSavePath.find(
'\\')] =
'/';
327 std::string sLoadPath = _sOption.substr(_sOption.find(
'=')+1);
330 if (sLoadPath.length())
332 while (sLoadPath.find(
'\\') != std::string::npos)
333 sLoadPath[sLoadPath.find(
'\\')] =
'/';
341 std::string sPlotOutputPath = _sOption.substr(_sOption.find(
'=')+1);
344 if (sPlotOutputPath.length())
346 while (sPlotOutputPath.find(
'\\') != std::string::npos)
347 sPlotOutputPath[sPlotOutputPath.find(
'\\')] =
'/';
355 std::string sScriptpath = _sOption.substr(_sOption.find(
'=')+1);
358 if (sScriptpath.length())
360 while (sScriptpath.find(
'\\') != std::string::npos)
361 sScriptpath[sScriptpath.find(
'\\')] =
'/';
369 std::string sProcsPath = _sOption.substr(_sOption.find(
'=')+1);
372 if (sProcsPath.length())
374 while (sProcsPath.find(
'\\') != std::string::npos)
375 sProcsPath[sProcsPath.find(
'\\')] =
'/';
383 size_t nPrecision =
StrToInt(_sOption.substr(_sOption.find(
'=')+1));
385 if (nPrecision > 0 && nPrecision < 15)
413 std::string sDefaultfont = _sOption.substr(_sOption.find(
'=')+1);
415 if (sDefaultfont ==
"palatino")
416 sDefaultfont =
"pagella";
418 if (sDefaultfont ==
"times")
419 sDefaultfont =
"termes";
421 if (sDefaultfont ==
"bookman")
422 sDefaultfont =
"bonum";
424 if (sDefaultfont ==
"avantgarde")
425 sDefaultfont =
"adventor";
427 if (sDefaultfont ==
"chancery")
428 sDefaultfont =
"chorus";
430 if (sDefaultfont ==
"courier")
431 sDefaultfont =
"cursor";
433 if (sDefaultfont ==
"helvetica")
434 sDefaultfont =
"heros";
436 if (sDefaultfont ==
"pagella"
437 || sDefaultfont ==
"adventor"
438 || sDefaultfont ==
"bonum"
439 || sDefaultfont ==
"chorus"
440 || sDefaultfont ==
"cursor"
441 || sDefaultfont ==
"heros"
442 || sDefaultfont ==
"heroscn"
443 || sDefaultfont ==
"schola"
444 || sDefaultfont ==
"termes"
476 else if (
findParameter(_sOption,
"trytodecodeprocedurearguments",
'='))
498 size_t nAutoSaveInterval =
StrToInt(_sOption.substr(_sOption.find(
'=')+1));
500 if (nAutoSaveInterval)
508 size_t nBuffer_y = (size_t)
StrToInt(_sOption.substr(_sOption.find(
',')+1));
510 if (nBuffer_y >= 300)
518 size_t nWindow_x = (size_t)
StrToInt(_sOption.substr(_sOption.find(
'=')+1,_sOption.find(
',')));
519 size_t nWindow_y = (size_t)
StrToInt(_sOption.substr(_sOption.find(
',')+1));
521 if (nWindow_x >= 80 && nWindow_y >= 34)
555 std::string sReturn = _sPath;
557 if (sReturn.find(
sPath) != std::string::npos)
558 sReturn.replace(sReturn.find(
sPath),
sPath.length(),
"<>");
609 std::ifstream Settings_ini;
619 if (Settings_ini.fail())
621 Settings_ini.close();
622 Settings_ini.clear();
623 Settings_ini.open((
sExecutablePath+
".back").c_str(), std::ios_base::in);
625 if (Settings_ini.fail())
630 Settings_ini.close();
639 std::getline(Settings_ini,s);
643 if (Settings_ini.eof() || Settings_ini.fail())
649 if (s ==
"# NUMERE-CONFIG-1x-SERIES")
653 while (!Settings_ini.eof())
655 std::getline(Settings_ini, s);
658 if (!s.length() || s[0] ==
'#')
664 else if (s ==
"# NUMERE-CONFIG-09-SERIES")
668 while (!Settings_ini.eof())
670 std::getline(Settings_ini, s);
673 if (!s.length() || s[0] ==
'#')
689 std::getline(Settings_ini, s);
690 std::getline(Settings_ini, s);
692 std::getline(Settings_ini, s);
694 std::getline(Settings_ini, s);
697 if (!Settings_ini.eof())
699 for (
size_t i = 0; i < 6; i++)
700 std::getline(Settings_ini, s);
706 if (!Settings_ini.eof())
708 std::getline(Settings_ini, s);
709 std::getline(Settings_ini, s);
715 if (!Settings_ini.eof())
717 std::getline(Settings_ini, s);
718 std::getline(Settings_ini, s);
This class handles the documentation index and provides lookup functionalities to obtain the correspo...
std::string sExecutablePath
void setTokens(std::string _sTokens)
This member function may be used to update the path placeholders of the current FileSystem instance.
std::string get(const std::string &sMessage, const std::vector< std::string > &vTokens) const
This member function returns the language string for the passed language identifier and replaces all ...
static void printPreFmt(const std::string &__sLine, bool printingEnabled=true)
This member function appends the pre- formatted string to the buffer and informs the terminal that we...
static void print(const std::string &__sLine, bool printingEnabled=true)
This member function appends the passed string as a new output line to the buffer and informs the ter...
This class manages the setting values of the internal (kernel) settings of this application.
std::map< std::string, SettingsValue > m_settings
void import_v1x(const std::string &sSettings)
Imports a setting value string from a v1.x configuration file.
std::string getTokenPaths() const
Returns a semicolon-separated list of the current defined path placeholders and their values.
std::string sSettings_ini
Settings()
Settings class default constructor. Creates and fills the internal setting value map with their defau...
void prepareFilePaths(const std::string &_sExePath)
This member function is a helper, which will replace the <> path token in all default file paths with...
bool set(const std::string &)
Imports a setting value from a v0.9x configuration file.
void copySettings(const Settings &_settings)
This member function is an alias for the assignment operator overload.
std::string replaceExePath(const std::string &_sPath)
This member function is a helper, which will replace the executable path part in the passed file path...
void load(const std::string &_sWhere)
Opens the configuration file, identifies its version and imports the setting values.
void save(const std::string &_sWhere, bool bMkBackUp=false)
Saves the setting values to the corresponding config file. Does only save the setting values,...
This class represents a single abstract settings value implemented as void*. We're using asserts to a...
std::string toSystemCodePage(std::string)
Converts an internal to an external string. Does nothing currently.
CONSTCD11 std::enable_if<!std::chrono::treat_as_floating_point< T >::value, T >::type trunc(T t) NOEXCEPT
void StripSpaces(std::string &)
Removes leading and trailing white spaces and tabulator characters.
int StrToInt(const std::string &)
Converts a string into an integer.
int findParameter(const std::string &sCmd, const std::string &sParam, const char cFollowing)
This function searches the passed parameter in the passed command string. If something is found,...
#define SETTING_B_SMARTSENSE
#define SETTING_B_TOOLBARTEXT
#define DEFAULT_ST_DOCCOMMENT
#define DEFAULT_ST_ACTIVELINE
#define SETTING_B_SAVEBOOKMARKS
#define DEFAULT_ST_STANDARD
#define SETTING_B_ICONSONTABS
#define SETTING_S_ST_FUNCTION
#define SETTING_B_AN_CONSTANTS
#define SETTING_S_ST_CLUSTER
#define SETTING_B_AN_USEERRORS
#define SETTING_V_POS_SASH_T
#define SETTING_B_USEREVISIONS
#define SETTING_V_PRECISION
#define SETTING_S_ST_PROCCOMMAND
#define DEFAULT_ST_OPERATOR
#define SETTING_B_AN_GLOBALVARS
#define SETTING_B_AN_TYPING
#define DEFAULT_ST_PROCEDURE
#define SETTING_B_AN_PROCLENGTH
#define DEFAULT_ST_OPTION
#define DEFAULT_ST_FUNCTION
#define SETTING_B_GREETING
#define SETTING_B_AN_INLINEIF
#define SETTING_B_AN_START
#define SETTING_B_QUOTEAUTOCOMP
#define SETTING_B_BLOCKAUTOCOMP
#define SETTING_B_MASKDEFAULT
#define SETTING_S_PLOTFONT
#define DEFAULT_ST_CLUSTER
#define SETTING_B_FORMATBEFORESAVING
#define SETTING_S_ST_INCLUDES
#define SETTING_S_EDITORFONT
#define SETTING_S_LATEXROOT
#define SETTING_S_ST_ACTIVELINE
#define SETTING_S_ST_OPTION
#define DEFAULT_ST_NUMBER
#define SETTING_V_AUTOSAVE
#define DEFAULT_ST_COMMAND
#define SETTING_B_TABLEREFS
#define SETTING_V_FOCUSEDLINE
#define SETTING_S_ST_CUSTOMFUNC
#define SETTING_S_PROCPATH
#define SETTING_S_ST_INSTALL
#define SETTING_B_AN_COMMENTDENS
#define SETTING_B_COMPACT
#define SETTING_B_LINELENGTH
#define SETTING_B_AN_COMPLEXITY
#define SETTING_S_ST_METHODS
#define SETTING_B_EXTERNALDOCWINDOW
#define SETTING_B_AN_USENOTES
#define SETTING_S_ST_STRINGPARSER
#define SETTING_V_POS_SASH_V
#define SETTING_B_SAVESASHS
#define DEFAULT_ST_STRINGPARSER
#define SETTING_S_ST_START
#define SETTING_B_AN_UNDERSCOREARGS
#define SETTING_B_AN_THISFILE
#define SETTING_B_LOADEMPTYCOLS
#define SETTING_S_EXEPATH
#define SETTING_V_WINDOW_X
#define SETTING_B_AN_PROGRESS
#define SETTING_B_DEVELOPERMODE
#define DEFAULT_ST_INCLUDES
#define SETTING_B_USECUSTOMLANG
#define SETTING_B_AN_UNUSEDVARS
#define SETTING_S_LOADPATH
#define SETTING_B_PROCEDUREARGS
#define SETTING_S_ST_PROCEDURE
#define SETTING_B_AN_FALLTHROUGH
#define SETTING_B_PATHSONTABS
#define DEFAULT_ST_STRING
#define DEFAULT_ST_DEFVARS
#define SETTING_B_AN_ALWAYSMETRICS
#define SETTING_B_HIGHLIGHTLOCALS
#define SETTING_B_USETABS
#define DEFAULT_ST_SPECIALVAL
#define SETTING_S_ST_DOCKEYWORD
#define DEFAULT_ST_PROCCOMMAND
#define SETTING_S_ST_SPECIALVAL
#define SETTING_B_AN_VARLENGTH
#define DEFAULT_ST_METHODS
#define SETTING_S_HISTORYFONT
#define SETTING_B_EXTENDEDFILEINFO
#define SETTING_B_SAVEWINDOWSIZE
#define SETTING_B_AN_RESULTASS
#define SETTING_S_ST_COMMENT
#define SETTING_B_USEESCINSCRIPTS
#define SETTING_B_LINESINSTACK
#define SETTING_B_AUTOSAVEEXECUTION
#define SETTING_V_BUFFERSIZE
#define SETTING_S_ST_STANDARD
#define DEFAULT_ST_CONSOLESTD
#define SETTING_S_ST_STRING
#define SETTING_B_DECODEARGUMENTS
#define SETTING_V_WINDOW_Y
#define SETTING_S_SAVEPATH
#define SETTING_B_FLASHTASKBAR
#define SETTING_S_TERMINALFONT
#define SETTING_B_HOMEENDCANCELS
#define DEFAULT_ST_CUSTOMFUNC
#define DEFAULT_ST_CONSTANT
#define SETTING_B_SYSTEMPRINTS
#define SETTING_S_WINDOWSIZE
#define DEFAULT_ST_COMMENT
#define DEFAULT_ST_DOCKEYWORD
#define SETTING_B_ENABLEEXECUTE
#define SETTING_B_GLOBALVARS
#define SETTING_S_ST_DEFVARS
#define SETTING_B_DRAFTMODE
#define DEFAULT_ST_INSTALL
#define SETTING_S_ST_OPERATOR
#define SETTING_S_ST_NUMBER
#define SETTING_B_DEFCONTROL
#define SETTING_S_WORKPATH
#define SETTING_B_AN_RESULTSUP
#define SETTING_S_ST_COMMAND
#define SETTING_S_ST_CONSTANT
#define SETTING_B_MODULESINSTACK
#define SETTING_B_PRINTINCOLOR
#define SETTING_S_ST_CONSOLESTD
#define SETTING_B_SAVESESSION
#define SETTING_B_DEBUGGER
#define SETTING_S_PLOTPATH
#define SETTING_B_FOLDLOADEDFILE
#define SETTING_B_SHOWHINTS
#define SETTING_S_SCRIPTPATH
#define SETTING_B_AN_MISLEADINGTYPE
#define SETTING_B_PRINTLINENUMBERS
#define SETTING_B_AN_USEWARNINGS
#define SETTING_B_AN_MAGICNUMBERS
#define SETTING_V_CARETBLINKTIME
#define SETTING_B_LOGFILE
#define SETTING_S_ST_DOCCOMMENT
#define SETTING_B_BRACEAUTOCOMP
#define SETTING_V_POS_SASH_H