static Console* instance;
- static std::ostream input; /**< stream of keyboard input to send to the console. Do not forget to send std::endl or to flush the stream. */
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 backspace(); /**< delete last character sent to the input stream */
+ 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 toggle(); /**< display the console if hidden, hide otherwise */
bool hasFocus(); /**< true if characters should be sent to the console instead of their normal target */
- void registerCommand(std::string command, ConsoleCommandReceiver* ccr); /**< associate command with the given CCR */
- void unregisterCommand(std::string command, ConsoleCommandReceiver* ccr); /**< dissociate command and CCR */
- void unregisterCommands(ConsoleCommandReceiver* ccr); /**< dissociate all commands of given CCR */
template<typename T> static bool string_is(std::string s) {
std::istringstream iss(s);
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::map<std::string, std::list<ConsoleCommandReceiver*> > commands; /**< map of console commands and a list of associated ConsoleCommandReceivers */
std::auto_ptr<Surface> background; /**< console background image */
std::auto_ptr<Surface> background2; /**< second, moving console background image */
float stayOpen;
- static ConsoleStreamBuffer inputBuffer; /**< stream buffer used by input stream */
+ static int inputBufferPosition; /**< position in inputBuffer before which to append new characters */
+ static std::string inputBuffer; /**< string used for keyboard input */
static ConsoleStreamBuffer outputBuffer; /**< stream buffer used by output stream */
void addLines(std::string s); /**< display a string of (potentially) multiple lines in the console */
}
};
-class ConsoleCommandReceiver
-{
-public:
- virtual ~ConsoleCommandReceiver()
- {
- Console::instance->unregisterCommands(this);
- }
-
- /**
- * callback from Console; return false if command was unknown,
- * true otherwise
- */
- virtual bool consoleCommand(std::string command, std::vector<std::string> arguments) = 0;
-};
-
#endif