Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStijn Buys <ingar@osirion.org>2008-10-06 18:18:30 +0000
committerStijn Buys <ingar@osirion.org>2008-10-06 18:18:30 +0000
commit094221dae7b094bf0d61128634a00d52b265b0d5 (patch)
tree666f7f3708b273e8254269a77460fa62f5a76a1d /src/server
parente8b466caefa3b0b3b70458035d1c52e9fd9c0662 (diff)
pgup pgdn scrolling for the ncurses server console
Diffstat (limited to 'src/server')
-rw-r--r--src/server/console.cc19
-rw-r--r--src/server/console.h3
2 files changed, 17 insertions, 5 deletions
diff --git a/src/server/console.cc b/src/server/console.cc
index 0fe874e..3f32337 100644
--- a/src/server/console.cc
+++ b/src/server/console.cc
@@ -47,7 +47,7 @@ void Console::init()
keypad(stdwin, TRUE); // enable special keys
nodelay(stdwin, TRUE); // non-blocking input
curs_set(1); // enable cursor
-
+
if (has_colors() == TRUE) {
start_color();
// this is ncurses-specific
@@ -73,7 +73,7 @@ void Console::init()
server_console.history.push_back("");
server_console.history_pos = server_console.history.rbegin();
server_console.input_pos = 0;
-
+ server_console.console_scroll = 0;
server_console.draw();
#endif // HAVE_CURSES
}
@@ -225,9 +225,8 @@ void Console::draw_text()
std::deque<std::string> lines;
- int console_scroll = 0;
int height = stdwin->_maxy - 1;
- int width = stdwin->_maxx - 1;
+ int width = stdwin->_maxx - 1;
int bottom = (int) consoleinterface_text.size() - console_scroll;
int current_line = 0;
@@ -372,6 +371,7 @@ void Console::draw()
void Console::frame(float seconds)
{
+ const size_t scroll_offset = 3;
std::deque<std::string>::reverse_iterator upit;
flush();
@@ -449,7 +449,18 @@ 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();
+ console_updated = true;
+ break;
} else if (key == KEY_NPAGE) {
+ if (console_scroll > scroll_offset)
+ console_scroll -= scroll_offset;
+ else
+ console_scroll = 0;
+ console_updated = true;
+ break;
} else if ((key >= 32) && (key < 127) && ((*history_pos).size() < MAXCMDSIZE)) {
if (input_pos == (*history_pos).size()) {
(*history_pos) += (char)key;
diff --git a/src/server/console.h b/src/server/console.h
index 9cfe604..bf77ecd 100644
--- a/src/server/console.h
+++ b/src/server/console.h
@@ -25,6 +25,7 @@ public:
virtual void resize();
/// run one console frame
void frame(float seconds);
+
protected:
/// draw the ncurses console
void draw();
@@ -50,7 +51,7 @@ private:
std::deque<std::string>::reverse_iterator history_pos;
size_t input_pos;
-
+ size_t console_scroll;
#endif
};