[5971] | 1 | /* |
---|
| 2 | * ORXONOX - the hottest 3D action shooter ever to exist |
---|
| 3 | * > www.orxonox.net < |
---|
| 4 | * |
---|
| 5 | * |
---|
| 6 | * License notice: |
---|
| 7 | * |
---|
| 8 | * This program is free software; you can redistribute it and/or |
---|
| 9 | * modify it under the terms of the GNU General Public License |
---|
| 10 | * as published by the Free Software Foundation; either version 2 |
---|
| 11 | * of the License, or (at your option) any later version. |
---|
| 12 | * |
---|
| 13 | * This program is distributed in the hope that it will be useful, |
---|
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
| 16 | * GNU General Public License for more details. |
---|
| 17 | * |
---|
| 18 | * You should have received a copy of the GNU General Public License |
---|
| 19 | * along with this program; if not, write to the Free Software |
---|
| 20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
---|
| 21 | * |
---|
| 22 | * Author: |
---|
[5968] | 23 | * Oliver Scheuss |
---|
| 24 | * Reto Grieder |
---|
[5971] | 25 | * Co-authors: |
---|
| 26 | * ... |
---|
| 27 | * |
---|
| 28 | */ |
---|
| 29 | |
---|
| 30 | #ifndef _IOConsole_H__ |
---|
| 31 | #define _IOConsole_H__ |
---|
| 32 | |
---|
[7287] | 33 | #include "core/CorePrereqs.h" |
---|
[5971] | 34 | |
---|
[6037] | 35 | #include <sstream> |
---|
[6015] | 36 | #include <string> |
---|
| 37 | #include <vector> |
---|
[5971] | 38 | #include "util/Singleton.h" |
---|
[6746] | 39 | #include "Shell.h" |
---|
[5971] | 40 | |
---|
| 41 | struct termios; |
---|
| 42 | |
---|
| 43 | namespace orxonox |
---|
| 44 | { |
---|
| 45 | class _CoreExport IOConsole : public Singleton<IOConsole>, public ShellListener |
---|
| 46 | { |
---|
| 47 | friend class Singleton<IOConsole>; |
---|
| 48 | |
---|
| 49 | public: |
---|
| 50 | IOConsole(); |
---|
| 51 | ~IOConsole(); |
---|
| 52 | |
---|
[6417] | 53 | void preUpdate(const Clock& time); |
---|
[5971] | 54 | |
---|
| 55 | private: |
---|
| 56 | void setTerminalMode(); |
---|
[6013] | 57 | void getTerminalSize(); |
---|
[5995] | 58 | void printStatusLines(); |
---|
[6417] | 59 | static int extractLogLevel(std::string* text); |
---|
[5971] | 60 | |
---|
| 61 | // Methods from ShellListener |
---|
| 62 | void linesChanged(); |
---|
| 63 | void onlyLastLineChanged(); |
---|
| 64 | void lineAdded(); |
---|
| 65 | void inputChanged(); |
---|
| 66 | void cursorChanged(); |
---|
[5983] | 67 | void executed(); |
---|
[5971] | 68 | void exit(); |
---|
[6417] | 69 | |
---|
[7287] | 70 | bool willPrintStatusLines(); |
---|
| 71 | void printInputLine(); |
---|
| 72 | void printOutputLine(const std::string& line, Shell::LineType type); |
---|
| 73 | static void resetTerminalMode(); |
---|
| 74 | |
---|
[6004] | 75 | Shell* shell_; |
---|
[5971] | 76 | InputBuffer* buffer_; |
---|
[6037] | 77 | std::ostream cout_; |
---|
| 78 | std::ostringstream origCout_; |
---|
[6417] | 79 | int terminalWidth_; |
---|
| 80 | int terminalHeight_; |
---|
| 81 | int lastTerminalWidth_; |
---|
| 82 | int lastTerminalHeight_; |
---|
[6010] | 83 | const std::string promptString_; |
---|
[5971] | 84 | |
---|
[6417] | 85 | bool bPrintStatusLine_; |
---|
| 86 | bool bStatusPrinted_; |
---|
| 87 | std::vector<int> statusLineWidths_; |
---|
| 88 | int statusLineMaxWidth_; |
---|
| 89 | static const int minOutputLines_ = 3; |
---|
[6015] | 90 | termios* originalTerminalSettings_; |
---|
[6417] | 91 | |
---|
[5971] | 92 | static IOConsole* singletonPtr_s; |
---|
| 93 | }; |
---|
| 94 | } |
---|
| 95 | |
---|
| 96 | #endif /* _IOConsole_H__ */ |
---|