Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/usability/src/libraries/core/command/IOConsoleWindows.h @ 10233

Last change on this file since 10233 was 7401, checked in by landauf, 14 years ago

merged doc branch back to trunk

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