Orxonox  0.0.5 Codename: Arcturus
IOConsolePOSIX.h
Go to the documentation of this file.
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:
23  * Oliver Scheuss
24  * Reto Grieder
25  * Co-authors:
26  * ...
27  *
28  */
29 
35 #ifndef _IOConsole_H__
36 #define _IOConsole_H__
37 
38 #include "core/CorePrereqs.h"
39 
40 #include <sstream>
41 #include <string>
42 #include <vector>
43 #include "util/Singleton.h"
44 #include "Shell.h"
45 
46 struct termios;
47 
48 namespace orxonox
49 {
50  class _CoreExport IOConsole : public Singleton<IOConsole>, public ShellListener
51  {
52  friend class Singleton<IOConsole>;
53 
54  public:
55  IOConsole();
56  ~IOConsole();
57 
58  void preUpdate(const Clock& time);
59 
60  private:
61  void setTerminalMode();
62  void getTerminalSize();
63  void printStatusLines();
64  static int extractLogLevel(std::string* text);
65 
66  // Methods from ShellListener
67  virtual void linesChanged() override;
68  virtual void lineAdded() override;
69  virtual void inputChanged() override;
70  virtual void cursorChanged() override;
71  virtual void executed() override;
72  virtual void exit() override;
73 
74  bool willPrintStatusLines();
75  void printInputLine();
76  void printOutputLine(const std::string& line, Shell::LineType type);
77  static void resetTerminalMode();
78 
81  std::ostream cout_;
82  std::ostringstream origCout_;
88 
91  std::vector<int> statusLineWidths_;
93  static const int minOutputLines_ = 3;
95 
97  };
98 }
99 
100 #endif /* _IOConsole_H__ */
termios * originalTerminalSettings_
Definition: IOConsolePOSIX.h:94
int lastTerminalWidth_
Definition: IOConsolePOSIX.h:85
std::ostream cout_
Definition: IOConsolePOSIX.h:81
int terminalHeight_
Definition: IOConsolePOSIX.h:84
Shared library macros, enums, constants and forward declarations for the core library ...
::std::string string
Definition: gtest-port.h:756
int terminalWidth_
Definition: IOConsolePOSIX.h:83
Shell * shell_
Definition: IOConsolePOSIX.h:79
int statusLineMaxWidth_
Definition: IOConsolePOSIX.h:92
static IOConsole * singletonPtr_s
Definition: IOConsolePOSIX.h:96
The Shell is the logical component of the console that displays output to the user and allows him to ...
Definition: Shell.h:86
InputBuffer * buffer_
Definition: IOConsolePOSIX.h:80
const std::string promptString_
Definition: IOConsolePOSIX.h:87
Base for singleton classes.
Definition: Singleton.h:114
Die Wagnis Klasse hat die folgenden Aufgaben:
Definition: ApplicationPaths.cc:66
#define _CoreExport
Definition: CorePrereqs.h:61
std::ostringstream origCout_
Definition: IOConsolePOSIX.h:82
bool bStatusPrinted_
Definition: IOConsolePOSIX.h:90
int lastTerminalHeight_
Definition: IOConsolePOSIX.h:86
Definition of the Singleton template that is used as base class for classes that allow only one insta...
Simple real time clock based on Ogre::Timer.
Definition: Clock.h:57
LineType
Defines the type of a line of text in the Shell - some types depend on the output level...
Definition: Shell.h:90
An interface, used to get a notification if the state of the Shell changes.
Definition: Shell.h:58
Definition: InputBuffer.h:76
Definition: IOConsolePOSIX.h:50
Declaration of the Shell and ShellListener classes.
bool bPrintStatusLine_
Definition: IOConsolePOSIX.h:89
std::vector< int > statusLineWidths_
Definition: IOConsolePOSIX.h:91