Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/presentation2/src/libraries/core/IOConsole.h @ 6140

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

Extended IOConsole to a Windows implementation. It doesn't yet work entirely as I wish, but it's not too bad either.
If you don't like the colors, I agree

  • Property svn:eol-style set to native
File size: 3.2 KB
RevLine 
[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
33#include "CorePrereqs.h"
34
[6037]35#include <sstream>
[6015]36#include <string>
37#include <vector>
[5971]38#include "util/Singleton.h"
39#include "core/Shell.h"
40
[6015]41#ifdef ORXONOX_PLATFORM_UNIX
[5971]42struct termios;
[6140]43#elif defined(ORXONOX_PLATFORM_WINDOWS)
44#define WIN32_LEAN_AND_MEAN
45#include <windows.h>
[6015]46#endif
[5971]47
48namespace 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 update(const Clock& time);
59
60    private:
61        void setTerminalMode();
[6007]62        void resetTerminalMode();
[6013]63        void getTerminalSize();
64        bool willPrintStatusLines();
[6015]65        int extractLogLevel(std::string* text);
[5971]66
[5998]67        void printLogText(const std::string& line);
[5971]68        void printInputLine();
[5995]69        void printStatusLines();
[5971]70
71        // Methods from ShellListener
72        void linesChanged();
73        void onlyLastLineChanged();
74        void lineAdded();
75        void inputChanged();
76        void cursorChanged();
[5983]77        void executed();
[5971]78        void exit();
[6004]79        Shell*                  shell_;
[5971]80        InputBuffer*            buffer_;
[6037]81        std::ostream            cout_;
82        std::ostringstream      origCout_;
[6013]83        unsigned int            terminalWidth_;
84        unsigned int            terminalHeight_;
[6014]85        unsigned int            lastTerminalWidth_;
86        unsigned int            lastTerminalHeight_;
[5995]87        bool                    bPrintStatusLine_;
88        bool                    bStatusPrinted_;
89        std::vector<unsigned>   statusLineWidths_;
[6004]90        unsigned int            statusLineMaxWidth_;
[6010]91        const std::string       promptString_;
[6004]92        static const unsigned   minOutputLines_ = 3;
[5971]93
[6015]94#ifdef ORXONOX_PLATFORM_UNIX
95        termios*                originalTerminalSettings_;
[6140]96#elif defined(ORXONOX_PLATFORM_WINDOWS)
97        void moveCursor(int dx, int dy);
98        void moveCursorYAndHome(int dy);
99        void clearCurrentLine();
100
101        DWORD                   originalTerminalSettings_;
102        HANDLE                  stdInHandle_;
103        HANDLE                  stdOutHandle_;
[6015]104#endif
105
[5971]106        static IOConsole* singletonPtr_s;
107    };
108}
109
110#endif /* _IOConsole_H__ */
Note: See TracBrowser for help on using the repository browser.