Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--osirion.kdevelop.pcsbin298592 -> 302061 bytes
-rw-r--r--osirion.kdevses28
-rw-r--r--src/client/console.cc58
-rw-r--r--src/client/console.h6
-rw-r--r--src/core/commandbuffer.cc28
-rw-r--r--src/render/tga.cc2
6 files changed, 107 insertions, 15 deletions
diff --git a/osirion.kdevelop.pcs b/osirion.kdevelop.pcs
index cca6c43..7285ff5 100644
--- a/osirion.kdevelop.pcs
+++ b/osirion.kdevelop.pcs
Binary files differ
diff --git a/osirion.kdevses b/osirion.kdevses
index 95b3884..c801edd 100644
--- a/osirion.kdevses
+++ b/osirion.kdevses
@@ -1,13 +1,31 @@
<?xml version = '1.0' encoding = 'UTF-8'?>
<!DOCTYPE KDevPrjSession>
<KDevPrjSession>
- <DocsAndViews NumberOfDocuments="2" >
- <Doc0 NumberOfViews="1" URL="file:///home/ingar/projects/osirion/osirion-work/src/client/video.cc" >
- <View0 Encoding="" Type="Source" />
+ <DocsAndViews NumberOfDocuments="8" >
+ <Doc0 NumberOfViews="1" URL="file:///home/ingar/projects/osirion/osirion-work/src/render/render.cc" >
+ <View0 Encoding="" line="22" Type="Source" />
</Doc0>
- <Doc1 NumberOfViews="1" URL="file:///home/ingar/projects/osirion/osirion-work/src/core/cvar.cc" >
- <View0 Encoding="" line="81" Type="Source" />
+ <Doc1 NumberOfViews="1" URL="file:///home/ingar/projects/osirion/osirion-work/src/render/tga.h" >
+ <View0 Encoding="" line="0" Type="Source" />
</Doc1>
+ <Doc2 NumberOfViews="1" URL="file:///home/ingar/projects/osirion/osirion-work/src/render/tga.cc" >
+ <View0 Encoding="" line="76" Type="Source" />
+ </Doc2>
+ <Doc3 NumberOfViews="1" URL="file:///home/ingar/projects/osirion/osirion-work/src/core/commandbuffer.cc" >
+ <View0 Encoding="" line="76" Type="Source" />
+ </Doc3>
+ <Doc4 NumberOfViews="1" URL="file:///home/ingar/projects/osirion/osirion-work/src/client/console.cc" >
+ <View0 Encoding="" line="201" Type="Source" />
+ </Doc4>
+ <Doc5 NumberOfViews="1" URL="file:///home/ingar/projects/osirion/osirion-work/src/core/cvar.h" >
+ <View0 Encoding="" line="10" Type="Source" />
+ </Doc5>
+ <Doc6 NumberOfViews="1" URL="file:///home/ingar/projects/osirion/osirion-work/src/core/func.h" >
+ <View0 Encoding="" line="12" Type="Source" />
+ </Doc6>
+ <Doc7 NumberOfViews="1" URL="file:///home/ingar/projects/osirion/osirion-work/src/core/commandbuffer.h" >
+ <View0 Encoding="" line="29" Type="Source" />
+ </Doc7>
</DocsAndViews>
<pluginList>
<kdevdebugger>
diff --git a/src/client/console.cc b/src/client/console.cc
index 71f3d5a..01f90da 100644
--- a/src/client/console.cc
+++ b/src/client/console.cc
@@ -4,13 +4,15 @@
the terms and conditions of the GNU General Public License version 2
*/
+#include "filesystem/filesystem.h"
+#include "core/core.h"
+#include "render/render.h"
#include "client/console.h"
#include "client/video.h"
#include "client/keyboard.h"
-#include "core/core.h"
-#include "render/render.h"
#include <iostream>
+#include <fstream>
#include <cmath>
namespace client {
@@ -79,12 +81,16 @@ void init()
history.push_back("");
history_pos = history.rbegin();
input_pos = 0;
+
+ load_history();
}
void shutdown()
{
con_print << "Shutting down console..." << std::endl;
+ save_history();
+
// remove engine functions
core::func::remove("con_toggle");
@@ -282,6 +288,54 @@ bool visible()
return console_visible;
}
+void save_history()
+{
+
+ if (history.size() <= 1)
+ return;
+
+ std::string filename(filesystem::writedir);
+ filename.append("history.txt");
+ std::ofstream ofs(filename.c_str());
+
+ if (!ofs.is_open()) {
+ con_warn << "Could not write " << filename << std::endl;
+ return;
+ }
+ std::deque<std::string>::iterator it;
+ size_t l = 1;
+ for (it = history.begin(); it != history.end(); it++) {
+ if (l < history.size())
+ ofs << (*it) << std::endl;
+ l++;
+ }
+
+ ofs.close();
+}
+
+void load_history()
+{
+ std::string filename(filesystem::writedir);
+ filename.append("history.txt");
+ std::ifstream ifs(filename.c_str(), std::ifstream::in);
+
+ if (!ifs.is_open()) {
+ con_warn << "Could not read " << filename << std::endl;
+ return;
+ }
+
+ history.clear();
+ char line[MAXCMDSIZE];
+ while (ifs.getline(line, MAXCMDSIZE-1)) {
+ history.push_back(line);
+ }
+
+ ifs.close();
+
+ history.push_back("");
+ history_pos = history.rbegin();
+ input_pos = 0;
+}
//--- private -----------------------------------------------------
std::ostream & Console::messagestream()
diff --git a/src/client/console.h b/src/client/console.h
index e848720..e96c0d4 100644
--- a/src/client/console.h
+++ b/src/client/console.h
@@ -47,6 +47,12 @@ void keypressed(const SDL_keysym &keysym);
/// true of the console is visible
bool visible();
+/// load input history
+void load_history();
+
+/// save input history
+void save_history();
+
}
}
diff --git a/src/core/commandbuffer.cc b/src/core/commandbuffer.cc
index a46863c..965f428 100644
--- a/src/core/commandbuffer.cc
+++ b/src/core/commandbuffer.cc
@@ -102,16 +102,30 @@ void complete(std::string &input, size_t &pos)
if (!match.size())
return;
+
+ std::string maxmatch(*match.begin());
- if (match.size() == 1) {
+ if (match.size() > 1) {
std::list<std::string>::iterator l;
- l = match.begin();
- input.replace(0, pos, (*l));
- pos = (*l).size();
- } else {
- std::list<std::string>::iterator l;
- for (l = match.begin(); l !=match.end(); l++)
+ for (l = match.begin(); l !=match.end(); l++) {
+ if (maxmatch.size()) {
+ size_t i =0;
+ while ((i < maxmatch.size() && i < (*l).size()) && (maxmatch[i] == (*l)[i])) {
+ i++;
+ }
+ if (i < maxmatch.size())
+ maxmatch.erase(i);
+ }
con_print << " " << (*l) << std::endl;
+ }
+ con_print << match.size() << " matches" << std::endl;
+
+ }
+
+ if (maxmatch.size() > partial.size()) {
+ if (match.size()==1) maxmatch += ' ';
+ input.replace(0, pos, maxmatch);
+ pos = maxmatch.size();
}
}
diff --git a/src/render/tga.cc b/src/render/tga.cc
index 3584566..18236fa 100644
--- a/src/render/tga.cc
+++ b/src/render/tga.cc
@@ -74,7 +74,7 @@ TGA::image *TGA::load(const char *filename)
f->read((void *)&bits, sizeof(GLubyte));
f->skip(length +1);
- con_debug << " TGA loading " << width << "x" << height << " " << (int) bits << "bpp" << std::endl;
+ con_debug << " " << filename << " " << width << "x" << height << "x" << (int) bits << "bpp" << std::endl;
if (imgType != TGA_RLE) {
// Check for 24 or 32 Bit