diff --git a/celestia.cfg b/celestia.cfg index fb1268ff..7444d58e 100644 --- a/celestia.cfg +++ b/celestia.cfg @@ -326,6 +326,13 @@ StarTextures # IgnoreGLExtensions [ "GL_ARB_vertex_program" ] +#------------------------------------------------------------------------ +# The number of rows in the debug log (displayable onscreen by pressing +# the ~ (tilde). The default log size is 200. +#------------------------------------------------------------------------ +# LogSize 1000 + + #------------------------------------------------------------------------ # The LabelledStars section defines which stars will have text labels # assigned to them, which are visible when this option is turned on. diff --git a/src/celengine/console.cpp b/src/celengine/console.cpp index 46abebc2..d68db601 100644 --- a/src/celengine/console.cpp +++ b/src/celengine/console.cpp @@ -10,6 +10,7 @@ #include #include #include +#include #include "celutil/utf8.h" #include "gl.h" #include "vecgl.h" @@ -52,6 +53,32 @@ Console::~Console() } +/*! Resize the console log to use the specified number of rows. + * Old long entries are preserved in the resize. setRowCount() + * returns true if it was able to successfully allocate a new + * buffer, and false if there was a problem (out of memory.) + */ +bool Console::setRowCount(int _nRows) +{ + wchar_t* newText = new wchar_t[(nColumns + 1) * _nRows]; + if (newText == NULL) + return false; + + for (int i = 0; i < _nRows; i++) + { + newText[(nColumns + 1) * i] = '\0'; + } + + std::copy(newText, newText + (nColumns + 1) * min(_nRows, nRows), text); + + delete[] text; + text = newText; + nRows = _nRows; + + return true; +} + + void Console::begin() { glMatrixMode(GL_PROJECTION); diff --git a/src/celengine/console.h b/src/celengine/console.h index d69352f3..37c91105 100644 --- a/src/celengine/console.h +++ b/src/celengine/console.h @@ -47,6 +47,8 @@ class Console : public std::ostream Console(int _nRows, int _nColumns); ~Console(); + bool setRowCount(int _nRows); + void begin(); void end(); void render(int rowHeight); diff --git a/src/celestia/celestiacore.cpp b/src/celestia/celestiacore.cpp index 665008f0..1af95225 100644 --- a/src/celestia/celestiacore.cpp +++ b/src/celestia/celestiacore.cpp @@ -3969,6 +3969,10 @@ bool CelestiaCore::initSimulation(const string* configFileName, return false; } + // Set the console log size; ignore any request to use less than 100 lines + if (config->consoleLogRows > 100) + console.setRowCount(config->consoleLogRows); + #ifdef USE_SPICE if (!InitializeSpice()) { diff --git a/src/celestia/configfile.cpp b/src/celestia/configfile.cpp index e85dd56a..edf74d94 100644 --- a/src/celestia/configfile.cpp +++ b/src/celestia/configfile.cpp @@ -131,6 +131,8 @@ CelestiaConfig* ReadCelestiaConfig(string filename, CelestiaConfig *config) config->shadowTextureSize = getUint(configParams, "ShadowTextureSize", 256); config->eclipseTextureSize = getUint(configParams, "EclipseTextureSize", 128); + config->consoleLogRows = getUint(configParams, "LogSize", 200); + Value* solarSystemsVal = configParams->getValue("SolarSystemCatalogs"); if (solarSystemsVal != NULL) { diff --git a/src/celestia/configfile.h b/src/celestia/configfile.h index 7f3c4d6c..b91a44e2 100644 --- a/src/celestia/configfile.h +++ b/src/celestia/configfile.h @@ -63,6 +63,8 @@ public: unsigned int aaSamples; bool hdr; + + unsigned int consoleLogRows; Hash* params;