3
*************************************************************************
5
ArmageTron -- Just another Tron Lightcycle Game in 3D.
6
Copyright (C) 2000 Manuel Moos (manuel@moosnet.de)
8
**************************************************************************
10
This program is free software; you can redistribute it and/or
11
modify it under the terms of the GNU General Public License
12
as published by the Free Software Foundation; either version 2
13
of the License, or (at your option) any later version.
15
This program is distributed in the hope that it will be useful,
16
but WITHOUT ANY WARRANTY; without even the implied warranty of
17
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
GNU General Public License for more details.
20
You should have received a copy of the GNU General Public License
21
along with this program; if not, write to the Free Software
22
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
24
***************************************************************************
31
#include "tConfiguration.h"
43
//#define fileno _fileno
44
//#define fcntl _fcntl
49
void rConsole::DoCenterDisplay(const tString &s,REAL timeout,REAL r,REAL g,REAL b){
50
std::cout << tColoredString::RemoveColors(s) << '\n';
54
static int stdin_descriptor;
55
static bool unblocked = false;
57
static void sr_HandleSigCont( int signal )
59
// con << "Continuing.\n";
61
// unblock stdin again
65
void sr_Unblock_stdin(){
69
signal( SIGCONT, &sr_HandleSigCont );
74
stdin_descriptor=fileno(stdin);
76
// if (isatty(stdin_descriptor))
78
int flag=fcntl(stdin_descriptor,F_GETFL);
79
fcntl(stdin_descriptor,F_SETFL,flag | O_NONBLOCK);
87
static char line_in[MAXLINE+2];
88
static int currentIn=0;
91
// stdin commands are executed at owner level
92
tCurrentAccessLevel level( tAccessLevel_Owner, true );
94
tConfItemBase::LoadPlayback( true );
101
// std::cerr << "\n";
103
HANDLE stdinhandle = GetStdHandle(STD_INPUT_HANDLE);
104
HANDLE stdouthandle = GetStdHandle(STD_OUTPUT_HANDLE);
108
unsigned long reallyread;
110
bool ret=PeekConsoleInput(stdinhandle, &input, 1, &reallyread);
113
bool ret=ReadConsoleInput(stdinhandle, &input, 1, &reallyread);
114
if (input.EventType == KEY_EVENT)
116
char key = input.Event.KeyEvent.uChar.AsciiChar;
119
if (key && input.Event.KeyEvent.bKeyDown)
121
WriteConsole(stdouthandle, &key, 1, &written, NULL);
122
line_in[currentIn] = key;
124
if (key == 13 || currentIn>=MAXLINE-1){
125
line_in[currentIn]='\n';
126
line_in[currentIn+1]='\0';
127
std::istringstream s(line_in);
128
WriteConsole(stdouthandle, "\n", 1, &written, NULL);
129
tConfItemBase::LoadAll(s, true);
136
// bool ret=ReadFile(stdinhandle, &line_in[currentIn], 1, &reallyread, NULL);
144
while ( read(stdin_descriptor,&line_in[currentIn],1)>0){
145
if (line_in[currentIn]=='\n' || currentIn>=MAXLINE-1)
147
line_in[currentIn+1]='\0';
148
std::istringstream s(line_in);
149
tConfItemBase::LoadAll(s, true);
159
void rConsole::DisplayAtNewline(){