Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/trunk/src/libraries/core/command/IOConsoleWindows.h @ 7287

Last change on this file since 7287 was 7287, checked in by rgrieder, 14 years ago

Split IOConsole in two separate files for better browsing.

  • Property svn:eol-style set to native
File size: 3.2 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 *      Reto Grieder
24 *   Co-authors:
25 *      ...
26 *
27 */
28
29#ifndef _IOConsole_H__
30#define _IOConsole_H__
31
32#include "core/CorePrereqs.h"
33
34#include <sstream>
35#include <string>
36#include <vector>
37#include "util/Singleton.h"
38#include "Shell.h"
39
40#define WIN32_LEAN_AND_MEAN
41#ifndef NOMINMAX
42#define NOMINMAX
43#endif
44#include <windows.h>
45
46namespace orxonox
47{
48    class _CoreExport IOConsole : public Singleton<IOConsole>, public ShellListener
49    {
50        friend class Singleton<IOConsole>;
51
52    public:
53        IOConsole();
54        ~IOConsole();
55
56        void preUpdate(const Clock& time);
57
58    private:
59        void setTerminalMode();
60        void getTerminalSize();
61        void printStatusLines();
62        static int extractLogLevel(std::string* text);
63
64        // Methods from ShellListener
65        void linesChanged();
66        void onlyLastLineChanged();
67        void lineAdded();
68        void inputChanged();
69        void cursorChanged();
70        void executed();
71        void exit();
72
73        void resetTerminalMode();
74        void moveCursor(int dx, int dy);
75        void writeText(const std::string& text, const COORD& pos, WORD attributes = FOREGROUND_BLUE | FOREGROUND_GREEN | FOREGROUND_RED);
76        void createNewOutputLines(int lines);
77        void printOutputLine(const std::string& line, Shell::LineType type, const COORD& pos);
78
79        static inline COORD makeCOORD(int x, int y)
80        {
81            COORD val = {x, y};
82            return val;
83        }
84
85        Shell*                  shell_;
86        InputBuffer*            buffer_;
87        std::ostream            cout_;
88        std::ostringstream      origCout_;
89        int                     terminalWidth_;
90        int                     terminalHeight_;
91        int                     lastTerminalWidth_;
92        int                     lastTerminalHeight_;
93        const std::string       promptString_;
94
95        DWORD                   originalTerminalSettings_;
96        HANDLE                  stdInHandle_;
97        HANDLE                  stdOutHandle_;
98        int                     inputLineRow_;
99        int                     inputLineHeight_;
100        const int               statusLines_;
101        int                     lastOutputLineHeight_;
102        uint64_t                lastRefreshTime_;
103
104        static IOConsole* singletonPtr_s;
105    };
106}
107
108#endif /* _IOConsole_H__ */
Note: See TracBrowser for help on using the repository browser.