+public:
+ Console();
+ ~Console();
+
+ static Console* instance;
+
+ static std::ostream output; /**< stream of characters to output to the console. Do not forget to send std::endl or to flush the stream. */
+
+ void init_graphics();
+
+ void input(char c); /**< add character to inputBuffer */
+ void backspace(); /**< delete character left of inputBufferPosition */
+ void eraseChar(); /**< delete character at inputBufferPosition */
+ void enter(); /**< process and clear input stream */
+ void scroll(int offset); /**< scroll console text up or down by @c offset lines */
+ void autocomplete(); /**< autocomplete current command */
+ void show_history(int offset); /**< move @c offset lines forward through history; Negative offset moves backward */
+ void move_cursor(int offset); /**< move the cursor @c offset chars to the right; Negative offset moves backward; 0xFFFF moves to the end */
+
+ void draw(DrawingContext& context); /**< draw the console in a DrawingContext */
+ void update(float elapsed_time);
+
+ void show(); /**< display the console */
+ void hide(); /**< hide the console */
+ void toggle(); /**< display the console if hidden, hide otherwise */
+
+ bool hasFocus(); /**< true if characters should be sent to the console instead of their normal target */
+
+ template<typename T> static bool string_is(std::string s) {
+ std::istringstream iss(s);
+ T i;
+ if ((iss >> i) && iss.eof()) {
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ template<typename T> static T string_to(std::string s) {
+ std::istringstream iss(s);
+ T i;
+ if ((iss >> i) && iss.eof()) {
+ return i;
+ } else {
+ return T();
+ }
+ }
+
+private:
+ std::list<std::string> history; /**< command history. New lines get added to back. */
+ std::list<std::string>::iterator history_position; /**< item of command history that is currently displayed */
+ std::list<std::string> lines; /**< backbuffer of lines sent to the console. New lines get added to front. */
+
+ std::auto_ptr<Surface> background; /**< console background image */
+ std::auto_ptr<Surface> background2; /**< second, moving console background image */
+
+ HSQUIRRELVM vm; /**< squirrel thread for the console (with custom roottable) */
+ HSQOBJECT vm_object;