Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/trunk/src/libraries/core/IOConsole.h @ 6271

Last change on this file since 6271 was 6105, checked in by rgrieder, 15 years ago

Merged console branch back to trunk.

  • Property svn:eol-style set to native
File size: 2.8 KB
Line 
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
30#ifndef _IOConsole_H__
31#define _IOConsole_H__
32
33#include "CorePrereqs.h"
34
35#include <sstream>
36#include <string>
37#include <vector>
38#include "util/Singleton.h"
39#include "core/Shell.h"
40
41#ifdef ORXONOX_PLATFORM_UNIX
42struct termios;
43#endif
44
45namespace orxonox
46{
47    class _CoreExport IOConsole : public Singleton<IOConsole>, public ShellListener
48    {
49        friend class Singleton<IOConsole>;
50
51    public:
52        IOConsole();
53        ~IOConsole();
54
55        void update(const Clock& time);
56
57    private:
58        void setTerminalMode();
59        void resetTerminalMode();
60        void getTerminalSize();
61        bool willPrintStatusLines();
62        int extractLogLevel(std::string* text);
63
64        void printLogText(const std::string& line);
65        void printInputLine();
66        void printStatusLines();
67
68        // Methods from ShellListener
69        void linesChanged();
70        void onlyLastLineChanged();
71        void lineAdded();
72        void inputChanged();
73        void cursorChanged();
74        void executed();
75        void exit();
76        Shell*                  shell_;
77        InputBuffer*            buffer_;
78        std::ostream            cout_;
79        std::ostringstream      origCout_;
80        unsigned int            terminalWidth_;
81        unsigned int            terminalHeight_;
82        unsigned int            lastTerminalWidth_;
83        unsigned int            lastTerminalHeight_;
84        bool                    bPrintStatusLine_;
85        bool                    bStatusPrinted_;
86        std::vector<unsigned>   statusLineWidths_;
87        unsigned int            statusLineMaxWidth_;
88        const std::string       promptString_;
89        static const unsigned   minOutputLines_ = 3;
90
91#ifdef ORXONOX_PLATFORM_UNIX
92        termios*                originalTerminalSettings_;
93#endif
94
95        static IOConsole* singletonPtr_s;
96    };
97}
98
99#endif /* _IOConsole_H__ */
Note: See TracBrowser for help on using the repository browser.