Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'src/ui/console.cc')
-rw-r--r--src/ui/console.cc131
1 files changed, 66 insertions, 65 deletions
diff --git a/src/ui/console.cc b/src/ui/console.cc
index 4fcba7d..c486c65 100644
--- a/src/ui/console.cc
+++ b/src/ui/console.cc
@@ -1,7 +1,7 @@
/*
client/console.cc
- This file is part of the Osirion project and is distributed under
- the terms and conditions of the GNU General Public License version 2
+ This file is part of the Osirion project and is distributed under
+ the terms and conditions of the GNU General Public License version 2
*/
#include <iostream>
@@ -18,7 +18,8 @@
#include "ui/console.h"
#include "ui/paint.h"
-namespace ui {
+namespace ui
+{
const float DEFAULT_CONSOLE_HEIGHT = 0.7f;
const size_t DEFAULT_MAX_HISTO_LINES = 512;
@@ -29,7 +30,7 @@ ConsoleBuffer Console::con_buffer;
/* -- ConsoleBuffer ------------------------------------------------ */
ConsoleBuffer::ConsoleBuffer() : sys::ConsoleInterface()
{
- //con_print << "^BInitializing console..." << std::endl;
+ //con_print << "^BInitializing console..." << std::endl;
}
@@ -109,64 +110,64 @@ bool Console::on_keypress(const int key, const unsigned int modifier)
ui::Text::reverse_iterator upit;
- switch( key ) {
-
- case SDLK_ESCAPE:
- if (visible()) {
- hide();
+ switch (key) {
+
+ case SDLK_ESCAPE:
+ if (visible()) {
+ hide();
+ return true;
+ } else {
+ return false;
+ }
+ break;
+ /*
+ case SDLK_TAB:
+ core::CommandBuffer::complete( (*history_pos), input_pos);
+ return true;
+ break;
+ */
+ case SDLK_RETURN:
+ if (console_input->text().size()) {
+ // store input in history
+ while (history.size() >= DEFAULT_MAX_HISTO_LINES) {
+ history.pop_front();
+ }
+ core::cmd() << console_input->text() << std::endl;
+ con_print << "^B>" << console_input->text() << std::endl;
+ (*history.rbegin()).assign(console_input->text());
+ history.push_back("");
+ history_pos = history.rbegin();
+ console_input->set_text((*history_pos));
+ }
return true;
- } else {
- return false;
- }
- break;
-/*
- case SDLK_TAB:
- core::CommandBuffer::complete( (*history_pos), input_pos);
- return true;
- break;
-*/
- case SDLK_RETURN:
- if (console_input->text().size()) {
- // store input in history
- while (history.size() >= DEFAULT_MAX_HISTO_LINES) {
- history.pop_front();
+ break;
+
+ case SDLK_UP:
+ upit = history_pos;
+ ++upit;
+ if (upit != history.rend()) {
+ history_pos = upit;
+ console_input->set_text((*history_pos));
}
- core::cmd() << console_input->text() << std::endl;
- con_print << "^B>" << console_input->text() << std::endl;
- (*history.rbegin()).assign(console_input->text());
- history.push_back("");
- history_pos = history.rbegin();
- console_input->set_text((*history_pos));
- }
- return true;
- break;
-
- case SDLK_UP:
- upit = history_pos;
- ++upit;
- if (upit != history.rend()) {
- history_pos = upit;
- console_input->set_text((*history_pos));
- }
- return true;
- break;
- case SDLK_DOWN:
- if (history_pos != history.rbegin()) {
- --history_pos;
- console_input->set_text((*history_pos));
- }
- return true;
- break;
- case 512 + SDL_BUTTON_WHEELUP:
- case SDLK_PAGEUP:
- console_scrollpane->inc_scroll(scroll_offset);
- return true;
- break;
- case 512 + SDL_BUTTON_WHEELDOWN:
- case SDLK_PAGEDOWN:
- console_scrollpane->dec_scroll(scroll_offset);
- return true;
- break;
+ return true;
+ break;
+ case SDLK_DOWN:
+ if (history_pos != history.rbegin()) {
+ --history_pos;
+ console_input->set_text((*history_pos));
+ }
+ return true;
+ break;
+ case 512 + SDL_BUTTON_WHEELUP:
+ case SDLK_PAGEUP:
+ console_scrollpane->inc_scroll(scroll_offset);
+ return true;
+ break;
+ case 512 + SDL_BUTTON_WHEELDOWN:
+ case SDLK_PAGEDOWN:
+ console_scrollpane->dec_scroll(scroll_offset);
+ return true;
+ break;
}
return false;
@@ -186,8 +187,8 @@ void Console::draw()
console_scrollpane->set_location(4, 4);
console_scrollpane->set_size(s.width(), s.height() - font()->height());
-
- console_input->set_location(4, height() - font()->height() -4);
+
+ console_input->set_location(4, height() - font()->height() - 4);
console_input->set_size(s.width(), font()->height());
math::Color fancy(palette()->fancy());
@@ -196,8 +197,8 @@ void Console::draw()
std::string version(core::name() + ' ' + core::version());
s.assign(version.size() * font()->width(), font()->height());
math::Vector2f l(global_location());
- l[0] += width() - s.width() -4;
- l[1] += height() - s.height() -4;
+ l[0] += width() - s.width() - 4;
+ l[1] += height() - s.height() - 4;
paint::text(l, s, font(), version);
}
@@ -238,7 +239,7 @@ void Console::load_history()
history.clear();
char line[MAXCMDSIZE];
- while (ifs.getline(line, MAXCMDSIZE-1)) {
+ while (ifs.getline(line, MAXCMDSIZE - 1)) {
history.push_back(line);
}