Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'src/server/console.cc')
-rw-r--r--src/server/console.cc63
1 files changed, 26 insertions, 37 deletions
diff --git a/src/server/console.cc b/src/server/console.cc
index 3f32337..ab03c58 100644
--- a/src/server/console.cc
+++ b/src/server/console.cc
@@ -59,14 +59,15 @@ void Console::init()
init_pair(4, COLOR_BLUE, -1);
init_pair(5, COLOR_CYAN, -1);
init_pair(6, COLOR_MAGENTA, -1);
- init_pair(7, -1, -1);
+ init_pair(7, COLOR_WHITE, -1);
+ init_pair(8, -1, -1);
}
console_initialized = true;
console_updated = true;
#endif // HAVE_CURSES
- con_print << "Initializing console..." << std::endl;
+ con_print << "^BInitializing console..." << std::endl;
#ifdef HAVE_CURSES
server_console.history.clear();
@@ -80,7 +81,7 @@ void Console::init()
void Console::shutdown()
{
- con_print << "Shutting down console..." << std::endl;
+ con_print << "^BShutting down console..." << std::endl;
#ifdef HAVE_CURSES
server_console.draw();
@@ -91,15 +92,20 @@ void Console::shutdown()
#endif
}
+Console::Console()
+{
+}
+
+Console::~Console()
+{
+}
+
#ifdef HAVE_CURSES
void Console::dump()
{
- flush();
-
// dump console content
- for (std::deque<std::string>::iterator it = consoleinterface_text.begin(); it != consoleinterface_text.end(); it++) {
- print_ansi((*it).c_str());
- std::cout << std::endl;
+ for (Text::iterator it = log().begin(); it != log().end(); it++) {
+ sys::ConsoleInterface::print((*it));
}
}
@@ -114,23 +120,9 @@ void Console::resize()
draw();
}
-void Console::flush()
+void Console::print(const std::string & text)
{
- if (rcon())
- return;
-
- char line[MAXCMDSIZE];
-
- while(consoleinterface_buffer.getline(line, MAXCMDSIZE-1)) {
-
- while (consoleinterface_text.size() >= sys::MAXCONLINES) {
- consoleinterface_text.pop_front();
- }
- consoleinterface_text.push_back(std::string(line));
- console_updated = true;
- }
-
- consoleinterface_buffer.clear();
+ console_updated = true;
}
void Console::set_color(const char *color_code)
@@ -143,10 +135,10 @@ void Console::set_color(const char *color_code)
if (aux::is_base_color_code(color_code)) {
// base colors
- // Black=0, Red=1, Green=2, Yellow=3, Blue=4, Cyan=5, Magenta=6, White=7
+ // Default=0, Red=1, Green=2, Yellow=3, Blue=4, Cyan=5, Magenta=6, White=7
color = *(color_code+1) - '0';
- if (color == 3 || color == 0)
+ if (color == 3 || color == 7)
bold = true;
else
bold = false;
@@ -223,15 +215,15 @@ void Console::draw_text()
if ((w < 3) || (h < 3))
return;
- std::deque<std::string> lines;
+ Text lines;
int height = stdwin->_maxy - 1;
int width = stdwin->_maxx - 1;
- int bottom = (int) consoleinterface_text.size() - console_scroll;
+ int bottom = (int) log().size() - console_scroll;
int current_line = 0;
// parse console text, wrap long lines
- for (std::deque<std::string>::iterator it = consoleinterface_text.begin(); it != consoleinterface_text.end() && current_line < bottom; it++) {
+ for (Text::iterator it = log().begin(); it != log().end() && current_line < bottom; it++) {
if (current_line >= bottom - height) {
std::string linedata(*it);
linedata += '\n';
@@ -322,7 +314,7 @@ void Console::draw_text()
color_set(0, NULL);
attroff(A_BOLD);
- for (std::deque<std::string>::reverse_iterator rit = lines.rbegin(); (y > 0) && (rit != lines.rend()); ++rit) {
+ for (Text::reverse_iterator rit = lines.rbegin(); (y > 0) && (rit != lines.rend()); ++rit) {
const char *c = (*rit).c_str();
int x = 0;
@@ -366,20 +358,16 @@ void Console::draw()
wrefresh(stdwin);
console_updated = false;
- console_lastrefresh = 0;
}
void Console::frame(float seconds)
{
const size_t scroll_offset = 3;
- std::deque<std::string>::reverse_iterator upit;
-
- flush();
+ Text::reverse_iterator upit;
if (!console_initialized)
return;
- console_lastrefresh += seconds;
bool input_updated = false;
int key = wgetch(stdwin);
@@ -450,8 +438,8 @@ void Console::frame(float seconds)
break;
} else if (key == KEY_PPAGE) {
console_scroll += scroll_offset;
- if (console_scroll > consoleinterface_text.size())
- console_scroll = consoleinterface_text.size();
+ if (console_scroll > log().size())
+ console_scroll = log().size();
console_updated = true;
break;
} else if (key == KEY_NPAGE) {
@@ -487,6 +475,7 @@ void Console::frame(float seconds)
if (input_updated) {
// move the cursor to input position
move(stdwin->_maxy, 1 + input_pos);
+ wrefresh(stdwin);
}
}
}